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

build-chroot: /dev im Systemroot, solange rpm --root die Scriptlets ausführt

install_rpm_root installierte ISO- und Docker-Roots ohne /dev: jedes
">/dev/null" in einem %post schlug fehl ("fresh: /dev/null: No such file
or directory") und übersprang den Befehl. So fehlten gschemas.compiled
(glib-compile-schemas aus gtk3), immodules.cache und der hicolor-Icon-Cache
auf jedem installierten System - GTKs Dateiauswahl (g_settings_new
org.gtk.Settings.FileChooser) brach mit "No GSettings schemas are installed"
ab, z.B. meplay beim Klick auf "Öffnen".

in_chroot hängt mit IN_CHROOT_DEV=<root> /dev zusätzlich unter <root>/dev
ein, nur im privaten Mount-Namespace des Aufrufs.

Co-Authored-By: default avatarClaude Opus 5.5 <noreply@anthropic.com>
parent 0b550c5b
Loading
Loading
Loading
Loading
+9 −3
Changes for build-chroot.sh: 9 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -1085,10 +1085,13 @@ cargo_vendor() {

# in_chroot <cmd...> -- run a command inside the chroot as (mapped) root,
# with /dev and /proc mounted privately (gone again with the process)
# IN_CHROOT_DEV=<dir>: /dev is also mounted on <dir>/dev in the chroot (the
# system root that rpm --root installs into, so its scriptlets have /dev/null)
in_chroot() {
    unshare -rm sh -c 'c="$1"; shift; mount --rbind /dev "$c/dev" && mount --rbind /proc "$c/proc" &&
    unshare -rm sh -c 'c="$1" d="$2"; shift 2; mount --rbind /dev "$c/dev" && mount --rbind /proc "$c/proc" &&
        { [ -z "$d" ] || { mkdir -p "$c$d/dev" && mount --rbind /dev "$c$d/dev"; }; } &&
        exec chroot "$c" /usr/bin/env -i HOME=/root TMPDIR=/var/tmp PATH=/usr/bin:/bin:/usr/sbin:/sbin "$@"' \
        sh "$CHROOT" "$@"
        sh "$CHROOT" "${IN_CHROOT_DEV:-}" "$@"
}

# fetch_url <file> <url>... -- download into the source cache (the first
@@ -1673,7 +1676,10 @@ install_rpm_root() {
    ln -s usr/lib  "$CHROOT$root/lib64"
    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")
    # the scriptlets run in the root: without its /dev every ">/dev/null"
    # fails and skips the command (glib-compile-schemas: GTK's file chooser
    # aborted, gtk-query-immodules-3.0, gtk-update-icon-cache, fc-cache)
    IN_CHROOT_DEV="$root" run "$log" in_chroot /bin/sh -c 'x=; [ -z "$3" ] || x=$(sed "s/^/--excludepath=/" "$3")
            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}