Added experimental scripts which build Kernel + ToyBox with simple DHCP network. DNS is still broken due to glibc issues.
This commit is contained in:
		
							parent
							
								
									aea0fb471f
								
							
						
					
					
						commit
						3fdba9f45e
					
				
							
								
								
									
										12
									
								
								src/experimental/.config
									
									
									
									
									
										Normal file
									
								
							
							
								
								
								
								
								
								
							
						
						
									
										12
									
								
								src/experimental/.config
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,12 @@ | ||||
| # You can find the latest Linux kernel source bundles here: | ||||
| # | ||||
| # http://kernel.org | ||||
| # | ||||
| KERNEL_SOURCE_URL=https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.1.6.tar.xz | ||||
| 
 | ||||
| # You can find the latest BusyBox source bundles here: | ||||
| # | ||||
| # http://busybox.net | ||||
| # | ||||
| TOYBOX_SOURCE_URL=http://landley.net/toybox/downloads/toybox-0.6.0.tar.gz | ||||
| 
 | ||||
							
								
								
									
										8
									
								
								src/experimental/0_prepare.sh
									
									
									
									
									
										Executable file
									
								
							
							
								
								
								
								
								
								
							
						
						
									
										8
									
								
								src/experimental/0_prepare.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,8 @@ | ||||
| #!/bin/sh | ||||
| 
 | ||||
| rm -rf work | ||||
| mkdir work | ||||
| 
 | ||||
| # -p stops errors if the directory already exists | ||||
| mkdir -p source | ||||
| 
 | ||||
							
								
								
									
										24
									
								
								src/experimental/1_get_kernel.sh
									
									
									
									
									
										Executable file
									
								
							
							
								
								
								
								
								
								
							
						
						
									
										24
									
								
								src/experimental/1_get_kernel.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,24 @@ | ||||
| #!/bin/sh | ||||
| 
 | ||||
| # Grab everything after the '=' character | ||||
| DOWNLOAD_URL=$(grep -i KERNEL_SOURCE_URL .config | cut -f2 -d'=') | ||||
| 
 | ||||
