commit: 10d2a72d16b12eca04c760db6eebad5f329a4001
parent 50947ca61eeaf985b08bf3ed85bc2c4ca66d1b07
Author: fosslinux <fosslinux@aussies.space>
Date: Mon, 5 Feb 2024 07:50:36 +0000
Merge pull request #415 from Googulator/grub
Support reboot in non-chroot modes using grub and an init script
Diffstat:
9 files changed, 167 insertions(+), 1 deletion(-)
diff --git a/steps/SHA256SUMS.pkgs b/steps/SHA256SUMS.pkgs
@@ -60,6 +60,7 @@ dc67fc1b132fa3945349efe74c5b2197bd0b6babf4d29d2deddd04f09d9af680 gettext-0.21_0
62edfa633f64202b2d29199d11d56a897654a441c7ae39a4d59ca5fe75199f61 gperf-3.1_0.tar.bz2
276e073496931ff7d4caaabb53079412b88de953def88aec966c1f8506293e88 grep-2.4_0.tar.bz2
8e612afb9a439aa8bf5db0fc2589eec890a6017690412d5c8e88a5838730b42c grep-3.7_0.tar.bz2
+8035da0f42b40509a1f68c91164f20fec624cf8b61017aa4e135473e547dddf4 grub-2.06_0.tar.bz2
e2a85aad6d51e52c9a30afeed058f95172fde1215f77243549274672990f6237 guile-3.0.9_0.tar.bz2
6585ae3bc8149ec0e3fba766278fa30e2d7f0e7d1b9a9a4a457e0afa15b109c9 gzip-1.13_0.tar.bz2
8d2015b87337abbf287f7a39ee4cf53514120b5d3e90a93fe7d533dcc43f14fa help2man-1.36.4_0.tar.bz2
diff --git a/steps/grub-2.06/import-gnulib.sh b/steps/grub-2.06/import-gnulib.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# SPDX-FileCopyrightText: 2021 Melg Eight <public.melg8@gmail.com>
+# SPDX-FileCopyrightText: 2023 fosslinux <fosslinux@aussies.space>
+# SPDX-FileCopyrightText: 2024 Gábor Stefanik <netrolller.3d@gmail.com>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+# Regenerate unicode files
+pushd ../gnulib-d271f86/lib
+gcc -Iunictype -o gen-uni-tables gen-uni-tables.c
+mv ../../*.txt .
+./gen-uni-tables UnicodeData-9.0.0.txt PropList-9.0.0.txt DerivedCoreProperties-9.0.0.txt ArabicShaping-9.0.0.txt Scripts-9.0.0.txt Blocks-9.0.0.txt PropList-3.0.1.txt EastAsianWidth-9.0.0.txt LineBreak-9.0.0.txt WordBreakProperty-9.0.0.txt GraphemeBreakProperty-9.0.0.txt CompositionExclusions-9.0.0.txt SpecialCasing-9.0.0.txt CaseFolding-9.0.0.txt 9.0
+popd
+
+../gnulib-d271f86/gnulib-tool --import --local-dir=gl \
+ --lib=libgnu \
+ --source-base=grub-core/lib/gnulib \
+ --m4-base=m4 \
+ --doc-base=doc \
+ --tests-base=tests \
+ --aux-dir=build-aux \
+ --no-conditional-dependencies \
+ --no-libtool \
+ --macro-prefix=gl \
+ --no-vc-files \
+ argp \
+ base64 \
+ error \
+ fnmatch \
+ getdelim \
+ getline \
+ gettext-h \
+ gitlog-to-changelog \
+ mbswidth \
+ progname \
+ realloc-gnu \
+ regex \
+ save-cwd
diff --git a/steps/grub-2.06/pass1.sh b/steps/grub-2.06/pass1.sh
@@ -0,0 +1,35 @@
+# SPDX-FileCopyrightText: 2024 Gábor Stefanik <netrolller.3d@gmail.com>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+src_prepare() {
+ default
+
+ # Remove pregenerated gnulib files
+ pushd ../gnulib-d271f86
+ rm lib/unictype/ctype*.h
+ rm lib/unicase/tolower.h
+ popd
+
+ . ../../import-gnulib.sh
+
+ for patchname in fix-base64 fix-null-deref fix-null-state-deref fix-regcomp-uninit-token \
+ fix-regexec-null-deref fix-uninit-structure fix-unused-value fix-width no-abort; do
+ patch -d grub-core/lib/gnulib -p2 < "grub-core/lib/gnulib-patches/$patchname.patch"
+ done
+
+ ./autogen.sh
+
+ cp -a INSTALL INSTALL.grub
+ autoreconf-2.69 -vif
+ mv INSTALL.grub INSTALL
+}
+
+src_configure() {
+ CFLAGS="-Wno-error" ./configure --prefix="${PREFIX}" --sbindir="${PREFIX}/bin" --build=i686-pc-linux-musl
+}
+
+src_install() {
+ default
+ rm "${DESTDIR}${PREFIX}/share/info/dir"
+}
diff --git a/steps/grub-2.06/sources b/steps/grub-2.06/sources
@@ -0,0 +1,16 @@
+https://mirrors.kernel.org/gnu/grub/grub-2.06.tar.xz b79ea44af91b93d17cd3fe80bdae6ed43770678a9a5ae192ccea803ebb657ee1
+https://git.savannah.gnu.org/cgit/gnulib.git/snapshot/gnulib-d271f86.tar.gz 31d69d3d251e39135b5194ddc6f897910d344059f7494d96a739aecbf7ac2b66
+http://ftp.unicode.org/Public/9.0.0/ucd/UnicodeData.txt 68dfc414d28257b9b5d6ddbb8b466c768c00ebdf6cbf7784364a9b6cad55ee8f UnicodeData-9.0.0.txt
+http://ftp.unicode.org/Public/9.0.0/ucd/PropList.txt f413ea8dbd3858de72f3148b47dd0586019761357d1481e3b65f3a025bc27f82 PropList-9.0.0.txt
+http://ftp.unicode.org/Public/9.0.0/ucd/DerivedCoreProperties.txt 6662c7e30b572df5d948c092692f52bcc79ab36d49a063a73d6435042db6fb3b DerivedCoreProperties-9.0.0.txt
+http://ftp.unicode.org/Public/9.0.0/ucd/ArabicShaping.txt 47cb62a53beea6d0263e2147331c7e751853c9327225d95bbe2d9e1dc3e1aa44 ArabicShaping-9.0.0.txt
+http://ftp.unicode.org/Public/9.0.0/ucd/Scripts.txt fba415952f5654145acad220dc2b878f815c673474d2bb4928934e3ba6ccca1d Scripts-9.0.0.txt
+http://ftp.unicode.org/Public/9.0.0/ucd/Blocks.txt 612127d4889032e55d82522e4a0c19793bda8aa8da14ecb3c696d17c83e6be13 Blocks-9.0.0.txt
+http://ftp.unicode.org/Public/3.0-Update1/PropList-3.0.1.txt 909eef4adbeddbdddcd9487c856fe8cdbb8912aa8eb315ed7885b6ef65f4dc4c
+http://ftp.unicode.org/Public/9.0.0/ucd/EastAsianWidth.txt 3382cb4980e0021e9d4312f2d099315cfab6100ce0ff63a22d6937bfa720bcb7 EastAsianWidth-9.0.0.txt
+http://ftp.unicode.org/Public/9.0.0/ucd/LineBreak.txt e2698584982ccd96e0c688bbcd4d2c48a23805baa0a0084388ef2e50ebd30aad LineBreak-9.0.0.txt
+http://ftp.unicode.org/Public/9.0.0/ucd/auxiliary/WordBreakProperty.txt cb2db065c77287e0f1d35b8c9b473d848b7566a1670439f67c357ca393084043 WordBreakProperty-9.0.0.txt
+http://ftp.unicode.org/Public/9.0.0/ucd/auxiliary/GraphemeBreakProperty.txt 4bb8931857e0a698fd2ec4a51a84c6de33e48a50d8b4bf0b57d960c41d77a191 GraphemeBreakProperty-9.0.0.txt
+http://ftp.unicode.org/Public/9.0.0/ucd/CompositionExclusions.txt 5623df16856ad4007c60bdfff6f054e087521becd24cb4006be69c3a1d851aee CompositionExclusions-9.0.0.txt
+http://ftp.unicode.org/Public/9.0.0/ucd/SpecialCasing.txt dfc4f159c5c68328114ff17cd520451714a72ff48657287e5fe2f64344980695 SpecialCasing-9.0.0.txt
+http://ftp.unicode.org/Public/9.0.0/ucd/CaseFolding.txt 37d40cf8c2c35637f4a04e746814e1fc4eb764c272bed9238a87ee96a4866857 CaseFolding-9.0.0.txt
diff --git a/steps/improve/finalize_fhs.sh b/steps/improve/finalize_fhs.sh
@@ -16,6 +16,11 @@ mount | grep '/sys' &> /dev/null || (mkdir -p /sys; mount -t sysfs sysfs /sys)
mount | grep '/tmp' &> /dev/null || (mkdir -p /tmp; mount -t tmpfs tmpfs /tmp)
mount | grep '/dev/shm' &> /dev/null || (mkdir -p /dev/shm; mount -t tmpfs tmpfs /dev/shm)
+if [ "${CHROOT}" = False ]; then
+ rm /etc/mtab
+ ln -s /proc/mounts /etc/mtab
+fi
+
# Add /etc/resolv.conf
if [ ! -e "/etc/resolv.conf" ]; then
echo 'nameserver 1.1.1.1' > /etc/resolv.conf
diff --git a/steps/improve/make_bootable.sh b/steps/improve/make_bootable.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+# SPDX-FileCopyrightText: 2024 Gábor Stefanik <netrolller.3d@gmail.com>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+# find the physical disk name
+PHYSICAL=${DISK}
+
+# take care of e.g. "sda1"
+if echo "${DISK}" | grep -Eq '^[a-z]{3}[0-9]+$'
+then
+ PHYSICAL=$(echo "${DISK}" | sed -E 's/^([a-z]{3})[0-9]+$/\1/')
+fi
+
+# take care of e.g. "mmcblk0p1"
+if echo "${DISK}" | grep -Eq '^[a-z0-9]{3,}p[0-9]+$'
+then
+ PHYSICAL=$(echo "${DISK}" | sed -E 's/^([a-z0-9]{3,})p[0-9]+$/\1/')
+fi
+
+grub-install "/dev/${PHYSICAL}"
+
+cat > /boot/grub/grub.cfg <<- EOF
+set timeout=5
+set default=0
+menuentry 'Linux live-bootstrap (4.9.10)' {
+ insmod part_msdos
+ set root='grub-probe -d /dev/${DISK} -t bios_hints | sed -e 's/ //g')'
+ linux /boot/linux-4.9.10 root=/dev/${DISK} rw $(cat /proc/cmdline)
+}
+EOF
+
+cat > /init <<- 'EOF'
+#!/usr/bin/bash
+cd /steps
+. ./bootstrap.cfg
+. ./env
+. ./helpers.sh
+trap 'env PATH=${PREFIX}/bin PS1="[TRAP] \w # " bash -i' ERR
+# /dev is automounted by the kernel at this point
+mount | grep '/proc' &> /dev/null || (mkdir -p /proc; mount -t proc proc /proc)
+mount | grep '/sys' &> /dev/null || (mkdir -p /sys; mount -t sysfs sysfs /sys)
+# Make /tmp a ramdisk (speeds up configure etc significantly)
+mount | grep '/tmp' &> /dev/null || (mkdir -p /tmp; mount -t tmpfs tmpfs /tmp)
+mount | grep '/dev/shm' &> /dev/null || (mkdir -p /dev/shm; mount -t tmpfs tmpfs /dev/shm)
+
+if test -f /swapfile; then
+ swapon /swapfile
+fi
+
+if [ "${CHROOT}" = False ]; then
+ dhcpcd --waitip=4
+fi
+
+env - PATH=${PREFIX}/bin PS1="\w # " setsid openvt -fec1 -- bash -i
+
+# ignore errors due to fstab or swapfile not existing
+swapoff -a &> /dev/null || true
+sync
+# sysrq to avoid device busy; then mount to wait for it to finish
+echo u > /proc/sysrq-trigger
+mount -o remount,ro /
+echo o > /proc/sysrq-trigger # power off
+while true; do sleep 1; done
+EOF
+
+chmod +x /init
diff --git a/steps/improve/swap.sh b/steps/improve/swap.sh
@@ -1,4 +1,3 @@
-
#!/bin/sh
#
# SPDX-FileCopyrightText: 2024 Gábor Stefanik <netrolller.3d@gmail.com>
diff --git a/steps/jump/move_disk.sh b/steps/jump/move_disk.sh
@@ -32,6 +32,7 @@ if [ $((0x$(stat -c "%T" "/dev/${DISK}") % 8)) -eq 0 ]; then
echo "Creating ext4 partition..."
mkfs.ext4 -F -F "/dev/${DISK}1"
DISK="${DISK}1"
+ echo DISK="${DISK}" >> /steps/bootstrap.cfg
fi
# Mount the partition, move everything into /external
diff --git a/steps/manifest b/steps/manifest
@@ -194,6 +194,8 @@ jump: break ( INTERNAL_CI == pass1 ) # scripts are generated in pass1
build: gcc-10.4.0
build: binutils-2.41
build: gcc-13.1.0
+build: grub-2.06 ( BUILD_LINUX == True )
+improve: make_bootable ( CHROOT == False )
build: libmd-1.1.0
build: libbsd-0.11.8
build: shadow-4.14.3