[arch-dev-public] [PATCH] Read cachedir from pacman.conf in working dir
Allan McRae
allan at archlinux.org
Sat Feb 13 03:06:59 EST 2010
This allows setting a different cachedir for (e.g.) i686 and x86_64
chroots.
Signed-off-by: Allan McRae <allan at archlinux.org>
---
Here is a description of my setup:
i686 cache = /var/cache/pacman/pkg (default)
x86_64 cache = /var/cache/pacman/pkg-x86_64
I have "clean" pacman.confs for i686 and x86_64 in /etc/pacman32.conf and
/etc/pacman64.conf respectively. The CACHEDIR variable for the x86_64
conf is set appropriately.
With this patch I can create chroots like:
sudo mkarchroot -C /etc/pacman32.conf -M /etc/makepkg32.conf ...
sudo linux64 mkarchroot -C /etc/pacman64.conf -M /etc/makepkg64.conf ...
and then use them as usual and the cachedir is handled transparently.
Tested with both CACHEDIR defined and undefined in pacman.conf. Have not
tested specifying the cachedir on the command line. I suspect there will
be issues with updating due to different cachedirs specified on the command
line and in the working directory pacman.conf. This could be solved by
mounting the cache_dir to $working_dir/var/cache/pacman/pkg for people
using the command-line parameter and to $working_dir/$cache_dir for people
specifying a cachedir in pacman.conf, but that seems ugly...
mkarchroot | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/mkarchroot b/mkarchroot
index f760792..4ff8993 100755
--- a/mkarchroot
+++ b/mkarchroot
@@ -13,7 +13,6 @@ RUN=""
NOCOPY="n"
working_dir=""
-cache_dir=$((grep -m 1 '^CacheDir' /etc/pacman.conf || echo 'CacheDir = /var/cache/pacman/pkg') | sed 's/CacheDir\s*=\s*//')
APPNAME=$(basename "${0}")
@@ -67,6 +66,13 @@ shift 1
[ "${working_dir}" = "" ] && echo "error: please specify a working directory" && usage 1
+if [ -z "$cachedir" ]; then
+ cache_conf=${working_dir}/etc/pacman.conf
+ [ ! -f $cache_conf ] && cache_conf=${pac_conf:-/etc/pacman.conf}
+ cache_dir=$((grep -m 1 '^CacheDir' $cache_conf || echo 'CacheDir = /var/cache/pacman/pkg') | sed 's/CacheDir\s*=\s*//')
+ unset cache_conf
+fi
+
# {{{ functions
chroot_mount ()
@@ -80,9 +86,9 @@ chroot_mount ()
[ -e "${working_dir}/dev" ] || mkdir "${working_dir}/dev"
mount -o bind /dev "${working_dir}/dev"
- [ -e "${working_dir}/var/cache/pacman/pkg" ] || mkdir -p "${working_dir}/var/cache/pacman/pkg"
[ -e "${cache_dir}" ] || mkdir -p "${cache_dir}"
- mount -o bind "${cache_dir}" "${working_dir}/var/cache/pacman/pkg"
+ [ -e "${working_dir}/${cache_dir}" ] || mkdir -p "${working_dir}/${cache_dir}"
+ mount -o bind "${cache_dir}" "${working_dir}/${cache_dir}"
trap 'chroot_umount' 0 1 2 15
}
@@ -99,7 +105,7 @@ chroot_umount ()
umount "${working_dir}/proc"
umount "${working_dir}/sys"
umount "${working_dir}/dev"
- umount "${working_dir}/var/cache/pacman/pkg"
+ umount "${working_dir}/${cache_dir}"
}
# }}}
--
1.6.6.1
More information about the arch-dev-public
mailing list