blob: 6ebd6dc308ef9fe287c5df009524c10567c8be33 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#!/bin/sh
# fake/schroot-1.6.10-3 -- emulate how schroot/1.6.10-3 would chroot.
#
# Please do not modify this script without verifying that its behaviour
# is still equivalent to the stated versions of schroot. If a future
# version of schroot changes its behaviour, please copy this script and
# modify the copy instead.
#
# This version has #856877 unfixed. It bind-mounts /dev/pts and maybe
# /dev from the host system, rather than creating a new instance of /dev/pts.
# (There is of course a lot more that it does, but these are the parts that
# affect pty users like script(1).)
#
# Copyright © 2017-2023 Simon McVittie
# SPDX-License-Identifier: MIT
# (see debian/copyright)
set -e
# Reference: /etc/schroot/default/fstab
# (in schroot source tree: etc/profile-templates/default/linux/fstab)
bind_dev=yes
while true; do
case "$1" in
(--sbuild)
shift
# Reference: /etc/schroot/sbuild/fstab
# (source: etc/profile-templates/sbuild/linux/fstab)
bind_dev=no
;;
(*)
break
esac
done
chroot="$1"
shift
if test -z "$chroot" || test -z "$1"; then
echo "Usage: $0 CHROOT COMMAND...">&2
exit 2
fi
[ "$bind_dev" = no ] || mount --bind /dev "$chroot/dev"
mount --bind /dev/pts "$chroot/dev/pts"
ls -l "/dev/ptmx" | sed -e 's/^/# fake-schroot: outside chroot: /' >&2
ls -l "/dev/pts/ptmx" | sed -e 's/^/# fake-schroot: outside chroot: /' >&2
ls -l "$chroot/dev/ptmx" | sed -e 's/^/# fake-schroot: /' >&2
ls -l "$chroot/dev/pts/ptmx" | sed -e 's/^/# fake-schroot: /' >&2
e=0
chroot "$chroot" "$@" || e=$?
umount "$chroot/dev/pts"
[ "$bind_dev" = no ] || umount "$chroot/dev"
exit "$e"
|