Updated all scripts to use common functions. Updated the sparse image size to 3MB by default.

This commit is contained in:
Ivan Davidov 2017-12-06 19:27:20 +02:00
parent b87a4e2a95
commit 691a321ead
20 changed files with 231 additions and 289 deletions

View File

@ -1,4 +1,4 @@
# If this is the first time you build "Minimal Linux Live", then I suggest you
# If this is the first time you build 'Minimal Linux Live', then I suggest you
# go through the README file first.
###################################################
@ -13,7 +13,7 @@
#
KERNEL_SOURCE_URL=http://kernel.org/pub/linux/kernel/v4.x/linux-4.14.4.tar.xz
# You can find the latest GNU libc source bundles here:
# You can find the latest GNU C library source bundles here:
#
# http://gnu.org/software/libc
#
@ -66,9 +66,9 @@ USE_PREDEFINED_BUSYBOX_CONFIG=false
# media is writeable, then all changes on the root filesystem are automatically
# persisted and preserved on reboot.
#
# sparse - use sparse file 'minimal.img' with hardcoded maximal size of 1MB (see
# xx_generate_iso.sh). The generated ISO image is larger because the
# sparse file is treated as regular file. This option requires root
# sparse - use sparse file 'minimal.img' with hardcoded maximal size of 3MB (see
# xx_generate_overlay.sh). The generated ISO image is larger because
# the sparse file is treated as regular file. This option requires root
# permissions or otherwise sparse file generation is silently skipped.
# Sparse file is treated as separate disk image and works fine on FAT.
#
@ -97,7 +97,7 @@ OVERLAY_TYPE=folder
#
# Note that if you build any overlay software and you are using sparse image file
# for the overlay structure then most probably something will go wrong because
# the overlay software requires more than 1MB free space. The solution is to use
# the overlay software requires more than 3MB free space. The solution is to use
# folder overlay or to edit the script 'xx_generate_overlay.sh' and modify it to
# create sparse image file with bigger size.
#

View File

@ -2,11 +2,14 @@
set -e
# Load common properties and functions in the current script.
. ./common.sh
echo "*** CLEAN BEGIN ***"
echo "Cleaning up the main work area. This may take a while."
rm -rf work
mkdir work
mkdir -p source
rm -rf $WORK_DIR
mkdir $WORK_DIR
mkdir -p $SOURCE_DIR
echo "*** CLEAN END ***"

View File

@ -19,7 +19,7 @@ download_source $DOWNLOAD_URL $SOURCE_DIR/$ARCHIVE_FILE
# Extract the kernel sources in the 'work/kernel' directory.
extract_source $SOURCE_DIR/$ARCHIVE_FILE kernel
# Just in case we go back to the main MLL source folder.
# We go back to the main MLL source folder.
cd $SRC_DIR
echo "*** GET KERNEL END ***"

View File

@ -7,14 +7,13 @@ set -e
echo "*** BUILD KERNEL BEGIN ***"
cd work/kernel
# Prepare the kernel install area.
rm -rf kernel_installed
mkdir kernel_installed
echo "Removing old kernel artifacts. This may take a while."
rm -rf $KERNEL_INSTALLED
mkdir $KERNEL_INSTALLED
# Change to the kernel source directory which ls finds, e.g. 'linux-4.4.6'.
cd $(ls -d linux-*)
cd `ls -d $WORK_DIR/kernel/linux-*`
# Cleans up the kernel sources, including configuration files.
echo "Preparing kernel work area."
@ -98,13 +97,13 @@ make \
# Install the kernel file.
cp arch/x86/boot/bzImage \
$SRC_DIR/work/kernel/kernel_installed/kernel
$KERNEL_INSTALLED/kernel
# Install kernel headers which are used later when we build and configure the
# GNU C library (glibc).
echo "Generating kernel headers."
make \
INSTALL_HDR_PATH=$SRC_DIR/work/kernel/kernel_installed \
INSTALL_HDR_PATH=$KERNEL_INSTALLED \
headers_install -j $NUM_JOBS
cd $SRC_DIR

View File

