aboutsummaryrefslogtreecommitdiff
path: root/pbuilder-modules
diff options
context:
space:
mode:
authorJunichi Uekawa <dancer@netfort.gr.jp>2009-12-02 23:00:08 +0900
committerJunichi Uekawa <dancer@netfort.gr.jp>2009-12-02 23:00:08 +0900
commitb9fedf28f1ddf14c219cc8ee295bf592db5c1656 (patch)
tree7ef12f99293d6e232cd48915e431dcada1110c55 /pbuilder-modules
parent513230e99b27f772793e0cb9bcd1e99f9f87a2dc (diff)
downloadpbuilder-b9fedf28f1ddf14c219cc8ee295bf592db5c1656.tar
pbuilder-b9fedf28f1ddf14c219cc8ee295bf592db5c1656.tar.gz
Gracefully handle non-existing bind-mount in --bindmount option (closes: #556164)
When bind-mount fails, /proc etc are mounted and not unmounted. umount them in that case.
Diffstat (limited to 'pbuilder-modules')
-rw-r--r--pbuilder-modules13
1 files changed, 9 insertions, 4 deletions
diff --git a/pbuilder-modules b/pbuilder-modules
index 98c1868..8f604eb 100644
--- a/pbuilder-modules
+++ b/pbuilder-modules
@@ -226,16 +226,19 @@ function umountproc () {
# Mount /proc /dev/pts /dev and bind-mount points
# Also create a policy-rc.d script if it doesn't already exist.
function mountproc () {
+ local -a mounted
if [ "$USEPROC" = "yes" ]; then
log "I: mounting /proc filesystem"
mkdir -p $BUILDPLACE/proc
mount -t proc /proc "$BUILDPLACE/proc"
ln -s ../proc/mounts $BUILDPLACE/etc/mtab 2> /dev/null || true
+ mounted[${#mounted[@]}]="$BUILDPLACE/proc"
fi
if [ "$USEDEVFS" = "yes" ]; then
log "I: mounting /dev filesystem"x
mkdir -p $BUILDPLACE/dev || true
mount -t devfs /dev "$BUILDPLACE/dev"
+ mounted[${#mounted[@]}]="$BUILDPLACE/dev"
fi
if [ "$USEDEVPTS" = "yes" ]; then
log "I: mounting /dev/pts filesystem"
@@ -244,13 +247,14 @@ function mountproc () {
TTYMODE=620
[ -f /etc/default/devpts ] && . /etc/default/devpts
mount -t devpts /dev/pts "$BUILDPLACE/dev/pts" -onoexec,nosuid,gid=$TTYGRP,mode=$TTYMODE
+ mounted[${#mounted[@]}]="$BUILDPLACE/dev/pts"
fi
if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
log "I: mounting selinux filesystem"
mkdir -p $BUILDPLACE/selinux
mount -t selinuxfs /selinux "$BUILDPLACE/selinux"
- fi
- local -a mounted
+ mounted[${#mounted[@]}]="$BUILDPLACE/selinux"
+ fi
for mnt in $BINDMOUNTS; do
log "I: Mounting $mnt"
if mkdir -p "$BUILDPLACE/$mnt" &&
@@ -258,9 +262,10 @@ function mountproc () {
# successful.
mounted[${#mounted[@]}]="$mnt"
else
- # when unsuccessful, backtrack / umount and abort.
+ # this part of code is the only part which is supposed to fail.
+ # When unsuccessful, backtrack / umount and abort.
if [ -n "${mounted[*]}" ]; then
- log "I: error recovery: umount successfully mounted bind-mounts: ${mounted[@]}"
+ log "I: error recovery: umount successfully mounted mount-points: ${mounted[@]}"
for umnt in "${mounted[@]}"; do
log "I: umounting $umnt"
umount "$umnt"