Compare commits

...

5 Commits

Author SHA1 Message Date
Dustin 6c588d59a2 podman-build: Mount /mnt/gentoo as a volume
Using a bind-mount instead of an overlay should marginally increase
performance.
2023-02-13 22:59:51 -06:00
Dustin 8a2bb1666d Add top-level Makefile
Building the OS is now as simple as running `make` on a Gentoo system.

Interestingly, when `make` is executed as a (grand)child process of
another `make` process, it always prints an `Entering directory ...`
message.  This breaks the `make kernelversion` command, by adding
extraneous text to the output.
2023-02-13 22:59:51 -06:00
Dustin b35ff1b85d build-rootfs: Avoid spurious boot errors
The *ldconfig.service* fails because `/etc` is not writable and thus
`/etc/ld.so.cache` cannot be generated.

The files specified in the `provision.d` *tmpfiles.d(5)* configuration
are unnecessary, and many of them cannot be created at runtime because
the root filesystem is immutable.
2023-02-13 22:59:51 -06:00
Dustin 594dc43366 build-rootfs: Create /lib and /lib64 symlinks 2023-02-13 22:59:51 -06:00
Dustin 6be78932df uboot: Apply patches outside container
When running inside a rootless Podman container on a SELinux-enabled
host, the `patch` command fails because it cannot copy SELinux labels
from the original file to the patched file.  This only happens patching
files that are located in a bind mount.
2023-02-13 22:59:51 -06:00
7 changed files with 131 additions and 11 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
/images
/linux
/output
/.prepared
/.host-tools

95
Makefile Normal file
View File

@ -0,0 +1,95 @@
update.tar: output/update.tar.zstd
.prepared: \
prepare.sh \
config-portage.sh \
setup-local-repo.sh \
$(shell find portage host-portage -type f) \
$(shell find patches/ebuilds -type f)
./prepare.sh
./config-portage.sh
./setup-local-repo.sh
touch .prepared
prepare: .prepared
.host-tools: \
build-host-tools.sh \
.prepared
./build-host-tools.sh
touch .host-tools
host-tools: .host-tools
images/rootfs.squashfs: \
build.sh \
build-rootfs.sh \
build-squashfs.sh \
linux/arch/arm64/boot/Image.gz \
.host-tools \
.prepared
./build.sh
./build-rootfs.sh
./build-squashfs.sh
squashfs: images/rootfs.squashfs
linux/arch/arm64/boot/Image.gz: \
build-kernel.sh \
linux.config \
.host-tools \
.prepared
./build-kernel.sh
kernel: linux/arch/arm64/boot/Image.gz
output/efi-part/EFI/BOOT/BOOTAA64.efi: \
build-grub.sh \
grub.cfg \
.host-tools \
.prepared
./build-grub.sh
grub: output/efi-part/EFI/BOOT/BOOTAA64.efi
output/efi-part/u-boot.bin: \
build-uboot.sh \
u-boot.config
./build-uboot.sh
uboot: output/efi-part/u-boot.bin
images/sdcard.img: \
genimage.cfg \
genimage.sh \
post-build.sh \
output/efi-part/u-boot.bin \
output/efi-part/EFI/BOOT/BOOTAA64.efi
./post-build.sh
./genimage.sh
sdcard.img: images/sdcard.img
images/firmware.img: images/sdcard.img
output/update.tar.zstd: \
images/rootfs.squashfs \
images/firmware.img \
.host-tools \
.prepared
./build-update.sh
clean:
git -C u-boot clean -fdx && git -C u-boot checkout -- .
rm -rf linux output images tmp
rm -f .prepared .host-tools
.PHONY: \
grub \
host-tools \
kernel \
prepare \
sdcard.img \
squashfs \
uboot \
update.tar

View File

@ -15,11 +15,11 @@ cd linux
../linux.config
make -C /usr/src/linux O=${PWD} olddefconfig
make -j$(nproc)
kver=$(make kernelversion)
kver=$(make -s kernelversion)
make modules_install INSTALL_MOD_PATH=/mnt/gentoo
cd -
printf 'Installing Kernel ...\n'
printf 'Installing Kernel %s ...\n' "${kver}"
mkdir -p /mnt/gentoo/boot
cp -au linux/arch/arm64/boot/Image.gz /mnt/gentoo/boot/vmlinuz-${kver}
cp -au linux/.config /mnt/gentoo/boot/config-${kver}

View File

@ -5,10 +5,16 @@ set -e
. ./config
mkdir -p /mnt/gentoo/usr/bin
mkdir -p \
/mnt/gentoo/usr/bin \
/mnt/gentoo/usr/lib \
/mnt/gentoo/usr/lib64 \
|| exit
[ -h /mnt/gentoo/bin ] || ln -s usr/bin /mnt/gentoo/bin
[ -h /mnt/gentoo/sbin ] || ln -s usr/sbin /mnt/gentoo/sbin
[ -h /mnt/gentoo/usr/sbin ] || ln -s bin /mnt/gentoo/usr/sbin
[ -h /mnt/gentoo/lib ] || ln -s usr/lib /mnt/gentoo/lib
[ -h /mnt/gentoo/lib64 ] || ln -s usr/lib64 /mnt/gentoo/lib64
mkdir -p /mnt/gentoo/etc/portage
ln -snf \
@ -59,7 +65,10 @@ if [ -f /mnt/gentoo/etc/udev/hwdb.bin ]; then
mv /mnt/gentoo/etc/udev/hwdb.bin /mnt/gentoo/usr/lib/udev/
fi
rm -f /mnt/gentoo/lib/tmpfiles.d/provision.conf
systemctl preset-all --root=/mnt/gentoo
rm -f /mnt/gentoo/lib/systemd/system/sysinit.target.wants/ldconfig.service
systemd-sysusers --root=/mnt/gentoo
if grep -q '^root:.*/bin/bash$' /mnt/gentoo/etc/passwd; then

View File

@ -5,14 +5,8 @@ set -e
. ./config
./patch-uboot.sh
cd u-boot
if [ ! -f .patched ]; then
for x in ../patches/uboot/*.patch; do
printf 'Applying patch %s ...\n' "${x##*/}"
patch -p1 < "${x}"
done
: > .patched
fi
cat configs/rpi_4_defconfig ../u-boot.config > configs/yellow_defconfig
make yellow_defconfig
CROSS_COMPILE=${target}- make

17
patch-uboot.sh Executable file
View File

@ -0,0 +1,17 @@
#!/bin/sh
# vim: set sw=4 ts=4 sts=4 et :
if [ -f u-boot/.patched ]; then
exit 0
fi
rc=0
cd u-boot || exit
for x in ../patches/uboot/*.patch; do
[ -f "${x}" ] || continue
printf 'Applying patch %s ...\n' "${x##*/}"
patch -p1 < "${x}" || rc=$?
done
if [ $rc -eq 0 ]; then
: > .patched
fi

View File

@ -12,6 +12,7 @@ cid=$(podman run \
-v packages:/var/cache/binpkgs \
-v distfiles:/var/cache/distfiles \
-v packages:/usr/${target}/var/cache/binpkgs \
-v /mnt/gentoo \
-v ${PWD}:/tmp/build:rw,z \
-w /tmp/build \
-d \
@ -20,7 +21,9 @@ cid=$(podman run \
python -c 'from signal import *;signal(SIGTERM, lambda x, y: None);pause()'
)
podman exec -it ${cid} ./build-all.sh "${target}"
./patch-uboot.sh
podman exec -it ${cid} make
podman stop ${cid}
podman rm ${cid}