@ -2,43 +2,24 @@
set -e
# Load common properties and functions in the current script.
. ./common.sh
echo "*** GET GLIBC BEGIN ***"
SRC_DIR=$(pwd)
# Grab everything after the '=' character.
DOWNLOAD_URL=$(grep -i ^GLIBC_SOURCE_URL .config | cut -f2 -d'=')
# Read the 'GLIBC_SOURCE_URL' property from '.config'.
DOWNLOAD_URL=`read_property GLIBC_SOURCE_URL`
# Grab everything after the last '/' character.
ARCHIVE_FILE=${DOWNLOAD_URL##*/}
# Read the 'USE_LOCAL_SOURCE' property from '.config'
USE_LOCAL_SOURCE="$(grep -i ^USE_LOCAL_SOURCE .config | cut -f2 -d'=')"
# Download glibc source archive in the 'source' directory.
download_source $DOWNLOAD_URL $SOURCE_DIR/$ARCHIVE_FILE
if [ "$USE_LOCAL_SOURCE" = "true" -a ! -f $SRC_DIR/source/$ARCHIVE_FILE ] ; then
echo "Source bundle $SRC_DIR/source/$ARCHIVE_FILE is missing and will be downloaded."
USE_LOCAL_SOURCE="false"
fi
cd source
if [ ! "$USE_LOCAL_SOURCE" = "true" ] ; then
# Downloading glibc source bundle file. The '-c' option allows the download to resume.
echo "Downloading glibc source bundle from $DOWNLOAD_URL"
wget -c $DOWNLOAD_URL
else
echo "Using local glibc source bundle $SRC_DIR/source/$ARCHIVE_FILE"
fi
# Delete folder with previously extracted glibc.
echo "Removing glibc work area. This may take a while."
rm -rf ../work/glibc
mkdir ../work/glibc
# Extract glibc to folder 'work/glibc'.
# Full path will be something like 'work/glibc/glibc-2.23'.
tar -xvf $ARCHIVE_FILE -C ../work/glibc
# Extract the glibc sources in the 'work/glibc' directory.
extract_source $SOURCE_DIR/$ARCHIVE_FILE glibc
# We go back to the main MLL source folder.
cd $SRC_DIR
echo "*** GET GLIBC END ***"

View File

@ -2,47 +2,29 @@
set -e
# Load common properties and functions in the current script.
. ./common.sh
echo "*** BUILD GLIBC BEGIN ***"
SRC_DIR=$(pwd)
# Read the 'JOB_FACTOR' property from '.config'
JOB_FACTOR="$(grep -i ^JOB_FACTOR .config | cut -f2 -d'=')"
# Read the 'CFLAGS' property from '.config'
CFLAGS="$(grep -i ^CFLAGS .config | cut -f2 -d'=')"
# Find the number of available CPU cores.
NUM_CORES=$(grep ^processor /proc/cpuinfo | wc -l)
# Calculate the number of 'make' jobs to be used later.
NUM_JOBS=$((NUM_CORES * JOB_FACTOR))
# Save the kernel installation directory.
KERNEL_INSTALLED=$SRC_DIR/work/kernel/kernel_installed
cd work/glibc
# Find the glibc source directory, e.g. 'glibc-2.23' and remember it.
cd $(ls -d glibc-*)
GLIBC_SRC=$(pwd)
cd ..
# Prepare the work area, e.g. 'work/glibc/glibc_objects'.
echo "Preparing glibc object area. This may take a while."
rm -rf glibc_objects
mkdir glibc_objects
rm -rf $GLIBC_OBJECTS
mkdir $GLIBC_OBJECTS
# Prepare the install area, e.g. 'work/glibc/glibc_installed'.
echo "Preparing glibc install area. This may take a while."
rm -rf glibc_installed
mkdir glibc_installed
GLIBC_INSTALLED=$(pwd)/glibc_installed
rm -rf $GLIBC_INSTALLED
mkdir $GLIBC_INSTALLED
# Find the glibc source directory, e.g. 'glibc-2.23' and remember it.
cd $WORK_DIR/glibc
GLIBC_SRC=$PWD/`ls -d glibc-*`
# All glibc work is done from the working area.
cd glibc_objects
cd $GLIBC_OBJECTS
# glibc is configured to use the root folder (--prefix=) and as result all
# 'glibc' is configured to use the root folder (--prefix=) and as result all
# libraries will be installed in '/lib'. Note that on 64-bit machines BusyBox
# will be linked with the libraries in '/lib' while the Linux loader is expected
# to be in '/lib64'. Kernel headers are taken from our already prepared kernel

View File

@ -2,22 +2,32 @@
set -e
# Load common properties and functions in the current script.
. ./common.sh
echo "*** PREPARE SYSROOT BEGIN ***"
SRC_DIR=$(pwd)
cd work
echo "Cleaning existing sysroot. This may take a while."
rm -rf sysroot
rm -rf $SYSROOT
mkdir -p $SYSROOT
echo "Preparing glibc. This may take a while."
mkdir -p sysroot/usr
ln -s ../include sysroot/usr/include
ln -s ../lib sysroot/usr/lib
cp -r kernel/kernel_installed/include sysroot
cp -r glibc/glibc_installed/* sysroot
# 1) Copy everything from glibc to the new sysroot area.
cp -r $GLIBC_INSTALLED/* $SYSROOT
# 2) Copy all kernel headers to the sysroot folder.
cp -r $KERNEL_INSTALLED/include $SYSROOT
# 3) Hack for the missing '/work/sysroot/usr' folder. We link
# the existing libraries and the kernel headers. Without
# this hack the BusyBox compilation process fails. The proper
# way to handle this is to use '--prefix=/usr' in the glibc
# build process but then we have to deal with other issues.
# For now this hack is the easiest and the simplest solution.
mkdir -p $SYSROOT/usr
ln -s ../include $SYSROOT/usr/include
ln -s ../lib $SYSROOT/usr/lib
cd $SRC_DIR

View File

@ -2,43 +2,24 @@
set -e
# Load common properties and functions in the current script.
. ./common.sh
echo "*** GET BUSYBOX BEGIN ***"
SRC_DIR=$(pwd)
# Grab everything after the '=' character.
DOWNLOAD_URL=$(grep -i ^BUSYBOX_SOURCE_URL .config | cut -f2 -d'=')
# Read the 'BUSYBOX_SOURCE_URL' property from '.config'.
DOWNLOAD_URL=`read_property BUSYBOX_SOURCE_URL`
# Grab everything after the last '/' character.
ARCHIVE_FILE=${DOWNLOAD_URL##*/}
# Read the 'USE_LOCAL_SOURCE' property from '.config'
USE_LOCAL_SOURCE="$(grep -i ^USE_LOCAL_SOURCE .config | cut -f2 -d'=')"
# Download BusyBox source archive in the 'source' directory.
download_source $DOWNLOAD_URL $SOURCE_DIR/$ARCHIVE_FILE
if [ "$USE_LOCAL_SOURCE" = "true" -a ! -f $SRC_DIR/source/$ARCHIVE_FILE ] ; then
echo "Source bundle $SRC_DIR/source/$ARCHIVE_FILE is missing and will be downloaded."
USE_LOCAL_SOURCE="false"
fi
cd source
if [ ! "$USE_LOCAL_SOURCE" = "true" ] ; then
# Downloading BusyBox source bundle file. The '-c' option allows the download to resume.
echo "Downloading BusyBox source bundle from $DOWNLOAD_URL"
wget -c $DOWNLOAD_URL
else
echo "Using local BusyBox source bundle $SRC_DIR/source/$ARCHIVE_FILE"
fi
# Delete folder with previously extracted busybox.
echo "Removing BusyBox work area. This may take a while."
rm -rf ../work/busybox
mkdir ../work/busybox
# Extract busybox to folder 'busybox'.
# Full path will be something like 'work/busybox/busybox-1.24.2'.
tar -xvf $ARCHIVE_FILE -C ../work/busybox
# Extract the BusyBox sources in the 'work/busybox' directory.
extract_source $SOURCE_DIR/$ARCHIVE_FILE busybox
# We go back to the main MLL source folder.
cd $SRC_DIR
echo "*** GET BUSYBOX END ***"

