diff --git a/src/0_prepare.sh b/src/0_prepare.sh index 78520b271..7f153ed22 100644 --- a/src/0_prepare.sh +++ b/src/0_prepare.sh @@ -3,3 +3,5 @@ rm -rf work mkdir work +# -p stops errors if the directory already exists +mkdir -p source diff --git a/src/1_get_kernel.sh b/src/1_get_kernel.sh index 4dd79f6b0..928ac69c2 100644 --- a/src/1_get_kernel.sh +++ b/src/1_get_kernel.sh @@ -1,13 +1,22 @@ #!/bin/sh +# Grab everything after the '=' sign DOWNLOAD_URL=$(grep -i KERNEL_SOURCE_URL .config | cut -f2 -d'=') + +# Grab everything after the last '/' ARCHIVE_FILE=${DOWNLOAD_URL##*/} -cd work -rm -f $ARCHIVE_FILE -wget $DOWNLOAD_URL -rm -rf kernel -mkdir kernel -tar -xvf $ARCHIVE_FILE -C kernel -cd .. +cd source +# Downloading kernel file +# -c option allows the download to resume +wget -c $DOWNLOAD_URL + +# Delete folder with previously extracted kernel +rm -rf ../work/kernel +mkdir ../work/kernel + +# Extract kernel to folder 'kernel' +# Full path will be something like, kernel\linux-3.16 +tar -xvf $ARCHIVE_FILE -C ../work/kernel +cd .. diff --git a/src/2_build_kernel.sh b/src/2_build_kernel.sh index c903d6f95..2533dcc50 100644 --- a/src/2_build_kernel.sh +++ b/src/2_build_kernel.sh @@ -1,10 +1,21 @@ -#/bin/sh +#!/bin/sh cd work/kernel -cd $(ls -d *) -make clean -make defconfig -sed -i "s/.*CONFIG_DEFAULT_HOSTNAME.*/CONFIG_DEFAULT_HOSTNAME=\"minimal-linux-live\"/" .config -make vmlinux -cd ../../.. +# Change to the first directory ls finds, e.g. linux-3.16 +cd $(ls -d *) + +# Cleans up the kernel sources, including configuration files +make mrproper + +# Create a default configuration file for the kernel +make defconfig + +# Changes the name of the system +sed -i "s/.*CONFIG_DEFAULT_HOSTNAME.*/CONFIG_DEFAULT_HOSTNAME=\"minimal-linux-live\"/" .config + +# Compile the kernel +# Good explanation of the different kernels +# http://unix.stackexchange.com/questions/5518/what-is-the-difference-between-the-following-kernel-makefile-terms-vmlinux-vmlinux +make bzImage +cd ../../.. diff --git a/src/3_get_busybox.sh b/src/3_get_busybox.sh index 2c2dc6125..3abaa7fe7 100644 --- a/src/3_get_busybox.sh +++ b/src/3_get_busybox.sh @@ -1,13 +1,23 @@ -#/bin/sh +#!/bin/sh +# Grab everything after the '=' sign DOWNLOAD_URL=$(grep -i BUSYBOX_SOURCE_URL .config | cut -f2 -d'=') + +# Grab everything after the last '/' ARCHIVE_FILE=${DOWNLOAD_URL##*/} -cd work -rm -f $ARCHIVE_FILE -wget $DOWNLOAD_URL -rm -rf busybox -mkdir busybox -tar -xvf $ARCHIVE_FILE -C busybox +cd source + +# Downloading busybox source +# -c option allows the download to resume +wget -c $DOWNLOAD_URL + +# Delete folder with previously extracted busybox +rm -rf ../work/busybox +mkdir ../work/busybox + +# Extract kernel to folder 'busybox' +# Full path will be something like, busybox\busybox-1.22.1 +tar -xvf $ARCHIVE_FILE -C ../work/busybox cd .. diff --git a/src/4_build_busybox.sh b/src/4_build_busybox.sh index 277d733ad..55cff6571 100644 --- a/src/4_build_busybox.sh +++ b/src/4_build_busybox.sh @@ -1,11 +1,25 @@ -#/bin/sh +#!/bin/sh cd work/busybox -cd $(ls -d *) -make clean -make defconfig -sed -i "s/.*CONFIG_STATIC.*/CONFIG_STATIC=y/" .config -make busybox -make install -cd ../../.. +# Change to the first directory ls finds, e.g/ busybox-1.22.1 +cd $(ls -d *) + +# Clean's the source? +make clean + +# Create a default configuration file +make defconfig + +# Change the configuration, so that busybox is statically compiled +# You could do this manually with 'make menuconfig' +sed -i "s/.*CONFIG_STATIC.*/CONFIG_STATIC=y/" .config + +# Compile busybox +make busybox + +# Create the symlinks for busybox +# It uses the file busybox.links for this +make install + +cd ../../..