summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2017-03-05 18:27:41 (GMT)
committerCyril Brulebois <kibi@debian.org>2017-03-09 22:24:37 (GMT)
commitbf2fb7cb0c410edde4ad938dcdf2c35384663dd0 (patch)
treeea2767325f376b441d040c4eaff649365e8073da
parent76afc9b35e0ac4d23362503708fa8c764afc7a63 (diff)
downloaddebootstrap-bf2fb7cb0c410edde4ad938dcdf2c35384663dd0.zip
debootstrap-bf2fb7cb0c410edde4ad938dcdf2c35384663dd0.tar.gz
debootstrap-bf2fb7cb0c410edde4ad938dcdf2c35384663dd0.tar.bz2
autopkgtest: Exercise schroot behaviour proposed on #856877
-rwxr-xr-xdebian/tests/debian-testing3
-rwxr-xr-xdebian/tests/fake/schroot-proposed68
2 files changed, 71 insertions, 0 deletions
diff --git a/debian/tests/debian-testing b/debian/tests/debian-testing
index 1520cb4..783dca1 100755
--- a/debian/tests/debian-testing
+++ b/debian/tests/debian-testing
@@ -113,6 +113,9 @@ sub check_chroot {
$reference);
check_fake_schroot(%params, reference => $reference);
+ check_fake_schroot(%params, reference => $reference, version => 'proposed');
+ check_fake_schroot(%params, reference => $reference, version => 'proposed',
+ extra_argv => ['--sbuild']);
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=817236
if (Dpkg::Version->new($params{kernel}) < Dpkg::Version->new('4.7') &&
diff --git a/debian/tests/fake/schroot-proposed b/debian/tests/fake/schroot-proposed
new file mode 100755
index 0000000..33c53b6
--- /dev/null
+++ b/debian/tests/fake/schroot-proposed
@@ -0,0 +1,68 @@
+#!/bin/sh
+# fake/schroot-proposed -- emulate proposed mount behaviour for schroot
+#
+# Copyright © 2017 Simon McVittie
+# SPDX-License-Identifier: MIT
+# (see debian/copyright)
+
+set -e
+
+# /etc/schroot/default/fstab
+bind_dev=yes
+
+while true; do
+ case "$1" in
+ (--sbuild)
+ shift
+ # /etc/schroot/sbuild/fstab
+ bind_dev=no
+ ;;
+ (*)
+ break
+ esac
+done
+
+CHROOT_PATH="$1"
+shift
+if test -z "$CHROOT_PATH" || test -z "$1"; then
+ echo "Usage: $0 CHROOT COMMAND...">&2
+ exit 2
+fi
+
+[ "$bind_dev" = no ] || mount --bind /dev "$CHROOT_PATH/dev"
+mount -t devpts -o rw,newinstance,ptmxmode=666,mode=620,gid=5 /dev/pts "$CHROOT_PATH/dev/pts"
+
+ls -l "$CHROOT_PATH/dev/ptmx" | sed -e 's/^/# fake-schroot: /' >&2
+ls -l "$CHROOT_PATH/dev/pts/ptmx" | sed -e 's/^/# fake-schroot: /' >&2
+
+mounted_ptmx=no
+
+if [ -e "$CHROOT_PATH/dev/pts/ptmx" ] && \
+ ! [ -L "$CHROOT_PATH/dev/ptmx" ]; then
+ mount --bind "$CHROOT_PATH/dev/pts/ptmx" "$CHROOT_PATH/dev/ptmx"
+ mounted_ptmx=yes
+fi
+
+mounted_console=no
+
+if stdin_tty="$(tty)"; then
+ if [ ! -e "$CHROOT_PATH/dev/console" ]; then
+ mknod -m700 "$CHROOT_PATH/dev/console" c 5 1
+ fi
+
+ mount --bind "$stdin_tty" "$CHROOT_PATH/dev/console"
+ mounted_console=yes
+fi
+
+ls -l "$CHROOT_PATH/dev/ptmx" | sed -e 's/^/# fake-schroot: /' >&2
+ls -l "$CHROOT_PATH/dev/pts/ptmx" | sed -e 's/^/# fake-schroot: /' >&2
+
+e=0
+chroot "$CHROOT_PATH" "$@" || e=$?
+
+[ "$mounted_console" = no ] || umount "$CHROOT_PATH/dev/console"
+[ "$mounted_ptmx" = no ] || umount "$CHROOT_PATH/dev/ptmx"
+umount "$CHROOT_PATH/dev/pts"
+[ "$bind_dev" = no ] || umount "$CHROOT_PATH/dev"
+
+exit "$e"