View File

@ -2,29 +2,17 @@
set -e
# Load common properties and functions in the current script.
. ./common.sh
echo "*** BUILD BUSYBOX BEGIN ***"
SRC_DIR=$(pwd)
# Read the 'JOB_FACTOR' property from '.config'
JOB_FACTOR="$(grep -i ^JOB_FACTOR .config | cut -f2 -d'=')"
# Find the number of available CPU cores.
NUM_CORES=$(grep ^processor /proc/cpuinfo | wc -l)
# Calculate the number of 'make' jobs to be used later.
NUM_JOBS=$((NUM_CORES * JOB_FACTOR))
# Remember the sysroot
SYSROOT=$(pwd)/work/sysroot
cd work/busybox
# Remove the old BusyBox install area
rm -rf busybox_installed
# Remove the old BusyBox install area.
echo "Removing old BusyBox artifacts. This may take a while."
rm -rf $BUSYBOX_INSTALLED
# Change to the source directory ls finds, e.g. 'busybox-1.24.2'.
cd $(ls -d busybox-*)
cd `ls -d $WORK_DIR/busybox/busybox-*`
# Remove previously generated artifacts.
echo "Preparing BusyBox work area. This may take a while."
@ -67,7 +55,7 @@ make \
# Create the symlinks for busybox. The file 'busybox.links' is used for this.
echo "Generating BusyBox based initramfs area."
make \
CONFIG_PREFIX="../busybox_installed" \
CONFIG_PREFIX="$BUSYBOX_INSTALLED" \
install -j $NUM_JOBS
cd $SRC_DIR

