Added Oracle JRE/JDK and Apache Felix OSGi framework as overlay bundles. This needs additional cleanup. Updated the kernel build process - artifacts are used from separate install location.

This commit is contained in:
Ivan Davidov 2016-05-29 19:38:55 +03:00
parent b613b066f1
commit 4328fa806c
16 changed files with 232 additions and 78 deletions

View File

@ -8,7 +8,7 @@
# #
# http://kernel.org # http://kernel.org
# #
KERNEL_SOURCE_URL=http://kernel.org/pub/linux/kernel/v4.x/linux-4.5.3.tar.xz KERNEL_SOURCE_URL=http://kernel.org/pub/linux/kernel/v4.x/linux-4.5.5.tar.xz
# You can find the latest GNU libc source bundles here: # You can find the latest GNU libc source bundles here:
# #
@ -32,11 +32,11 @@ SYSLINUX_SOURCE_URL=http://kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.0
###################################################### #####################################################################
# # # #
# This section contains the overlay source bundles # # This section contains the overlay source bundles and properties #
# # # #
###################################################### #####################################################################
# You can find the latest Links source bundles here: # You can find the latest Links source bundles here:
# #
@ -50,6 +50,20 @@ LINKS_SOURCE_URL=http://links.twibright.com/download/links-2.12.tar.bz2
# #
DROPBEAR_SOURCE_URL=http://matt.ucc.asn.au/dropbear/releases/dropbear-2016.73.tar.bz2 DROPBEAR_SOURCE_URL=http://matt.ucc.asn.au/dropbear/releases/dropbear-2016.73.tar.bz2
# You can find the latest Apache Felix source bundles here:
#
# http://felix.apache.org
#
FELIX_SOURCE_URL=http://www-us.apache.org/dist/felix/org.apache.felix.main.distribution-5.4.0.tar.gz
# Download Oracle's jdk/jre and set the property with the absolute path to
# the archive. Example:
#
# JAVA_ARCHIVE=/home/ivan/Downloads/jdk-8u91-linux-x64.tar.gz
#
#JAVA_ARCHIVE=/absolute/path/to/java.archive.tar.gz
JAVA_ARCHIVE=/home/ivan/Downloads/jdk-8u91-linux-x64.tar.gz
#################################################### ####################################################
@ -102,7 +116,7 @@ OVERLAY_TYPE=folder
# internet. This is useful when you have already downloaded the sources and have # 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 # no internet connection. Or if you want to share your version of "Minimal Linux
# Live" with predefined sources. # Live" with predefined sources.
USE_LOCAL_SOURCE=false USE_LOCAL_SOURCE=true
# Copy "Minimal Linux Live" source files and folders in '/src' inside initramfs. # Copy "Minimal Linux Live" source files and folders in '/src' inside initramfs.
# The default value is 'true'. You can use any other value, no value, or comment # The default value is 'true'. You can use any other value, no value, or comment
@ -130,8 +144,11 @@ COPY_SOURCE_ISO=true
# glibc_full - all core GNU C libraries (useful if other software is included) # glibc_full - all core GNU C libraries (useful if other software is included)
# links - text browser # links - text browser
# dropbear - SSH server and client # dropbear - SSH server and client
# java - installs Oracle's JRE or JDK. Manual steps required.
# felix - Apache Felix OSGi framework.
# #
#OVERLAY_SOFTWARE=glibc_full,links,dropbear #OVERLAY_BUNDLES=glibc_full,links,dropbear,java,felix
OVERLAY_BUNDLES=glibc_full,java,felix
# This property enables the standard penguin boot logo in the upper left corner # 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 # of the screen. The property is used in 'xx_build_kernel.sh'. The default value
@ -140,8 +157,8 @@ USE_BOOT_LOGO=true
# This property is the multiplicator which is used during the build process. The # This property is the multiplicator which is used during the build process. The
# total number of each 'make' jobs will be equal to the number of detected CPU # total number of each 'make' jobs will be equal to the number of detected CPU
# cores mutiplied by this property. For example, if your CPU has 4 cores, then # cores mutiplied by this property. For example, if you set this property with
# the number of 'make' jobs will be 4 * 2 = 8. Don't change this value unless # value '2' and if your CPU has 4 cores, then the number of 'make' jobs will be
# you know what 'make' jobs are! # 4 * 2 = 8. Don't change this property unless you know what 'make' jobs are!
JOB_FACTOR=2 JOB_FACTOR=1

View File

