Commit 67c9257d authored by jan.koester's avatar jan.koester
Browse files

build-cross: mtd-utils and kernel-<board> packages; rootfs from the newest RPMs

kernel-<board>.spec (if present) is built with the packages; the rootfs
then takes kernel, DTB and modules from that RPM instead of the kernel
step's tree. Only the newest build of each package goes into the rootfs.

Co-Authored-By: default avatarClaude Opus 5.5 <noreply@anthropic.com>
parent e44ab316
Loading
Loading
Loading
Loading
+26 −2
Changes for build-cross.sh: 26 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -88,10 +88,16 @@ RPM_ARCH="${RPM_ARCH:-ppc}"
# FenrirOS specs cross-built by the 'packages' step, in dependency order
# (libyaml before libconfplus: its backends need it, which the x86 chroot
# just happens to have)
CROSS_PACKAGES_SET="${CROSS_PACKAGES:+1}"
CROSS_PACKAGES="${CROSS_PACKAGES:-systempp fresh zlib zstd bzip2 libjson-c libbrotli libcmdplus libuuidp libnetplus libyaml libconfplus
    libhttppp libressl syslite sharedd adconnect storaged iscsid upsd firewalld tinyxml2 snmpdd ntpplus containerd webctl
    popt lua file libelf libsqlite3 rpm ca-certificates fenriros-release liblzma libxml2 libarchive glib2 curl
    libsolv librepo fmt toml11 libsmartcols dnf5 e2fsprogs dosfstools gptfdisk}"
    libsolv librepo fmt toml11 libsmartcols dnf5 e2fsprogs dosfstools gptfdisk mtd-utils}"
# the board's kernel as a package (kernel-<board>.spec, e.g. the NAS ITX's
# writes its boot image into the NAND on installation)
if [[ -z ${CROSS_PACKAGES_SET:-} && -f $FENRIR_FILES/rpm/specs/kernel-$BOARD.spec ]]; then
    CROSS_PACKAGES+=" kernel-$BOARD"
fi

PREFIX=/usr
INTERP="$PREFIX/lib/ld-linux-$PROC.so"
@@ -503,8 +509,15 @@ step_rootfs() {
        # run in the root through binfmt's qemu-$PROC, as mapped root.
        local list="$BUILD/rootfs-rpms"
        # (noarch: ca-certificates, fenriros-release, ...)
        # newest build of each package only: rebuilds with a new Release
        # leave the older RPMs next to them
        local r
        find "$rpmdir" "$WORK/rpmbuild/RPMS/noarch" -name '*.rpm' ! -name '*-dev-*' ! -name '*-devel-*' \
            ! -name '*-debuginfo-*' 2>/dev/null | sort >"$list"
            ! -name '*-debuginfo-*' 2>/dev/null | while read -r r; do
                printf '%s %s %s\n' "$(rpm -qp --qf '%{NAME}' "$r" 2>/dev/null)" \
                    "$(rpm -qp --qf '%{VERSION}-%{RELEASE}' "$r" 2>/dev/null)" "$r"
            done | sort -k1,1 -k2,2V | awk '{ last[$1] = $3 } END { for (n in last) print last[n] }' |
            sort >"$list"
        msg "rootfs: installing $(wc -l <"$list") RPMs"
        : >"$LOGS/rootfs.log"
        run rootfs unshare -r rpm --root "$ROOTFS" --initdb
@@ -529,6 +542,16 @@ step_rootfs() {
    [[ -x $ROOTFS$PREFIX/sbin/syslite ]] || die "no /usr/sbin/syslite in the rootfs"
    [[ -e $ROOTFS$PREFIX/sbin/init ]] || ln -sf syslite "$ROOTFS$PREFIX/sbin/init"

    if [[ -f $ROOTFS/var/lib/rpm/rpmdb.sqlite ]] &&
       unshare -r rpm --root "$ROOTFS" -q "kernel-$BOARD" >/dev/null 2>&1; then
        # the kernel-<board> RPM brought kernel, DTB and modules
        msg "rootfs: kernel from $(unshare -r rpm --root "$ROOTFS" -q "kernel-$BOARD")"
        local kv
        for kv in "$ROOTFS$PREFIX"/lib/modules/*/; do
            kv="$(basename "$kv")"
            command -v depmod >/dev/null && run rootfs depmod -b "$ROOTFS$PREFIX" "$kv"
        done
    else
        msg "rootfs: kernel modules"
        run rootfs kmake INSTALL_MOD_PATH="$ROOTFS$PREFIX" INSTALL_MOD_STRIP=1 DEPMOD=true modules_install
        rm -f "$ROOTFS$PREFIX"/lib/modules/*/build "$ROOTFS$PREFIX"/lib/modules/*/source
@@ -537,6 +560,7 @@ step_rootfs() {
        fi
        cp "$OUT/$KIMAGE" "$ROOTFS/boot/"
        cp "$OUT/$BOARD.dtb" "$ROOTFS/boot/"
    fi

    write_system_config "$ROOTFS" "$HOSTNAME_FENRIR"