[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[RFC] fixing pbuilder



Hello,

Attached 2 patches to make pbuilder working:

debootstrap.diff
  Disconnect (orphan) TARGET/proc passive translator and bind-mount /proc.
  Add "nobindmount" variant to create chroots without bind-mounting any
  filesystem. Main Hurd use case is chroot for subhurds.

pbuilder.diff
  Bind-{mount,umount} /dev, /servers and /proc if not already done
  Two workarounds:
    - 1st and last hunk guarantee that there are no superfluous "/" and
      "." hurd mount can't support at the moment.
    - once all bind-mounts are removed, on chroot some devices still
      block chroot removal.
      4th hunk makes TARGET/dev/{netdde,tty*,pty*,fd,vcs} go away.

-- 
G..e
diff --git a/debootstrap b/debootstrap
index fef1ab5..9dced1e 100755
--- a/debootstrap
+++ b/debootstrap
@@ -100,7 +100,7 @@ usage()
                              archive
       --variant=X            use variant X of the bootstrap scripts
                              (currently supported variants: buildd, fakechroot,
-                              scratchbox, minbase)
+                              scratchbox, minbase, nobindmount)
       --keyring=K            check Release files against keyring K
       --no-check-gpg         avoid checking Release file signatures
       --no-resolve-deps      don't try to resolve dependencies automatically
diff --git a/debootstrap.8 b/debootstrap.8
index 2cf44ca..b448089 100644
--- a/debootstrap.8
+++ b/debootstrap.8
@@ -71,13 +71,14 @@ or apt, and that it is far better to specify the entire base system than
 rely on this option.
 With this option set, this behaviour is disabled.
 .IP
-.IP "\fB\-\-variant=minbase|buildd|fakechroot|scratchbox\fP"
+.IP "\fB\-\-variant=minbase|buildd|fakechroot|scratchbox|nobindmount\fP"
 Name of the bootstrap script variant to use.
 Currently, the variants supported are minbase, which only includes
 essential packages and apt; buildd, which installs the build-essential
 packages into
 .IR TARGET ;
-and fakechroot, which installs the packages without root privileges.
+nobindmount, which doesn't bind-mount any filesystem; and fakechroot,
+which installs the packages without root privileges.
 Finally there is variant scratchbox, which is for creating targets
 for scratchbox usage.
 The default, with no \fB\-\-variant=X\fP argument, is to create a base
diff --git a/functions b/functions
index 0d48390..07147c0 100644
--- a/functions
+++ b/functions
@@ -1064,10 +1064,13 @@ setup_devices () {
 
 setup_devices_hurd () {
 	# Use the setup-translators of the hurd package, and firmlink
-	# $TARGET/{dev,servers} to the system ones.
+	# $TARGET/{dev,servers,proc} to the system ones.
 	in_target /usr/lib/hurd/setup-translators -k
-	settrans -a $TARGET/dev /hurd/firmlink /dev
-	settrans -a $TARGET/servers /hurd/firmlink /servers
+	if ! doing_variant nobindmount; then
+		settrans -a $TARGET/dev /hurd/firmlink /dev
+		settrans -a $TARGET/servers /hurd/firmlink /servers
+		settrans -oa $TARGET/proc /hurd/firmlink /proc
+	fi
 }
 
 setup_devices_fakechroot () {
diff --git a/scripts/sid b/scripts/sid
index bf3404f..34089f7 100644
--- a/scripts/sid
+++ b/scripts/sid
@@ -1,7 +1,7 @@
 mirror_style release
 download_style apt
 finddebs_style from-indices
-variants - buildd fakechroot minbase scratchbox
+variants - buildd fakechroot minbase scratchbox nobindmount
 keyring /usr/share/keyrings/debian-archive-keyring.gpg
 
 if doing_variant fakechroot; then
diff --git a/pbuilder-createbuildenv b/pbuilder-createbuildenv
index 8362b1c..1441d4c 100755
--- a/pbuilder-createbuildenv
+++ b/pbuilder-createbuildenv
@@ -73,7 +73,7 @@ if ! ( cd "$BUILDPLACE" && \
     --include=apt \
     "${DEBOOTSTRAPOPTS[@]}" \
     "$DISTRIBUTION" \
-    . \
+    "$BUILDPLACE" \
     "$MIRRORSITE" \
     $DEBOOTSTRAPSCRIPT ) ; then
     log "E: $DEBOOTSTRAP failed"
diff --git a/pbuilder-modules b/pbuilder-modules
index 055d611..f40f76d 100644
--- a/pbuilder-modules
+++ b/pbuilder-modules
@@ -153,6 +153,7 @@ function seems_truly_unmounted() {
 }
 
 function umount_one () {
+    DEB_BUILD_ARCH_OS=$(dpkg-architecture -qDEB_BUILD_ARCH_OS)
     if [ "${IGNORE_UMOUNT}" = "yes" ]; then
 	# support ignore umount option.
 	log "I: ignoring umount of $1 filesystem"
@@ -221,7 +222,7 @@ function umountproc () {
     if [ "$USEDEVFS" = "yes" ]; then
 	umount_one "dev"
     fi
-    if [ "$USERUNSHM" = "yes" ]; then
+    if [ "$USERUNSHM" = "yes" ] && [ "$DEB_BUILD_ARCH_OS" != "hurd" ]; then
 	umount_one "run/shm"
     fi
     if [ "$USEPROC" = "yes" ]; then
@@ -233,6 +234,17 @@ function umountproc () {
     if [ "$DEB_BUILD_ARCH_OS" = "kfreebsd" ]; then
         umount_one "sys"
     fi
+    if [ "$DEB_BUILD_ARCH_OS" = "hurd" ]; then
+        umount_one "servers"
+        umount_one "dev"
+
+        # Workaround to remove chroot on Hurd: once /dev firmlink is
+        # removed, chroot removal either gets stuck or fails by removing
+        # some devices.
+        for dev in $BUILDPLACE/dev/{netdde,tty*,pty*,fd,vcs}; do
+            settrans -fg $dev
+        done
+    fi
 }
 
 
@@ -244,11 +256,15 @@ function mountproc () {
     if [ "$USEPROC" = "yes" ]; then
 	log "I: mounting /proc filesystem"
 	mkdir -p $BUILDPLACE/proc
-	PROCFS="proc"
-	if [ "$DEB_BUILD_ARCH_OS" = "kfreebsd" ]; then
-	    PROCFS="linprocfs"
-	fi
-	mount -t $PROCFS /proc "$BUILDPLACE/proc"
+        case "$DEB_BUILD_ARCH_OS" in
+            kfreebsd)   PROCFS="linprocfs" ;;
+            hurd)       settrans -fg "$BUILDPLACE/proc"
+                        PROCFS="firmlink"
+            ;;
+            *)          PROCFS="proc" ;;
+        esac
+        mount -t $PROCFS /proc "$BUILDPLACE/proc" ||
+            [ $DEB_BUILD_ARCH_OS = hurd ] && true
 	ln -s ../proc/mounts $BUILDPLACE/etc/mtab 2> /dev/null || true
 	mounted[${#mounted[@]}]="$BUILDPLACE/proc"
     fi
@@ -279,6 +295,14 @@ function mountproc () {
 	mount -t selinuxfs /selinux "$BUILDPLACE/selinux"
 	mounted[${#mounted[@]}]="$BUILDPLACE/selinux"
     fi
+    if [ "$DEB_BUILD_ARCH_OS" = "hurd" ]; then
+        # /dev and /servers might have already been mounted at
+        # debootstrap chroot creation
+        mount -t firmlink /dev "$BUILDPLACE/dev" || true
+        mounted[${#mounted[@]}]="$BUILDPLACE/dev"
+        mount -t firmlink /servers "$BUILDPLACE/servers" || true
+        mounted[${#mounted[@]}]="$BUILDPLACE/servers"
+    fi
     MOUNTPARAMS="-obind"
     [ "$DEB_BUILD_ARCH_OS" = "kfreebsd" ] && MOUNTPARAMS="-t nullfs"
     for mnt in $BINDMOUNTS; do
diff --git a/pbuilderrc b/pbuilderrc
index d15eb53..9fdb14d 100644
--- a/pbuilderrc
+++ b/pbuilderrc
@@ -4,7 +4,7 @@
 BASETGZ=/var/cache/pbuilder/base.tgz
 #EXTRAPACKAGES=""
 #export DEBIAN_BUILDARCH=athlon
-BUILDPLACE=/var/cache/pbuilder/build/
+BUILDPLACE=/var/cache/pbuilder/build
 MIRRORSITE=http://cdn.debian.net/debian
 #OTHERMIRROR="deb http://www.home.com/updates/ ./"
 #export http_proxy=http://your-proxy:8080/

Reply to: