[arch-dev-public] [PATCH] Read cachedir from pacman.conf in working dir
This allows setting a different cachedir for (e.g.) i686 and x86_64 chroots. Signed-off-by: Allan McRae <allan@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
Am Samstag, 13. Februar 2010 09:06:59 schrieb Allan McRae:
This allows setting a different cachedir for (e.g.) i686 and x86_64 chroots.
Thanks and committed. It's definitely useful although there are now a lot of ways to set your cachedir. ;-) Btw: I think it would be good to add some helper scripts and default makepkg and pacman config files. -- Pierre Schmitz, https://users.archlinux.de/~pierre
participants (2)
-
Allan McRae
-
Pierre Schmitz