Commit bdb8c8cc authored by jan.koester's avatar jan.koester
Browse files

build-chroot: a fresh chroot installs the signed RPMs; keep systempp's elf.h

Found rebuilding the chroot from scratch (RC4's had grown in place):
- the packages a fresh chroot builds are signed, but its rpm is the
  bootstrap one (step_rpm, no OpenPGP) until rpm.spec's replaces it, and
  that rpm refuses every signed package ("RPM was compiled without
  OpenPGP support") -- python3 never got installed, llvm-project and
  ca-certificates failed without it. Installs of our own just-built RPMs
  into the chroot and the image roots use --nosignature.
- step_rpm's elfutils build installed glibc's elf.h (no ElfW) into
  rpmroot, which the chroot takes after systempp's: <link.h> broke rpm's
  rpmrc.cc. It is removed there as libelf.spec does.

Co-Authored-By: default avatarClaude Opus 5.5 <noreply@anthropic.com>
parent 0e020693
Loading
Loading
Loading
Loading
+14 −5
Changes for build-chroot.sh: 14 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -777,6 +777,10 @@ EOF
    cp "$FENRIR_FILES/libelf/musl-compat.h" "$src/elfutils/musl-compat.h"
    rpm_cmake libelf "$src/elfutils" \
        -DZLIB_LIB="$RPMROOT/usr/lib/libz.a" -DZLIB_INC="$RPMROOT/usr/include"
    # elfutils installs glibc's elf.h (no ElfW); the chroot takes rpmroot's
    # files after systempp's, so it replaced systempp's elf.h there and
    # <link.h> broke (rpm's rpmrc.cc). libelf.spec removes it the same way.
    rm -f "$RPMROOT/usr/include/elf.h"

    fetch_git "$src/rpm" https://github.com/rpm-software-management/rpm.git rpm-6.0.1-release
    grep -q '#ifdef GLOB_BRACE' "$src/rpm/rpmio/rpmglob.cc" || sed -i \
@@ -1419,6 +1423,11 @@ check_depgen() {
            "libmagic broken? Rebuild it and rpmbuild with PACKAGES=\"file rpm\" first"
}

# --nosignature on every install of our own just-built RPMs into the chroot
# and the image roots: a fresh chroot's rpm is the bootstrap one (step_rpm,
# no OpenPGP), which refuses any signed package outright ("RPM was compiled
# without OpenPGP support") until rpm.spec's build replaces it -- and
# checking the signature we just made proves nothing anyway.
step_packages() {
    [[ -x $CHROOT$PREFIX/bin/rpmbuild ]] || die "no rpmbuild in the chroot -- run the 'rpm' and 'chroot' steps first"
    # a list starting with file (and then rpm) is how a broken one is fixed
@@ -1460,7 +1469,7 @@ step_packages() {
            skipped+=("$pkg")
            sign_rpms $(printf "$CHROOT%s " $existing_rpms)
            # Auch bereits vorhandene Pakete sicherheitshalber in den Chroot installieren
            in_chroot /bin/sh -c "rpm -Uvh --nodeps --force --replacepkgs $existing_rpms" >>"$log" 2>&1 || true
            in_chroot /bin/sh -c "rpm -Uvh --nodeps --force --nosignature --replacepkgs $existing_rpms" >>"$log" 2>&1 || true
            continue
        fi

@@ -1482,7 +1491,7 @@ step_packages() {
            if [[ -n $rpms ]]; then
                sign_rpms $(printf "$CHROOT%s " $rpms)
                msg "packages: installing $pkg (and its subpackages) into the chroot"
                in_chroot /bin/sh -c "rpm -Uvh --nodeps --force --replacepkgs $rpms" \
                in_chroot /bin/sh -c "rpm -Uvh --nodeps --force --nosignature --replacepkgs $rpms" \
                    >>"$log" 2>&1 || failed+=("$pkg(install)")
                case $pkg in rpm|systempp) check_depgen ;; esac
            fi
@@ -1548,7 +1557,7 @@ step_fenstore() {
        in_chroot rpmbuild -bb --nodeps --define "_rpmdir $dir" "/build/rpmbuild/SPECS/$pkg.spec" >"$log" 2>&1 ||
            { tail -n 15 "$log" >&2; die "fenstore: $pkg failed (log: $log)"; }
        [[ $pkg == fenstore ]] ||
            in_chroot /bin/sh -c "rpm -Uvh --nodeps --force --replacepkgs $dir/x86_64/$pkg-*.rpm" >>"$log" 2>&1
            in_chroot /bin/sh -c "rpm -Uvh --nodeps --force --nosignature --replacepkgs $dir/x86_64/$pkg-*.rpm" >>"$log" 2>&1
    done
    sign_rpms "$CHROOT$dir"/*/*.rpm
    msg "fenstore: RPMs in $CHROOT$dir"
@@ -1600,7 +1609,7 @@ install_rpm_root() {
    setup_merged_usr "$CHROOT$root"
    run "$log" in_chroot rpm --root "$root" --initdb
    run "$log" in_chroot /bin/sh -c 'x=; [ -z "$3" ] || x=$(sed "s/^/--excludepath=/" "$3")
            rpm -ivh --nodeps --force --root "$1" $x $(cat "$2")' \
            rpm -ivh --nodeps --force --nosignature --root "$1" $x $(cat "$2")' \
        sh "$root" "/build/rpmbuild/$list" "${excl:+/build/rpmbuild/$excl}"
    mkdir -p "$CHROOT$root"/{dev,proc,sys,run,tmp,root,home,mnt,var/tmp,var/log}
    [[ -e $CHROOT$root/var/run ]] || ln -s ../run "$CHROOT$root/var/run"
@@ -1826,7 +1835,7 @@ docker_image() {
    # Nutze den absoluten Pfad innerhalb der Chroot für die Paketliste
    local chroot_list="/build/rpmbuild/$(basename "$list")"
    
    in_chroot /bin/sh -c 'rpm -ivh --nodeps --force --root "$1" $(cat "$2")' sh "/build/docker-$name" "$chroot_list"
    in_chroot /bin/sh -c 'rpm -ivh --nodeps --force --nosignature --root "$1" $(cat "$2")' sh "/build/docker-$name" "$chroot_list"

    # no RPM owns these, same as install_rpm_root
    mkdir -p "$CHROOT/build/docker-$name"/{run,tmp,root,home,var/tmp,var/log}