summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2010-08-17 19:23:16 +0200
committerPierre Schmitz <pierre@archlinux.de>2010-08-17 19:23:16 +0200
commit87f5eb6300d07541a20cd590b3308c233ab027d7 (patch)
tree3bb0be9777150758f5760627450d741f9701e93d
parent1a419e7974add7787e932186c199e50d00e6438c (diff)
downloaddevtools-87f5eb6300d07541a20cd590b3308c233ab027d7.tar.gz
devtools-87f5eb6300d07541a20cd590b3308c233ab027d7.tar.xz
Use host mirror in chroot environment
* Set first enabled mirror found mirrorlist as mirror within the chroot. * If the mirror is local bind its directory read-only into the chroot. * Fallback is the kernel.org mirror.
-rwxr-xr-xmkarchroot18
1 files changed, 18 insertions, 0 deletions
diff --git a/mkarchroot b/mkarchroot
index b7249a4..fcb65db 100755
--- a/mkarchroot
+++ b/mkarchroot
@@ -72,6 +72,16 @@ if [ -z "$cache_dir" ]; then
unset cache_conf
fi
+if [ -f /etc/pacman.d/mirrorlist ]; then
+ host_mirror=$(grep -v '^#' -m1 /etc/pacman.d/mirrorlist | sed -E 's#/os/(i686|x86_64)#/os/\$arch#g')
+fi
+if [ -z "${host_mirror}" ]; then
+ host_mirror='Server = http://mirrors.kernel.org/archlinux/$repo/os/$arch'
+fi
+if echo "${host_mirror}" | grep -q 'file://'; then
+ host_mirror_path=$(echo "${host_mirror}" | sed -E 's#Server\s=\sfile://(/.*)/\$repo/os/(\$arch|i686|x86_64)#\1#g')
+fi
+
# {{{ functions
chroot_mount() {
@@ -94,12 +104,19 @@ chroot_mount() {
[ -e "${working_dir}/${cache_dir}" ] || mkdir -p "${working_dir}/${cache_dir}"
mount -o bind "${cache_dir}" "${working_dir}/${cache_dir}"
+ if [ -n "${host_mirror_path}" ]; then
+ [ -e "${working_dir}/${host_mirror_path}" ] || mkdir -p "${working_dir}/${host_mirror_path}"
+ mount -o bind "${host_mirror_path}" "${working_dir}/${host_mirror_path}"
+ mount -o remount,ro,bind "${host_mirror_path}" "${working_dir}/${host_mirror_path}"
+ fi
+
trap 'chroot_umount' 0 1 2 15
}
copy_hostconf () {
cp /etc/mtab "${working_dir}/etc/mtab"
cp /etc/resolv.conf "${working_dir}/etc/resolv.conf"
+ echo "${host_mirror}" > ${working_dir}/etc/pacman.d/mirrorlist
}
chroot_umount () {
@@ -109,6 +126,7 @@ chroot_umount () {
umount "${working_dir}/dev/shm"
umount "${working_dir}/dev"
umount "${working_dir}/${cache_dir}"
+ [ -n "${host_mirror_path}" ] && umount "${working_dir}/${host_mirror_path}"
}
# }}}