From bbd6a84a3f1f217cfff3dfd2aaa39c6fb6110ac4 Mon Sep 17 00:00:00 2001 From: Ella-0 <23418164+Ella-0@users.noreply.github.com> Date: Sat, 30 Jan 2021 07:29:13 +0000 Subject: [PATCH] Added scripts to create bootable image --- createimg.sh | 19 +++++++++ geninitrd.sh | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 createimg.sh create mode 100755 geninitrd.sh diff --git a/createimg.sh b/createimg.sh new file mode 100644 index 0000000..2786fa8 --- /dev/null +++ b/createimg.sh @@ -0,0 +1,19 @@ +cat > fdiskscript << EOF +o +n +p +1 +63 + +t +ef +w +EOF +cat fdiskscript | fdisk lazybox.img + +losetup -o 32256 /dev/loop0 lazybox.img +mkfs.vfat /dev/loop0 +mount /dev/loop0 ./isoroot +#rm -r isoroot/* +cp -r isoout/* isoroot +umount ./isoroot diff --git a/geninitrd.sh b/geninitrd.sh new file mode 100755 index 0000000..580dd44 --- /dev/null +++ b/geninitrd.sh @@ -0,0 +1,109 @@ +#!/bin/sh +# +# Creates an ISO from the following built packages. +# Linux, Musl, Toybox, Busybox, LLVM, CMake, Samurai,BYacc, Flex, BMake, +# LibreSSL, Curl, Git, Expat, Zlib, NetBSD-Curses +# +# This should be enough to completely rebuild LazyBox from Source +# + +# Create the root fs dir +mkdir isoroot +mkdir isoout + +tar -xf pkgs/linux/out/linux.5.10.11.tar.xz -C ./isoroot +tar -xf pkgs/linux/out/linux-dev.5.10.11.tar.xz -C ./isoroot +tar -xf pkgs/musl/out/musl.1.2.2.tar.xz -C ./isoroot +tar -xf pkgs/musl/out/musl-dev.1.2.2.tar.xz -C ./isoroot +tar -xf pkgs/toybox/out/toybox.0.8.4.tar.xz -C ./isoroot +tar -xf pkgs/busybox/out/busybox.1.33.0.tar.xz -C ./isoroot +tar -xf pkgs/llvm/out/llvm.11.0.1.tar.xz -C ./isoroot +tar -xf pkgs/cmake/out/cmake.3.19.2.tar.xz -C ./isoroot +tar -xf pkgs/samurai/out/samurai.1.2.tar.xz -C ./isoroot +tar -xf pkgs/byacc/out/byacc.20210109.tar.xz -C ./isoroot +tar -xf pkgs/bmake/out/bmake.20201212.tar.xz -C ./isoroot +tar -xf pkgs/flex/out/flex.2.6.4.tar.xz -C ./isoroot +tar -xf pkgs/libressl/out/*.tar.xz -C ./isoroot +tar -xf pkgs/curl/out/*.tar.xz -C ./isoroot +tar -xf pkgs/git/out/*.tar.xz -C ./isoroot +tar -xf pkgs/expat/out/*.tar.xz -C ./isoroot +tar -xf pkgs/zlib/out/*.tar.xz -C ./isoroot +tar -xf pkgs/mksh/out/*.tar.xz -C ./isoroot +tar -xf pkgs/netbsd-curses/out/*.tar.xz -C ./isoroot + + +cat >isoroot/init << EOF +#!/bin/sh +exec /sbin/init +EOF + +chmod +x isoroot/init + +mkdir -p isoroot/etc/init.d/ + + +cat >isoroot/etc/init.d/rcS << EOF +#!/bin/sh +export PATH=/usr/sbin:/usr/bin:/sbin:/bin +mkdir /proc +mkdir /sys +mkdir /tmp +mount -t proc proc /proc +mount -t sysfs sysfs /sys +mount -t tmpfs tmpfs /tmp + +echo 0 > /proc/sys/kernel/printk + +ln -s /proc/self/fd/0 /dev/stdin +ln -s /proc/self/fd/1 /dev/stdout +ln -s /proc/self/fd/2 /dev/stderr + +busybox mdev -s +busybox mdev -d + +mkdir -p /dev/pts +mount -t devpts devpts /dev/pts + +hostname -F /etc/hostname + +mount -a + +#busybox modprobe broadcom +#busybox modprobe tg3 +#ifconfig eth0 192.168.2.16 +#busybox route add default gw 192.168.2.1 +#busybox modprobe radeon + +#busybox telnetd + +#clear + +EOF +chmod +x isoroot/etc/init.d/rcS + +cp /etc/inittab isoroot/etc/ + +cd isoroot +find . | cpio -ov | gzip -9 >../isoout/initramfs.img +cp boot/vmlinuz ../isoout/vmlinuz + +cd ../isoout +mkdir -p EFI/BOOT +cp ~/Shell.efi EFI/BOOT/BOOTX64.EFI + +cat >startup.nsh << EOF +\vmlinuz initrd=\initramfs.img console=ttyS0 console=tty0 + + +EOF + +exit + +#dd if=/dev/zero of=lazybox.img count=524288 +#fdisk lazybox.img +cd .. +losetup -o 32256 /dev/loop0 lazybox.img +mount /dev/loop0 ./isoroot +rm -r isoroot/* +cp -r isoout/* isoroot +umount ./isoroot