Package: sbuild Version: 0.85.11 Severity: wishlist Tags: patch I attempted building a package for jessie using unshare and that didn't go well: jessie has no dumb-init package. Bummer. Looking into options, I considered adding dumb-init to jessie and rewriting dumb-init in perl, but then it also occurred to me that dumb-init doesn't actually do any filesystem accesses. In other words, it doesn't really care whether it is run inside or outside the chroot.
This change could affect the return of ischroot as /proc/1/root will look different. Johannes also indicated that he tried this and that it didn't work without giving details. In simple examples such as hostname, it just works. Commit d4ca3885977228f06e8fee8aa75c1a87e1662ce1 added dumb-init, but did not mention why it wasn't put outside chroot. The reason for adding it was cleaning up zombie processes. This aspect continues to work after the swap. Try it? Helmut
diff --minimal -Nru sbuild-0.85.11/debian/changelog sbuild-0.85.11+nmu1/debian/changelog --- sbuild-0.85.11/debian/changelog 2024-08-28 11:15:11.000000000 +0200 +++ sbuild-0.85.11+nmu1/debian/changelog 2024-09-05 14:49:28.000000000 +0200 @@ -1,3 +1,11 @@ +sbuild (0.85.11+nmu1) UNRELEASED; urgency=medium + + * Non-maintainer upload. + * Unshare: Swap chroot and dumb-init to reduce the build environment. + (Closes: #-1) + + -- Helmut Grohne <hel...@subdivi.de> Thu, 05 Sep 2024 14:49:28 +0200 + sbuild (0.85.11) unstable; urgency=medium [ Christian Kastner ] diff --minimal -Nru sbuild-0.85.11/debian/control sbuild-0.85.11+nmu1/debian/control --- sbuild-0.85.11/debian/control 2024-08-28 11:15:11.000000000 +0200 +++ sbuild-0.85.11+nmu1/debian/control 2024-09-05 14:48:34.000000000 +0200 @@ -57,7 +57,7 @@ ${misc:Depends}, ${perl:Depends}, ${shlibs:Depends} -Recommends: autopkgtest (>= 4.0.4), debootstrap, schroot (>= 1.6.0), uidmap +Recommends: autopkgtest (>= 4.0.4), debootstrap, dumb-init, schroot (>= 1.6.0), uidmap Suggests: deborphan, e2fsprogs, kmod, wget Description: Tool for building Debian binary packages from Debian sources The sbuild suite of programs (buildd and sbuild) are used to build diff --minimal -Nru sbuild-0.85.11/lib/Sbuild/Build.pm sbuild-0.85.11+nmu1/lib/Sbuild/Build.pm --- sbuild-0.85.11/lib/Sbuild/Build.pm 2024-08-28 11:15:11.000000000 +0200 +++ sbuild-0.85.11+nmu1/lib/Sbuild/Build.pm 2024-09-05 14:48:50.000000000 +0200 @@ -826,9 +826,6 @@ $self->set('Install Start Time', time); $self->set('Install End Time', $self->get('Install Start Time')); my @coredeps = @{$self->get_conf('CORE_DEPENDS')}; - if ($self->get_conf('CHROOT_MODE') eq 'unshare') { - push(@coredeps, 'dumb-init:native'); - } if ($self->get('Host Arch') ne $self->get('Build Arch')) { my $crosscoredeps = $self->get_conf('CROSSBUILD_CORE_DEPENDS'); if (defined($crosscoredeps->{$self->get('Host Arch')})) { diff --minimal -Nru sbuild-0.85.11/lib/Sbuild/ChrootUnshare.pm sbuild-0.85.11+nmu1/lib/Sbuild/ChrootUnshare.pm --- sbuild-0.85.11/lib/Sbuild/ChrootUnshare.pm 2024-08-28 11:15:11.000000000 +0200 +++ sbuild-0.85.11+nmu1/lib/Sbuild/ChrootUnshare.pm 2024-09-05 14:49:25.000000000 +0200 @@ -340,7 +340,7 @@ mount -t tmpfs tmpfs \"\$rootdir/sys/kernel\" -o mode=0000,size=4k,ro; mkdir -p \"\$rootdir/proc\"; mount -t proc proc \"\$rootdir/proc\"; - exec /usr/sbin/chroot \"\$rootdir\" $init /sbin/runuser -p -u \"\$user\" -- sh -c \"cd \\\"\\\$1\\\" && shift && \\\"\\\$@\\\"\" -- \"\$dir\" \"\$@\"; + exec $init /usr/sbin/chroot \"\$rootdir\" /sbin/runuser -p -u \"\$user\" -- sh -c \"cd \\\"\\\$1\\\" && shift && \\\"\\\$@\\\"\" -- \"\$dir\" \"\$@\"; ", '--', $self->get('Session ID'), $user, $dir, @bind_mounts, '--' ); }