View File

@ -2,7 +2,8 @@
set -e
SRC_DIR=$(pwd)
# Load common properties and functions in the current script.
. ./common.sh
echo "*** PREPARE OVERLAY BEGIN ***"
@ -10,11 +11,11 @@ echo "Preparing overlay work area."
rm -rf $SRC_DIR/work/overlay*
# Read the 'OVERLAY_BUNDLES' property from '.config'
OVERLAY_BUNDLES="$(grep -i ^OVERLAY_BUNDLES .config | cut -f2 -d'=')"
OVERLAY_BUNDLES=`read_property OVERLAY_BUNDLES`
if [ ! "$OVERLAY_BUNDLES" = "" ] ; then
echo "Generating additional overlay bundles. This may take a while."
cd minimal_overlay
cd $SRC_DIR/minimal_overlay
./overlay_build.sh
cd $SRC_DIR
else

View File

@ -2,74 +2,69 @@
set -e
# Load common properties and functions in the current script.
. ./common.sh
echo "*** GENERATE ROOTFS BEGIN ***"
SRC_DIR=$(pwd)
# Remember the sysroot
SYSROOT=$(pwd)/work/sysroot
# Remember the BysyBox install folder.
BUSYBOX_INSTALLED=$(pwd)/work/busybox/busybox_installed
cd work
echo "Preparing rootfs work area."
rm -rf rootfs
echo "Preparing rootfs work area. This may take a while."
rm -rf $ROOTFS
# Copy all BusyBox generated stuff to the location of our 'rootfs' folder.
cp -r $BUSYBOX_INSTALLED rootfs
cp -r $BUSYBOX_INSTALLED $ROOTFS
# Copy all rootfs resources to the location of our 'rootfs' folder.
cp -r ../minimal_rootfs/* rootfs
cd rootfs
cp -r $SRC_DIR/minimal_rootfs/* $ROOTFS
# Delete the '.keep' files which we use in order to keep track of otherwise
# empty folders.
find * -type f -name '.keep' -exec rm {} +
find $ROOTFS/* -type f -name '.keep' -exec rm {} +
# Remove 'linuxrc' which is used when we boot in 'RAM disk' mode.
rm -f linuxrc
rm -f $ROOTFS/linuxrc
# This is for the dynamic loader. Note that the name and the location are both
# specific for 32-bit and 64-bit machines. First we check the BusyBox executable
# and then we copy the dynamic loader to its appropriate location.
BUSYBOX_ARCH=$(file bin/busybox | cut -d' ' -f3)
BUSYBOX_ARCH=$(file $ROOTFS/bin/busybox | cut -d' ' -f3)
if [ "$BUSYBOX_ARCH" = "64-bit" ] ; then
mkdir lib64
cp $SYSROOT/lib/ld-linux* lib64
mkdir -p $ROOTFS/lib64
cp $SYSROOT/lib/ld-linux* $ROOTFS/lib64
echo "Dynamic loader is accessed via '/lib64'."
else
cp $SYSROOT/lib/ld-linux* lib
cp $SYSROOT/lib/ld-linux* $ROOTFS/lib
echo "Dynamic loader is accessed via '/lib'."
fi
# Copy all necessary 'glibc' libraries to '/lib' BEGIN.
# BusyBox has direct dependencies on these libraries.
cp $SYSROOT/lib/libm.so.6 lib
cp $SYSROOT/lib/libc.so.6 lib
cp $SYSROOT/lib/libm.so.6 $ROOTFS/lib
cp $SYSROOT/lib/libc.so.6 $ROOTFS/lib
# Copy all necessary 'glibc' libraries to '/lib' END.
echo "Reducing the size of libraries and executables."
set +e
strip -g \
$SRC_DIR/work/rootfs/bin/* \
$SRC_DIR/work/rootfs/sbin/* \
$SRC_DIR/work/rootfs/lib/* \
$ROOTFS/bin/* \
$ROOTFS/sbin/* \
$ROOTFS/lib/* \
2>/dev/null
set -e
# Read the 'OVERLAY_LOCATION' property from '.config'
OVERLAY_LOCATION="$(grep -i ^OVERLAY_LOCATION $SRC_DIR/.config | cut -f2 -d'=')"
OVERLAY_LOCATION=`read_property OVERLAY_LOCATION`
if [ "$OVERLAY_LOCATION" = "rootfs" -a -d $SRC_DIR/work/overlay_rootfs ] ; then
if [ "$OVERLAY_LOCATION" = "rootfs" -a -d $OVERLAY_ROOTFS ] ; then
echo "Merging overlay software in rootfs."
cp -r $SRC_DIR/work/overlay_rootfs/* .
cp -r $SRC_DIR/minimal_overlay/rootfs/* .
# With '--remove-destination' all possibly existing soft links in
# $OVERLAY_ROOTFS will be overwritten correctly.
cp -r --remove-destination \
$OVERLAY_ROOTFS/* $ROOTFS
cp -r --remove-destination \
$SRC_DIR/minimal_overlay/rootfs/* $ROOTFS
fi
echo "The rootfs area has been generated."

View File

@ -2,21 +2,20 @@
set -e
# Load common properties and functions in the current script.
. ./common.sh
echo "*** PACK ROOTFS BEGIN ***"
SRC_DIR=$(pwd)
cd work
echo "Packing initramfs. This may take a while."
# Remove the old 'initramfs' archive if it exists.
rm -f rootfs.cpio.xz
rm -f $WORK_DIR/rootfs.cpio.xz
cd rootfs
cd $ROOTFS
# Packs the current 'initramfs' folder structure in 'cpio.xz' archive.
find . | cpio -R root:root -H newc -o | xz -9 --check=none > ../rootfs.cpio.xz
find . | cpio -R root:root -H newc -o | xz -9 --check=none > $WORK_DIR/rootfs.cpio.xz
echo "Packing of initramfs has finished."

View File

@ -2,25 +2,26 @@
set -e
echo "*** GENERATE OVERLAY BEGIN ***"
# Load common properties and functions in the current script.
. ./common.sh
SRC_DIR=$(pwd)
echo "*** GENERATE OVERLAY BEGIN ***"
# Remove the old ISO generation area if it exists.
echo "Removing old overlay area. This may take a while."
rm -rf work/isoimage_overlay
mkdir -p work/isoimage_overlay
cd work/isoimage_overlay
rm -rf $ISOIMAGE_OVERLAY
mkdir -p $ISOIMAGE_OVERLAY
cd $ISOIMAGE_OVERLAY
# Read the 'OVERLAY_TYPE' property from '.config'
OVERLAY_TYPE="$(grep -i ^OVERLAY_TYPE $SRC_DIR/.config | cut -f2 -d'=')"
OVERLAY_TYPE=`read_property OVERLAY_TYPE`
# Read the 'OVERLAY_LOCATION' property from '.config'
OVERLAY_LOCATION="$(grep -i ^OVERLAY_LOCATION $SRC_DIR/.config | cut -f2 -d'=')"
OVERLAY_LOCATION=`read_property OVERLAY_LOCATION`
if [ "$OVERLAY_LOCATION" = "iso" \
-a "$OVERLAY_TYPE" = "sparse" \
-a -d $SRC_DIR/work/overlay_rootfs \
-a -d $OVERLAY_ROOTFS \
-a "$(id -u)" = "0" ] ; then
# Use sparse file as storage place. The above check guarantees that the whole
@ -31,45 +32,44 @@ if [ "$OVERLAY_LOCATION" = "iso" \
echo "Using sparse file for overlay."
# This is the BusyBox executable that we have already generated.
BUSYBOX=../rootfs/bin/busybox
BUSYBOX=$ROOTFS/bin/busybox
# Create sparse image file with 1MB size. Note that this increases the ISO
# Create sparse image file with 3MB size. Note that this increases the ISO
# image size.
$BUSYBOX truncate -s 1M minimal.img
$BUSYBOX truncate -s 3M $ISOIMAGE_OVERLAY/minimal.img
# Find available loop device.
LOOP_DEVICE=$($BUSYBOX losetup -f)
# Associate the available loop device with the sparse image file.
$BUSYBOX losetup $LOOP_DEVICE minimal.img
$BUSYBOX losetup $LOOP_DEVICE $ISOIMAGE_OVERLAY/minimal.img
# Format the sparse image file with Ext2 file system.
$BUSYBOX mkfs.ext2 $LOOP_DEVICE
# Mount the sparse file in folder 'sparse".
mkdir sparse
$BUSYBOX mount minimal.img sparse
mkdir $ISOIMAGE_OVERLAY/sparse
$BUSYBOX mount $ISOIMAGE_OVERLAY/minimal.img sparse
# Create the overlay folders.
mkdir -p sparse/rootfs
mkdir -p sparse/work
mkdir -p $ISOIMAGE_OVERLAY/sparse/rootfs
mkdir -p $ISOIMAGE_OVERLAY/sparse/work
# Copy the overlay content.
cp -r $SRC_DIR/overlay_rootfs/* sparse/rootfs
cp -r $SRC_DIR/minimal_overlay/rootfs/* sparse/rootfs
cp -r $OVERLAY_ROOTFS/* \
$ISOIMAGE_OVERLAY/sparse/rootfs
cp -r $SRC_DIR/minimal_overlay/rootfs/* \
$ISOIMAGE_OVERLAY/sparse/rootfs
# Unmount the sparse file and delete the temporary folder.
$BUSYBOX umount sparse
rm -rf sparse
$BUSYBOX umount $ISOIMAGE_OVERLAY/sparse
rm -rf $ISOIMAGE_OVERLAY/sparse
# Detach the loop device since we no longer need it.
$BUSYBOX losetup -d $LOOP_DEVICE
echo "Applying original ownership to all affected files and folders."
chown -R $(logname) .
elif [ "$OVERLAY_LOCATION" = "iso" \
-a "$OVERLAY_TYPE" = "folder" \
-a -d $SRC_DIR/work/overlay_rootfs ] ; then
-a -d $OVERLAY_ROOTFS ] ; then
# Use normal folder structure for overlay. All files and folders located in
# the folder 'minimal_overlay' will be merged with the root folder on boot.
@ -77,12 +77,14 @@ elif [ "$OVERLAY_LOCATION" = "iso" \
echo "Using folder structure for overlay."
# Create the overlay folders.
mkdir -p minimal/rootfs
mkdir -p minimal/work
mkdir -p $ISOIMAGE_OVERLAY/minimal/rootfs
mkdir -p $ISOIMAGE_OVERLAY/minimal/work
# Copy the overlay content.
cp -rf $SRC_DIR/work/overlay_rootfs/* minimal/rootfs
cp -r $SRC_DIR/minimal_overlay/rootfs/* minimal/rootfs
cp -rf $OVERLAY_ROOTFS/* \
$ISOIMAGE_OVERLAY/minimal/rootfs
cp -r $SRC_DIR/minimal_overlay/rootfs/* \
$ISOIMAGE_OVERLAY/minimal/rootfs
else
echo "The ISO image will have no overlay structure."
fi

View File

@ -2,44 +2,24 @@
set -e
# Load common properties and functions in the current script.
. ./common.sh
echo "*** GET SYSLINUX BEGIN ***"
SRC_DIR=$(pwd)
# Grab everything after the '=' character.
DOWNLOAD_URL=$(grep -i ^SYSLINUX_SOURCE_URL .config | cut -f2 -d'=')
# Read the 'SYSLINUX_SOURCE_URL' property from '.config'.
DOWNLOAD_URL=`read_property SYSLINUX_SOURCE_URL`
# Grab everything after the last '/' character.
ARCHIVE_FILE=${DOWNLOAD_URL##*/}
# Read the 'USE_LOCAL_SOURCE' property from '.config'
USE_LOCAL_SOURCE="$(grep -i ^USE_LOCAL_SOURCE .config | cut -f2 -d'=')"
# Download Syslinux source archive in the 'source' directory.
download_source $DOWNLOAD_URL $SOURCE_DIR/$ARCHIVE_FILE
if [ "$USE_LOCAL_SOURCE" = "true" -a ! -f $SRC_DIR/source/$ARCHIVE_FILE ] ; then
echo "Source bundle $SRC_DIR/source/$ARCHIVE_FILE is missing and will be downloaded."
USE_LOCAL_SOURCE="false"
fi
cd source
if [ ! "$USE_LOCAL_SOURCE" = "true" ] ; then
# Downloading SYSLINUX source bundle file. The '-c' option allows the download to resume.
echo "Downloading SYSLINUX source bundle from $DOWNLOAD_URL"
wget -c $DOWNLOAD_URL
else
echo "Using local SYSLINUX source bundle $SRC_DIR/source/$ARCHIVE_FILE"
fi
# Delete folder with previously extracted Syslinux.
echo "Removing SYSLINUX work area. This may take a while."
rm -rf ../work/syslinux
mkdir ../work/syslinux
# Extract Syslinux to folder 'work/syslinux'.
# Full path will be something like 'work/syslinux/syslinux-6.03'.
tar -xvf $ARCHIVE_FILE -C ../work/syslinux
# Extract the Syslinux sources in the 'work/syslinux' directory.
extract_source $SOURCE_DIR/$ARCHIVE_FILE syslinux
# We go back to the main MLL source folder.
cd $SRC_DIR
echo "*** GET SYSLINUX END ***"

