Added support for building additional/overlay software on top of MLL. The only such software for now is Links (text browser).

This commit is contained in:
Ivan Davidov 2016-05-06 23:44:54 +03:00
parent c83c5d6b25
commit 848f5e5623
38 changed files with 241 additions and 44 deletions

View File

@ -1,3 +1,9 @@
###################################################
# #
# This section contains the main source bundles #
# #
###################################################
# You can find the latest Linux kernel source bundles here:
#
# http://kernel.org
@ -24,9 +30,27 @@ BUSYBOX_SOURCE_URL=http://busybox.net/downloads/busybox-1.24.2.tar.bz2
#
SYSLINUX_SOURCE_URL=http://kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.03.tar.xz
### ### ### ###
### ### ### ###
### ### ### ###
######################################################
# #
# This section contains the overlay source bundles #
# #
######################################################
# You can find the latest Links source bundles here:
#
# http://links.twibright.com
#
LINKS_SOURCE_URL=http://links.twibright.com/download/links-2.12.tar.bz2
####################################################
# #
# This section contains configuration properties #
# #
####################################################
# Use predefined '.config' file when building the kernel. This overrides the
# config generation in '03_build_kernel.sh' and the build process uses the
@ -84,3 +108,8 @@ COPY_SOURCE_ROOTFS=true
# the property in order to disable it.
COPY_SOURCE_ISO=true
# This flag defines whether to build additional overlay software which will be
# placed in the 'minimal_overlay' folder. This software will be visible and
# fully usable after boot. The default is 'false'.
BUILD_OVERLAY_SOFTWARE=true

View File

@ -1,9 +1,13 @@
#!/bin/sh
echo "Cleaning up the work area. This may take a while..."
echo "*** CLEAN BEGIN ***"
echo "Cleaning up the main work area. This may take a while..."
rm -rf work
mkdir work
# -p stops errors if the directory already exists
mkdir -p source
echo "*** CLEAN END ***"

View File

@ -1,5 +1,7 @@
#!/bin/sh
echo "*** GET KERNEL BEGIN ***"
SRC_DIR=$(pwd)
# Grab everything after the '=' character.
@ -37,3 +39,5 @@ tar -xvf $ARCHIVE_FILE -C ../work/kernel
cd $SRC_DIR
echo "*** GET KERNEL END ***"

View File

@ -1,5 +1,7 @@
#!/bin/sh
echo "*** BUILD KERNEL BEGIN ***"
SRC_DIR=$(pwd)
cd work/kernel
@ -14,15 +16,15 @@ make mrproper
# Read the 'USE_PREDEFINED_KERNEL_CONFIG' property from '.config'
USE_PREDEFINED_KERNEL_CONFIG="$(grep -i USE_PREDEFINED_KERNEL_CONFIG $SRC_DIR/.config | cut -f2 -d'=')"
if [ "$USE_PREDEFINED_KERNEL_CONFIG" = "true" -a ! -f $SRC_DIR/config_predefined/kernel.config ] ; then
echo "Config file $SRC_DIR/config_predefined/kernel.config does not exist."
if [ "$USE_PREDEFINED_KERNEL_CONFIG" = "true" -a ! -f $SRC_DIR/minimal_config/kernel.config ] ; then
echo "Config file $SRC_DIR/minimal_config/kernel.config does not exist."
USE_PREDEFINED_KERNEL_CONFIG="false"
fi
if [ "$USE_PREDEFINED_KERNEL_CONFIG" = "true" ] ; then
# Use predefined configuration file for the kernel.
echo "Using config file $SRC_DIR/config_predefined/kernel.config"
cp -f $SRC_DIR/config_predefined/kernel.config .config
echo "Using config file $SRC_DIR/minimal_config/kernel.config"
cp -f $SRC_DIR/minimal_config/kernel.config .config
else
# Create default configuration file for the kernel.
make defconfig
@ -56,3 +58,5 @@ make headers_install
cd $SRC_DIR
echo "*** BUILD KERNEL END ***"

View File

@ -1,5 +1,7 @@
#!/bin/sh
echo "*** GET GLIBC BEGIN ***"
SRC_DIR=$(pwd)
# Grab everything after the '=' character.
@ -37,3 +39,5 @@ tar -xvf $ARCHIVE_FILE -C ../work/glibc
cd $SRC_DIR
echo "*** GET GLIBC END ***"

View File

