From 31b7e114ca396c85f746f4ddf551414235297875 Mon Sep 17 00:00:00 2001 From: aheirman <48590738+aheirman@users.noreply.github.com> Date: Sat, 13 Feb 2021 14:42:50 +0100 Subject: [PATCH 1/7] Make geninitrd by default clean & add hostname --- geninitrd.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/geninitrd.sh b/geninitrd.sh index 651bf94..b6c06df 100755 --- a/geninitrd.sh +++ b/geninitrd.sh @@ -10,10 +10,11 @@ # # Create the root fs dir + +rm -rf isoout isoroot mkdir isoroot mkdir isoout -mkdir diskroot cp_packages (){ #NOTE: this will assume that there always is a '*-dev'/'*-doc' package,\n this is not true. @@ -32,7 +33,7 @@ packages=(musl linux mksh busybox toybox iglunix) 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 ./diskroot +#cp_packages ./isoroot cat >isoroot/init << EOF #!/bin/sh @@ -115,6 +116,8 @@ chmod +x isoroot/sbin/init # cp /etc/inittab isoroot/etc/ +cp /etc/hostname ./isoroot/hostname + cd isoroot find . | cpio -ov | gzip -9 >../isoout/initramfs.img cp boot/vmlinuz ../isoout/vmlinuz From 54cc0916732c95f04196f18179da266e7a97abb6 Mon Sep 17 00:00:00 2001 From: aheirman <48590738+aheirman@users.noreply.github.com> Date: Sat, 13 Feb 2021 14:56:28 +0100 Subject: [PATCH 2/7] tlb build: rm /tiny-linux-bootloader --- pkgs/tiny-linux-bootloader/build.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/tiny-linux-bootloader/build.sh b/pkgs/tiny-linux-bootloader/build.sh index 6dc5e3a..d604697 100644 --- a/pkgs/tiny-linux-bootloader/build.sh +++ b/pkgs/tiny-linux-bootloader/build.sh @@ -11,6 +11,8 @@ fetch() { package() { cd $pkgname-$pkgver + + rm -rf /tiny-linux-bootloader mkdir /tiny-linux-bootloader CURR_DIR=$(pwd) From f5bf272992dbf4086df9209463dec1035a24d25b Mon Sep 17 00:00:00 2001 From: aheirman <48590738+aheirman@users.noreply.github.com> Date: Sat, 13 Feb 2021 22:34:07 +0100 Subject: [PATCH 3/7] add e2fsprogs --- pkgs/e2fsprogs/build.sh | 51 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 pkgs/e2fsprogs/build.sh diff --git a/pkgs/e2fsprogs/build.sh b/pkgs/e2fsprogs/build.sh new file mode 100644 index 0000000..ea56348 --- /dev/null +++ b/pkgs/e2fsprogs/build.sh @@ -0,0 +1,51 @@ +pkgname=e2fsprogs +pkgver=1.45.6 +bad="gmake" + + +fetch() { + curl -L "https://mirrors.edge.kernel.org/pub/linux/kernel/people/tytso/e2fsprogs/v$pkgver/$pkgname-$pkgver.tar.xz" -o $pkgname-$pkgver.tar.xz + tar -xf $pkgname-$pkgver.tar.xz +} + +build() { + cd $pkgname-$pkgver + + echo "$pkgdir" + ./configure \ + --prefix=/usr \ + --build=x86_64-unknown-linux-musl \ + --host=x86_64-unknown-linux-musl \ + + #--exec_prefix=/ + + gmake +} + +package() { + cd $pkgname-$pkgver + # Doesn't work :( + #gmake install DESTDIR=$pkgdir PREFIX=/usr + + # We're not moving util/subst + # Do we need to? IDK + + mkdir -p $pkgdir/usr/bin + mkdir -p $pkgdir/usr/lib + + + mv misc/badblocks misc/blkid misc/chattr misc/dumpe2fs misc/e2freefrag misc/e2fuzz misc/e2image \ + misc/e2initrd_helper misc/e2undo misc/e4crypt misc/e4defrag misc/filefrag misc/fsck \ + misc/logsave misc/lsattr misc/mke2fs misc/mklost+found misc/tune2fs misc/uuidd misc/uuidgen \ + $pkgdir/usr/bin + + mv e2fsck/e2fsck debugfs/debugfs resize/resize2fs $pkgdir/usr/bin + + cd lib + mv libblkid.a libe2p.a libss.a libuuid.a libcom_err.a libext2fs.a libsupport.a $pkgdir/usr/lib +} + +license() { + cd $pkgname-$pkgver + cat NOTICE +} From bb4afc18c9fcb6250f11323b7f0f38a4415e6eb9 Mon Sep 17 00:00:00 2001 From: aheirman <48590738+aheirman@users.noreply.github.com> Date: Sun, 14 Feb 2021 18:34:51 +0100 Subject: [PATCH 4/7] Format partition to ext4 & cp packages there & switch_root --- build_utils | 27 +++++++++++++++++++++++++++ createimg.sh | 24 ++++++++++++++++++++++++ geninitrd.sh | 38 +++++++++++++++----------------------- 3 files changed, 66 insertions(+), 23 deletions(-) create mode 100755 build_utils diff --git a/build_utils b/build_utils new file mode 100755 index 0000000..7b69825 --- /dev/null +++ b/build_utils @@ -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 +} + diff --git a/createimg.sh b/createimg.sh index ea708a6..b1d0ea8 100755 --- a/createimg.sh +++ b/createimg.sh @@ -1,9 +1,13 @@ #!/bin/sh +echo "Createimg.sh" + rm iglunix.img dd if=../tiny-linux-bootloader/disk of=iglunix.img +source build_utils + FILE_SIZE=$(stat -c %s iglunix.img) echo "FILE_SIZE=${FILE_SIZE}" PARTITION_START=$(($FILE_SIZE / 512)) @@ -24,6 +28,26 @@ ${PARTITION_START} w " | 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 # losetup -o 32256 /dev/loop0 iglunix.img diff --git a/geninitrd.sh b/geninitrd.sh index b6c06df..5e1c6d6 100755 --- a/geninitrd.sh +++ b/geninitrd.sh @@ -11,37 +11,29 @@ # Create the root fs dir +echo "geninitrd.sh" + +source build_utils + rm -rf isoout isoroot mkdir isoroot mkdir isoout -cp_packages (){ - #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. - 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 -} +# This should be a minimal number of packages, if we want fast boot times. +# The remaining packages are in createimg.sh #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) 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 #!/bin/sh exec /sbin/init EOF rm isoroot/sbin/init -cat >isoroot/sbin/init << EOF +cat >isoroot/sbin/init << 'EOF' #!/bin/sh export PATH=/usr/sbin:/usr/bin:/sbin:/bin @@ -55,17 +47,17 @@ mount -t tmpfs tmpfs /tmp busybox mdev -s busybox mdev -d -exec /bin/sh - mkdir /mnt -# while not mount $(blkid -L IGLUNIX_BS_MEDIA) /mnt; do -# echo "Failed to mount boot disk" -# echo "Retrying" -# sleep 0.5 -# done +while ! mount $(findfs LABEL=__IGLUNIX_ROOT) /mnt; do + echo "Failed to mount boot disk" + echo "Retrying" + sleep 0.5 +done -exec switch_root /mnt + +echo "Starting switch_root" +exec switch_root /mnt /bin/sh EOF From 0ada838249b9cee85566b7b66537e5e5d481a293 Mon Sep 17 00:00:00 2001 From: aheirman <48590738+aheirman@users.noreply.github.com> Date: Sun, 14 Feb 2021 21:12:49 +0100 Subject: [PATCH 5/7] Fix license of linux-pam --- pkgs/linux-pam/build.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkgs/linux-pam/build.sh b/pkgs/linux-pam/build.sh index 593b596..c891887 100644 --- a/pkgs/linux-pam/build.sh +++ b/pkgs/linux-pam/build.sh @@ -26,6 +26,5 @@ package() { license() { cd $pkgname-$pkgver - cat LICENSE -# cat COPYING + cat COPYING } From 262d3d8d42af1fa38a3448c419edc9a916010be1 Mon Sep 17 00:00:00 2001 From: aheirman <48590738+aheirman@users.noreply.github.com> Date: Sun, 14 Feb 2021 21:28:50 +0000 Subject: [PATCH 6/7] Add kbd --- pkgs/kbd/build.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 pkgs/kbd/build.sh diff --git a/pkgs/kbd/build.sh b/pkgs/kbd/build.sh new file mode 100644 index 0000000..7c06c6e --- /dev/null +++ b/pkgs/kbd/build.sh @@ -0,0 +1,29 @@ +pkgname=kbd +pkgver=2.4.0 + + + +fetch() { + curl "https://mirrors.edge.kernel.org/pub/linux/utils/kbd/kbd-$pkgver.tar.xz" -o $pkgname-$pkgver.tar.xz + tar -xf $pkgname-$pkgver.tar.xz +} + +build() { + cd $pkgname-$pkgver + ./configure \ + --prefix=/usr \ + --build=x86_64-unknown-linux-musl \ + --host=x86_64-unknown-linux-musl + + make +} + +package() { + cd $pkgname-$pkgver + make install DESTDIR=$pkgdir +} + +license() { + cd $pkgname-$pkgver + cat COPYING +} From b8e911ec3b5b93701bae880c3aeb91d4f3c32c49 Mon Sep 17 00:00:00 2001 From: aheirman <48590738+aheirman@users.noreply.github.com> Date: Sun, 14 Feb 2021 21:32:45 +0000 Subject: [PATCH 7/7] Add kbd to default install --- createimg.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/createimg.sh b/createimg.sh index b1d0ea8..c42880a 100755 --- a/createimg.sh +++ b/createimg.sh @@ -34,18 +34,22 @@ 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 +ROOT=/mnt/__IGLUNIX_ROOT +umount ${ROOT} +rm -rf ${ROOT} -mkdir -p /mnt/__IGLUNIX_ROOT -mount ${LOOPBACK} /mnt/__IGLUNIX_ROOT +mkdir -p ${ROOT} +mount ${LOOPBACK} ${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 +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 linux-pam kbd) +cp_packages ${ROOT} + +echo "Using the host keymap" +cp /etc/vconsole.conf ${ROOT}/etc/vconsole.conf echo "Unmounting & closing loopback" -umount /mnt/__IGLUNIX_ROOT +umount ${ROOT} losetup -d ${LOOPBACK} exit