[util-iso] mounting tweaks

This commit is contained in:
udeved 2016-02-27 12:31:29 +01:00
parent 2ebe5c58b9
commit 2002cf50d8
4 changed files with 33 additions and 25 deletions

View file

@ -9,22 +9,25 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
track_image() {
info "%s mount: [%s]" "${iso_fs}" "$6"
mount "$@" && IMAGE_ACTIVE_MOUNTS=("$6" "${IMAGE_ACTIVE_MOUNTS[@]}")
}
# $1: new branch
mount_image(){
info "%s mount: [%s]" "${iso_fs}" "${1##*/}"
mount -t aufs -o br="$1":${work_dir}/root-image=ro none "$1"
IMAGE_ACTIVE_MOUNTS=()
track_image -t aufs -o br="$1":${work_dir}/root-image=ro none "$1"
}
mount_image_custom(){
info "%s mount: [%s]" "${iso_fs}" "${1##*/}"
mount -t aufs -o br="$1":${work_dir}/${profile}-image=ro:${work_dir}/root-image=ro none "$1"
IMAGE_ACTIVE_MOUNTS=()
track_image -t aufs -o br="$1":${work_dir}/${profile}-image=ro:${work_dir}/root-image=ro none "$1"
}
# $1: image path
umount_image(){
if mountpoint -q "$1";then
info "%s umount: [%s]" "${iso_fs}" "${1##*/}"
umount $1
fi
umount "${IMAGE_ACTIVE_MOUNTS[@]}"
unset IMAGE_ACTIVE_MOUNTS
find $1 -name '.wh.*' -delete &> /dev/null
}

View file

@ -9,23 +9,27 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
track_image() {
info "%s mount: [%s]" "${iso_fs}" "$5"
mount "$@" && IMAGE_ACTIVE_MOUNTS=("$5" "${IMAGE_ACTIVE_MOUNTS[@]}")
}
# $1: new branch
mount_image(){
info "%s mount: [%s]" "${iso_fs}" "${1##*/}"
IMAGE_ACTIVE_MOUNTS=()
mkdir -p "${work_dir}/work"
mount -t overlay overlay -olowerdir="${work_dir}/root-image",upperdir="$1",workdir="${work_dir}/work" "$1"
track_image -t overlay overlay -olowerdir="${work_dir}/root-image",upperdir="$1",workdir="${work_dir}/work" "$1"
}
mount_image_custom(){
info "%s mount: [%s]" "${iso_fs}" "${1##*/}"
IMAGE_ACTIVE_MOUNTS=()
mkdir -p "${work_dir}/work"
mount -t overlay overlay -olowerdir="${work_dir}/${profile}-image":"${work_dir}/root-image",upperdir="$1",workdir="${work_dir}/work" "$1"
track_image -t overlay overlay -olowerdir="${work_dir}/${profile}-image":"${work_dir}/root-image",upperdir="$1",workdir="${work_dir}/work" "$1"
}
umount_image(){
if mountpoint -q "$1";then
info "%s umount: [%s]" "${iso_fs}" "${1##*/}"
umount $1
rm -rf "${work_dir}/work"
fi
info "%s umount: [%s]" "${iso_fs}" "${IMAGE_ACTIVE_MOUNTS[@]}"
umount "${IMAGE_ACTIVE_MOUNTS[@]}"
unset IMAGE_ACTIVE_MOUNTS
rm -rf "${work_dir}/work"
}

View file

@ -22,9 +22,7 @@ error_function() {
error "A failure occurred in %s()." "$1"
plain "Aborting..."
fi
for mp in ${work_dir}/{root,${profile},live,mhwd,boot}-image;do
umount_image "$mp"
done
umount_image
exit 2
}
@ -241,7 +239,7 @@ make_image_custom() {
configure_custom_image "${path}"
${is_custom_pac_conf} && clean_pacman_conf "${path}"
umount_image "${path}"
umount_image
clean_up_image "${path}"
: > ${work_dir}/build.${FUNCNAME}
@ -273,7 +271,7 @@ make_image_live() {
configure_live_image "${path}"
${is_custom_pac_conf} && clean_pacman_conf "${path}"
umount_image "${path}"
umount_image
# Clean up GnuPG keys
rm -rf "${path}/etc/pacman.d/gnupg"
@ -306,7 +304,7 @@ make_image_mhwd() {
make_repo "${path}"
configure_mhwd_drivers "${path}"
umount_image "${path}"
umount_image
clean_up_mhwd_image "${path}"
@ -334,7 +332,7 @@ make_image_boot() {
mv ${path}/boot/${iso_name}.img ${path_iso}/${arch}/${iso_name}.img
[[ -f ${path}/boot/intel-ucode.img ]] && copy_ucode "${path}" "${path_iso}"
umount_image "${path}"
umount_image
rm -R ${path}
: > ${work_dir}/build.${FUNCNAME}

View file

@ -40,6 +40,7 @@ get_chroot_arch(){
}
chroot_part_mount() {
info "mount: [%s]" "$2"
mount "$@" && CHROOT_ACTIVE_PART_MOUNTS=("$2" "${CHROOT_ACTIVE_PART_MOUNTS[@]}")
msg2 "mounted: %s" "${CHROOT_ACTIVE_PART_MOUNTS[@]}"
}
@ -119,8 +120,8 @@ chroot_mount_partitions(){
}
chroot_mount() {
info "mount: [%s]" "$2"
mount "$@" && CHROOT_ACTIVE_MOUNTS=("$2" "${CHROOT_ACTIVE_MOUNTS[@]}")
#msg2 "mounted: %s" "${CHROOT_ACTIVE_MOUNTS[@]}"
}
chroot_mount_conditional() {
@ -148,11 +149,13 @@ chroot_api_mount() {
}
chroot_part_umount() {
info "umount: [%s]" "${CHROOT_ACTIVE_PART_MOUNTS[@]}"
umount "${CHROOT_ACTIVE_PART_MOUNTS[@]}"
unset CHROOT_ACTIVE_PART_MOUNTS
}
chroot_api_umount() {
info "umount: [%s]" "${CHROOT_ACTIVE_MOUNTS[@]}"
umount "${CHROOT_ACTIVE_MOUNTS[@]}"
unset CHROOT_ACTIVE_MOUNTS
}