Format partition to ext4 & cp packages there & switch_root
This commit is contained in:
		
							parent
							
								
									f5bf272992
								
							
						
					
					
						commit
						bb4afc18c9
					
				
					 3 changed files with 66 additions and 23 deletions
				
			
		
							
								
								
									
										27
									
								
								build_utils
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										27
									
								
								build_utils
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,27 @@ | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | cp_packages (){ | ||||||
|  | 	#IMPORTANT: must be run from the folder where the iglunix repo is. | ||||||
|  | 	#NOTE: this will assume that there always is a '*-dev'/'*-doc' package,\n this is not true. | ||||||
|  | 	# That's why the errors are shown to some one who cares. | ||||||
|  | 
 | ||||||
|  | 	echo "Hello this is build-utils" | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 	for pkg in ${packages[@]} | ||||||
|  | 	do | ||||||
|  | 		if [ ! -d pkgs/${pkg}/out ]; then | ||||||
|  | 			echo "NOTE: ${pkg} was not yet build, building it now" | ||||||
|  | 			cd pkgs/${pkg}/ | ||||||
|  | 			../../iglupkg.sh | ||||||
|  | 			cd ../.. | ||||||
|  | 		fi | ||||||
|  | 
 | ||||||
|  | 		echo "Going to copy: $pkg to $1" | ||||||
|  | 		tar -xf pkgs/${pkg}/out/${pkg}.*.tar.xz     -C $1 | ||||||
|  | 		tar -xf pkgs/${pkg}/out/${pkg}-dev.*.tar.xz -C $1 2> /dev/null | ||||||
|  | 		tar -xf pkgs/${pkg}/out/${pkg}-doc.*.tar.xz -C $1 2> /dev/null | ||||||
|  | 
 | ||||||
|  | 	done | ||||||
|  | } | ||||||
|  | 
 | ||||||
							
								
								
									
										24
									
								
								createimg.sh
									
										
									
									
									
								
							
							
						
						
									
										24
									
								
								createimg.sh
									
										
									
									
									
								
							|  | @ -1,9 +1,13 @@ | ||||||
| #!/bin/sh | #!/bin/sh | ||||||
| 
 | 
 | ||||||
|  | echo "Createimg.sh" | ||||||
|  | 
 | ||||||
| rm iglunix.img | rm iglunix.img | ||||||
| 
 | 
 | ||||||
| dd if=../tiny-linux-bootloader/disk of=iglunix.img | dd if=../tiny-linux-bootloader/disk of=iglunix.img | ||||||
| 
 | 
 | ||||||
|  | source build_utils | ||||||
|  | 
 | ||||||
| FILE_SIZE=$(stat -c %s iglunix.img) | FILE_SIZE=$(stat -c %s iglunix.img) | ||||||
| echo "FILE_SIZE=${FILE_SIZE}" | echo "FILE_SIZE=${FILE_SIZE}" | ||||||
| PARTITION_START=$(($FILE_SIZE / 512)) | PARTITION_START=$(($FILE_SIZE / 512)) | ||||||
|  | @ -24,6 +28,26 @@ ${PARTITION_START} | ||||||
| w | w | ||||||
| " | fdisk iglunix.img | " | fdisk iglunix.img | ||||||
| 
 | 
 | ||||||
|  | PARTITION_START2=$((${PARTITION_START} * 512)) | ||||||
|  | echo "PARTITION_START2: ${PARTITION_START2}" | ||||||
|  | LOOPBACK=$(losetup -o ${PARTITION_START2} -s -f iglunix.img) | ||||||
|  | echo "LOOPBACK: ${LOOPBACK}" | ||||||
|  | mke2fs -t ext4 -L "__IGLUNIX_ROOT" ${LOOPBACK} | ||||||
|  | 
 | ||||||
|  | umount /mnt/__IGLUNIX_ROOT | ||||||
|  | rm -rf /mnt/__IGLUNIX_ROOT | ||||||
|  | 
 | ||||||
|  | mkdir -p /mnt/__IGLUNIX_ROOT | ||||||
|  | mount ${LOOPBACK} /mnt/__IGLUNIX_ROOT | ||||||
|  | 
 | ||||||
|  | packages=(musl mksh bmake gmake libressl cmake curl rsync flex byacc om4 zlib samurai libffi python ca-certificates zlib expat gettext-tiny git kati netbsd-curses kakoune iglunix rust toybox busybox less file pci-ids e2fsprogs) | ||||||
|  | cp_packages /mnt/__IGLUNIX_ROOT | ||||||
|  | 
 | ||||||
|  | echo "Unmounting & closing loopback" | ||||||
|  | 
 | ||||||
|  | umount /mnt/__IGLUNIX_ROOT | ||||||
|  | 
 | ||||||
|  | losetup -d ${LOOPBACK} | ||||||
| exit | exit | ||||||
| 
 | 
 | ||||||