@ -15,6 +15,10 @@ NUM_JOBS=$((NUM_CORES * JOB_FACTOR))
cd work/kernel cd work/kernel
# Prepare the kernel install area.
rm -rf kernel_installed
mkdir kernel_installed
# Change to the kernel source directory which ls finds, e.g. 'linux-4.4.6'. # Change to the kernel source directory which ls finds, e.g. 'linux-4.4.6'.
cd $(ls -d linux-*) cd $(ls -d linux-*)
@ -77,10 +81,16 @@ make \
CFLAGS="-Os -s -fno-stack-protector -U_FORTIFY_SOURCE" \ CFLAGS="-Os -s -fno-stack-protector -U_FORTIFY_SOURCE" \
bzImage -j $NUM_JOBS bzImage -j $NUM_JOBS
# Install kernel headers in './usr' (this is not '/usr') which are used later # Install the kernel file.
# when we build and configure the GNU C library (glibc). cp arch/x86/boot/bzImage \
$SRC_DIR/work/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..." echo "Generating kernel headers..."
make headers_install -j $NUM_JOBS make \
INSTALL_HDR_PATH=$SRC_DIR/work/kernel/kernel_installed \
headers_install -j $NUM_JOBS
cd $SRC_DIR cd $SRC_DIR

View File

@ -13,11 +13,8 @@ NUM_CORES=$(grep ^processor /proc/cpuinfo | wc -l)
# Calculate the number of 'make' jobs to be used later. # Calculate the number of 'make' jobs to be used later.
NUM_JOBS=$((NUM_CORES * JOB_FACTOR)) NUM_JOBS=$((NUM_CORES * JOB_FACTOR))
# Find the kernel build directory. # Save the kernel installation directory.
cd work/kernel KERNEL_INSTALLED=$SRC_DIR/work/kernel/kernel_installed
cd $(ls -d linux-*)
WORK_KERNEL_DIR=$(pwd)
cd $SRC_DIR
cd work/glibc cd work/glibc
@ -49,7 +46,7 @@ cd glibc_objects
echo "Configuring glibc..." echo "Configuring glibc..."
$GLIBC_SRC/configure \ $GLIBC_SRC/configure \
--prefix= \ --prefix= \
--with-headers=$WORK_KERNEL_DIR/usr/include \ --with-headers=$KERNEL_INSTALLED/include \
--without-gd \ --without-gd \
--without-selinux \ --without-selinux \
--disable-werror \ --disable-werror \

View File

@ -4,11 +4,8 @@ echo "*** PREPARE GLIBC BEGIN ***"
SRC_DIR=$(pwd) SRC_DIR=$(pwd)
# Find the kernel build directory. # Save the kernel installation directory.
cd work/kernel KERNEL_INSTALLED=$(pwd)
cd $(ls -d *)
WORK_KERNEL_DIR=$(pwd)
cd $SRC_DIR
cd work/glibc cd work/glibc
@ -45,10 +42,10 @@ ln -s ../lib lib
cd ../include cd ../include
ln -s $WORK_KERNEL_DIR/usr/include/linux linux ln -s $KERNEL_INSTALLED/include/linux linux
ln -s $WORK_KERNEL_DIR/usr/include/asm asm ln -s $KERNEL_INSTALLED/include/asm asm
ln -s $WORK_KERNEL_DIR/usr/include/asm-generic asm-generic ln -s $KERNEL_INSTALLED/asm-generic asm-generic
ln -s $WORK_KERNEL_DIR/usr/include/mtd mtd ln -s $KERNEL_INSTALLED/include/mtd mtd
cd $SRC_DIR cd $SRC_DIR

View File

@ -6,6 +6,8 @@ SRC_DIR=$(pwd)
cd work cd work
echo "Preparing source files and folders. This may take a while..."
# Remove old sources (if they exist) # Remove old sources (if they exist)
rm -rf src rm -rf src
mkdir src mkdir src

View File

@ -6,14 +6,17 @@ SRC_DIR=$(pwd)
cd work cd work
echo "Packing initramfs. This may take a while..."
# Remove the old 'initramfs' archive if it exists. # Remove the old 'initramfs' archive if it exists.
rm -f rootfs.cpio.gz rm -f rootfs.cpio.gz
cd rootfs cd rootfs
# Packs the current 'initramfs' folder structure in 'cpio.xz' archive. # Packs the current 'initramfs' folder structure in 'cpio.xz' archive.
echo "Packing initramfs..." find . | cpio -R root:root -H newc -o | xz -9 --check=none > ../rootfs.cpio.xz
find . | cpio -R root:root -H newc -o | xz --check=none > ../rootfs.cpio.xz
echo "Packing of initramfs has finished."
cd $SRC_DIR cd $SRC_DIR

View File