@ -1,5 +1,7 @@
#!/bin/sh
echo "*** BUILD GLIBC BEGIN ***"
SRC_DIR=$(pwd)
# Find the kernel build directory.
@ -56,3 +58,5 @@ make install \
cd $SRC_DIR
echo "*** BUILD GLIBC END ***"

View File

@ -1,5 +1,7 @@
#!/bin/sh
echo "*** PREPARE GLIBC BEGIN ***"
SRC_DIR=$(pwd)
# Find the kernel build directory.
@ -50,3 +52,5 @@ ln -s $WORK_KERNEL_DIR/usr/include/mtd mtd
cd $SRC_DIR
echo "*** PREPARE GLIBC END ***"

View File

@ -1,5 +1,7 @@
#!/bin/sh
echo "*** GET BUSYBOX BEGIN ***"
SRC_DIR=$(pwd)
# Grab everything after the '=' character.
@ -37,3 +39,5 @@ tar -xvf $ARCHIVE_FILE -C ../work/busybox
cd $SRC_DIR
echo "*** GET BUSYBOX END ***"

View File

@ -1,5 +1,7 @@
#!/bin/sh
echo "*** BUILD BUSYBOX BEGIN ***"
SRC_DIR=$(pwd)
# Remember the glibc installation area.
@ -20,15 +22,15 @@ make distclean
# Read the 'USE_PREDEFINED_BUSYBOX_CONFIG' property from '.config'
USE_PREDEFINED_BUSYBOX_CONFIG="$(grep -i USE_PREDEFINED_BUSYBOX_CONFIG $SRC_DIR/.config | cut -f2 -d'=')"
if [ "$USE_PREDEFINED_BUSYBOX_CONFIG" = "true" -a ! -f $SRC_DIR/config_predefined/busybox.config ] ; then
echo "Config file $SRC_DIR/config_predefined/busybox.config does not exist."
if [ "$USE_PREDEFINED_BUSYBOX_CONFIG" = "true" -a ! -f $SRC_DIR/minimal_config/busybox.config ] ; then
echo "Config file $SRC_DIR/minimal_config/busybox.config does not exist."
USE_PREDEFINED_BUSYBOX_CONFIG="false"
fi
if [ "$USE_PREDEFINED_BUSYBOX_CONFIG" = "true" ] ; then
# Use predefined configuration file for Busybox.
echo "Using config file $SRC_DIR/config_predefined/busybox.config"
cp -f $SRC_DIR/config_predefined/busybox.config .config
echo "Using config file $SRC_DIR/minimal_config/busybox.config"
cp -f $SRC_DIR/minimal_config/busybox.config .config
else
# Create default configuration file.
echo "Generating default BusyBox configuration..."
@ -61,3 +63,5 @@ make \
cd $SRC_DIR
echo "*** BUILD BUSYBOX END ***"

View File

