Skip to content

Commit

Permalink
Add additional build mounts support to puavo-configure-chroot.
Browse files Browse the repository at this point in the history
  • Loading branch information
juhaerk committed Feb 26, 2016
1 parent bdc15a3 commit 41a0440
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions rules/puavo-configure-chroot
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,31 @@ do_mounts() {
mount -o bind /dev/pts "${target_dir}/dev/pts"
mount -o bind /proc "${target_dir}/proc"
mount -o bind /sys "${target_dir}/sys"

for mountinfo in $buildmounts; do
mountdir=${mountinfo%:*}
mountfile=${mountinfo#*:}

mkdir -p "${target_dir}/${mountdir}"

if [ -d "$mountfile" ]; then
mountopts='bind' # bind,ro would be nice but does not work
else
mountopts='ro'
fi

mount -o "$mountopts" "${mountfile}" "${target_dir}/${mountdir}"
done
}

do_umounts() {
test -d "$target_dir" || return 0

for mountinfo in $buildmounts; do
mountdir=${mountinfo%:*}
umount -l "${target_dir}/${mountdir}"
done

# umount -l or -f ? (XXX -f did not seem to work)
umount -l "${target_dir}/dev/pts"
umount -l "${target_dir}/dev"
Expand Down Expand Up @@ -146,20 +166,22 @@ EOF
exit 1
}

trap cleanup 0 INT TERM

if ! args=$(getopt -n "$0" -o + \
-l 'apply-buildrules,bootstrap,buildrule-dirs:,image-configure-script:,install-packages:,target-dir:,wipe-chroot' \
-l 'apply-buildrules,bootstrap,buildmounts:,buildrule-dirs:,image-configure-script:,install-packages:,target-dir:,wipe-chroot' \
-- "$@"); then
usage
fi

action=
buildmounts=
buildrule_dirs=
image_configure_script=
package_dirs=
target_dir=

# cleanup trap uses buildmounts variable, so it must be defined before this:
trap cleanup 0 INT TERM

eval "set -- $args"

while [ $# -ne 0 ]; do
Expand All @@ -174,6 +196,9 @@ while [ $# -ne 0 ]; do
action=install-packages
;;

--buildmounts)
buildmounts=$2; shift; shift
;;
--buildrule-dirs)
buildrule_dirs=$2; shift; shift
;;
Expand Down

0 comments on commit 41a0440

Please sign in to comment.