Skip to content

Commit

Permalink
New feature - overlay bundles can be merged in the rootfs. The defaul…
Browse files Browse the repository at this point in the history
…t merge location is the ISO image. Also added few fixes and enhancements to some other scripts.
  • Loading branch information
ivandavidov committed Nov 29, 2017
1 parent 77f04c6 commit bafad2d
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 34 deletions.
29 changes: 21 additions & 8 deletions src/.config
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ USE_PREDEFINED_BUSYBOX_CONFIG=false

# Define the overlay type to use. Possible values are 'sparse' and 'folder'. You
# can use any other value, no value, or comment the property in order to disable
# it. Put your overlay content in the folder 'minimal_overlay' and it will be
# automatically merged with the root file system on boot. The build process
# it. Put your overlay content in the folder 'minimal_overlay/rootfs' and it will
# be automatically merged with the root file system on boot. The build process
# creates either '/minimal.img/rootfs' or '/minimal/rootfs' (read below) and
# this folder contains all overlay content in it. The build process also creates
# '/minimal.img/work' or '/minimal/work'. This folder is used by the overlay
Expand All @@ -216,12 +216,6 @@ USE_PREDEFINED_BUSYBOX_CONFIG=false
#
OVERLAY_TYPE=folder

# Use already downloaded source bundles instead of downloading them from
# internet. This is useful when you have already downloaded the sources and have
# no internet connection. Or if you want to share your version of "Minimal Linux
# Live" with predefined sources.
USE_LOCAL_SOURCE=false

# This property defines one or more additional overlay software pieces which
# will be generated and placed in the 'work/src/minimal_overlay/rootfs' folder.
# These software pieces will be visible and fully usable after boot. By default
Expand Down Expand Up @@ -272,8 +266,27 @@ USE_LOCAL_SOURCE=false
# The only default overlay bundle is 'mll_source'. It provides all MLL sources
# in the directory '/usr/src'. Note that these sources will not work there
# since MLL does not provide build tool chain.
#
OVERLAY_BUNDLES=mll_source

# The location where the overlay bundle software will be stored.
#
# rootfs - all overlay bundles will be embedded in the initramfs. In this way
# the software will be available on boot but the initramfs size will
# grow significantly and MLL will require more RAM in order to boot.
#
# iso - all overlay bundles will be packed in the ISO image structure. The
# actual location depends on the value of the configuration property
# 'OVERLAY_TYPE'.
#
OVERLAY_LOCATION=iso

# Use already downloaded source bundles instead of downloading them from
# internet. This is useful when you have already downloaded the sources and have
# no internet connection. Or if you want to share your version of "Minimal Linux
# Live" with predefined sources.
USE_LOCAL_SOURCE=false

# This property enables the standard penguin boot logo in the upper left corner
# of the screen. The property is used in 'xx_build_kernel.sh'. The default value
# is 'true' for demonstration purposes.
Expand Down
3 changes: 3 additions & 0 deletions src/08_prepare_bundles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ SRC_DIR=$(pwd)

echo "*** PREPARE OVERLAY BEGIN ***"

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'=')"

Expand Down
28 changes: 19 additions & 9 deletions src/09_generate_rootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -e

echo "*** GENERATE ROOTFS BEGIN ***"

SRC_ROOT=$(pwd)
SRC_DIR=$(pwd)

# Remember the sysroot
SYSROOT=$(pwd)/work/sysroot
Expand All @@ -13,13 +13,13 @@ BUSYBOX_INSTALLED=$(pwd)/work/busybox/busybox_installed

cd work

echo "Preparing initramfs work area..."
echo "Preparing rootfsfs work area."
rm -rf rootfs

# Copy all BusyBox generated stuff to the location of our 'initramfs' folder.
# Copy all BusyBox generated stuff to the location of our 'rootfs' folder.
cp -r $BUSYBOX_INSTALLED rootfs