| # losetup -o 32256 /dev/loop0 iglunix.img | # losetup -o 32256 /dev/loop0 iglunix.img | ||||||
|  |  | ||||||
							
								
								
									
										38
									
								
								geninitrd.sh
									
										
									
									
									
								
							
							
						
						
									
										38
									
								
								geninitrd.sh
									
										
									
									
									
								
							|  | @ -11,37 +11,29 @@ | ||||||
| 
 | 
 | ||||||
| # Create the root fs dir | # Create the root fs dir | ||||||
| 
 | 
 | ||||||
|  | echo "geninitrd.sh" | ||||||
|  | 
 | ||||||
|  | source build_utils | ||||||
|  | 
 | ||||||
| rm -rf isoout isoroot | rm -rf isoout isoroot | ||||||
| mkdir isoroot | mkdir isoroot | ||||||
| mkdir isoout | mkdir isoout | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| cp_packages (){ | # This should be a minimal number of packages, if we want fast boot times. | ||||||
| 	#NOTE: this will assume that there always is a '*-dev'/'*-doc' package,\n this is not true. | # The remaining packages are in createimg.sh | ||||||
| 	# That's why the errors are shown to some one who cares. |  | ||||||
| 	for pkg in ${packages[@]} |  | ||||||
| 	do |  | ||||||
| 		echo "Going to copy: $pkg to $1" |  | ||||||
| 		tar -xf pkgs/${pkg}/out/${pkg}.*.tar.xz -C $1 |  | ||||||
| 		tar -xf pkgs/${pkg}/out/${pkg}-dev.*.tar.xz -C $1 2> /dev/null |  | ||||||
| 		tar -xf pkgs/${pkg}/out/${pkg}-doc.*.tar.xz -C $1 2> /dev/null |  | ||||||
| 	done |  | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
| #packages=(musl mksh bmake gmake libressl cmake curl rsync linux flex byacc om4 zlib samurai libffi python ca-certificates zlib expat gettext-tiny git kati netbsd-curses kakoune iglunix) | #packages=(musl mksh bmake gmake libressl cmake curl rsync linux flex byacc om4 zlib samurai libffi python ca-certificates zlib expat gettext-tiny git kati netbsd-curses kakoune iglunix) | ||||||
| packages=(musl linux mksh busybox toybox iglunix) | packages=(musl linux mksh busybox toybox iglunix) | ||||||
| cp_packages ./isoroot | cp_packages ./isoroot | ||||||
| 
 | 
 | ||||||
| #packages=(musl mksh busybox toybox llvm bmake gmake libressl cmake curl rsync linux flex byacc om4 zlib samurai libffi python ca-certificates zlib expat gettext-tiny git kati netbsd-curses kakoune iglunix rust less heirloom-doctools file pci-ids) |  | ||||||
| #cp_packages ./isoroot |  | ||||||
| 
 |  | ||||||
| cat >isoroot/init << EOF | cat >isoroot/init << EOF | ||||||
| #!/bin/sh | #!/bin/sh | ||||||
| exec /sbin/init | exec /sbin/init | ||||||
| EOF | EOF | ||||||
| 
 | 
 | ||||||
| rm isoroot/sbin/init | rm isoroot/sbin/init | ||||||
| cat >isoroot/sbin/init << EOF | cat >isoroot/sbin/init << 'EOF' | ||||||
| #!/bin/sh | #!/bin/sh | ||||||
| 
 | 
 | ||||||
| export PATH=/usr/sbin:/usr/bin:/sbin:/bin | export PATH=/usr/sbin:/usr/bin:/sbin:/bin | ||||||
|  | @ -55,17 +47,17 @@ mount -t tmpfs tmpfs /tmp | ||||||
| busybox mdev -s | busybox mdev -s | ||||||
| busybox mdev -d | busybox mdev -d | ||||||
| 
 | 
 | ||||||
| exec /bin/sh |  | ||||||
| 
 |  | ||||||
| mkdir /mnt | mkdir /mnt | ||||||
| 
 | 
 | ||||||
| # while not mount $(blkid -L IGLUNIX_BS_MEDIA) /mnt; do | while ! mount $(findfs LABEL=__IGLUNIX_ROOT) /mnt; do | ||||||
| # 	echo "Failed to mount boot disk" |   echo "Failed to mount boot disk" | ||||||
| # 	echo "Retrying" |   echo "Retrying" | ||||||
| # 	sleep 0.5 |   sleep 0.5 | ||||||
| # done | done | ||||||
| 
 | 
 | ||||||
| exec switch_root /mnt | 
 | ||||||
|  | echo "Starting switch_root" | ||||||
|  | exec switch_root /mnt /bin/sh | ||||||
| 
 | 
 | ||||||
| EOF | EOF | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue