Bug#593100: Suggested patch for specifying BINDMOUNTS destination

Austin Phillips austin.phillips at ceos.com.au
Thu Jul 4 06:07:50 UTC 2013


I also think it would be a useful addition to allow specification of the 
destination for a bind mount.

In my case, I'm working on a squeeze system and would like to build a 
package under pbuilder using a wheezy pbuilder chroot, but my unit tests 
require /dev/shm to be mounted.  BINDMOUNTS='/dev/shm' will fail because 
of the move to /run/shm in wheezy.  ie. pbuilder tries to mount the 
local /dev/shm to /dev/shm inside the chroot, which in wheezy has been 
replaced by a symlink.  Instead, what works is to mount /dev/shm to 
/run/shm inside the chroot.

The patch below alters the format of BINDMOUNTS, allowing a colon 
separated <src>:<dest> bind mount specification.  In the previous 
example this would be BINDMOUNTS="/dev/shm:/run/shm".  This should be 
backwards compatible with existing BINDMOUNTS specifications.

This has been tested against pbuilder 0.199+nmu1squeeze1.

Austin


--- pbuilder-modules.orig    2013-07-04 15:04:06.000000000 +1000
+++ pbuilder-modules    2013-07-04 15:46:28.000000000 +1000
@@ -206,7 +206,7 @@
      reversed="$mnt $reversed"
      done
      for mnt in $reversed; do
-    umount_one "$mnt"
+    umount_one "${mnt#*:}"
      done
      if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
      umount_one "selinux"
@@ -259,11 +259,17 @@
      mounted[${#mounted[@]}]="$BUILDPLACE/selinux"
      fi
      for mnt in $BINDMOUNTS; do
-    log "I: Mounting $mnt"
-    if mkdir -p "$BUILDPLACE/$mnt" &&
-        mount -obind "$mnt" "$BUILDPLACE/$mnt"; then
+    mntpoint=${mnt#*:}
+    mnt=${mnt%%:*}
+    if [ "$mnt" = "$mntpoint" ]; then
+        log "I: Mounting $mnt"
+    else
+        log "I: Mounting $mnt to $mntpoint"
+    fi
+    if mkdir -p "$BUILDPLACE/$mntpoint" &&
+        mount -obind "$mnt" "$BUILDPLACE/$mntpoint"; then
          # successful.
-        mounted[${#mounted[@]}]="$mnt"
+        mounted[${#mounted[@]}]="$BUILDPLACE/$mntpoint"
      else
          # this part of code is the only part which is supposed to fail.
          # When unsuccessful, backtrack / umount and abort.



More information about the Pbuilder-maint mailing list