From a6e1f8cfd300ce591c279f7e1093ca059ae6b56e Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Sat, 13 Feb 2010 18:06:59 +1000 Subject: 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 Signed-off-by: Pierre Schmitz --- mkarchroot | 14 ++++++++++---- 1 file 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}" } # }}} -- cgit v1.2.3-70-g09d2