From 807e1b9bc008b3f5199c08f9e1eb57146acbd866 Mon Sep 17 00:00:00 2001 From: Ivan Davidov Date: Sun, 15 Jan 2017 18:49:01 +0200 Subject: [PATCH] Major refactoring - the overlay structure is now independet build subsystem. Tested on 32-bit, not tested on 64-bit. --- src/.config | 5 +- src/12_generate_iso.sh | 9 ++-- src/Makefile | 2 +- src/build_minimal_linux_overlay.sh | 25 --------- src/minimal_overlay/README | 12 ----- .../bundles/dropbear/01_get.sh} | 17 ++++--- .../bundles/dropbear/02_build.sh} | 25 +++++---- .../bundles/dropbear/bundle.sh | 9 ++++ .../bundles/felix/01_get.sh} | 17 ++++--- .../bundles/felix/02_install.sh | 40 +++++++++++++++ src/minimal_overlay/bundles/felix/bundle.sh | 9 ++++ .../bundles/glibc_full/bundle.sh} | 23 ++++++--- .../bundles/java/bundle.sh} | 20 +++++--- .../bundles/links/01_get.sh} | 17 ++++--- .../bundles/links/02_build.sh} | 15 ++++-- src/minimal_overlay/bundles/links/bundle.sh | 9 ++++ .../bundles/mll_utils/01_prepare.sh} | 9 +++- .../bundles/mll_utils/02_disk_erase.sh} | 11 ++-- .../bundles/mll_utils/03_installer.sh} | 33 +++++++----- .../bundles/mll_utils/04_install.sh | 22 ++++++++ .../bundles/mll_utils/bundle.sh | 11 ++++ src/minimal_overlay/overlay_build.sh | 51 +++++++++++++++++++ .../overlay_clean.sh} | 13 +++-- src/minimal_overlay/rootfs/README | 13 +++++ src/overlay_dropbear.sh | 5 -- src/overlay_felix.sh | 5 -- src/overlay_felix_02_install.sh | 35 ------------- src/overlay_links.sh | 5 -- src/overlay_mll_utils.sh | 7 --- src/overlay_mll_utils_04_install.sh | 17 ------- 30 files changed, 302 insertions(+), 189 deletions(-) delete mode 100755 src/build_minimal_linux_overlay.sh delete mode 100644 src/minimal_overlay/README rename src/{overlay_dropbear_01_get.sh => minimal_overlay/bundles/dropbear/01_get.sh} (60%) rename src/{overlay_dropbear_02_build.sh => minimal_overlay/bundles/dropbear/02_build.sh} (74%) create mode 100755 src/minimal_overlay/bundles/dropbear/bundle.sh rename src/{overlay_felix_01_get.sh => minimal_overlay/bundles/felix/01_get.sh} (60%) create mode 100755 src/minimal_overlay/bundles/felix/02_install.sh create mode 100755 src/minimal_overlay/bundles/felix/bundle.sh rename src/{overlay_glibc_full.sh => minimal_overlay/bundles/glibc_full/bundle.sh} (52%) rename src/{overlay_java.sh => minimal_overlay/bundles/java/bundle.sh} (70%) rename src/{overlay_links_01_get.sh => minimal_overlay/bundles/links/01_get.sh} (59%) rename src/{overlay_links_02_build.sh => minimal_overlay/bundles/links/02_build.sh} (75%) create mode 100755 src/minimal_overlay/bundles/links/bundle.sh rename src/{overlay_mll_utils_01_prepare.sh => minimal_overlay/bundles/mll_utils/01_prepare.sh} (51%) rename src/{overlay_mll_utils_02_disk_erase.sh => minimal_overlay/bundles/mll_utils/02_disk_erase.sh} (87%) rename src/{overlay_mll_utils_03_installer.sh => minimal_overlay/bundles/mll_utils/03_installer.sh} (73%) create mode 100755 src/minimal_overlay/bundles/mll_utils/04_install.sh create mode 100755 src/minimal_overlay/bundles/mll_utils/bundle.sh create mode 100755 src/minimal_overlay/overlay_build.sh rename src/{overlay_00_clean.sh => minimal_overlay/overlay_clean.sh} (60%) create mode 100644 src/minimal_overlay/rootfs/README delete mode 100755 src/overlay_dropbear.sh delete mode 100755 src/overlay_felix.sh delete mode 100755 src/overlay_felix_02_install.sh delete mode 100755 src/overlay_links.sh delete mode 100755 src/overlay_mll_utils.sh delete mode 100755 src/overlay_mll_utils_04_install.sh diff --git a/src/.config b/src/.config index 5cd09b09f..5e9bc70ba 100644 --- a/src/.config +++ b/src/.config @@ -11,7 +11,7 @@ # # http://kernel.org # -KERNEL_SOURCE_URL=http://kernel.org/pub/linux/kernel/v4.x/linux-4.4.40.tar.xz +KERNEL_SOURCE_URL=http://kernel.org/pub/linux/kernel/v4.x/linux-4.4.43.tar.xz # You can find the latest GNU libc source bundles here: # @@ -23,7 +23,7 @@ GLIBC_SOURCE_URL=http://ftp.gnu.org/gnu/glibc/glibc-2.24.tar.bz2 # # http://busybox.net # -BUSYBOX_SOURCE_URL=http://busybox.net/downloads/busybox-1.26.1.tar.bz2 +BUSYBOX_SOURCE_URL=http://busybox.net/downloads/busybox-1.26.2.tar.bz2 # You can find the latest Syslinux source bundles here: # @@ -65,6 +65,7 @@ FELIX_SOURCE_URL=http://www-us.apache.org/dist/felix/org.apache.felix.main.distr # JAVA_ARCHIVE=/home/ivan/Downloads/jdk-8u102-linux-x64.tar.gz # #JAVA_ARCHIVE=/absolute/path/to/java.archive.tar.gz +#JAVA_ARCHIVE=/home/ivan/Downloads/jdk-8u111-linux-i586.tar.gz diff --git a/src/12_generate_iso.sh b/src/12_generate_iso.sh index 1b2403567..15ac5c888 100755 --- a/src/12_generate_iso.sh +++ b/src/12_generate_iso.sh @@ -53,7 +53,9 @@ OVERLAY_BUNDLES="$(grep -i ^OVERLAY_BUNDLES .config | cut -f2 -d'=')" if [ ! "$OVERLAY_BUNDLES" = "" ] ; then echo "Generating additional overlay bundles. This may take a while..." - time sh build_minimal_linux_overlay.sh + cd minimal_overlay + time sh overlay_build.sh + cd $SRC_DIR else echo "Generation of additional overlay bundles has been skipped." fi @@ -102,7 +104,7 @@ if [ "$OVERLAY_TYPE" = "sparse" -a "$(id -u)" = "0" ] ; then mkdir -p sparse/work # Copy the overlay content. - cp -r $SRC_DIR/work/src/minimal_overlay/* sparse/rootfs/ + cp -r $SRC_DIR/work/src/minimal_overlay/rootfs/* sparse/rootfs/ # Unmount the sparse file and delete the temporary folder. $BUSYBOX umount sparse @@ -119,7 +121,8 @@ elif [ "$OVERLAY_TYPE" = "folder" ] ; then mkdir -p minimal/rootfs mkdir -p minimal/work - cp -rf $SRC_DIR/work/src/minimal_overlay/* minimal/rootfs/ + cp -rf $SRC_DIR/work/src/minimal_overlay/rootfs/* \ + minimal/rootfs/ else echo "Generating ISO image with no overlay structure..." fi diff --git a/src/Makefile b/src/Makefile index c554d32e9..94159a217 100644 --- a/src/Makefile +++ b/src/Makefile @@ -18,7 +18,7 @@ clean: @echo "Removing predefined configuration files..." @rm -rf minimal_overlay/*.config @echo "Removing source level overlay software..." - @cd minimal_overlay && rm -rf $(shell ls -d */) && cd .. + @cd minimal_overlay/rootfs && rm -rf $(shell ls -d */) && cd .. @echo "Removing build log file..." @rm -f minimal_linux_live.log @$(eval USE_LOCAL_SOURCE := $(shell grep -i ^USE_LOCAL_SOURCE .config | cut -f2 -d'=')) diff --git a/src/build_minimal_linux_overlay.sh b/src/build_minimal_linux_overlay.sh deleted file mode 100755 index 43de83f87..000000000 --- a/src/build_minimal_linux_overlay.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh - -# Read the 'OVERLAY_BUNDLES' property from '.config' -OVERLAY_BUNDLES="$(grep -i ^OVERLAY_BUNDLES .config | cut -f2 -d'=')" - -if [ "$OVERLAY_BUNDLES" = "" ] ; then - echo "There are no overlay bundles to build." -else - time sh overlay_00_clean.sh - - OVERLAY_BUNDLES_LIST="$(echo $OVERLAY_BUNDLES | tr ',' ' ')" - - for BUNDLE in $OVERLAY_BUNDLES_LIST - do - OVERLAY_SCRIPT=overlay_$BUNDLE.sh - - if [ ! -f $OVERLAY_SCRIPT ] ; then - echo "Error - cannot find overlay script file '$OVERLAY_SCRIPT'." - else - echo "Building overlay bundle '$BUNDLE'..." - time sh $OVERLAY_SCRIPT - fi - done -fi - diff --git a/src/minimal_overlay/README b/src/minimal_overlay/README deleted file mode 100644 index b61838f17..000000000 --- a/src/minimal_overlay/README +++ /dev/null @@ -1,12 +0,0 @@ - -This file is located in the folder 'minimal_overlay'. You can use this folder to -put your own content (files and folders) which will be visible in the root -folder of your 'Minimal Linux Live' system, just like this file is visible. The -files/folders will override the content in the root folder, so be careful what -you put there because you may end up with broken system. If the boot media is -writeable, then all changes on the root file system are persisted automatically, -so be very careful what you do when you use the overlay support. - -Check the '.config' file in the source folder for more details on the overlay -options and how to use them. - diff --git a/src/overlay_dropbear_01_get.sh b/src/minimal_overlay/bundles/dropbear/01_get.sh similarity index 60% rename from src/overlay_dropbear_01_get.sh rename to src/minimal_overlay/bundles/dropbear/01_get.sh index fd764c870..4276c98c2 100755 --- a/src/overlay_dropbear_01_get.sh +++ b/src/minimal_overlay/bundles/dropbear/01_get.sh @@ -2,28 +2,33 @@ SRC_DIR=$(pwd) +# Find the main source directory +cd ../../.. +MAIN_SRC_DIR=$(pwd) +cd $SRC_DIR + # Grab everything after the '=' character. -DOWNLOAD_URL=$(grep -i DROPBEAR_SOURCE_URL .config | cut -f2 -d'=') +DOWNLOAD_URL=$(grep -i DROPBEAR_SOURCE_URL $MAIN_SRC_DIR/.config | cut -f2 -d'=') # 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'=')" +USE_LOCAL_SOURCE="$(grep -i USE_LOCAL_SOURCE $MAIN_SRC_DIR/.config | cut -f2 -d'=')" -if [ "$USE_LOCAL_SOURCE" = "true" -a ! -f $SRC_DIR/source/overlay/$ARCHIVE_FILE ] ; then - echo "Source bundle $SRC_DIR/source/overlay/$ARCHIVE_FILE is missing and will be downloaded." +if [ "$USE_LOCAL_SOURCE" = "true" -a ! -f $MAIN_SRC_DIR/source/overlay/$ARCHIVE_FILE ] ; then + echo "Source bundle $MAIN_SRC_DIR/source/overlay/$ARCHIVE_FILE is missing and will be downloaded." USE_LOCAL_SOURCE="false" fi -cd source/overlay +cd $MAIN_SRC_DIR/source/overlay if [ ! "$USE_LOCAL_SOURCE" = "true" ] ; then # Downloading Dropbear source bundle file. The '-c' option allows the download to resume. echo "Downloading Links source bundle from $DOWNLOAD_URL" wget -c $DOWNLOAD_URL else - echo "Using local Dropbear source bundle $SRC_DIR/source/overlay/$ARCHIVE_FILE" + echo "Using local Dropbear source bundle $MAIN_SRC_DIR/source/overlay/$ARCHIVE_FILE" fi # Delete folder with previously extracted Dropbear. diff --git a/src/overlay_dropbear_02_build.sh b/src/minimal_overlay/bundles/dropbear/02_build.sh similarity index 74% rename from src/overlay_dropbear_02_build.sh rename to src/minimal_overlay/bundles/dropbear/02_build.sh index cf00fba18..9fe2db003 100755 --- a/src/overlay_dropbear_02_build.sh +++ b/src/minimal_overlay/bundles/dropbear/02_build.sh @@ -2,11 +2,16 @@ SRC_DIR=$(pwd) +# Find the main source directory +cd ../../.. +MAIN_SRC_DIR=$(pwd) +cd $SRC_DIR + # Read the 'JOB_FACTOR' property from '.config' -JOB_FACTOR="$(grep -i ^JOB_FACTOR .config | cut -f2 -d'=')" +JOB_FACTOR="$(grep -i ^JOB_FACTOR $MAIN_SRC_DIR/.config | cut -f2 -d'=')" # Read the 'CFLAGS' property from '.config' -CFLAGS="$(grep -i ^CFLAGS .config | cut -f2 -d'=')" +CFLAGS="$(grep -i ^CFLAGS $MAIN_SRC_DIR/.config | cut -f2 -d'=')" # Find the number of available CPU cores. NUM_CORES=$(grep ^processor /proc/cpuinfo | wc -l) @@ -14,12 +19,12 @@ NUM_CORES=$(grep ^processor /proc/cpuinfo | wc -l) # Calculate the number of 'make' jobs to be used later. NUM_JOBS=$((NUM_CORES * JOB_FACTOR)) -if [ ! -d $SRC_DIR/work/glibc/glibc_prepared ] ; then +if [ ! -d $MAIN_SRC_DIR/work/glibc/glibc_prepared ] ; then echo "Cannot continue - Dropbear SSH depends on GLIBC. Please buld GLIBC first." exit 1 fi -cd work/overlay/dropbear +cd $MAIN_SRC_DIR/work/overlay/dropbear # Change to the Dropbear source directory which ls finds, e.g. 'dropbear-2016.73'. cd $(ls -d dropbear-*) @@ -31,7 +36,7 @@ rm -rf ../dropbear_installed echo "Configuring Dropbear..." ./configure \ - --prefix=$SRC_DIR/work/overlay/dropbear/dropbear_installed \ + --prefix=$MAIN_SRC_DIR/work/overlay/dropbear/dropbear_installed \ --disable-zlib \ --disable-loginfunc \ CFLAGS="$CFLAGS" @@ -45,10 +50,10 @@ make install -j $NUM_JOBS mkdir -p ../dropbear_installed/lib # Copy all dependent GLIBC libraries. -cp $SRC_DIR/work/glibc/glibc_prepared/lib/libnsl.so.1 ../dropbear_installed/lib -cp $SRC_DIR/work/glibc/glibc_prepared/lib/libnss_compat.so.2 ../dropbear_installed/lib -cp $SRC_DIR/work/glibc/glibc_prepared/lib/libutil.so.1 ../dropbear_installed/lib -cp $SRC_DIR/work/glibc/glibc_prepared/lib/libcrypt.so.1 ../dropbear_installed/lib +cp $MAIN_SRC_DIR/work/glibc/glibc_prepared/lib/libnsl.so.1 ../dropbear_installed/lib +cp $MAIN_SRC_DIR/work/glibc/glibc_prepared/lib/libnss_compat.so.2 ../dropbear_installed/lib +cp $MAIN_SRC_DIR/work/glibc/glibc_prepared/lib/libutil.so.1 ../dropbear_installed/lib +cp $MAIN_SRC_DIR/work/glibc/glibc_prepared/lib/libcrypt.so.1 ../dropbear_installed/lib mkdir -p ../dropbear_installed/etc/dropbear @@ -97,7 +102,7 @@ cp -r \ ../dropbear_installed/bin \ ../dropbear_installed/sbin \ ../dropbear_installed/lib \ - $SRC_DIR/work/src/minimal_overlay + $MAIN_SRC_DIR/work/src/minimal_overlay/rootfs echo "Dropbear has been installed." diff --git a/src/minimal_overlay/bundles/dropbear/bundle.sh b/src/minimal_overlay/bundles/dropbear/bundle.sh new file mode 100755 index 000000000..6284178ab --- /dev/null +++ b/src/minimal_overlay/bundles/dropbear/bundle.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +SRC_DIR=$(pwd) + +time sh 01_get.sh +time sh 02_build.sh + +cd $SRC_DIR + diff --git a/src/overlay_felix_01_get.sh b/src/minimal_overlay/bundles/felix/01_get.sh similarity index 60% rename from src/overlay_felix_01_get.sh rename to src/minimal_overlay/bundles/felix/01_get.sh index 3ee9ce365..2f0133189 100755 --- a/src/overlay_felix_01_get.sh +++ b/src/minimal_overlay/bundles/felix/01_get.sh @@ -2,28 +2,33 @@ SRC_DIR=$(pwd) +# Find the main source directory +cd ../../.. +MAIN_SRC_DIR=$(pwd) +cd $SRC_DIR + # Grab everything after the '=' character. -DOWNLOAD_URL=$(grep -i FELIX_SOURCE_URL .config | cut -f2 -d'=') +DOWNLOAD_URL=$(grep -i FELIX_SOURCE_URL $MAIN_SRC_DIR/.config | cut -f2 -d'=') # 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'=')" +USE_LOCAL_SOURCE="$(grep -i USE_LOCAL_SOURCE $MAIN_SRC_DIR/.config | cut -f2 -d'=')" -if [ "$USE_LOCAL_SOURCE" = "true" -a ! -f $SRC_DIR/source/overlay/$ARCHIVE_FILE ] ; then - echo "Source bundle $SRC_DIR/source/overlay/$ARCHIVE_FILE is missing and will be downloaded." +if [ "$USE_LOCAL_SOURCE" = "true" -a ! -f $MAIN_SRC_DIR/source/overlay/$ARCHIVE_FILE ] ; then + echo "Source bundle $MAIN_SRC_DIR/source/overlay/$ARCHIVE_FILE is missing and will be downloaded." USE_LOCAL_SOURCE="false" fi -cd source/overlay +cd $MAIN_SRC_DIR/source/overlay if [ ! "$USE_LOCAL_SOURCE" = "true" ] ; then # Downloading Apache Felix source bundle file. The '-c' option allows the download to resume. echo "Downloading Apache Felix source bundle from $DOWNLOAD_URL" wget -c $DOWNLOAD_URL else - echo "Using local Apache Felix source bundle $SRC_DIR/source/overlay/$ARCHIVE_FILE" + echo "Using local Apache Felix source bundle $MAIN_SRC_DIR/source/overlay/$ARCHIVE_FILE" fi # Delete folder with previously extracted Felix. diff --git a/src/minimal_overlay/bundles/felix/02_install.sh b/src/minimal_overlay/bundles/felix/02_install.sh new file mode 100755 index 000000000..0b90d86bf --- /dev/null +++ b/src/minimal_overlay/bundles/felix/02_install.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +SRC_DIR=$(pwd) + +# Find the main source directory +cd ../../.. +MAIN_SRC_DIR=$(pwd) +cd $SRC_DIR + +echo "Removing old Apache Felix artifacts. This may take a while..." +rm -rf $MAIN_SRC_DIR/work/overlay/felix/felix_installed +mkdir -p $MAIN_SRC_DIR/work/overlay/felix/felix_installed/opt/felix +mkdir -p $MAIN_SRC_DIR/work/overlay/felix/felix_installed/bin + +cd $MAIN_SRC_DIR/work/overlay/felix +cd $(ls -d felix-*) + +cat << CEOF > bin/felix-start.sh +#!/bin/sh + +cd /opt/felix +java -jar bin/felix.jar + +CEOF + +chmod +rx bin/felix-start.sh + +cp -r * $MAIN_SRC_DIR/work/overlay/felix/felix_installed/opt/felix + +cd $MAIN_SRC_DIR/work/overlay/felix/felix_installed + +ln -s ../opt/felix/bin/felix-start.sh bin/felix-start + +cp -r $MAIN_SRC_DIR/work/overlay/felix/felix_installed/* \ + $MAIN_SRC_DIR/work/src/minimal_overlay/rootfs + +echo "Apache Felix has been installed." + +cd $SRC_DIR + diff --git a/src/minimal_overlay/bundles/felix/bundle.sh b/src/minimal_overlay/bundles/felix/bundle.sh new file mode 100755 index 000000000..cf641b3e8 --- /dev/null +++ b/src/minimal_overlay/bundles/felix/bundle.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +SRC_DIR=$(pwd) + +time sh 01_get.sh +time sh 02_install.sh + +cd $SRC_DIR + diff --git a/src/overlay_glibc_full.sh b/src/minimal_overlay/bundles/glibc_full/bundle.sh similarity index 52% rename from src/overlay_glibc_full.sh rename to src/minimal_overlay/bundles/glibc_full/bundle.sh index a1b2e44e2..4d64d1578 100755 --- a/src/overlay_glibc_full.sh +++ b/src/minimal_overlay/bundles/glibc_full/bundle.sh @@ -2,21 +2,26 @@ SRC_DIR=$(pwd) -if [ ! -d $SRC_DIR/work/glibc/glibc_prepared ] ; then +# Find the main source directory +cd ../../.. +MAIN_SRC_DIR=$(pwd) +cd $SRC_DIR + +if [ ! -d $MAIN_SRC_DIR/work/glibc/glibc_prepared ] ; then echo "Cannot continue - GLIBC is missing. Please buld GLIBC first." exit 1 fi echo "Preparing the overlay glibc folder. This may take a while..." -rm -rf work/overlay/glibc -mkdir -p work/overlay/glibc/lib +rm -rf $MAIN_SRC_DIR/work/overlay/glibc +mkdir -p $MAIN_SRC_DIR/work/overlay/glibc/lib -cd work/glibc/glibc_prepared/lib +cd $MAIN_SRC_DIR/work/glibc/glibc_prepared/lib -find . -type l -exec cp {} $SRC_DIR/work/overlay/glibc/lib \; +find . -type l -exec cp {} $MAIN_SRC_DIR/work/overlay/glibc/lib \; echo "All libraries have been copied." -cd $SRC_DIR/work/overlay/glibc/lib +cd $MAIN_SRC_DIR/work/overlay/glibc/lib for FILE_DEL in $(ls *.so) do @@ -33,8 +38,10 @@ echo "Duplicate libraries have been replaced with soft links." strip -g * echo "All libraries have been optimized for size." -cp -r $SRC_DIR/work/overlay/glibc/lib $SRC_DIR/work/src/minimal_overlay -echo "All libraries have been installed." +cp -r $MAIN_SRC_DIR/work/overlay/glibc/lib \ + $MAIN_SRC_DIR/work/src/minimal_overlay/rootfs + +echo "All GNU C libraries have been installed." cd $SRC_DIR diff --git a/src/overlay_java.sh b/src/minimal_overlay/bundles/java/bundle.sh similarity index 70% rename from src/overlay_java.sh rename to src/minimal_overlay/bundles/java/bundle.sh index 9df912357..dcffd407d 100755 --- a/src/overlay_java.sh +++ b/src/minimal_overlay/bundles/java/bundle.sh @@ -18,8 +18,13 @@ SRC_DIR=$(pwd) +# Find the main source directory +cd ../../.. +MAIN_SRC_DIR=$(pwd) +cd $SRC_DIR + # Read the 'JAVA_ARCHIVE' property from '.config' -JAVA_ARCHIVE="$(grep -i ^JAVA_ARCHIVE .config | cut -f2 -d'=')" +JAVA_ARCHIVE="$(grep -i ^JAVA_ARCHIVE $MAIN_SRC_DIR/.config | cut -f2 -d'=')" if [ "$JAVA_ARCHIVE" = "" ] ; then echo "ERROR: configuration property 'JAVA_ARCHIVE' is not set." @@ -29,24 +34,25 @@ elif [ ! -f "$JAVA_ARCHIVE" ] ; then exit 1 fi -rm -rf $SRC_DIR/work/overlay/java -mkdir -p $SRC_DIR/work/overlay/java/opt +rm -rf $MAIN_SRC_DIR/work/overlay/java +mkdir -p $MAIN_SRC_DIR/work/overlay/java/opt tar -xvf \ $JAVA_ARCHIVE \ - -C $SRC_DIR/work/overlay/java/opt + -C $MAIN_SRC_DIR/work/overlay/java/opt -cd $SRC_DIR/work/overlay/java/opt +cd $MAIN_SRC_DIR/work/overlay/java/opt mv $(ls -d *) java -mkdir $SRC_DIR/work/overlay/java/bin +mkdir $MAIN_SRC_DIR/work/overlay/java/bin for FILE in $(ls java/bin) do ln -s ../opt/java/bin/$FILE ../bin/$FILE done -cp -r $SRC_DIR/work/overlay/java/* $SRC_DIR/work/src/minimal_overlay +cp -r $MAIN_SRC_DIR/work/overlay/java/* \ + $MAIN_SRC_DIR/work/src/minimal_overlay/rootfs echo "Java has been installed." diff --git a/src/overlay_links_01_get.sh b/src/minimal_overlay/bundles/links/01_get.sh similarity index 59% rename from src/overlay_links_01_get.sh rename to src/minimal_overlay/bundles/links/01_get.sh index 3c50fbcc6..e2a9f4da6 100755 --- a/src/overlay_links_01_get.sh +++ b/src/minimal_overlay/bundles/links/01_get.sh @@ -2,28 +2,33 @@ SRC_DIR=$(pwd) +# Find the main source directory +cd ../../.. +MAIN_SRC_DIR=$(pwd) +cd $SRC_DIR + # Grab everything after the '=' character. -DOWNLOAD_URL=$(grep -i LINKS_SOURCE_URL .config | cut -f2 -d'=') +DOWNLOAD_URL=$(grep -i LINKS_SOURCE_URL $MAIN_SRC_DIR/.config | cut -f2 -d'=') # 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'=')" +USE_LOCAL_SOURCE="$(grep -i USE_LOCAL_SOURCE $MAIN_SRC_DIR/.config | cut -f2 -d'=')" -if [ "$USE_LOCAL_SOURCE" = "true" -a ! -f $SRC_DIR/source/overlay/$ARCHIVE_FILE ] ; then - echo "Source bundle $SRC_DIR/source/overlay/$ARCHIVE_FILE is missing and will be downloaded." +if [ "$USE_LOCAL_SOURCE" = "true" -a ! -f $MAIN_SRC_DIR/source/overlay/$ARCHIVE_FILE ] ; then + echo "Source bundle $MAIN_SRC_DIR/source/overlay/$ARCHIVE_FILE is missing and will be downloaded." USE_LOCAL_SOURCE="false" fi -cd source/overlay +cd $MAIN_SRC_DIR/source/overlay if [ ! "$USE_LOCAL_SOURCE" = "true" ] ; then # Downloading Links source bundle file. The '-c' option allows the download to resume. echo "Downloading Links source bundle from $DOWNLOAD_URL" wget -c $DOWNLOAD_URL else - echo "Using local Links source bundle $SRC_DIR/source/overlay/$ARCHIVE_FILE" + echo "Using local Links source bundle $MAIN_SRC_DIR/source/overlay/$ARCHIVE_FILE" fi # Delete folder with previously extracted Links. diff --git a/src/overlay_links_02_build.sh b/src/minimal_overlay/bundles/links/02_build.sh similarity index 75% rename from src/overlay_links_02_build.sh rename to src/minimal_overlay/bundles/links/02_build.sh index bd2faf19c..7a23f778f 100755 --- a/src/overlay_links_02_build.sh +++ b/src/minimal_overlay/bundles/links/02_build.sh @@ -2,11 +2,16 @@ SRC_DIR=$(pwd) +# Find the main source directory +cd ../../.. +MAIN_SRC_DIR=$(pwd) +cd $SRC_DIR + # Read the 'JOB_FACTOR' property from '.config' -JOB_FACTOR="$(grep -i ^JOB_FACTOR .config | cut -f2 -d'=')" +JOB_FACTOR="$(grep -i ^JOB_FACTOR $MAIN_SRC_DIR/.config | cut -f2 -d'=')" # Read the 'CFLAGS' property from '.config' -CFLAGS="$(grep -i ^CFLAGS .config | cut -f2 -d'=')" +CFLAGS="$(grep -i ^CFLAGS $MAIN_SRC_DIR/.config | cut -f2 -d'=')" # Find the number of available CPU cores. NUM_CORES=$(grep ^processor /proc/cpuinfo | wc -l) @@ -14,7 +19,7 @@ NUM_CORES=$(grep ^processor /proc/cpuinfo | wc -l) # Calculate the number of 'make' jobs to be used later. NUM_JOBS=$((NUM_CORES * JOB_FACTOR)) -cd work/overlay/links +cd $MAIN_SRC_DIR/work/overlay/links # Change to the Links source directory which ls finds, e.g. 'links-2.12'. cd $(ls -d links-*) @@ -46,7 +51,9 @@ make install -j $NUM_JOBS echo "Reducing Links size..." strip -g ../links_installed/bin/* 2>/dev/null -cp -r ../links_installed/bin $SRC_DIR/work/src/minimal_overlay +cp -r ../links_installed/bin \ + $MAIN_SRC_DIR/work/src/minimal_overlay/rootfs + echo "Links has been installed." cd $SRC_DIR diff --git a/src/minimal_overlay/bundles/links/bundle.sh b/src/minimal_overlay/bundles/links/bundle.sh new file mode 100755 index 000000000..6284178ab --- /dev/null +++ b/src/minimal_overlay/bundles/links/bundle.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +SRC_DIR=$(pwd) + +time sh 01_get.sh +time sh 02_build.sh + +cd $SRC_DIR + diff --git a/src/overlay_mll_utils_01_prepare.sh b/src/minimal_overlay/bundles/mll_utils/01_prepare.sh similarity index 51% rename from src/overlay_mll_utils_01_prepare.sh rename to src/minimal_overlay/bundles/mll_utils/01_prepare.sh index 4ff261df5..b8aa8d9c9 100755 --- a/src/overlay_mll_utils_01_prepare.sh +++ b/src/minimal_overlay/bundles/mll_utils/01_prepare.sh @@ -2,9 +2,14 @@ SRC_DIR=$(pwd) +# Find the main source directory +cd ../../.. +MAIN_SRC_DIR=$(pwd) +cd $SRC_DIR + echo "Preparing the Minimal Linux Live utilities folder. This may take a while..." -rm -rf work/overlay/mll_utils -mkdir -p work/overlay/mll_utils/sbin +rm -rf $MAIN_SRC_DIR/work/overlay/mll_utils +mkdir -p $MAIN_SRC_DIR/work/overlay/mll_utils/sbin echo "Miminal Linux Live utilities folder has been prepared." diff --git a/src/overlay_mll_utils_02_disk_erase.sh b/src/minimal_overlay/bundles/mll_utils/02_disk_erase.sh similarity index 87% rename from src/overlay_mll_utils_02_disk_erase.sh rename to src/minimal_overlay/bundles/mll_utils/02_disk_erase.sh index 0ebec48bd..7c4671f4c 100755 --- a/src/overlay_mll_utils_02_disk_erase.sh +++ b/src/minimal_overlay/bundles/mll_utils/02_disk_erase.sh @@ -2,12 +2,17 @@ SRC_DIR=$(pwd) -if [ ! -d "$SRC_DIR/work/overlay/mll_utils" ] ; then - echo "The directory $SRC_DIR/work/overlay/mll_utils does not exist. Cannot continue." +# Find the main source directory +cd ../../.. +MAIN_SRC_DIR=$(pwd) +cd $SRC_DIR + +if [ ! -d "$MAIN_SRC_DIR/work/overlay/mll_utils" ] ; then + echo "The directory $MAIN_SRC_DIR/work/overlay/mll_utils does not exist. Cannot continue." exit 1 fi -cd work/overlay/mll_utils +cd $MAIN_SRC_DIR/work/overlay/mll_utils # 'mll-disk-erase' BEGIN diff --git a/src/overlay_mll_utils_03_installer.sh b/src/minimal_overlay/bundles/mll_utils/03_installer.sh similarity index 73% rename from src/overlay_mll_utils_03_installer.sh rename to src/minimal_overlay/bundles/mll_utils/03_installer.sh index 95d493012..1bb460cae 100755 --- a/src/overlay_mll_utils_03_installer.sh +++ b/src/minimal_overlay/bundles/mll_utils/03_installer.sh @@ -2,12 +2,17 @@ SRC_DIR=$(pwd) -if [ ! -d "$SRC_DIR/work/overlay/mll_utils" ] ; then - echo "The directory $SRC_DIR/work/overlay/mll_utils does not exist. Cannot continue." +# Find the main source directory +cd ../../.. +MAIN_SRC_DIR=$(pwd) +cd $SRC_DIR + +if [ ! -d "$MAIN_SRC_DIR/work/overlay/mll_utils" ] ; then + echo "The directory $MAIN_SRC_DIR/work/overlay/mll_utils does not exist. Cannot continue." exit 1 fi -cd work/overlay/mll_utils +cd $MAIN_SRC_DIR/work/overlay/mll_utils # 'mll-install' BEGIN @@ -97,28 +102,30 @@ chmod +rx sbin/mll-install # 'mll-install' END -if [ ! -d "$SRC_DIR/work/syslinux" ] ; then +if [ ! -d "$MAIN_SRC_DIR/work/syslinux" ] ; then echo "The installer depends on Syslinux which is missing. Cannot continue." exit 1 fi; -cd $SRC_DIR/work/syslinux +cd $MAIN_SRC_DIR/work/syslinux cd $(ls -d syslinux-*) cp bios/extlinux/extlinux \ - $SRC_DIR/work/overlay/mll_utils/sbin -mkdir -p $SRC_DIR/work/overlay/mll_utils/opt/syslinux + $MAIN_SRC_DIR/work/overlay/mll_utils/sbin +mkdir -p $MAIN_SRC_DIR/work/overlay/mll_utils/opt/syslinux cp bios/mbr/mbr.bin \ - $SRC_DIR/work/overlay/mll_utils/opt/syslinux + $MAIN_SRC_DIR/work/overlay/mll_utils/opt/syslinux -# Big mama hack - find workaround and remove it!!! +# Big mama hack - need to find proper workaround!!! # Both syslinux and extlinux are 32-bit executables which require 32-bit libs. -mkdir -p $SRC_DIR/work/overlay/mll_utils/lib -mkdir -p $SRC_DIR/work/overlay/mll_utils/usr/lib +# Possible solution 1 - build 32-bit GLIBC on demand. +# Possible solution 2 - drop 32-bit MLL and provide 64-bit with multi-arch. +mkdir -p $MAIN_SRC_DIR/work/overlay/mll_utils/lib +mkdir -p $MAIN_SRC_DIR/work/overlay/mll_utils/usr/lib cp /lib/ld-linux.so.2 \ - $SRC_DIR/work/overlay/mll_utils/lib + $MAIN_SRC_DIR/work/overlay/mll_utils/lib cp /lib/i386-linux-gnu/libc.so.6 \ - $SRC_DIR/work/overlay/mll_utils/usr/lib + $MAIN_SRC_DIR/work/overlay/mll_utils/usr/lib # Big mama hack - end. echo "Minimal Linux Live installer has been generated." diff --git a/src/minimal_overlay/bundles/mll_utils/04_install.sh b/src/minimal_overlay/bundles/mll_utils/04_install.sh new file mode 100755 index 000000000..5610549af --- /dev/null +++ b/src/minimal_overlay/bundles/mll_utils/04_install.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +SRC_DIR=$(pwd) + +# Find the main source directory +cd ../../.. +MAIN_SRC_DIR=$(pwd) +cd $SRC_DIR + +if [ ! -d "$MAIN_SRC_DIR/work/overlay/mll_utils" ] ; then + echo "The directory $MAIN_SRC_DIR/work/overlay/mll_utils does not exist. Cannot continue." + exit 1 +fi + +# Copy all generated files to the source overlay folder. +cp -r $MAIN_SRC_DIR/work/overlay/mll_utils/* \ + $MAIN_SRC_DIR/work/src/minimal_overlay/rootfs + +echo "All MLL utilities have been installed." + +cd $SRC_DIR + diff --git a/src/minimal_overlay/bundles/mll_utils/bundle.sh b/src/minimal_overlay/bundles/mll_utils/bundle.sh new file mode 100755 index 000000000..3653a88fa --- /dev/null +++ b/src/minimal_overlay/bundles/mll_utils/bundle.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +SRC_DIR=$(pwd) + +time sh 01_prepare.sh +time sh 02_disk_erase.sh +time sh 03_installer.sh +time sh 04_install.sh + +cd $SRC_DIR + diff --git a/src/minimal_overlay/overlay_build.sh b/src/minimal_overlay/overlay_build.sh new file mode 100755 index 000000000..254fd6b84 --- /dev/null +++ b/src/minimal_overlay/overlay_build.sh @@ -0,0 +1,51 @@ +#!/bin/sh + +SRC_DIR=$(pwd) + +# Find the main source directory +cd .. +MAIN_SRC_DIR=$(pwd) +cd $SRC_DIR + +if [ "$1" = "" ] ; then + # Read the 'OVERLAY_BUNDLES' property from '.config' + OVERLAY_BUNDLES="$(grep -i ^OVERLAY_BUNDLES $MAIN_SRC_DIR/.config | cut -f2 -d'=')" +else + OVERLAY_BUNDLES=$1 +fi + +if [ "$OVERLAY_BUNDLES" = "" ] ; then + echo "There are no overlay bundles to build." + exit 1 +fi + +time sh overlay_clean.sh + +BUNDLES_LIST="$(echo $OVERLAY_BUNDLES | tr ',' ' ')" + +for BUNDLE in $BUNDLES_LIST +do + BUNDLE_DIR=$SRC_DIR/bundles/$BUNDLE + + if [ ! -d $BUNDLE_DIR ] ; then + echo "Error - cannot find overlay bundle directory '$BUNDLE_DIR'." + continue + fi + + BUNDLE_SCRIPT=$BUNDLE_DIR/bundle.sh + + if [ ! -f $BUNDLE_SCRIPT ] ; then + echo "Error - cannot find overlay bundle script file '$BUNDLE_SCRIPT'." + continue + fi + + cd $BUNDLE_DIR + + echo "Building overlay bundle '$BUNDLE'..." + time sh $BUNDLE_SCRIPT + + cd $SRC_DIR +done + +cd $SRC_DIR + diff --git a/src/overlay_00_clean.sh b/src/minimal_overlay/overlay_clean.sh similarity index 60% rename from src/overlay_00_clean.sh rename to src/minimal_overlay/overlay_clean.sh index a77a83955..1abc7742c 100755 --- a/src/overlay_00_clean.sh +++ b/src/minimal_overlay/overlay_clean.sh @@ -3,17 +3,16 @@ SRC_DIR=$(pwd) echo "Cleaning up the overlay work area. This may take a while..." -rm -rf work/overlay -mkdir -p work/overlay - -mkdir -p work/src/minimal_overlay +rm -rf ../work/overlay # -p stops errors if the directory already exists. -mkdir -p source/overlay +mkdir -p ../work/overlay +mkdir -p ../work/src/minimal_overlay/rootfs +mkdir -p ../source/overlay -cd work/src/minimal_overlay +cd ../work/src/minimal_overlay/rootfs -# Remove all previously prepared overlay artifacts. +# Remove all previously generated overlay artifacts. for dir in $(ls -d */ 2>/dev/null) ; do rm -rf $dir echo "Overlay folder '$dir' has been removed." diff --git a/src/minimal_overlay/rootfs/README b/src/minimal_overlay/rootfs/README new file mode 100644 index 000000000..bb54bdd5d --- /dev/null +++ b/src/minimal_overlay/rootfs/README @@ -0,0 +1,13 @@ + +This file is located in the folder 'minimal_overlay/rootfs'. +You can use this folder to put your own content (files and folders) which will +be visible in the root folder of your 'Minimal Linux Live' system, just like +this file is visible. The files/folders will override the content in the root +folder, so be careful what you put there because you may end up with broken +system. If the boot media is writeable, then all changes on the root file system +are persisted automatically, so be very careful what you do when you use the +overlay support. + +Check the '.config' file in the source folder for more details on the overlay +options and how to use them. + diff --git a/src/overlay_dropbear.sh b/src/overlay_dropbear.sh deleted file mode 100755 index ba80a3840..000000000 --- a/src/overlay_dropbear.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -time sh overlay_dropbear_01_get.sh -time sh overlay_dropbear_02_build.sh - diff --git a/src/overlay_felix.sh b/src/overlay_felix.sh deleted file mode 100755 index 3a2eb671a..000000000 --- a/src/overlay_felix.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -time sh overlay_felix_01_get.sh -time sh overlay_felix_02_install.sh - diff --git a/src/overlay_felix_02_install.sh b/src/overlay_felix_02_install.sh deleted file mode 100755 index 63d5e874b..000000000 --- a/src/overlay_felix_02_install.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh - -SRC_DIR=$(pwd) - -echo "Removing old Apache Felix artifacts. This may take a while..." -rm -rf $SRC_DIR/work/overlay/felix/felix_installed -mkdir -p $SRC_DIR/work/overlay/felix/felix_installed/opt/felix -mkdir -p $SRC_DIR/work/overlay/felix/felix_installed/bin - -cd $SRC_DIR/work/overlay/felix -cd $(ls -d felix-*) - -cat << CEOF > bin/felix-start.sh -#!/bin/sh - -cd /opt/felix -java -jar bin/felix.jar - -CEOF - -chmod +rx bin/felix-start.sh - -cp -r * $SRC_DIR/work/overlay/felix/felix_installed/opt/felix - -cd $SRC_DIR/work/overlay/felix/felix_installed - -ln -s ../opt/felix/bin/felix-start.sh bin/felix-start - -cp -r $SRC_DIR/work/overlay/felix/felix_installed/* \ - $SRC_DIR/work/src/minimal_overlay - -echo "Apache Felix has been installed." - -cd $SRC_DIR - diff --git a/src/overlay_links.sh b/src/overlay_links.sh deleted file mode 100755 index 5d1bf64f3..000000000 --- a/src/overlay_links.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -time sh overlay_links_01_get.sh -time sh overlay_links_02_build.sh - diff --git a/src/overlay_mll_utils.sh b/src/overlay_mll_utils.sh deleted file mode 100755 index 89ed32c18..000000000 --- a/src/overlay_mll_utils.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -time sh overlay_mll_utils_01_prepare.sh -time sh overlay_mll_utils_02_disk_erase.sh -time sh overlay_mll_utils_03_installer.sh -time sh overlay_mll_utils_04_install.sh - diff --git a/src/overlay_mll_utils_04_install.sh b/src/overlay_mll_utils_04_install.sh deleted file mode 100755 index fbc621bab..000000000 --- a/src/overlay_mll_utils_04_install.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -SRC_DIR=$(pwd) - -if [ ! -d "$SRC_DIR/work/overlay/mll_utils" ] ; then - echo "The directory $SRC_DIR/work/overlay/mll_utils does not exist. Cannot continue." - exit 1 -fi - -# Copy all generated files to the source overlay folder. -cp -r $SRC_DIR/work/overlay/mll_utils/* \ - $SRC_DIR/work/src/minimal_overlay - -echo "All utilities have been installed." - -cd $SRC_DIR -