Read pacman cache dir from pacman.conf or cli
This commit is contained in:
parent
f8ab1fb7a7
commit
16dd1fe6e0
19
mkarchroot
19
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"
|
||||
}
|
||||
# }}}
|
||||
|
||||
|
|
Loading…
Reference in New Issue