@ -4,11 +4,8 @@ echo "*** GENERATE ISO BEGIN ***"
SRC_DIR=$(pwd) SRC_DIR=$(pwd)
# Find the kernel build directory. # Save the kernel installation directory.
cd work/kernel KERNEL_INSTALLED=$SRC_DIR/work/kernel/kernel_installed
cd $(ls -d *)
WORK_KERNEL_DIR=$(pwd)
cd $SRC_DIR
# Find the Syslinux build directory. # Find the Syslinux build directory.
cd work/syslinux cd work/syslinux
@ -40,14 +37,14 @@ else
echo "Source files and folders have been skipped." echo "Source files and folders have been skipped."
fi fi
# Read the 'OVERLAY_SOFTWARE' property from '.config' # Read the 'OVERLAY_BUNDLES' property from '.config'
OVERLAY_SOFTWARE="$(grep -i ^OVERLAY_SOFTWARE .config | cut -f2 -d'=')" OVERLAY_BUNDLES="$(grep -i ^OVERLAY_BUNDLES .config | cut -f2 -d'=')"
if [ ! "$OVERLAY_SOFTWARE" = "" ] ; then if [ ! "$OVERLAY_BUNDLES" = "" ] ; then
echo "Generating additional overlay software. This may take a while..." echo "Generating additional overlay bundles. This may take a while..."
sh build_minimal_linux_overlay.sh time sh build_minimal_linux_overlay.sh
else else
echo "Generation of additional overlay software has been skipped." echo "Generation of additional overlay bundles has been skipped."
fi fi
cd work/isoimage cd work/isoimage
@ -58,7 +55,7 @@ cp $WORK_SYSLINUX_DIR/bios/core/isolinux.bin .
cp $WORK_SYSLINUX_DIR/bios/com32/elflink/ldlinux/ldlinux.c32 . cp $WORK_SYSLINUX_DIR/bios/com32/elflink/ldlinux/ldlinux.c32 .
# Now we copy the kernel. # Now we copy the kernel.
cp $WORK_KERNEL_DIR/arch/x86/boot/bzImage ./kernel.xz cp $KERNEL_INSTALLED/kernel ./kernel.xz
# Now we copy the root file system. # Now we copy the root file system.
cp ../rootfs.cpio.xz ./rootfs.xz cp ../rootfs.cpio.xz ./rootfs.xz
@ -121,8 +118,7 @@ else
echo "Generating ISO image with no overlay structure..." echo "Generating ISO image with no overlay structure..."
fi fi
# Create ISOLINUX configuration file. # Create the ISOLINUX configuration file.
#echo 'default kernel.xz initrd=rootfs.xz vga=769' > ./isolinux.cfg
echo 'default kernel.xz initrd=rootfs.xz vga=ask' > ./isolinux.cfg echo 'default kernel.xz initrd=rootfs.xz vga=ask' > ./isolinux.cfg
# Now we generate the ISO image file. # Now we generate the ISO image file.
@ -139,7 +135,9 @@ genisoimage \
./ ./
# This allows the ISO image to be bootable if it is burned on USB flash drive. # This allows the ISO image to be bootable if it is burned on USB flash drive.
isohybrid ../minimal_linux_live.iso 2>/dev/null || true # The -u option is used in EFI boot mode (still not supported) and it reduces
# the ISO image size.
isohybrid -u ../minimal_linux_live.iso 2>/dev/null || true
# Copy the ISO image to the root project folder. # Copy the ISO image to the root project folder.
cp ../minimal_linux_live.iso ../../ cp ../minimal_linux_live.iso ../../

View File

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

View File

@ -1,24 +1,24 @@
#!/bin/sh #!/bin/sh
# Read the 'OVERLAY_SOFTWARE' property from '.config' # Read the 'OVERLAY_BUNDLES' property from '.config'
OVERLAY_SOFTWARE="$(grep -i ^OVERLAY_SOFTWARE .config | cut -f2 -d'=')" OVERLAY_BUNDLES="$(grep -i ^OVERLAY_BUNDLES .config | cut -f2 -d'=')"
if [ "$OVERLAY_SOFTWARE" = "" ] ; then if [ "$OVERLAY_BUNDLES" = "" ] ; then
echo "There is no overlay software to build." echo "There are no overlay bundles to build."
else else
sh overlay_00_clean.sh time sh overlay_00_clean.sh
OVERLAY_PIECES="$(echo $OVERLAY_SOFTWARE | tr ',' ' ')" OVERLAY_BUNDLES_LIST="$(echo $OVERLAY_BUNDLES | tr ',' ' ')"
for OVERLAY in $OVERLAY_PIECES for BUNDLE in $OVERLAY_BUNDLES_LIST
do do
OVERLAY_SCRIPT=overlay_$OVERLAY.sh OVERLAY_SCRIPT=overlay_$BUNDLE.sh
if [ ! -f $OVERLAY_SCRIPT ] ; then if [ ! -f $OVERLAY_SCRIPT ] ; then
echo "Error - cannot find overlay script file '$OVERLAY_SCRIPT'." echo "Error - cannot find overlay script file '$OVERLAY_SCRIPT'."
else else
echo "Building '$OVERLAY'..." echo "Building overlay bundle '$BUNDLE'..."
sh $OVERLAY_SCRIPT time sh $OVERLAY_SCRIPT
fi fi
done done
fi fi

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
sh overlay_dropbear_01_get.sh time sh overlay_dropbear_01_get.sh
sh overlay_dropbear_02_build.sh time sh overlay_dropbear_02_build.sh

