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

dd-schroot-cmd on hurd boxes



Hello,

to make dd-schroot-cmd [0] work on Hurd porterboxes:

 * apply attached 01dd-schroot-cmd.diff to dd-schroot-cmd [1] (already
   sent to debian-admin@l.d.o)
 * apply attached 02schroot.diff to schroot 1.6.10
 * create a file chroot
   + with pbuilder --create (patched one [2] currently on debian-ports),
     then add a stanza like following one to /etc/schroot/schroot.conf
     (or under /etc/schroot/chroot.d)
------8<------
[sid-file]
type=file
description=Debian sid file-based chroot
groups=sbuild
root-groups=root
file=/srv/chroot/sid-file.tar.gz
------8<------

   or

   + with setup-dchroot in [1] (args: "-p default sid"), patched with
     attached 03setup-dchroot.diff. It will create a
     /etc/schroot/chroot.d/sid_hurd-i386-dchroot file.
     (bigger tarball, didn't check why)

[0] https://lists.debian.org/debian-devel-announce/2013/04/msg00009.html
[1] git clone git://anonscm.debian.org/mirror/dsa-puppet.git
[2] https://lists.debian.org/debian-hurd/2014/06/msg00032.html

Let's test it.

-- 
G..e
diff --git a/modules/porterbox/files/dd-schroot-cmd b/modules/porterbox/files/dd-schroot-cmd
index 8dc7a4b..179491c 100755
--- a/modules/porterbox/files/dd-schroot-cmd
+++ b/modules/porterbox/files/dd-schroot-cmd
@@ -80,7 +80,7 @@ def ensure_ok(session):
         die("Session owner mismatch.")
 
 def os_supports_unshare():
-    if platform.uname()[0] == 'GNU/kFreeBSD':
+    if platform.uname()[0] == 'GNU/kFreeBSD' or platform.uname()[0] == 'GNU':
         return False
     return True
 
diff --git a/etc/profile-templates/all/gnu/fstab b/etc/profile-templates/all/gnu/fstab
new file mode 100644
index 0000000..159c200
--- /dev/null
+++ b/etc/profile-templates/all/gnu/fstab
@@ -0,0 +1,3 @@
+/proc           /proc           none    bind            0       0
+/dev            /dev            none    bind            0       0
+/servers        /servers        none    bind            0       0
diff --git a/etc/profile-templates/default/gnu/fstab b/etc/profile-templates/default/gnu/fstab
new file mode 100644
index 0000000..e848dad
--- /dev/null
+++ b/etc/profile-templates/default/gnu/fstab
@@ -0,0 +1,11 @@
+/home           /home           none    bind            0       0
+/tmp            /tmp            none    bind            0       0
+
+# It may be desirable to have access to /run, especially if you wish
+# to run additional services in the chroot.  However, note that this
+# may potentially cause undesirable behaviour on upgrades, such as
+# killing services on the host.
+#/run            /run            none    bind            0       0
+#/run/lock       /run/lock       none    bind            0       0
+#/dev/shm        /dev/shm        none    bind            0       0
+#/run/shm        /run/shm        none    bind            0       0
diff --git a/etc/profile-templates/desktop/gnu/fstab b/etc/profile-templates/desktop/gnu/fstab
new file mode 100644
index 0000000..96f775a
--- /dev/null
+++ b/etc/profile-templates/desktop/gnu/fstab
@@ -0,0 +1,16 @@
+/home           /home           none    bind            0       0
+/tmp            /tmp            none    bind            0       0
+
+# If you use gdm3, uncomment this line to allow Xauth to work
+#/var/run/gdm3   /var/run/gdm3   none    bind            0       0
+# For PulseAudio and other desktop-related things
+/var/lib/dbus   /var/lib/dbus   none    bind            0       0
+
+# It may be desirable to have access to /run, especially if you wish
+# to run additional services in the chroot.  However, note that this
+# may potentially cause undesirable behaviour on upgrades, such as
+# killing services on the host.
+#/run            /run            none    bind            0       0
+#/run/lock       /run/lock       none    bind            0       0
+#/dev/shm        /dev/shm        none    bind            0       0
+#/run/shm        /run/shm        none    bind            0       0
diff --git a/etc/setup.d/10mount b/etc/setup.d/10mount
index 27c18d0..884c36a 100755
--- a/etc/setup.d/10mount
+++ b/etc/setup.d/10mount
@@ -224,6 +224,21 @@ if [ "$CHROOT_TYPE" = "directory" ] \
     elif [ $STAGE = "setup-stop" ]; then
 
         do_umount_all "$CHROOT_MOUNT_LOCATION"
+        #
+        # If CHROOT_TYPE is "file", _UNPACK_DIR is bindmounted on
+        # _MOUNT_LOCATION. Hurd does need to also bindmount /dev and
+        # /servers on respectively _MOUNT_LOCATION/dev and
+        # _MOUNT_LOCATION/servers, but due to a bug, currently
+        # bindmounts-on-bindmounts result mounted on first bindmount
+        # source device i.e. _UNPACK_DIR.
+        # Workaround also umounts filesystems under _UNPACK_DIR.
+        #
+        if [ "$CHROOT_TYPE" = "file" -a "$(uname -s)" = "GNU" ]; then
+            do_umount_all "${CHROOT_FILE_UNPACK_DIR}/${SESSION_ID}"
+            info "Unmounting ${CHROOT_FILE_UNPACK_DIR}/${SESSION_ID}/proc"
+            umount "${CHROOT_FILE_UNPACK_DIR}/${SESSION_ID}/proc" || exit 1
+        fi
+
         if [ "$CREATE_UNION" = "yes" ]; then
             do_umount_all "$CHROOT_UNION_UNDERLAY_DIRECTORY"
         fi
diff --git a/modules/porterbox/files/setup-dchroot b/modules/porterbox/files/setup-dchroot
index 81732c6..1fc3a21 100755
--- a/modules/porterbox/files/setup-dchroot
+++ b/modules/porterbox/files/setup-dchroot
@@ -267,6 +267,16 @@ case "$(uname -s)" in
   GNU/kFreeBSD)
     mount -t devfs none "$rootdir/dev"
     ;;
+  GNU)
+    cleanup+=("umount $rootdir/servers")
+    cleanup+=("settrans -fg $rootdir/proc")
+    # Workaround to remove chroot on Hurd: once /dev firmlink is
+    # removed, chroot removal either gets stuck or fails by removing
+    # some translators.
+    for dev in $rootdir/dev/{netdde,tty*,pty*,fd,vcs}; do
+        cleanup+=("settrans -fg $dev")
+    done
+    ;;
   *)
     echo >&2 "Warning: Unexpected uname -s output."
     ;;
@@ -301,6 +311,15 @@ chroot "$rootdir" apt-get clean
 umount "$rootdir/dev" 2>/dev/null || true
 umount "$rootdir/sys" 2>/dev/null || true
 
+# Workaround to create tarball on Hurd: once /dev firmlink is
+# removed, tarball creation either gets stuck or fails by accessing
+# some translators.
+if [ "$(uname -s)" = "GNU" ]; then
+    for dev in $rootdir/dev/{netdde,tty*,pty*,fd,vcs}; do
+        settrans -fg $dev
+    done 2>/dev/null || true
+fi
+
 tartmp=$(tempfile --directory "$basedir" --suffix=".tar.gz")
 cleanup+=("rm -f $tartmp")
 (cd "$rootdir" && tar caf "$tartmp" . && mv "$tartmp" "$target")

Reply to: