summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@parabola.nu>2017-02-15 14:40:06 -0500
committerLuke Shumaker <lukeshu@parabola.nu>2017-02-15 14:40:06 -0500
commit22da1ef5087e7065439e23187f0984148a905fff (patch)
tree36ed88f8ad25186d18bd4a9adcc57750bda1363c
parentc8300c3ff1afc667aa53f1782846902752687357 (diff)
downloaddevtools32-22da1ef5087e7065439e23187f0984148a905fff.tar.xz
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. <https://labs.parabola.nu/issues/435> 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.
-rw-r--r--arch-nspawn.in1
-rw-r--r--makechrootpkg.in11
2 files changed, 12 insertions, 0 deletions
diff --git a/arch-nspawn.in b/arch-nspawn.in
index ea6e5ea..85af8c5 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 '^CARCH=' "$working_dir/etc/makepkg.conf")
diff --git a/makechrootpkg.in b/makechrootpkg.in
index 878c663..3f4e009 100644
--- a/makechrootpkg.in
+++ b/makechrootpkg.in
@@ -308,6 +308,15 @@ EOF
chmod 440 "$copydir/etc/sudoers.d/builduser-pacman"
fi
+ if ! grep -q '^\[repo\]' "$copydir/etc/pacman.conf"; then
+ local 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
+
# This is a little gross, but this way the script is recreated every time in the
# working copy
{
@@ -399,6 +408,8 @@ _chrootprepare() {
exit 1
fi
+ # Sync deps now, as networking may be disabled during _chrootbuild
+ cp /repo/repo.db /var/lib/pacman/sync/repo.db
sudo -u builduser makepkg "$@" --nobuild
}