# Copy all rootfs resources to the location of our 'initramfs' folder.
# Copy all rootfs resources to the location of our 'rootfs' folder.
cp -r ../minimal_rootfs/* rootfs

cd rootfs
Expand Down Expand Up @@ -53,14 +53,24 @@ cp $SYSROOT/lib/libc.so.6 lib
# Copy all necessary 'glibc' libraries to '/lib' END.

strip -g \
$SRC_ROOT/work/rootfs/bin/* \
$SRC_ROOT/work/rootfs/sbin/* \
$SRC_ROOT/work/rootfs/lib/* \
$SRC_DIR/work/rootfs/bin/* \
$SRC_DIR/work/rootfs/sbin/* \
$SRC_DIR/work/rootfs/lib/* \
2>/dev/null
echo "Reduced the size of libraries and executables."

echo "The initramfs area has been generated."
# Read the 'OVERLAY_LOCATION' property from '.config'
OVERLAY_LOCATION="$(grep -i ^OVERLAY_LOCATION $SRC_DIR/.config | cut -f2 -d'=')"

cd $SRC_ROOT
if [ "$OVERLAY_LOCATION" = "rootfs" -a -d $SRC_DIR/work/overlay_rootfs ] ; then
echo "Merging overlay software in rootfs."

cp -r $SRC_DIR/work/overlay_rootfs/* .
cp -r $SRC_DIR/minimal_overlay/rootfs/* .
fi

echo "The rootfs area has been generated."

cd $SRC_DIR

echo "*** GENERATE ROOTFS END ***"
24 changes: 17 additions & 7 deletions src/12_generate_iso.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,14 @@ cp ../rootfs.cpio.xz ./rootfs.xz
# Read the 'OVERLAY_TYPE' property from '.config'
OVERLAY_TYPE="$(grep -i ^OVERLAY_TYPE $SRC_DIR/.config | cut -f2 -d'=')"

if [ "$OVERLAY_TYPE" = "sparse" -a "$(id -u)" = "0" ] ; then
# Read the 'OVERLAY_LOCATION' property from '.config'
OVERLAY_LOCATION="$(grep -i ^OVERLAY_LOCATION $SRC_DIR/.config | cut -f2 -d'=')"

if [ "$OVERLAY_LOCATION" = "iso" \
-a "$OVERLAY_TYPE" = "sparse" \
-a -d $SRC_DIR/work/overlay_rootfs \
-a "$(id -u)" = "0" ] ; then

# Use sparse file as storage place. The above check guarantees that the whole
# script is executed with root permissions or otherwise this block is skipped.
# All files and folders located in the folder 'minimal_overlay' will be merged
Expand Down Expand Up @@ -83,16 +90,19 @@ if [ "$OVERLAY_TYPE" = "sparse" -a "$(id -u)" = "0" ] ; then
mkdir -p 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 $SRC_DIR/overlay_rootfs/* sparse/rootfs
cp -r $SRC_DIR/minimal_overlay/rootfs/* sparse/rootfs

# Unmount the sparse file and delete the temporary folder.
$BUSYBOX umount sparse
rm -rf sparse

# Detach the loop device since we no longer need it.
$BUSYBOX losetup -d $LOOP_DEVICE
elif [ "$OVERLAY_TYPE" = "folder" ] ; then
elif [ "$OVERLAY_LOCATION" = "iso" \
-a "$OVERLAY_TYPE" = "folder" \
-a -d $SRC_DIR/work/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.

Expand All @@ -103,10 +113,10 @@ elif [ "$OVERLAY_TYPE" = "folder" ] ; then
mkdir -p 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 $SRC_DIR/work/overlay_rootfs/* minimal/rootfs
cp -r $SRC_DIR/minimal_overlay/rootfs/* minimal/rootfs
else
echo "Generating ISO image with no overlay structure..."
echo "The ISO image will have no overlay structure."
fi

# Copy the precompiled files 'isolinux.bin' and 'ldlinux.c32' in the ISO image
Expand Down
27 changes: 20 additions & 7 deletions src/13_generate_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,26 @@ rm -f mll_image.tgz
rm -rf $SRC_DIR/work/mll_image
mkdir -p $SRC_DIR/work/mll_image

# Copy the rootfs.
cp -r $SRC_DIR/work/rootfs/* \
$SRC_DIR/work/mll_image

# Copy the overlay area.
cp -r $SRC_DIR/work/src/minimal_overlay/rootfs/* \
$SRC_DIR/work/mll_image
if [ -d $SRC_DIR/work/rootfs ] ; then
# Copy the rootfs.
cp -r $SRC_DIR/work/rootfs/* \
$SRC_DIR/work/mll_image
else
echo "Cannot continue - rootfs is missing."
exit 1
fi

if [ -d $SRC_DIR/work/overlay_rootfs ] ; then
echo "Merging overlay software in image."

# Copy the overlay area.
cp -r $SRC_DIR/work/overlay_rootfs/* \
$SRC_DIR/work/mll_image
cp -r $SRC_DIR/minimal_overlay/rootfs/* \
$SRC_DIR/work/mll_image
else
echo "MLL image will have no overlay software."
fi

cd $SRC_DIR/work/mll_image

Expand Down
4 changes: 2 additions & 2 deletions src/qemu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ cmd="qemu-system-$(uname -m) -m 128M -cdrom minimal_linux_live.iso -boot d -vga

if [ "$1" = "-hdd" -o "$1" = "-h" ] ; then
echo "Starting QEMU with attached ISO image and hard disk."
$cmd -hda hdd.img
$cmd -hda hdd.img &
else
echo "Starting QEMU with attached ISO image."
$cmd
$cmd &
fi
2 changes: 1 addition & 1 deletion src/rebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -e
#
# Note: this will also rebuild all overlay bundles.

./08_prepare_src.sh
./08_prepare_bundles.sh
./09_generate_rootfs.sh
./10_pack_rootfs.sh
./12_generate_iso.sh
Expand Down

0 comments on commit bafad2d

Please sign in to comment.