galeb

Једноставна статичка дистрибуција заснована на musl-у
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување 805792d23bf68337bb0477a5694eb84625eddb8b
родитељ f7233a4b6effdce6681d04aae5891c357d45889b
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Fri, 12 Aug 2022 23:05:25 +0200

Continued work on boot image generation

Signed-off-by: Страхиња Радић <contact@strahinja.org>

Diffstat:
M03-packages.sh | 87+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
M04-finale.sh | 9+++++----
MTODO | 12++++++++----
Mlib/env.sh | 5+++++
Mlib/fun.sh | 4++--
Alib/mkbootimage | 40++++++++++++++++++++++++++++++++++++++++
Mlib/pkgs.tsv | 2+-
измењених датотека: 7, додавања: 144(+), брисања: 15(-)

diff --git a/03-packages.sh b/03-packages.sh @@ -6184,7 +6184,88 @@ end_substep # fi # end_substep -# TODO +# rsync is not needed for boot image - better to use mkpk mkfiles later on +# Needed for rsync +# https://github.com/Cyan4973/xxHash/archive/refs/tags/v0.8.1.tar.gz xxhash-0.8.1.tar.gz 12feedd6a1859ef55e27218dbd6dcceccbb5a4da34cd80240d2f7d44cd246c7afdeb59830c2d5b90189bb5159293532208bf5bb622250102e12d6e1bad14a193 +# begin_substep xxhash-0.8.1 +# if [ -x /sucks/lib/libxxhash.so.0.8.1 ]; then +# msg info "%s exists, skipping %s" /sucks/lib/libxxhash.so.0.8.1 ${pkg} +# elif [ -e ${G_SPKG}/${pkg}.tar.xz ]; then +# unpack_pkg ${pkg} / +# else +# extract_pkg ${G_SRC} xxHash-0.8.1 ${pkg}.tar.gz ${pkg} +# ( +# cd_or_fail ${G_SRC}/${pkg} +# +# cat <<! >MKPK +# mkpk_name() +# { +# printf "%s" "${pkg}" +# } +# +# mkpk_install() +# { +# CFLAGS='-Os -pipe' +# LDFLAGS='-s' +# PREFIX=/sucks +# DESTDIR=/build +# SED=/${TLD}/bin/sed +# export CFLAGS LDFLAGS PREFIX DESTDIR SED +# +# make ${JN} PREFIX=\${PREFIX} DESTDIR=\${DESTDIR} SED=\${SED} \\ +# -C . install || exit 1 +# } +# ! +# mkpk ${pkg} +# remove_dir ${G_SRC}/${pkg} +# unpack_pkg ${pkg} / +# ) || exit 1 +# fi +# timestamp=$(date +'%Y-%m-%d %T') +# printf "%s\t%s\t%s\n" xxhash 0.8.1 "${timestamp}" >>${G_PKGDB} +# end_substep +# +# https://github.com/WayneD/rsync/archive/refs/tags/v3.2.5pre2.tar.gz rsync-3.2.5pre2.tar.gz cc7884cced95ce6fafd8d322b8bdb42c250c869d94186f7c471ce09cc3906f596903aed65c070e3de1c6a5e28966c4cea4d75797f444424484ebb9e574a0d42c +# begin_substep rsync-3.2.5pre2 +# if [ -x /bin/rsync ]; then +# msg info "%s exists, skipping %s" /bin/rsync ${pkg} +# elif [ -e ${G_SPKG}/${pkg}.tar.xz ]; then +# unpack_pkg ${pkg} / +# else +# extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.gz +# ( +# cd_or_fail ${G_SRC}/${pkg} +# +# cat <<! >MKPK +# mkpk_name() +# { +# printf "%s" "${pkg}" +# } +# +# mkpk_install() +# { +# CFLAGS='-Os -pipe -static --static -fcommon' +# LDFLAGS='-static --static -fcommon -s' +# DESTDIR=/build +# export CFLAGS LDFLAGS DESTDIR +# +# +# ./configure --prefix='' \\ +# --disable-md2man \\ +# --disable-lz4 || exit 1 +# make ${JN} || exit 1 +# make install +# } +# ! +# mkpk ${pkg} +# remove_dir ${G_SRC}/${pkg} +# unpack_pkg ${pkg} / +# ) || exit 1 +# fi +# timestamp=$(date +'%Y-%m-%d %T') +# printf "%s\t%s\t%s\n" rsync 3.2.5pre2 "${timestamp}" >>${G_PKGDB} +# end_substep + begin_substep shim-15.6 if [ -x /share/shim ]; then msg info "%s exists, skipping %s" /share/shim \ @@ -6545,9 +6626,7 @@ msg warn " cp System.map /boot/ && \\\\ " msg warn " cp .config /boot/config " msg warn " mv /bin/_ln /bin/ln " msg warn "You might want to then use efibootmgr to add efistub to EFI. " -msg warn "For example (efibootmgr -h for help): " -msg warn " efibootmgr -c -d /dev/sda -l '\\\\vmlinuz' \\\\ " -msg warn " -L 'Galeb EFISTUB' -p1 -u root=/dev/sda2 " +msg warn "See BOOTING. " PATH=/local/bin:/bin:/sucks/bin:/tools/bin export PATH diff --git a/04-finale.sh b/04-finale.sh @@ -313,13 +313,14 @@ mkdir -p ${GR}/boot/EFI mkdir -p ${GR}/boot/EFI/BOOT mkdir -p ${GR}/boot/EFI/GALEB -cp_or_fail ${GR}/share/shim-15.6/shimx64.efi ${GR}/boot/EFI/BOOT/bootx64.efi -cp_or_fail ${GR}/share/shim-15.6/fbx64.efi ${GR}/boot/EFI/BOOT/fbx64.efi +cp_or_fail ${GR}/share/shim-15.6/fbx64.efi ${GR}/boot/EFI/BOOT/bootx64.efi +#cp_or_fail ${GR}/share/shim-15.6/shimx64.efi ${GR}/boot/EFI/BOOT/bootx64.efi +#cp_or_fail ${GR}/share/shim-15.6/fbx64.efi ${GR}/boot/EFI/BOOT/fbx64.efi cp_or_fail ${GR}/boot/vmlinuz ${GR}/boot/EFI/GALEB/vmlinuz msg info "Generating %s" "${GR}/boot/EFI/GALEB/BOOT.CSV" cat <<! >${GR}/boot/EFI/GALEB/BOOT-ASC.CSV -vmlinuz,Galeb EFISTUB,root=/dev/sda2,Boot entry for Galeb EFISTUB +vmlinuz,Galeb EFISTUB,root=${USBROOT} rootdelay=5,Boot entry for Galeb EFISTUB ! iconv -f ASCII -t UCS-2LE <${GR}/boot/EFI/GALEB/BOOT-ASC.CSV \ >${GR}/boot/EFI/GALEB/BOOT.CSV @@ -339,6 +340,6 @@ Galeb musl/Linux ${G_VER} ! msg warn "Create a partition and copy files from here to it, then setup booting" -msg warn "(For example using efibootmgr and efistub kernel) " +msg warn "(see BOOTING). " end_step diff --git a/TODO b/TODO @@ -1,16 +1,16 @@ TODO ==== -[~] Add shim - [x] Use shim and mksquashfs to create boot iso - - Using a slightly different method with raw image +[ ] Add information about boot image to BOOTING -[ ] See if any packages can be trimmed from the bootstrap +[ ] Add rsync to lib/mkbootimage Low priority ------------ +< > See if any packages can be trimmed from the bootstrap + < > Create a dedicated shutdown suid executable < > Add -h to free @@ -28,6 +28,10 @@ Low priority Done ---- +[x] Add shim + [x] Use shim and mksquashfs to create boot iso + - Using a slightly different method with raw image + [x] Add "ports" system using mk [x] Working on mkpk - Done [x] Add sacc diff --git a/lib/env.sh b/lib/env.sh @@ -2,7 +2,12 @@ # Edit this! Has to be hardcoded because of the # necessity to run some scripts as root + GUSER=strajder +USBROOT=/dev/sdb2 # Change to /dev/sda2, remove Galeb UEFI boot entry and + # rerun bootstrap scripts if you can't boot + +# /Edit this GHOME=/home/${GUSER} GUID=$(grep ^${GUSER}: /etc/passwd | sed 1q | cut -d : -f 3) diff --git a/lib/fun.sh b/lib/fun.sh @@ -477,13 +477,13 @@ msg() err) icon_plain="=E=" icon="${bold}${white}${bgred}${icon_plain}";; info) icon_plain="=I=" - icon="${bold}${faint}${green}${icon_plain}";; + icon="${green}${icon_plain}";; query) icon_plain="=Q=" icon="${bold}${yellow}${icon_plain}" log=0 newline=0;; warn) icon_plain="=W=" - icon="${bgyellow}${bold}${faint}${black}${icon_plain}";; + icon="${bgyellow}${black}${icon_plain}";; *) ;; esac printf "%s %s " "${icon}" ${tstamp} diff --git a/lib/mkbootimage b/lib/mkbootimage @@ -0,0 +1,40 @@ +#!/bin/sh + +. ./lib/env.sh +. ./lib/fun.sh + +if [ "$(id -u)" -ne 0 ]; then + msg err "You must run this script as root" + exit 1 +fi + +( +ver=2.0 +timestamp=$(date +'%Y%m%d') +diskimg=galeb-${ver}-${timestamp}.raw + +rm "${diskimg}" + +truncate -s $(echo '(25 * 1024 * 1024 * 1024)/10' | bc) "${diskimg}" || exit 1 + +printf "g\nn\n\n\n+500M\nt\n1\nn\n\n\n\nx\nn\n1\nGALBOOT\n"\ +"n\n2\nGalRoot\nr\nw\n" | fdisk "${diskimg}" || exit 1 + +losetup -P -f "${diskimg}" || exit 1 + +mkfs.ext4 -L GalRoot /dev/loop0p2 || exit 1 +mkfs.vfat -F 32 -n GALBOOT /dev/loop0p1 || exit 1 + +mount -t ext4 /dev/loop0p2 /mnt || exit 1 +mkdir -p /mnt/boot || exit 1 +mount -t vfat /dev/loop0p1 /mnt/boot || exit 1 + +# rsync ... + +umount /mnt/boot +umount /mnt +losetup -d /dev/loop0 || exit 1 + +#xz -9vvf "${diskimg}" +) || msg err "Image generation failed" + diff --git a/lib/pkgs.tsv b/lib/pkgs.tsv @@ -8,8 +8,8 @@ git+https://git.sr.ht/~strahinja/svc svc-20220808 git+https://github.com/cpeuvrel/usleep-aur usleep-20220718 git+https://github.com/mirbsd/mksh mksh-20220709 git+https://github.com/onetrueawk/awk awk-20220709 -git+https://github.com/rhboot/shim.git shim-15.6 git+https://github.com/rhboot/gnu-efi.git shim-15.6/rhboot-gnu-efi +git+https://github.com/rhboot/shim.git shim-15.6 git://git.2f30.org/pass pass-20220723 git://git.2f30.org/sdhcp sdhcp-20220716 git://git.suckless.org/9base 9base-20220706