View File

@ -2,58 +2,61 @@
set -e
# Load common properties and functions in the current script.
. ./common.sh
echo "*** PREPARE ISO BEGIN ***"
SRC_DIR=$(pwd)
# Save the kernel installation directory.
KERNEL_INSTALLED=$SRC_DIR/work/kernel/kernel_installed
# Find the Syslinux build directory.
cd work/syslinux
cd $(ls -d *)
WORK_SYSLINUX_DIR=$(pwd)
cd $SRC_DIR
# Remove the old ISO generation area if it exists.
echo "Removing old ISO image work area. This may take a while."
rm -rf work/isoimage
rm -rf $ISOIMAGE
# This is the root folder of the ISO image.
echo "Preparing new ISO image work area."
mkdir work/isoimage
cd work/isoimage
mkdir -p $ISOIMAGE
# Now we copy the kernel.
cp $KERNEL_INSTALLED/kernel ./kernel.xz
cp $KERNEL_INSTALLED/kernel $ISOIMAGE/kernel.xz
# Now we copy the root file system.
cp ../rootfs.cpio.xz ./rootfs.xz
cp $WORK_DIR/rootfs.cpio.xz $ISOIMAGE/rootfs.xz
# Now we copy the overlay content if it exists
if [ -d $SRC_DIR/work/isoimage_overlay \
-a ! "`ls $SRC_DIR/work/isoimage_overlay`" = "" ] ; then
if [ -d $ISOIMAGE_OVERLAY \
-a ! "`ls $ISOIMAGE`" = "" ] ; then
echo "The ISO image will have overlay structure."
cp -r $SRC_DIR/work/isoimage_overlay/* .
cp -r $ISOIMAGE_OVERLAY/* $ISOIMAGE
else
echo "The ISO image will have no overlay structure."
fi
# Copy the precompiled files 'isolinux.bin' and 'ldlinux.c32' in the ISO image
# root folder.
cp $WORK_SYSLINUX_DIR/bios/core/isolinux.bin .
cp $WORK_SYSLINUX_DIR/bios/com32/elflink/ldlinux/ldlinux.c32 .
cp $WORK_SYSLINUX_DIR/bios/core/isolinux.bin $ISOIMAGE
cp $WORK_SYSLINUX_DIR/bios/com32/elflink/ldlinux/ldlinux.c32 $ISOIMAGE
# Create the ISOLINUX configuration file.
cat << CEOF > ./syslinux.cfg
cat << CEOF > $ISOIMAGE/syslinux.cfg
PROMPT 1
TIMEOUT 50
DEFAULT mll
SAY Press enter to boot Minimal Linux Live or wait 5 seconds.
SAY Press tab to view available boot entries or enter Syslinux commands directly.
SAY
SAY ##################################################################
SAY # #
SAY # Press <ENTER> to boot Minimal Linux Live or wait 5 seconds. #
SAY # #
SAY # Press <TAB> to view available boot entries or enter Syslinux #
SAY # commands directly. #
SAY # #
SAY ##################################################################
SAY
LABEL mll
LINUX kernel.xz
@ -66,11 +69,20 @@ LABEL mll_nomodeset
INITRD rootfs.xz
CEOF
# Create UEFI start script.
mkdir -p efi/boot
cat << CEOF > ./efi/boot/startup.nsh
# Create UEFI start script '/efi/boot/startup.nsh'. This script is executed
# by the firmware on boot. Currently MLL doesn't provide native UEFI stub
# for boot manager and this script is the only UEFI compliant way to pass
# the execution from the firmware to the kernel.
mkdir -p $ISOIMAGE/efi/boot
cat << CEOF > $ISOIMAGE/efi/boot/startup.nsh
echo -off
echo Minimal Linux Live is starting.
echo.
echo ###################################
echo # #
echo # Welcome to Minimal Linux Live #
echo # #
echo ###################################
echo.
\\kernel.xz initrd=\\rootfs.xz
CEOF

View File

@ -2,33 +2,31 @@
set -e
# Load common properties and functions in the current script.
. ./common.sh
echo "*** GENERATE ISO BEGIN ***"
SRC_DIR=$(pwd)
if [ ! -d $SRC_DIR/work/isoimage ] ; then
if [ ! -d $ISOIMAGE ] ; then
echo "Cannot locate ISO image work folder. Cannot continue."
exit 1
fi
cd $SRC_DIR/work/isoimage
cd $ISOIMAGE
# Now we generate the ISO image file.
xorriso \
-as mkisofs \
-R \
-r \
-o ../minimal_linux_live.iso \
-o $SRC_DIR/minimal_linux_live.iso \
-b isolinux.bin \
-c boot.cat \
-input-charset UTF-8 \
-no-emul-boot \
-boot-load-size 4 \
-boot-info-table \
./
# Copy the ISO image to the root project folder.
cp ../minimal_linux_live.iso ../../
$ISOIMAGE
cd $SRC_DIR

View File

@ -2,39 +2,40 @@
set -e
# Load common properties and functions in the current script.
. ./common.sh
echo "*** GENERATE IMAGE BEGIN ***"
SRC_DIR=$(pwd)
# Prepare the work area.
rm -f mll_image.tgz
rm -rf $SRC_DIR/work/mll_image
mkdir -p $SRC_DIR/work/mll_image
rm -f $SRC_DIR/mll_image.tgz
rm -rf $WORK_DIR/mll_image
mkdir -p $WORK_DIR/mll_image
if [ -d $SRC_DIR/work/rootfs ] ; then
if [ -d $ROOTFS ] ; then
# Copy the rootfs.
cp -r $SRC_DIR/work/rootfs/* \
$SRC_DIR/work/mll_image
cp -r $ROOTFS/* \
$WORK_DIR/mll_image
else
echo "Cannot continue - rootfs is missing."
exit 1
fi
if [ -d $SRC_DIR/work/overlay_rootfs ] ; then
if [ -d $OVERLAY_ROOTFS ] ; then
echo "Merging overlay software in image."
# Copy the overlay content.
# With '--remove-destination' all possibly existing soft links in
# '$SRC_DIR/work/mll_image' will be overwritten correctly.
cp -r --remove-destination $SRC_DIR/work/overlay_rootfs/* \
$SRC_DIR/work/mll_image
# $WORK_DIR/mll_image will be overwritten correctly.
cp -r --remove-destination $OVERLAY_ROOTFS/* \
$WORK_DIR/mll_image
cp -r --remove-destination $SRC_DIR/minimal_overlay/rootfs/* \
$SRC_DIR/work/mll_image
$WORK_DIR/mll_image
else
echo "MLL image will have no overlay software."
fi
cd $SRC_DIR/work/mll_image
cd $WORK_DIR/mll_image
# Generate the image file (ordinary 'tgz').
tar -zcf $SRC_DIR/mll_image.tgz *

View File

@ -6,8 +6,6 @@
set -e
SRC_DIR=`pwd`
echo "*** CLEANUP BEGIN ***"
if [ "$(id -u)" = "0" ] ; then

View File

@ -3,9 +3,18 @@
set -e
SRC_DIR=`realpath --no-symlinks $PWD`
CONFIG=$SRC_DIR/.config
SOURCE_DIR=$SRC_DIR/source
WORK_DIR=$SRC_DIR/work
CONFIG=$SRC_DIR/.config
KERNEL_INSTALLED=$WORK_DIR/kernel/kernel_installed
GLIBC_OBJECTS=$WORK_DIR/glibc/glibc_objects
GLIBC_INSTALLED=$WORK_DIR/glibc/glibc_installed
BUSYBOX_INSTALLED=$WORK_DIR/busybox/busybox_installed
SYSROOT=$WORK_DIR/sysroot
ROOTFS=$WORK_DIR/rootfs
OVERLAY_ROOTFS=$WORK_DIR/overlay_rootfs
ISOIMAGE=$WORK_DIR/isoimage
ISOIMAGE_OVERLAY=$WORK_DIR/isoimage_overlay
# This function reads property from the main '.config' file.
#

View File

@ -42,7 +42,10 @@ elif [ "$1" = "-f" -o "$1" = "--folder" ] ; then
losetup -d $LOOP_DEVICE
echo "Detached hard disk image file from loop device."
chown $(logname) hdd.img
# Find the original user. Note that this may not always be correct.
ORIG_USER=`who | awk '{print \$1}'`
chown $ORIG_USER hdd.img
echo "Applied original ownership to hard disk image file."
elif [ "$1" = "-s" -o "$1" = "--sparse" ] ; then
if [ ! "$(id -u)" = "0" ] ; then
@ -66,8 +69,8 @@ elif [ "$1" = "-s" -o "$1" = "--sparse" ] ; then
echo "Mounted hard disk image file to temporary folder."
rm -f sparse/minimal.img
truncate -s 1M sparse/minimal.img
echo "Created new overlay image file with 1MB size."
truncate -s 3M sparse/minimal.img
echo "Created new overlay image file with 3MB size."
LOOP_DEVICE_OVL=$(losetup -f)
losetup $LOOP_DEVICE_OVL sparse/minimal.img
@ -121,7 +124,7 @@ elif [ "$1" = "-h" -o "$1" = "--help" ] ; then
contains compatible overlay folder structure.
-h, --help Prints this help information.
-s, --sparse Create sparse image file formatted with FAT filesystem which
contains sparse image file 'minimal.img' (1MB) formatted with
contains sparse image file 'minimal.img' (3MB) formatted with
Ext2 filesystem which contains the actual overlay structure.
CEOF