| # Grab everything after the last '/' character | ||||
| ARCHIVE_FILE=${DOWNLOAD_URL##*/} | ||||
| 
 | ||||
| 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 'work/kernel' | ||||
| # Full path will be something like 'work/kernel/linux-3.16.1' | ||||
| tar -xvf $ARCHIVE_FILE -C ../work/kernel | ||||
| 
 | ||||
| cd .. | ||||
| 
 | ||||
							
								
								
									
										23
									
								
								src/experimental/2_build_kernel.sh
									
									
									
									
									
										Executable file
									
								
							
							
								
								
								
								
								
								
							
						
						
									
										23
									
								
								src/experimental/2_build_kernel.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,23 @@ | ||||
| #!/bin/sh | ||||
| 
 | ||||
| cd work/kernel | ||||
| 
 | ||||
| # Change to the first directory ls finds, e.g. 'linux-3.18.6' | ||||
| 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\"/" .config | ||||
| 
 | ||||
| # Compile the kernel with optimization for "parallel jobs" = "number of processors" | ||||
| # 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 -j $(grep ^processor /proc/cpuinfo | wc -l) | ||||
| 
 | ||||
| cd ../../.. | ||||
| 
 | ||||
							
								
								
									
										24
									
								
								src/experimental/3_get_toybox.sh
									
									
									
									
									
										Executable file
									
								
							
							
								
								
								
								
								
								
							
						
						
									
										24
									
								
								src/experimental/3_get_toybox.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,24 @@ | ||||
| #!/bin/sh | ||||
| 
 | ||||
| # Grab everything after the '=' character | ||||
| DOWNLOAD_URL=$(grep -i TOYBOX_SOURCE_URL .config | cut -f2 -d'=') | ||||
| 
 | ||||
| # Grab everything after the last '/' character | ||||
| ARCHIVE_FILE=${DOWNLOAD_URL##*/} | ||||
| 
 | ||||
| cd source | ||||
| 
 | ||||
| # Downloading toybox source | ||||
| # -c option allows the download to resume | ||||
| wget -c $DOWNLOAD_URL | ||||
| 
 | ||||
| # Delete folder with previously extracted toybox | ||||
| rm -rf ../work/toybox | ||||
| mkdir ../work/toybox | ||||
| 
 | ||||
| # Extract toybox to folder 'toybox' | ||||
| # Full path will be something like 'work/toybox/toybox-0.6.0' | ||||
| tar -xvf $ARCHIVE_FILE -C ../work/toybox | ||||
| 
 | ||||
| cd .. | ||||
| 
 | ||||
							
								
								
									
										29
									
								
								src/experimental/4_build_toybox.sh
									
									
									
									
									
										Executable file
									
								
							
							
								
								
								
								
								
								
							
						
						
									
										29
									
								
								src/experimental/4_build_toybox.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,29 @@ | ||||
| #!/bin/sh | ||||
| 
 | ||||
| cd work/toybox | ||||
| 
 | ||||
| # Change to the first directory ls finds, e.g. 'toybox-0.6.0' | ||||
| cd $(ls -d *) | ||||
| 
 | ||||
| # Remove previously generated artefacts | ||||
| make distclean | ||||
| 
 | ||||
| # Create a default configuration file | ||||
| make allyesconfig | ||||
| 
 | ||||
| export LDFLAGS="--static" | ||||
| 
 | ||||
| # Compile toybox with optimization for "parallel jobs" = "number of processors" | ||||
| make toybox -j $(grep ^processor /proc/cpuinfo | wc -l) | ||||
| 
 | ||||
| unset LDFLAGS | ||||
| 
 | ||||
| rm -rf rootfs | ||||
| mkdir rootfs | ||||
| export PREFIX=rootfs | ||||
| # Create the symlinks for toybox | ||||
| make install_flat | ||||
| unset PREFIX | ||||
| 
 | ||||
| cd ../../.. | ||||
| 
 | ||||
							
								
								
									
										71
									
								
								src/experimental/5_generate_rootfs.sh
									
									
									
									
									
										Executable file
									
								
							
							
								
								
								
								
								
								
							
						
						
									
										71
									
								
								src/experimental/5_generate_rootfs.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,71 @@ | ||||
| #!/bin/sh | ||||
| 
 | ||||
| cd work | ||||
| 
 | ||||
| rm -rf rootfs | ||||
| mkdir rootfs | ||||
| 
 | ||||
| cd toybox | ||||
| cd $(ls -d *) | ||||
| 
 | ||||
| # Copy all toybox generated stuff to the location of our "initramfs" folder. | ||||
| cp -R rootfs ../../rootfs/bin | ||||
| cd ../../rootfs | ||||
| 
 | ||||
| # Create root FS folders | ||||
| mkdir dev | ||||
| mkdir etc | ||||
| mkdir proc | ||||
| mkdir root | ||||
| mkdir src | ||||
| mkdir sys | ||||
| mkdir tmp | ||||
| 
 | ||||
| # "1" means that only the owner of a file/directory (or root) can remove it. | ||||
| chmod 1777 tmp | ||||
| 
 | ||||
| cd etc | ||||
| 
 | ||||
| # The file "/etc/welcome.txt" is displayed on every boot of the system in each | ||||
| # available terminal. | ||||
| cat > welcome.txt << EOF | ||||
| 
 | ||||
|   ##################################### | ||||
|   #                                   # | ||||
|   #  Welcome to "Minimal Linux Live"  # | ||||
|   #                                   # | ||||
|   ##################################### | ||||
| 
 | ||||
| EOF | ||||
| 
 | ||||
| cd .. | ||||
| 
 | ||||
| # Problem setting default path | ||||
| cat > init << EOF | ||||
| #!/bin/sh | ||||
| dmesg -n 1 | ||||
| 
 | ||||
| mount -t devtmpfs none /dev | ||||
| mount -t proc none /proc | ||||
| mount -t sysfs none /sys | ||||
| 
 | ||||
| ifconfig eth0 up | ||||
| dhcp -i eth0 | ||||
| 
 | ||||
| cat /etc/welcome.txt | ||||
| 
 | ||||
| sh | ||||
| 
 | ||||
| poweroff | ||||
| EOF | ||||
| 
 | ||||
| chmod +rx init | ||||
| 
 | ||||
| # Copy all source files to "/src". Note that the scripts won't work there. | ||||
| cp ../../*.sh src | ||||
| cp ../../.config src | ||||
| chmod +r src/*.sh | ||||
| chmod +r src/.config | ||||
| 
 | ||||
| cd ../.. | ||||
| 
 | ||||
							
								
								
									
										14
									
								
								src/experimental/6_pack_rootfs.sh
									
									
									
									
									
										Executable file
									
								
							
							
								
								
								
								
								
								
							
						
						
									
										14
									
								
								src/experimental/6_pack_rootfs.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,14 @@ | ||||
| #!/bin/sh | ||||
| 
 | ||||
| cd work | ||||
| 
 | ||||
| # Remove the old initramfs archive if it exists. | ||||
| rm -f rootfs.cpio.gz | ||||
| 
 | ||||
| cd rootfs | ||||
| 
 | ||||
| # Packs the current folder structure in "cpio.gz" archive. | ||||
| find . | cpio -H newc -o | gzip > ../rootfs.cpio.gz | ||||
| 
 | ||||
| cd ../.. | ||||
| 
 | ||||
							
								
								
									
										19
									
								
								src/experimental/7_generate_iso.sh
									
									
									
									
									
										Executable file
									
								
							
							
								
								
								
								
								
								
							
						
						
									
										19
									
								
								src/experimental/7_generate_iso.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,19 @@ | ||||
| #!/bin/sh | ||||
| 
 | ||||
| rm -f minimal_linux_live.iso | ||||
| 
 | ||||
| cd work/kernel | ||||
| cd $(ls -d *) | ||||
| 
 | ||||
| # Edit Makefile to look for genisoimage instead of mkisofs. This was added as a | ||||
| # workaround for some "Debian" and "Arch Linux" distributions. In general this | ||||
| # fix should be harmless.  | ||||
| sed -i 's/mkisofs/genisoimage/g' arch/x86/boot/Makefile | ||||
| 
 | ||||
| # Generate the ISO image with optimization for "parallel jobs" = "number of processors" | ||||
| make isoimage FDINITRD=../../rootfs.cpio.gz -j $(grep ^processor /proc/cpuinfo | wc -l) | ||||
| 
 | ||||
| cp arch/x86/boot/image.iso ../../../minimal_linux_live.iso | ||||
| 
 | ||||
| cd ../../.. | ||||
| 
 | ||||
							
								
								
									
										10
									
								
								src/experimental/build_minimal_linux_live.sh
									
									
									
									
									
										Executable file
									
								
							
							
								
								
								
								
								
								
							
						
						
									
										10
									
								
								src/experimental/build_minimal_linux_live.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,10 @@ | ||||
| #!/bin/sh | ||||
| 
 | ||||
| sh 0_prepare.sh | ||||
| sh 1_get_kernel.sh | ||||
| sh 2_build_kernel.sh | ||||
| sh 3_get_busybox.sh | ||||
| sh 4_build_busybox.sh | ||||
| sh 5_generate_rootfs.sh | ||||
| sh 6_pack_rootfs.sh | ||||
| sh 7_generate_iso.sh | ||||
							
								
								
									
										4
									
								
								src/experimental/qemu32.sh
									
									
									
									
									
										Executable file
									
								
							
							
								
								
								
								
								
								
							
						
						
									
										4
									
								
								src/experimental/qemu32.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,4 @@ | ||||
| #!/bin/sh | ||||
| 
 | ||||
| qemu-system-i386 -cdrom minimal_linux_live.iso | ||||
| 
 | ||||
							
								
								
									
										4
									
								
								src/experimental/qemu64.sh
									
									
									
									
									
										Executable file
									
								
							
							
								
								
								
								
								
								
							
						
						
									
										4
									
								
								src/experimental/qemu64.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,4 @@ | ||||
| #!/bin/sh | ||||
| 
 | ||||
| qemu-system-x86_64 -cdrom minimal_linux_live.iso | ||||
| 
 | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user