diff options
-rwxr-xr-x | mkarchroot | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -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}" } # }}} |