#!/usr/bin/env bash # Build the GL-MT6000's root file system and FIT boot image: # mt6000-root.ext4 ext4 "Guix" with the system, for the `rootfs' partition # mt6000-boot.itb the FIT for the `kernel' partition (scripts/mt6000-fit.sh) # Cross-compiled from x86_64 (mt6000-image.scm's platform is aarch64). set -euo pipefail cd "$(dirname "$0")" export GUIX_PACKAGE_PATH="$PWD/packages:$HOME/channels/nonguix" img=$(guix system image mt6000-image.scm "$@" | tail -1) echo "image: $img" # The partition starts at 1 MiB (mt6000-image.scm); MBR, so it runs to the # end of the image. dd if="$img" of=mt6000-root.ext4 bs=1M skip=1 conv=sparse status=none echo "root: $PWD/mt6000-root.ext4 ($(stat -c %s mt6000-root.ext4) bytes)" # The FIT boots the system in the image -- not `guix system build`'s: the # image's has the root partition's UUID in place of the "Guix" label. debugfs=$(guix build e2fsprogs | grep -E -- '-e2fsprogs-[0-9][^-]*$')/sbin/debugfs sys=$("$debugfs" -R 'stat /var/guix/profiles/system-1-link' mt6000-root.ext4 2>/dev/null | sed -n 's/^Fast link dest: "\(.*\)"$/\1/p') [ -d "$sys" ] || { echo "no system in mt6000-root.ext4" >&2; exit 1; } echo "system: $sys" scripts/mt6000-fit.sh "$sys" mt6000-boot.itb