From 16dd1fe6e0022d317b07c6f8a0ec09ab896da4d4 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 11 Feb 2010 11:23:41 +0100 Subject: Read pacman cache dir from pacman.conf or cli --- mkarchroot | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'mkarchroot') diff --git a/mkarchroot b/mkarchroot index 69fac22..a27a57b 100755 --- a/mkarchroot +++ b/mkarchroot @@ -13,6 +13,7 @@ RUN="" NOCOPY="n" working_dir="" +cache_dir=$(grep -m 1 '^CacheDir' /etc/pacman.conf | sed 's/CacheDir\s*=\s*//') APPNAME=$(basename "${0}") @@ -24,14 +25,15 @@ usage () echo " -r Run 'app' within the context of the chroot" echo " -u Update the chroot via pacman" echo " -f Force overwrite of files in the working-dir" - echo " -C location of a pacman config file" - echo " -M location of a makepkg config file" - echo " -n do not copy config files into the chroot" + echo " -C Location of a pacman config file" + echo " -M Location of a makepkg config file" + echo " -n Do not copy config files into the chroot" + echo " -c Set pacman cache. Default: ${cache_dir}" echo " -h This message" exit $1 } -while getopts 'r:ufhC:M:' arg; do +while getopts 'r:ufhC:M:c:' arg; do case "${arg}" in r) RUN="$OPTARG" ;; u) RUN="pacman -Syu" ;; @@ -39,6 +41,7 @@ while getopts 'r:ufhC:M:' arg; do C) pac_conf="$OPTARG" ;; M) makepkg_conf="$OPTARG" ;; n) NOCOPY="y" ;; + c) cache_dir="$OPTARG" ;; h|?) usage 0 ;; *) echo "invalid argument '${arg}'"; usage 1 ;; esac @@ -80,9 +83,9 @@ chroot_mount () [ -e "${working_dir}/dev" ] || mkdir "${working_dir}/dev" mount -o bind /dev "${working_dir}/dev" - echo "binding pacman cache : /var/cache/pacman" - [ -e "${working_dir}/var/cache/pacman" ] || mkdir -p "${working_dir}/var/cache/pacman" - mount -o bind /var/cache/pacman "${working_dir}/var/cache/pacman" + echo "binding pacman cache : ${cache_dir}" + [ -e "${working_dir}/var/cache/pacman/pkg" ] || mkdir -p "${working_dir}/var/cache/pacman/pkg" + mount -o bind "${cache_dir}" "${working_dir}/var/cache/pacman/pkg" trap 'chroot_umount' 0 1 2 15 } @@ -103,7 +106,7 @@ chroot_umount () umount "${working_dir}/proc" umount "${working_dir}/sys" umount "${working_dir}/dev" - umount "${working_dir}/var/cache/pacman" + umount "${working_dir}/var/cache/pacman/pkg" } # }}} -- cgit v1.2.3-70-g09d2