@ -1,9 +1,12 @@
#!/bin/sh
echo "*** PREPARE SRC BEGIN ***"
SRC_DIR=$(pwd)
cd work
# Remove old sources (if they exist)
rm -rf src
mkdir src
@ -12,9 +15,9 @@ cp ../*.sh src
cp ../.config src
cp ../README src
cp ../*.txt src
cp -r ../09_generate_rootfs src
cp -r ../12_generate_iso src
cp -r ../config_predefined src
cp -r ../minimal_rootfs src
cp -r ../minimal_overlay src
cp -r ../minimal_config src
# Delete the '.gitignore' files which we use in order to keep track of otherwise
# empty folders.
@ -24,3 +27,5 @@ echo "Source files and folders have been prepared."
cd $SRC_DIR
echo "*** PREPARE SRC END ***"

View File

@ -1,5 +1,7 @@
#!/bin/sh
echo "*** GENERATE ROOTFS BEGIN ***"
SRC_ROOT=$(pwd)
# Remember the glibc prepared folder.
@ -17,7 +19,7 @@ rm -rf rootfs
cp -r $BUSYBOX_INSTALLED rootfs
# Copy all rootfs resources to the location of our 'initramfs' folder.
cp -r src/09_generate_rootfs/* rootfs
cp -r src/minimal_rootfs/* rootfs
cd rootfs
@ -65,3 +67,5 @@ echo "The initramfs area has been generated."
cd $SRC_ROOT
echo "*** GENERATE ROOTFS END ***"

View File

@ -1,5 +1,7 @@
#!/bin/sh
echo "*** PACK ROOTFS BEGIN ***"
SRC_DIR=$(pwd)
cd work
@ -13,5 +15,7 @@ cd rootfs
echo "Packing initramfs..."
find . | cpio -R root:root -H newc -o | xz --check=none > ../rootfs.cpio.xz
cd cd $SRC_DIR
cd $SRC_DIR
echo "*** PACK ROOTFS END ***"

View File

@ -1,5 +1,7 @@
#!/bin/sh
echo "*** GET SYSLINUX BEGIN ***"
SRC_DIR=$(pwd)
# Grab everything after the '=' character.
@ -37,3 +39,5 @@ tar -xvf $ARCHIVE_FILE -C ../work/syslinux
cd $SRC_DIR
echo "*** GET SYSLINUX END ***"

View File

@ -1,5 +1,7 @@
#!/bin/sh
echo "*** GENERATE ISO BEGIN ***"
SRC_DIR=$(pwd)
# Find the kernel build directory.
@ -24,9 +26,32 @@ rm -rf work/isoimage
# This is the root folder of the ISO image.
mkdir work/isoimage
cd work/isoimage
echo "Prepared new ISO image work area."
# Read the 'COPY_SOURCE_ISO' property from '.config'
COPY_SOURCE_ISO="$(grep -i COPY_SOURCE_ISO .config | cut -f2 -d'=')"
if [ "$COPY_SOURCE_ISO" = "true" ] ; then
# Copy all prepared source files and folders to '/src'. Note that the scripts
# will not work there because you also need proper toolchain.
cp -r work/src work/isoimage
echo "Source files and folders have been copied to '/src'."
else
echo "Source files and folders have been skipped."
fi
# Read the 'BUILD_OVERLAY_SOFTWARE' property from '.config'
BUILD_OVERLAY_SOFTWARE="$(grep -i BUILD_OVERLAY_SOFTWARE .config | cut -f2 -d'=')"
if [ "$BUILD_OVERLAY_SOFTWARE" = "true" ] ; then
echo "Generating additional overlay software. This may take a while..."
sh build_minimal_linux_overlay.sh
else
echo "Generation of additional overlay software has been skipped."
fi
cd work/isoimage
# 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 .
@ -37,25 +62,13 @@ cp $WORK_KERNEL_DIR/arch/x86/boot/bzImage ./kernel.xz
# Now we copy the root file system.
cp ../rootfs.cpio.xz ./rootfs.xz
# Read the 'COPY_SOURCE_ISO' property from '.config'
COPY_SOURCE_ISO="$(grep -i COPY_SOURCE_ISO ../../.config | cut -f2 -d'=')"
if [ "$COPY_SOURCE_ISO" = "true" ] ; then
# Copy all prepared source files and folders to '/src'. Note that the scripts
# will not work there because you also need proper toolchain.
cp -r ../src src
echo "Source files and folders have been copied to '/src'."
else
echo "Source files and folders have been skipped."
fi
# 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
# 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 '12_generate_iso' will be merged
# All files and folders located in the folder 'minimal_overlay' will be merged
# with the root folder on boot.
echo "Using sparse file for overlay."
@ -84,7 +97,7 @@ if [ "$OVERLAY_TYPE" = "sparse" -a "$(id -u)" = "0" ] ; then
mkdir -p sparse/work
# Copy the overlay content.
cp -r $SRC_DIR/12_generate_iso/* sparse/rootfs/
cp -r $SRC_DIR/work/src/minimal_overlay/* sparse/rootfs/
# Unmount the sparse file and delete the temporary folder.
$BUSYBOX umount sparse
@ -94,14 +107,14 @@ if [ "$OVERLAY_TYPE" = "sparse" -a "$(id -u)" = "0" ] ; then
$BUSYBOX losetup -d $LOOP_DEVICE
elif [ "$OVERLAY_TYPE" = "folder" ] ; then
# Use normal folder structure for overlay. All files and folders located in
# the folder '12_generate_iso' will be merged with the root folder on boot.
# the folder 'minimal_overlay' will be merged with the root folder on boot.
echo "Using folder structure for overlay."
mkdir -p minimal/rootfs
mkdir -p minimal/work
cp -rf $SRC_DIR/12_generate_iso/* minimal/rootfs/
cp -rf $SRC_DIR/work/src/minimal_overlay/* minimal/rootfs/
else
echo "Generating ISO image with no overlay structure..."
fi
@ -128,3 +141,5 @@ fi
cd $SRC_DIR
echo "*** GENERATE ISO END ***"

View File

@ -18,7 +18,9 @@ clean:
@echo "Removing generated ISO image..."
@rm -f minimal_linux_live.iso
@echo "Removing predefined configuration files..."
@rm -f config_predefined/*.config
@rm -rf minimal_overlay/*.config
@echo "Removing source level overlay software..."
@cd minimal_overlay && rm -rf $(shell ls -d */) && cd ..
@echo "Removing build log file..."
@rm -f minimal_linux_live.log
@ -31,7 +33,7 @@ src:
@echo "Generating source archive..."
@rm -f minimal_linux_live_*_src.tar.xz
@mkdir -p work
@sh 01_prepare_src.sh 1>/dev/null
@sh 08_prepare_src.sh 1>/dev/null
@$(eval DATE_PARSED := $(shell LANG=en_US ; date +"%d-%b-%Y"))
@cd work/src && tar -cpf - `ls -A` | xz - > ../../minimal_linux_live_$(DATE_PARSED)_src.tar.xz && cd ../..
@echo "Source archive: minimal_linux_live_$(DATE_PARSED)_src.tar.xz"

