Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package arch-install-scripts for openSUSE:Factory checked in at 2022-07-05 12:09:29 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/arch-install-scripts (Old) and /work/SRC/openSUSE:Factory/.arch-install-scripts.new.1548 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "arch-install-scripts" Tue Jul 5 12:09:29 2022 rev:2 rq:986693 version:25 Changes: -------- --- /work/SRC/openSUSE:Factory/arch-install-scripts/arch-install-scripts.changes 2022-01-06 15:51:57.780993649 +0100 +++ /work/SRC/openSUSE:Factory/.arch-install-scripts.new.1548/arch-install-scripts.changes 2022-07-05 12:10:05.488609408 +0200 @@ -1,0 +2,7 @@ +Mon Jul 4 15:17:52 UTC 2022 - Bruno Pitrus <brunopit...@hotmail.com> - 25 +- New upstream version 25 + * arch-chroot: add unshare mode + * arch-chroot: resolv.conf recursive host + target symlinks + * arch-chroot: Make run a tmpfs mount + +------------------------------------------------------------------- Old: ---- v24.tar.gz New: ---- v25.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ arch-install-scripts.spec ++++++ --- /var/tmp/diff_new_pack.wR0HpI/_old 2022-07-05 12:10:06.908611448 +0200 +++ /var/tmp/diff_new_pack.wR0HpI/_new 2022-07-05 12:10:06.912611453 +0200 @@ -17,7 +17,7 @@ Name: arch-install-scripts -Version: 24 +Version: 25 Release: 0 Summary: Scripts aimed at automating some menial installation/recovery tasks License: GPL-2.0-only @@ -27,7 +27,6 @@ Patch0: Do_not_build_Arch-specific_scripts.patch BuildRequires: asciidoc BuildRequires: m4 -BuildRequires: zsh Requires: awk Requires: bash >= 4.1 Requires: coreutils >= 8.15 @@ -63,6 +62,8 @@ %{_bindir}/genfstab %{_datadir}/bash-completion/completions/arch-chroot %{_datadir}/bash-completion/completions/genfstab +%dir %{_datadir}/zsh +%dir %{_datadir}/zsh/site-functions %{_datadir}/zsh/site-functions/_archinstallscripts %{_mandir}/man8/arch-chroot.8%{?ext_man} %{_mandir}/man8/genfstab.8%{?ext_man} ++++++ v24.tar.gz -> v25.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/arch-install-scripts-24/README.md new/arch-install-scripts-25/README.md --- old/arch-install-scripts-24/README.md 2021-04-22 20:52:37.000000000 +0200 +++ new/arch-install-scripts-25/README.md 2022-07-03 14:01:26.000000000 +0200 @@ -9,6 +9,7 @@ * util-linux (>= 2.23) * POSIX awk * bash (>= 4.1) +* asciidoc (for generating man pages) ## License diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/arch-install-scripts-24/arch-chroot.in new/arch-install-scripts-25/arch-chroot.in --- old/arch-install-scripts-24/arch-chroot.in 2021-04-22 20:52:37.000000000 +0200 +++ new/arch-install-scripts-25/arch-chroot.in 2022-07-03 14:01:26.000000000 +0200 @@ -4,11 +4,15 @@ m4_include(common) +setup=chroot_setup +unshare="$root_unshare" + usage() { cat <<EOF -usage: ${0##*/} chroot-dir [command] +usage: ${0##*/} chroot-dir [command] [arguments...] -h Print this help message + -N Run in unshare mode as a regular user -u <user>[:group] Specify non-root user and optional group to use If 'command' is unspecified, ${0##*/} will launch /bin/bash. @@ -23,40 +27,63 @@ EOF } +resolve_link() { + local target=$1 + local root=$2 + + # If a root was given, make sure it ends in a slash. + [[ -n $root && $root != */ ]] && root=$root/ + + while [[ -L $target ]]; do + target=$(readlink -m "$target") + # If a root was given, make sure the target is under it. + # Make sure to strip any leading slash from target first. + [[ -n $root && $target != $root* ]] && target=$root${target#/} + done + + printf %s "$target" +} + chroot_add_resolv_conf() { - local chrootdir=$1 resolv_conf=$1/etc/resolv.conf + local chrootdir=$1 + local src=$(resolve_link /etc/resolv.conf) + local dest=$(resolve_link "$chrootdir/etc/resolv.conf" "$chrootdir") + + # If we don't have a source resolv.conf file, there's nothing useful we can do. + [[ -e $src ]] || return 0 + + if [[ ! -e $dest ]]; then + # There are two reasons the destination might not exist: + # + # 1. There may be no resolv.conf in the chroot. In this case, $dest won't exist, + # and it will be equal to $1/etc/resolv.conf. In this case, we'll just exit. + # The chroot environment must not be concerned with DNS resolution. + # + # 2. $1/etc/resolv.conf is (or resolves to) a broken link. The environment + # clearly intends to handle DNS resolution, but something's wrong. Maybe it + # normally creates the target at boot time. We'll (try to) take care of it by + # creating a dummy file at the target, so that we have something to bind to. - [[ -e /etc/resolv.conf ]] || return 0 + # Case 1. + [[ $dest = $chrootdir/etc/resolv.conf ]] && return 0 - # Handle resolv.conf as a symlink to somewhere else. - if [[ -L $chrootdir/etc/resolv.conf ]]; then - # readlink(1) should always give us *something* since we know at this point - # it's a symlink. For simplicity, ignore the case of nested symlinks. - resolv_conf=$(readlink "$chrootdir/etc/resolv.conf") - if [[ $resolv_conf = /* ]]; then - resolv_conf=$chrootdir$resolv_conf - else - resolv_conf=$chrootdir/etc/$resolv_conf - fi - - # ensure file exists to bind mount over - if [[ ! -f $resolv_conf ]]; then - install -Dm644 /dev/null "$resolv_conf" || return 1 - fi - elif [[ ! -e $chrootdir/etc/resolv.conf ]]; then - # The chroot might not have a resolv.conf. - return 0 + # Case 2. + install -Dm644 /dev/null "$dest" || return 1 fi - chroot_add_mount /etc/resolv.conf "$resolv_conf" --bind + chroot_add_mount "$src" "$dest" --bind } -while getopts ':hu:' flag; do +while getopts ':hNu:' flag; do case $flag in h) usage exit 0 ;; + N) + setup=unshare_setup + unshare="$user_unshare" + ;; u) userspec=$OPTARG ;; @@ -70,21 +97,27 @@ done shift $(( OPTIND - 1 )) -(( EUID == 0 )) || die 'This script must be run with root privileges' (( $# )) || die 'No chroot directory specified' chrootdir=$1 shift -[[ -d $chrootdir ]] || die "Can't create chroot on non-directory %s" "$chrootdir" +arch-chroot() { + (( EUID == 0 )) || die 'This script must be run with root privileges' -if ! mountpoint -q "$chrootdir"; then - warning "$chrootdir is not a mountpoint. This may have undesirable side effects." -fi + [[ -d $chrootdir ]] || die "Can't create chroot on non-directory %s" "$chrootdir" -chroot_setup "$chrootdir" || die "failed to setup chroot %s" "$chrootdir" -chroot_add_resolv_conf "$chrootdir" || die "failed to setup resolv.conf" + $setup "$chrootdir" || die "failed to setup chroot %s" "$chrootdir" + chroot_add_resolv_conf "$chrootdir" || die "failed to setup resolv.conf" -chroot_args=() -[[ $userspec ]] && chroot_args+=(--userspec "$userspec") + if ! mountpoint -q "$chrootdir"; then + warning "$chrootdir is not a mountpoint. This may have undesirable side effects." + fi + + chroot_args=() + [[ $userspec ]] && chroot_args+=(--userspec "$userspec") + + SHELL=/bin/bash chroot "${chroot_args[@]}" -- "$chrootdir" "${args[@]}" +} -SHELL=/bin/bash unshare --fork --pid chroot "${chroot_args[@]}" -- "$chrootdir" "$@" +args=("$@") +$unshare bash -c "$(declare_all); arch-chroot" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/arch-install-scripts-24/common new/arch-install-scripts-25/common --- old/arch-install-scripts-24/common 2021-04-22 20:52:37.000000000 +0200 +++ new/arch-install-scripts-25/common 2022-07-03 14:01:26.000000000 +0200 @@ -39,6 +39,7 @@ [ext3]=1 [ext4]=1 [ext4dev]=1 + [f2fs]=1 [jfs]=1 [minix]=1 [msdos]=1 @@ -89,7 +90,7 @@ chroot_add_mount udev "$1/dev" -t devtmpfs -o mode=0755,nosuid && chroot_add_mount devpts "$1/dev/pts" -t devpts -o mode=0620,gid=5,nosuid,noexec && chroot_add_mount shm "$1/dev/shm" -t tmpfs -o mode=1777,nosuid,nodev && - chroot_add_mount /run "$1/run" --bind && + chroot_add_mount run "$1/run" -t tmpfs -o nosuid,nodev,mode=0755 && chroot_add_mount tmp "$1/tmp" -t tmpfs -o mode=1777,strictatime,nodev,nosuid } @@ -100,6 +101,77 @@ unset CHROOT_ACTIVE_MOUNTS } +chroot_add_mount_lazy() { + mount "$@" && CHROOT_ACTIVE_LAZY=("$2" "${CHROOT_ACTIVE_LAZY[@]}") +} + +chroot_bind_device() { + touch "$2" && CHROOT_ACTIVE_FILES=("$2" "${CHROOT_ACTIVE_FILES[@]}") + chroot_add_mount $1 "$2" --bind +} + +chroot_add_link() { + ln -sf "$1" "$2" && CHROOT_ACTIVE_FILES=("$2" "${CHROOT_ACTIVE_FILES[@]}") +} + +unshare_setup() { + CHROOT_ACTIVE_MOUNTS=() + CHROOT_ACTIVE_LAZY=() + CHROOT_ACTIVE_FILES=() + [[ $(trap -p EXIT) ]] && die '(BUG): attempting to overwrite existing EXIT trap' + trap 'unshare_teardown' EXIT + + chroot_add_mount_lazy "$1" "$1" --bind && + chroot_add_mount proc "$1/proc" -t proc -o nosuid,noexec,nodev && + chroot_add_mount_lazy /sys "$1/sys" --rbind && + chroot_add_link "$1/proc/self/fd" "$1/dev/fd" && + chroot_add_link "$1/proc/self/fd/0" "$1/dev/stdin" && + chroot_add_link "$1/proc/self/fd/1" "$1/dev/stdout" && + chroot_add_link "$1/proc/self/fd/2" "$1/dev/stderr" && + chroot_bind_device /dev/full "$1/dev/full" && + chroot_bind_device /dev/null "$1/dev/null" && + chroot_bind_device /dev/random "$1/dev/random" && + chroot_bind_device /dev/tty "$1/dev/tty" && + chroot_bind_device /dev/urandom "$1/dev/urandom" && + chroot_bind_device /dev/zero "$1/dev/zero" && + chroot_add_mount run "$1/run" -t tmpfs -o nosuid,nodev,mode=0755 && + chroot_add_mount tmp "$1/tmp" -t tmpfs -o mode=1777,strictatime,nodev,nosuid +} + +unshare_teardown() { + chroot_teardown + + if (( ${#CHROOT_ACTIVE_LAZY[@]} )); then + umount --lazy "${CHROOT_ACTIVE_LAZY[@]}" + fi + unset CHROOT_ACTIVE_LAZY + + if (( ${#CHROOT_ACTIVE_FILES[@]} )); then + rm "${CHROOT_ACTIVE_FILES[@]}" + fi + unset CHROOT_ACTIVE_FILES +} + +root_unshare="unshare --fork --pid" +user_unshare="$root_unshare --mount --map-auto --map-root-user --setuid 0 --setgid 0" + +# This outputs code for declaring all variables to stdout. For example, if +# FOO=BAR, then running +# declare -p FOO +# will result in the output +# declare -- FOO="bar" +# This function may be used to re-declare all currently used variables and +# functions in a new shell. +declare_all() { + # Remove read-only variables to avoid warnings. Unfortunately, declare +r -p + # doesn't work like it looks like it should (declaring only read-write + # variables). However, declare -rp will print out read-only variables, which + # we can then use to remove those definitions. + declare -p | grep -Fvf <(declare -rp) + # Then declare functions + declare -pf +} + try_cast() ( _=$(( $1#$2 )) ) 2>/dev/null @@ -243,7 +315,6 @@ else # don't leave the caller hanging, just print the original name # along with the failure. - print '%s' "$1" error 'Failed to resolve device mapper name for: %s' "$1" fi } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/arch-install-scripts-24/completion/arch-chroot.bash new/arch-install-scripts-25/completion/arch-chroot.bash --- old/arch-install-scripts-24/completion/arch-chroot.bash 2021-04-22 20:52:37.000000000 +0200 +++ new/arch-install-scripts-25/completion/arch-chroot.bash 2022-07-03 14:01:26.000000000 +0200 @@ -2,7 +2,7 @@ compopt +o dirnames local cur prev opts i _init_completion -n : || return - opts="-u -h" + opts="-N -u -h" for i in "${COMP_WORDS[@]:1:COMP_CWORD-1}"; do if [[ -d ${i} ]]; then diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/arch-install-scripts-24/completion/pacstrap.bash new/arch-install-scripts-25/completion/pacstrap.bash --- old/arch-install-scripts-24/completion/pacstrap.bash 2021-04-22 20:52:37.000000000 +0200 +++ new/arch-install-scripts-25/completion/pacstrap.bash 2022-07-03 14:01:26.000000000 +0200 @@ -8,7 +8,7 @@ COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" - opts="-C -c -G -i -M -h" + opts="-C -c -G -i -M -N -h" for i in "${COMP_WORDS[@]:1:COMP_CWORD-1}"; do if [[ -d ${i} ]]; then diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/arch-install-scripts-24/doc/arch-chroot.8.asciidoc new/arch-install-scripts-25/doc/arch-chroot.8.asciidoc --- old/arch-install-scripts-24/doc/arch-chroot.8.asciidoc 2021-04-22 20:52:37.000000000 +0200 +++ new/arch-install-scripts-25/doc/arch-chroot.8.asciidoc 2022-07-03 14:01:26.000000000 +0200 @@ -7,7 +7,7 @@ Synopsis -------- -arch-chroot [options] chroot-dir [command] +arch-chroot [options] chroot-dir [command] [arguments...] Description ----------- @@ -32,6 +32,11 @@ Options ------- +*-N*:: + Run in unshare mode. This will use linkman:unshare[1] to create a new + mount and user namespace, allowing regular users to create new system + installations. + *-u <user>[:group]*:: Specify non-root user and optional group to use. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/arch-install-scripts-24/doc/pacstrap.8.asciidoc new/arch-install-scripts-25/doc/pacstrap.8.asciidoc --- old/arch-install-scripts-24/doc/pacstrap.8.asciidoc 2021-04-22 20:52:37.000000000 +0200 +++ new/arch-install-scripts-25/doc/pacstrap.8.asciidoc 2022-07-03 14:01:26.000000000 +0200 @@ -37,6 +37,11 @@ *-M*:: Avoid copying the host's mirrorlist to the target. +*-N*:: + Run in unshare mode. This will use linkman:unshare[1] to create a new + mount and user namespace, allowing regular users to create new system + installations. + *-U*:: Use pacman -U to install packages. Useful for obtaining fine-grained control over the installed packages. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/arch-install-scripts-24/pacstrap.in new/arch-install-scripts-25/pacstrap.in --- old/arch-install-scripts-24/pacstrap.in 2021-04-22 20:52:37.000000000 +0200 +++ new/arch-install-scripts-25/pacstrap.in 2022-07-03 14:01:26.000000000 +0200 @@ -16,6 +16,8 @@ copykeyring=1 copymirrorlist=1 pacmode=-Sy +setup=chroot_setup +unshare="$root_unshare" usage() { cat <<EOF @@ -27,6 +29,7 @@ -G Avoid copying the host's pacman keyring to the target -i Prompt for package confirmation when needed (run interactively) -M Avoid copying the host's mirrorlist to the target + -N Run in unshare mode as a regular user -U Use pacman -U to install packages -h Print this help message @@ -42,9 +45,7 @@ exit $(( $# ? 0 : 1 )) fi -(( EUID == 0 )) || die 'This script must be run with root privileges' - -while getopts ':C:cdGiMU' flag; do +while getopts ':C:cdGiMNU' flag; do case $flag in C) pacman_config=$OPTARG @@ -64,6 +65,10 @@ M) copymirrorlist=0 ;; + N) + setup=unshare_setup + unshare="$user_unshare" + ;; U) pacmode=-U ;; @@ -95,30 +100,36 @@ [[ -d $newroot ]] || die "%s is not a directory" "$newroot" -# create obligatory directories -msg 'Creating install root at %s' "$newroot" -mkdir -m 0755 -p "$newroot"/var/{cache/pacman/pkg,lib/pacman,log} "$newroot"/{dev,run,etc/pacman.d} -mkdir -m 1777 -p "$newroot"/tmp -mkdir -m 0555 -p "$newroot"/{sys,proc} - -# mount API filesystems -chroot_setup "$newroot" || die "failed to setup chroot %s" "$newroot" - -if (( copykeyring )); then - # if there's a keyring on the host, copy it into the new root, unless it exists already - if [[ -d /etc/pacman.d/gnupg && ! -d $newroot/etc/pacman.d/gnupg ]]; then - cp -a /etc/pacman.d/gnupg "$newroot/etc/pacman.d/" +pacstrap() { + (( EUID == 0 )) || die 'This script must be run with root privileges' + + # create obligatory directories + msg 'Creating install root at %s' "$newroot" + mkdir -m 0755 -p "$newroot"/var/{cache/pacman/pkg,lib/pacman,log} "$newroot"/{dev,run,etc/pacman.d} + mkdir -m 1777 -p "$newroot"/tmp + mkdir -m 0555 -p "$newroot"/{sys,proc} + + # mount API filesystems + $setup "$newroot" || die "failed to setup chroot %s" "$newroot" + + if (( copykeyring )); then + # if there's a keyring on the host, copy it into the new root, unless it exists already + if [[ -d /etc/pacman.d/gnupg && ! -d $newroot/etc/pacman.d/gnupg ]]; then + cp -a --no-preserve=ownership /etc/pacman.d/gnupg "$newroot/etc/pacman.d/" + fi fi -fi -msg 'Installing packages to %s' "$newroot" -if ! unshare --fork --pid pacman -r "$newroot" $pacmode "${pacman_args[@]}"; then - die 'Failed to install packages to new root' -fi + msg 'Installing packages to %s' "$newroot" + if ! pacman -r "$newroot" $pacmode "${pacman_args[@]}"; then + die 'Failed to install packages to new root' + fi -if (( copymirrorlist )); then - # install the host's mirrorlist onto the new root - cp -a /etc/pacman.d/mirrorlist "$newroot/etc/pacman.d/" -fi + if (( copymirrorlist )); then + # install the host's mirrorlist onto the new root + cp -a /etc/pacman.d/mirrorlist "$newroot/etc/pacman.d/" + fi +} + +$unshare bash -c "$(declare_all); pacstrap" # vim: et ts=2 sw=2 ft=sh: