[arch-projects] [devtools] [PATCH 1/4] arch-nspawn: restore cachedir handling for host_mirrors
In commit 27ff286ee78eb2faac803e3ef67f3171ddfa0098, we moved from sourcing the primary cachedir via /etc/pacman.conf, to using the pacman.conf in the workdir. One unanticipated side effect of this was breaking the special host mirrors magic we used to turn a host mirror into a cachedir. It was still processed as a server, but we relied on it being in the host's cachedirs in order to be persisted, and this no longer occurred. Solve this by explicitly adding each host mirror root as a cachedir. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> --- arch-nspawn.in | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch-nspawn.in b/arch-nspawn.in index 5817143..90fe967 100644 --- a/arch-nspawn.in +++ b/arch-nspawn.in @@ -99,7 +99,14 @@ build_mount_args() { copy_hostconf () { unshare --fork --pid gpg --homedir "$working_dir"/etc/pacman.d/gnupg/ --no-permission-warning --quiet --batch --import --import-options import-local-sigs "$(pacman-conf GpgDir)"/pubring.gpg >/dev/null 2>&1 pacman-key --gpgdir "$working_dir"/etc/pacman.d/gnupg/ --import-trustdb "$(pacman-conf GpgDir)" >/dev/null 2>&1 + printf 'Server = %s\n' "${host_mirrors[@]}" >"$working_dir/etc/pacman.d/mirrorlist" + for host_mirror in "${host_mirrors[@]}"; do + if [[ $host_mirror == *file://* ]]; then + host_mirror=$(echo "$host_mirror" | sed -r 's#file://(/.*)/\$repo/os/\$arch#\1#g') + in_array "$host_mirror" "${cache_dirs[@]}" || cache_dirs+=("$host_mirror") + fi + done [[ -n $pac_conf ]] && cp "$pac_conf" "$working_dir/etc/pacman.conf" [[ -n $makepkg_conf ]] && cp "$makepkg_conf" "$working_dir/etc/makepkg.conf" -- 2.24.0
consolidate logic flows in the same area for parsing and building arrays. Don't bother having a special function just to build the mount_args array, since we now use the same handling for adding any cachedir (including host mirrors) to the mount arguments, this becomes a trivial for loop -- and it really did not need to be delayed until after the sanity check, anyway. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> --- arch-nspawn.in | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/arch-nspawn.in b/arch-nspawn.in index 90fe967..7aa6fd6 100644 --- a/arch-nspawn.in +++ b/arch-nspawn.in @@ -20,6 +20,7 @@ umask 0022 working_dir='' files=() +mount_args=() usage() { echo "Usage: ${0##*/} [options] working-dir [systemd-nspawn arguments]" @@ -65,6 +66,13 @@ fi # shellcheck disable=2016 host_mirrors=($($pacconf_cmd --repo extra Server 2> /dev/null | sed -r 's#(.*/)extra/os/.*#\1$repo/os/$arch#')) +for host_mirror in "${host_mirrors[@]}"; do + if [[ $host_mirror == *file://* ]]; then + host_mirror=$(echo "$host_mirror" | sed -r 's#file://(/.*)/\$repo/os/\$arch#\1#g') + in_array "$host_mirror" "${cache_dirs[@]}" || cache_dirs+=("$host_mirror") + fi +done + while read -r line; do mapfile -t lines < <($pacconf_cmd --config "${pac_conf:-$working_dir/etc/pacman.conf}" \ --repo $line Server | sed -r 's#(.*/)[^/]+/os/.+#\1$repo/os/$arch#') @@ -78,35 +86,18 @@ while read -r line; do fi done < <($pacconf_cmd --config "${pac_conf:-$working_dir/etc/pacman.conf}" --repo-list) -# {{{ functions -build_mount_args() { - declare -g mount_args=() - - for host_mirror in "${host_mirrors[@]}"; do - if [[ $host_mirror == *file://* ]]; then - host_mirror_path=$(echo "$host_mirror" | sed -r 's#file://(/.*)/\$repo/os/\$arch#\1#g') - mount_args+=("--bind-ro=${host_mirror_path//:/\\:}") - fi - done - - mount_args+=("--bind=${cache_dirs[0]//:/\\:}") +mount_args+=("--bind=${cache_dirs[0]//:/\\:}") - for cache_dir in "${cache_dirs[@]:1}"; do - mount_args+=("--bind-ro=${cache_dir//:/\\:}") - done -} +for cache_dir in "${cache_dirs[@]:1}"; do + mount_args+=("--bind-ro=${cache_dir//:/\\:}") +done +# {{{ functions copy_hostconf () { unshare --fork --pid gpg --homedir "$working_dir"/etc/pacman.d/gnupg/ --no-permission-warning --quiet --batch --import --import-options import-local-sigs "$(pacman-conf GpgDir)"/pubring.gpg >/dev/null 2>&1 pacman-key --gpgdir "$working_dir"/etc/pacman.d/gnupg/ --import-trustdb "$(pacman-conf GpgDir)" >/dev/null 2>&1 printf 'Server = %s\n' "${host_mirrors[@]}" >"$working_dir/etc/pacman.d/mirrorlist" - for host_mirror in "${host_mirrors[@]}"; do - if [[ $host_mirror == *file://* ]]; then - host_mirror=$(echo "$host_mirror" | sed -r 's#file://(/.*)/\$repo/os/\$arch#\1#g') - in_array "$host_mirror" "${cache_dirs[@]}" || cache_dirs+=("$host_mirror") - fi - done [[ -n $pac_conf ]] && cp "$pac_conf" "$working_dir/etc/pacman.conf" [[ -n $makepkg_conf ]] && cp "$makepkg_conf" "$working_dir/etc/makepkg.conf" @@ -130,7 +121,6 @@ elif [[ $(cat "$working_dir/.arch-chroot") != "$CHROOT_VERSION" ]]; then die "chroot '%s' is not at version %s. Please rebuild." "$working_dir" "$CHROOT_VERSION" fi -build_mount_args copy_hostconf eval "$(grep -a '^CARCH=' "$working_dir/etc/makepkg.conf")" -- 2.24.0
- drop homebrew function in makechrootpkg - use better mock to find invoking user's $HOME - make offload-build respect makepkg.conf to determine where to sync files, matching the behavior of makechrootpkg Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> --- makechrootpkg.in | 34 ++++++---------------------------- offload-build | 9 ++++++++- 2 files changed, 14 insertions(+), 29 deletions(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index f5a0e51..b3a1854 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -13,6 +13,8 @@ m4_include(lib/common.sh) m4_include(lib/archroot.sh) +source /usr/share/makepkg/util/config.sh + shopt -s nullglob default_makepkg_args=(--syncdeps --noconfirm --log --holdver --skipinteg) @@ -80,26 +82,6 @@ usage() { } # {{{ functions -# Usage: load_vars $makepkg_conf -# Globals: -# - SRCDEST -# - SRCPKGDEST -# - PKGDEST -# - LOGDEST -# - MAKEFLAGS -# - PACKAGER -load_vars() { - local makepkg_conf="$1" var - - [[ -f $makepkg_conf ]] || return 1 - - for var in {SRC,SRCPKG,PKG,LOG}DEST MAKEFLAGS PACKAGER; do - [[ -z ${!var:-} ]] && eval "$(source "$makepkg_conf"; printf "%s='%s'" "$var" "${!var}")" - done - - return 0 -} - # Usage: sync_chroot $chrootdir $copydir [$copy] sync_chroot() { local chrootdir=$1 @@ -338,16 +320,12 @@ for arg in "${@:$OPTIND}"; do esac done -if [[ -n $SUDO_USER ]]; then - eval "USER_HOME=~$SUDO_USER" -else - USER_HOME=$HOME -fi - umask 0022 -load_vars "${XDG_CONFIG_HOME:-$USER_HOME/.config}/pacman/makepkg.conf" || load_vars "$USER_HOME/.makepkg.conf" -load_vars /etc/makepkg.conf +ORIG_HOME=$HOME +IFS=: read -r _ _ _ _ _ HOME _ < <(getent passwd "${SUDO_USER:-$USER}") +load_makepkg_config +HOME=$ORIG_HOME # Use PKGBUILD directory if these don't exist [[ -d $PKGDEST ]] || PKGDEST=$PWD diff --git a/offload-build b/offload-build index 7a07b15..078796a 100755 --- a/offload-build +++ b/offload-build @@ -18,6 +18,8 @@ # along with this program. If not, see <https://www.gnu.org/licenses/>. # +source /usr/share/makepkg/util/config.sh + # global defaults suitable for use by Arch staff repo=extra @@ -105,4 +107,9 @@ mapfile -t files < <( makepkg --packagelist ') -(( ${#files[@]} )) && printf '%s\n' '' '-> copying files...' && scp "${files[@]/#/$server:}" . + +if (( ${#files[@]} )); then + printf '%s\n' '' '-> copying files...' + load_makepkg_config + scp "${files[@]/#/$server:}" "${PKGDEST:-${PWD}}/" +fi -- 2.24.0
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index a8e44ee..0eb7a88 100644 --- a/Makefile +++ b/Makefile @@ -4,19 +4,19 @@ PREFIX = /usr/local MANDIR = $(PREFIX)/share/man IN_PROGS = \ - checkpkg \ - commitpkg \ archco \ + arch-nspawn \ archrelease \ archbuild \ - lddd \ + checkpkg \ + commitpkg \ + crossrepomove\ finddeps \ - rebuildpkgs \ find-libdeps \ - crossrepomove\ - arch-nspawn \ + lddd \ mkarchroot \ makechrootpkg \ + rebuildpkgs \ sogrep BINPROGS = \ -- 2.24.0
The mailing list is breaking "From:" lines, so these patches can also be found at https://github.com/eli-schwartz/devtools/commits/arch-projects-review -- Eli Schwartz Bug Wrangler and Trusted User
participants (1)
-
Eli Schwartz