diff --git a/src/.config b/src/.config new file mode 100644 index 000000000..a8073a5cb --- /dev/null +++ b/src/.config @@ -0,0 +1,11 @@ +# You can find the latest Linux kernel source bundles here: +# +# http://kernel.org +# +KERNEL_SOURCE_URL=https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.15.6.tar.xz + +# You can find the latest BusyBox source bundles here: +# +# http://busybox.net +# +BUSYBOX_SOURCE_URL=http://busybox.net/downloads/busybox-1.22.1.tar.bz2 diff --git a/src/0_prepare.sh b/src/0_prepare.sh new file mode 100644 index 000000000..78520b271 --- /dev/null +++ b/src/0_prepare.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +rm -rf work +mkdir work + diff --git a/src/1_get_kernel.sh b/src/1_get_kernel.sh new file mode 100644 index 000000000..77013ef80 --- /dev/null +++ b/src/1_get_kernel.sh @@ -0,0 +1,13 @@ +#/bin/sh + +DOWNLOAD_URL=$(grep -i KERNEL_SOURCE_URL .config | cut -f2 -d'=') +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 .. + diff --git a/src/2_build_kernel.sh b/src/2_build_kernel.sh new file mode 100644 index 000000000..c903d6f95 --- /dev/null +++ b/src/2_build_kernel.sh @@ -0,0 +1,10 @@ +#/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 ../../.. + diff --git a/src/3_get_busybox.sh b/src/3_get_busybox.sh new file mode 100644 index 000000000..2c2dc6125 --- /dev/null +++ b/src/3_get_busybox.sh @@ -0,0 +1,13 @@ +#/bin/sh + +DOWNLOAD_URL=$(grep -i BUSYBOX_SOURCE_URL .config | cut -f2 -d'=') +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 .. + diff --git a/src/4_build_busybox.sh b/src/4_build_busybox.sh new file mode 100644 index 000000000..277d733ad --- /dev/null +++ b/src/4_build_busybox.sh @@ -0,0 +1,11 @@ +#/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 ../../.. + diff --git a/src/5_generate_rootfs.sh b/src/5_generate_rootfs.sh new file mode 100644 index 000000000..198d31f2b --- /dev/null +++ b/src/5_generate_rootfs.sh @@ -0,0 +1,42 @@ +#/bin/sh + +cd work +rm -rf rootfs +cd busybox +cd $(ls -d *) +cp -R _install ../../rootfs +cd ../../rootfs +rm -f linuxrc +mkdir dev +mkdir etc +mkdir proc +mkdir src +mkdir sys +mkdir tmp +cd etc +touch welcome.txt +echo >> welcome.txt +echo ' #####################################' >> welcome.txt +echo ' # #' >> welcome.txt +echo ' # Welcome to "Minimal Linux Live" #' >> welcome.txt +echo ' # #' >> welcome.txt +echo ' #####################################' >> welcome.txt +echo >> welcome.txt +cd .. +touch init +echo '#!/bin/sh' >> init +echo 'dmesg -n 1' >> init +echo 'mount -t devtmpfs none /dev' >> init +echo 'mount -t proc none /proc' >> init +echo 'mount -t sysfs none /sys' >> init +echo 'cat /etc/welcome.txt' >> init +echo 'while true' >> init +echo 'do' >> init +echo ' setsid cttyhack /bin/sh' >> init +echo 'done' >> init +echo >> init +chmod +x init +cp ../../*.sh src +cp ../../.config src +cd ../.. + diff --git a/src/6_pack_rootfs.sh b/src/6_pack_rootfs.sh new file mode 100644 index 000000000..4ae50cceb --- /dev/null +++ b/src/6_pack_rootfs.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +cd work +rm -f rootfs.cpio.gz +cd rootfs +find . | cpio -H newc -o | gzip > ../rootfs.cpio.gz +cd ../.. + diff --git a/src/7_generate_iso.sh b/src/7_generate_iso.sh new file mode 100644 index 000000000..cbb2880bd --- /dev/null +++ b/src/7_generate_iso.sh @@ -0,0 +1,9 @@ +#/bin/sh + +rm -f minimal_linux_live.iso +cd work/kernel +cd $(ls -d *) +make isoimage FDINITRD=../../rootfs.cpio.gz +cp arch/x86/boot/image.iso ../../../minimal_linux_live.iso +cd ../../.. + diff --git a/src/build_minimal_linux_live.sh b/src/build_minimal_linux_live.sh new file mode 100644 index 000000000..7e945f84c --- /dev/null +++ b/src/build_minimal_linux_live.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +./0_prepare.sh +./1_get_kernel.sh +./2_build_kernel.sh +./3_get_busybox.sh +./4_build_busybox.sh +./5_generate_rootfs.sh +./6_pack_rootfs.sh +./7_generate_iso.sh +