summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2017-03-05 17:41:32 (GMT)
committerCyril Brulebois <kibi@debian.org>2017-03-09 22:24:37 (GMT)
commit76afc9b35e0ac4d23362503708fa8c764afc7a63 (patch)
treecf318403c2862c047647dce9b55593a09d6c8b33
parent63365f0e237c7365e9981dac0b56a383e3eae70c (diff)
downloaddebootstrap-76afc9b35e0ac4d23362503708fa8c764afc7a63.zip
debootstrap-76afc9b35e0ac4d23362503708fa8c764afc7a63.tar.gz
debootstrap-76afc9b35e0ac4d23362503708fa8c764afc7a63.tar.bz2
autopkgtest: Exercise pbuilder behaviour proposed on #841935
-rwxr-xr-xdebian/tests/debian-testing13
-rwxr-xr-xdebian/tests/fake/pbuilder-proposed54
2 files changed, 63 insertions, 4 deletions
diff --git a/debian/tests/debian-testing b/debian/tests/debian-testing
index 3f8e81a..1520cb4 100755
--- a/debian/tests/debian-testing
+++ b/debian/tests/debian-testing
@@ -35,10 +35,13 @@ sub capture {
sub check_fake_schroot {
my %params = @_;
my $reference = $params{reference};
+ my $version = $params{version} || '1.6.10-3';
my $extra_argv = $params{extra_argv} || [];
+ # Use unshare -m to make sure the /dev mount gets cleaned up on exit, even
+ # on failures
my $response = capture([qw(unshare -m),
- "$srcdir/debian/tests/fake/schroot-1.6.10-3", @{$extra_argv},
+ "$srcdir/debian/tests/fake/schroot-$version", @{$extra_argv},
$params{chroot},
qw(runuser -u nobody --),
qw(script -q -c), 'cat /etc/debian_version', '/dev/null']);
@@ -49,9 +52,10 @@ sub check_fake_schroot {
sub check_fake_pbuilder {
my %params = @_;
my $reference = $params{reference};
+ my $version = $params{version} || '0.228.4-1';
my $response = capture([qw(unshare -m),
- "$srcdir/debian/tests/fake/pbuilder-0.228.4-1", $params{chroot},
+ "$srcdir/debian/tests/fake/pbuilder-$version", $params{chroot},
qw(runuser -u nobody --),
qw(script -q -c), 'cat /etc/debian_version', '/dev/null']);
$response =~ s/\r//g;
@@ -108,8 +112,6 @@ sub check_chroot {
cat /etc/debian_version)]),
$reference);
- # Use unshare -m to make sure the /dev mount gets cleaned up on exit, even
- # on failures
check_fake_schroot(%params, reference => $reference);
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=817236
@@ -135,6 +137,9 @@ sub check_chroot {
extra_argv => ['--sbuild']);
}
+ check_fake_pbuilder(%params, reference => $reference,
+ version => 'proposed');
+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=817236
if (! $params{can_mknod_ptmx}) {
TODO: {
diff --git a/debian/tests/fake/pbuilder-proposed b/debian/tests/fake/pbuilder-proposed
new file mode 100755
index 0000000..af31d5b
--- /dev/null
+++ b/debian/tests/fake/pbuilder-proposed
@@ -0,0 +1,54 @@
+#!/bin/sh
+# fake/pbuilder-proposed -- emulate how pbuilder is proposed to chroot in
+# future.
+#
+# Copyright © 2017 Simon McVittie
+# SPDX-License-Identifier: MIT
+# (see debian/copyright)
+
+set -e
+
+BUILDPLACE="$1"
+shift
+if test -z "$BUILDPLACE" || test -z "$1"; then
+ echo "Usage: $0 CHROOT COMMAND...">&2
+ exit 2
+fi
+
+devpts_options="noexec,nosuid,gid=5,mode=620"
+
+mkdir -p "$BUILDPLACE/dev/pts"
+if ! mount -t devpts none "$BUILDPLACE/dev/pts" -o "$devpts_options,newinstance,ptmxmode=666"; then
+ mount -t devpts none "$BUILDPLACE/dev/pts" -o "$devpts_options"
+fi
+
+mounted_ptmx=no
+
+if [ -e "$BUILDPLACE/dev/pts/ptmx" ] && \
+ ! [ -L "$BUILDPLACE/dev/ptmx" ]; then
+ chmod 666 "$BUILDPLACE/dev/pts/ptmx"
+ mount --bind "$BUILDPLACE/dev/pts/ptmx" "$BUILDPLACE/dev/ptmx"
+ mounted_ptmx=yes
+fi
+
+mounted_console=no
+
+if stdin_tty="$(tty)"; then
+ if [ ! -e "$BUILDPLACE/dev/console" ]; then
+ mknod -m700 "$BUILDPLACE/dev/console" c 5 1
+ fi
+
+ mount --bind "$stdin_tty" "$BUILDPLACE/dev/console"
+ mounted_console=yes
+fi
+
+ls -l "$BUILDPLACE/dev/ptmx" | sed -e 's/^/# fake-pbuilder: /' >&2
+ls -l "$BUILDPLACE/dev/pts/ptmx" | sed -e 's/^/# fake-pbuilder: /' >&2
+
+e=0
+chroot "$BUILDPLACE" "$@" || e=$?
+
+[ "$mounted_console" = no ] || umount "$BUILDPLACE/dev/console"
+[ "$mounted_ptmx" = no ] || umount "$BUILDPLACE/dev/ptmx"
+umount "$BUILDPLACE/dev/pts"
+exit "$e"