2024-01-22 14:23:32 +00:00
|
|
|
#!/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
|
Upgrade Linux kernel to 4.14.336
This is the last LTS version buildable using GCC 4.0.x. The next one,
version 4.19, requires at least GCC 4.6.
Fortunately, this is also the first version of the Linux kernel
without firmware blobs being included in /firmware, so the FSFLA
deblob scripts aren't needed anymore to ensure a fully auditable
kernel - the 3 remaining drivers that do include blobs masquerading
as source code are removed via a patch, avoiding all the other side
effects of the deblob scripts.
This doesn't compromise the trustworthiness of the bootstrapped
environment, since all the other drivers deblob would remove use
the firmware loader mechanism, which does nothing when the actual
firmware blobs aren't installed on the system separately. Features
dependent on firmware still won't work, but many drivers that load
firmware do so only optionally. This includes r8169, the driver for
the Realtek gigabit NICs found on many x86 motherboards.
This kernel is considerably larger than 4.9.10, and we build more
of it (including drivers that would previously get stripped away by
the deblob script, such as r8169), so to accommodate that, Fiwix
initrd size is increased by 64MiB, while lowering kexec space by
the same amount to ensure enough userspace memory available in Fiwix.
Fiwix's maximum open file count is also bumped from 1.5K to 2.5K.
The Documentation folder is deleted before build, to further save
space in the ramdisk.
2024-02-16 11:58:27 +00:00
|
|
|
menuentry 'Linux live-bootstrap' {
|
2024-01-22 14:23:32 +00:00
|
|
|
insmod part_msdos
|
2024-02-06 18:22:35 +00:00
|
|
|
set root='$(grub-probe -d /dev/${DISK} -t bios_hints | sed -e 's/ //g')'
|
2024-02-14 15:02:28 +00:00
|
|
|
set gfxpayload=auto
|
2024-02-18 16:49:32 +00:00
|
|
|
linux /boot/vmlinuz root=/dev/${DISK} rootwait rw $(cat /proc/cmdline)
|
2024-01-22 14:23:32 +00:00
|
|
|
}
|
|
|
|
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
|