From 4408bb2a1529b5a1e62e12ac617daac945d44e27 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sat, 30 Sep 2017 23:31:23 -0400 Subject: Revert "arch-nspawn: Work around pacman master returning file-URLs from the cache" This reverts commit eb6b0e3f11279b6512b1469ff042d2982eaaeef4. This never worked, as pacman-git returns file urls from the cache anyway and pacman stable doesn't have any problem at all. Having useless code which makes people think the issue is solved when it really isn't, is bloat, so remove it. --- arch-nspawn.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch-nspawn.in') diff --git a/arch-nspawn.in b/arch-nspawn.in index 7a7a274..50ce674 100644 --- a/arch-nspawn.in +++ b/arch-nspawn.in @@ -59,7 +59,7 @@ else fi # shellcheck disable=2016 -host_mirror=$(pacman --cachedir /doesnt/exist -Sddp extra/devtools 2>/dev/null | sed -r 's#(.*/)extra/os/.*#\1$repo/os/$arch#') +host_mirror=$(pacman -Sddp extra/devtools 2>/dev/null | sed -r 's#(.*/)extra/os/.*#\1$repo/os/$arch#') # shellcheck disable=2016 [[ $host_mirror == *file://* ]] && host_mirror_path=$(echo "$host_mirror" | sed -r 's#file://(/.*)/\$repo/os/\$arch#\1#g') -- cgit v1.2.3-70-g09d2 From 5b3c14454a9c1ec00a3ef11f3f599281127b383d Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sat, 30 Sep 2017 23:40:47 -0400 Subject: Proper fix for pacman-git returning file urls from the cache It is much nicer to use a proper configuration parser to retrieve the primary mirror, rather than clever hacks using undocumented APIs, especially when their behavior as used then breaks in later releases. Fortunately, pacutils exists now and pacconf handles this quite elegantly. It has since been moved to pacman-git proper. Check if pacman-conf from a new enough version of pacman exists and fallback on pacconf from pacutils. --- arch-nspawn.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'arch-nspawn.in') diff --git a/arch-nspawn.in b/arch-nspawn.in index 50ce674..b9c846e 100644 --- a/arch-nspawn.in +++ b/arch-nspawn.in @@ -58,8 +58,9 @@ else cache_dirs=("$cache_dir") fi +pacconf_cmd=$(command -v pacman-conf || command -v pacconf) # shellcheck disable=2016 -host_mirror=$(pacman -Sddp extra/devtools 2>/dev/null | sed -r 's#(.*/)extra/os/.*#\1$repo/os/$arch#') +host_mirror=$($pacconf_cmd --repo extra Server 2> /dev/null | head -1 | sed -r 's#(.*/)extra/os/.*#\1$repo/os/$arch#') # shellcheck disable=2016 [[ $host_mirror == *file://* ]] && host_mirror_path=$(echo "$host_mirror" | sed -r 's#file://(/.*)/\$repo/os/\$arch#\1#g') -- cgit v1.2.3-70-g09d2 From 01ea248b5a24f18f092c67f3b2e625d1affa33f3 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 9 May 2016 18:37:02 -0400 Subject: arch-nspawn: Message style: two spaces after a period This affects both the usage() text, and the error message if the `/.arch-chroot` version doesn't match. The latter is the one that I really care about, and motivates this change. On Parabola, the `arch-nspawn` program isn't in PATH, it's somewhere under `/usr/lib/`, and gets called as a helper to user-facing programs; and the error message is displayed directly to the user. These programs consistently put two spaces after a period when printing a message to the terminal. --- arch-nspawn.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'arch-nspawn.in') diff --git a/arch-nspawn.in b/arch-nspawn.in index b9c846e..f03c2e1 100644 --- a/arch-nspawn.in +++ b/arch-nspawn.in @@ -19,7 +19,7 @@ files=() usage() { echo "Usage: ${0##*/} [options] working-dir [systemd-nspawn arguments]" - echo "A wrapper around systemd-nspawn. Provides support for pacman." + echo "A wrapper around systemd-nspawn. Provides support for pacman." echo echo ' options:' echo ' -C Location of a pacman config file' @@ -102,7 +102,7 @@ umask 0022 if [[ ! -f "$working_dir/.arch-chroot" ]]; then die "'%s' does not appear to be an Arch chroot." "$working_dir" elif [[ $(cat "$working_dir/.arch-chroot") != "$CHROOT_VERSION" ]]; then - die "chroot '%s' is not at version %s. Please rebuild." "$working_dir" "$CHROOT_VERSION" + die "chroot '%s' is not at version %s. Please rebuild." "$working_dir" "$CHROOT_VERSION" fi build_mount_args -- cgit v1.2.3-70-g09d2 From 8252801a393f5a043cac2fba9513ac7a6a0956e8 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 10 May 2016 13:44:46 -0400 Subject: arch-nspawn: Add a table of CARCH/setarch overrides The table is just armv7h->armv7l for now. --- arch-nspawn.in | 3 +++ 1 file changed, 3 insertions(+) (limited to 'arch-nspawn.in') diff --git a/arch-nspawn.in b/arch-nspawn.in index f03c2e1..7f432a6 100644 --- a/arch-nspawn.in +++ b/arch-nspawn.in @@ -109,6 +109,9 @@ build_mount_args copy_hostconf eval "$(grep -a '^CARCH=' "$working_dir/etc/makepkg.conf")" +case "$CARCH" in + armv7h) CARCH=armv7l;; +esac [[ -z $nosetarch ]] || unset CARCH -- cgit v1.2.3-70-g09d2 From 35796c0490efcb7316b96d032e7330598beb9433 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 15 Feb 2017 14:40:06 -0500 Subject: makechrootpkg, arch-nspawn: Force-enable local '/repo/' repository The change in arch-nspawn is subtle: This was the source of "infamous" "it fails every other time" bug that took me over a year to solve. By having a repository of local packages (rather than simply running `pacman -U`), we are inviting pacman to cache them in `/var/cache/pacman/pkg`. Besides being needless disk writes, this actually causes a real issue. If the package gets rebuilt, pacman will balk, as the file no longer matches the cached signature. So, how do we prevent pacman from caching these local packages? Simple: include the directory they are already in in the pacman.conf:CacheDir list. This will prevent pacman from copying the files to one of the other cache directories. --- arch-nspawn.in | 1 + makechrootpkg.in | 13 +++++++++++++ 2 files changed, 14 insertions(+) (limited to 'arch-nspawn.in') diff --git a/arch-nspawn.in b/arch-nspawn.in index 7f432a6..96b3e38 100644 --- a/arch-nspawn.in +++ b/arch-nspawn.in @@ -106,6 +106,7 @@ elif [[ $(cat "$working_dir/.arch-chroot") != "$CHROOT_VERSION" ]]; then fi build_mount_args +cache_dirs+=('/repo/') copy_hostconf eval "$(grep -a '^CARCH=' "$working_dir/etc/makepkg.conf")" diff --git a/makechrootpkg.in b/makechrootpkg.in index 8480c56..a302e4d 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -196,6 +196,19 @@ builduser ALL = NOPASSWD: /usr/bin/pacman EOF chmod 440 "$copydir/etc/sudoers.d/builduser-pacman" + if ! grep -q '^\[repo\]' "$copydir/etc/pacman.conf"; then + local line + line=$(grep -n '^\[' "$copydir/etc/pacman.conf" |grep -Fv ':[options]'|sed 's/:.*//;1q') + local ins='[repo] +SigLevel = Optional TrustAll +Server = file:///repo +' + sed -i "${line}i${ins//$'\n'/\\n}" "$copydir/etc/pacman.conf" + fi + # Avoid having to use `pacman -Sy` to update [repo], as + # networking might be disabled inside of the chroot. + cp "$copydir/repo/repo.db" "$copydir/var/lib/pacman/sync/repo.db" + # This is a little gross, but this way the script is recreated every time in the # working copy { -- cgit v1.2.3-70-g09d2