View File

@ -1,14 +1,14 @@
#!/bin/sh
sh 00_clean.sh
sh 01_prepare_src.sh
sh 02_get_kernel.sh
sh 03_build_kernel.sh
sh 04_get_glibc.sh
sh 05_build_glibc.sh
sh 06_prepare_glibc.sh
sh 07_get_busybox.sh
sh 08_build_busybox.sh
sh 01_get_kernel.sh
sh 02_build_kernel.sh
sh 03_get_glibc.sh
sh 04_build_glibc.sh
sh 05_prepare_glibc.sh
sh 06_get_busybox.sh
sh 07_build_busybox.sh
sh 08_prepare_src.sh
sh 09_generate_rootfs.sh
sh 10_pack_rootfs.sh
sh 11_get_syslinux.sh

View File

@ -0,0 +1,6 @@
#!/bin/sh
sh overlay_00_clean.sh
sh overlay_01_get_links.sh
sh overlay_02_build_links.sh

26
src/overlay_00_clean.sh Executable file
View File

@ -0,0 +1,26 @@
#!/bin/sh
SRC_DIR=$(pwd)
echo "Cleaning up the overlay work area. This may take a while..."
rm -rf work/overlay
mkdir -p work/overlay
# Just in case we execute the overlay software generation script before we
# execute the main build script.
mkdir -p work/src/minimal_overlay
# -p stops errors if the directory already exists
mkdir -p source/overlay
cd minimal_overlay
for dir in $(ls -d */ 2>/dev/null) ; do
rm -rf $dir
echo "Overlay folder '$dir' has been removed."
done
echo "Ready to continue building the overlay software."
cd $SRC_DIR

39
src/overlay_01_get_links.sh Executable file
View File

@ -0,0 +1,39 @@
#!/bin/sh
SRC_DIR=$(pwd)
# Grab everything after the '=' character.
DOWNLOAD_URL=$(grep -i LINKS_SOURCE_URL .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'=')"
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."
USE_LOCAL_SOURCE="false"
fi
cd 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"
fi
# Delete folder with previously extracted Links.
echo "Removing Links work area. This may take a while..."
rm -rf ../../work/overlay/links
mkdir ../../work/overlay/links
# Extract Links to folder 'work/overlay/links'.
# Full path will be something like 'work/overlay/links/links-2.12'.
tar -xvf $ARCHIVE_FILE -C ../../work/overlay/links
cd $SRC_DIR

31
src/overlay_02_build_links.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/sh
SRC_DIR=$(pwd)
cd work/overlay/links
# Change to the Links source directory which ls finds, e.g. 'links-2.12'.
cd $(ls -d links-*)
echo "Preparing Links work area. This may take a while..."
make clean 2>/dev/null
echo "Configuring Links..."
./configure \
--prefix=../links_installed \
--disable-graphics \
--enable-utf8 \
--without-ipv6 \
--without-ssl \
--without-x
echo "Building Links..."
make
make install
cp -r ../links_installed/bin $SRC_DIR/work/src/minimal_overlay
echo "Links has been installed."
cd $SRC_DIR