5
src/overlay_felix.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
time sh overlay_felix_01_get.sh
time sh overlay_felix_02_install.sh

39
src/overlay_felix_01_get.sh Executable file
View File

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

35
src/overlay_felix_02_install.sh Executable file
View File

@ -0,0 +1,35 @@
#!/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.sh
cp -r $SRC_DIR/work/overlay/felix/felix_installed/* \
$SRC_DIR/work/src/minimal_overlay
echo "Apache Felix has been installed."
cd $SRC_DIR

View File

@ -7,14 +7,13 @@ if [ ! -d $SRC_DIR/work/glibc/glibc_prepared ] ; then
exit 1 exit 1
fi fi
echo "Preparing the overlay glibc folder. Tis may take a while..." echo "Preparing the overlay glibc folder. This may take a while..."
rm -rf work/overlay/glibc rm -rf work/overlay/glibc
mkdir -p work/overlay/glibc/lib mkdir -p work/overlay/glibc/lib
cd work/glibc/glibc_prepared/lib cd work/glibc/glibc_prepared/lib
find . -type l -exec cp {} $SRC_DIR/work/overlay/glibc/lib \; find . -type l -exec cp {} $SRC_DIR/work/overlay/glibc/lib \;
echo "All libraries have been copied." echo "All libraries have been copied."
cd $SRC_DIR/work/overlay/glibc/lib cd $SRC_DIR/work/overlay/glibc/lib
@ -32,11 +31,9 @@ done
echo "Duplicate libraries have been replaced with soft links." echo "Duplicate libraries have been replaced with soft links."
strip -g * strip -g *
echo "All libraries have been optimized for size." echo "All libraries have been optimized for size."
cp -r $SRC_DIR/work/overlay/glibc/lib $SRC_DIR/work/src/minimal_overlay cp -r $SRC_DIR/work/overlay/glibc/lib $SRC_DIR/work/src/minimal_overlay
echo "All libraries have been installed." echo "All libraries have been installed."
cd $SRC_DIR cd $SRC_DIR

54
src/overlay_java.sh Executable file
View File

@ -0,0 +1,54 @@
#!/bin/sh
# This script installs Oracle's JRE or JDK from already downloaded 'tar.gz'
# archive. Oracle's license doesn't allow direct downloads, so you need to do
# the following:
#
# 1) Download JRE or JDK from http://oracle.com
# 2) Add the following property in the '.config' file:
#
# JAVA_ARCHIVE=/absolute/path/to/java/archive.tar.gz
#
# Example:
#
# JAVA_ARCHIVE=/home/myself/Downloads/jdk-8u91-linux-x64.tar.gz
#
# 3) Run this script. Note that the script will fail with error message if the
# 'JAVA_ARCHIVE' property is not set or if it points to invalid file.
SRC_DIR=$(pwd)
# Read the 'JAVA_ARCHIVE' property from '.config'
JAVA_ARCHIVE="$(grep -i ^JAVA_ARCHIVE .config | cut -f2 -d'=')"
if [ "$JAVA_ARCHIVE" = "" ] ; then
echo "ERROR: configuration property 'JAVA_ARCHIVE' is not set."
exit 1
elif [ ! -f "$JAVA_ARCHIVE" ] ; then
echo "ERROR: configuration property 'JAVA_ARCHIVE' points to non existent file."
exit 1
fi
rm -rf $SRC_DIR/work/overlay/java
mkdir -p $SRC_DIR/work/overlay/java/opt
tar -xvf \
$JAVA_ARCHIVE \
-C $SRC_DIR/work/overlay/java/opt
cd $SRC_DIR/work/overlay/java/opt
mv $(ls -d *) java
mkdir $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
echo "Java has been installed."
cd $SRC_DIR

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
sh overlay_links_01_get.sh time sh overlay_links_01_get.sh
sh overlay_links_02_build.sh time sh overlay_links_02_build.sh