summaryrefslogtreecommitdiffstats
path: root/mkarchroot
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2010-02-11 11:23:41 +0100
committerPierre Schmitz <pierre@archlinux.de>2010-02-11 11:23:41 +0100
commit16dd1fe6e0022d317b07c6f8a0ec09ab896da4d4 (patch)
tree370dee92501490f665665cbe0476517acb587bcf /mkarchroot
parentf8ab1fb7a7a506406ed6f21a7828282a69b1907a (diff)
downloaddevtools-16dd1fe6e0022d317b07c6f8a0ec09ab896da4d4.tar.gz
devtools-16dd1fe6e0022d317b07c6f8a0ec09ab896da4d4.tar.xz
Read pacman cache dir from pacman.conf or cli
Diffstat (limited to 'mkarchroot')
-rwxr-xr-xmkarchroot19
1 files changed, 11 insertions, 8 deletions
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 <app> 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 <file> location of a pacman config file"
- echo " -M <file> location of a makepkg config file"
- echo " -n do not copy config files into the chroot"
+ echo " -C <file> Location of a pacman config file"
+ echo " -M <file> Location of a makepkg config file"
+ echo " -n Do not copy config files into the chroot"
+ echo " -c <dir> 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"
}
# }}}