| 1 | # Shared between regtest/debian-*.sh
|
| 2 |
|
| 3 | const DEBIAN_ROOT=$(pwd) ++ '/_debian_chroot'
|
| 4 | const CHROOT_DIR = DEBIAN_ROOT ++ '/debian_build'
|
| 5 |
|
| 6 | const CHROOT_HOME_DIR= CHROOT_DIR ++ '/home/udu'
|
| 7 |
|
| 8 | # For he.oils.pub
|
| 9 | # readonly BASE_DIR=_tmp/aports-build
|
| 10 |
|
| 11 | # For localhost
|
| 12 | # readonly REPORT_DIR=_tmp/aports-report
|
| 13 |
|
| 14 | const INTERACTIVE="${INTERACTIVE:-}"
|
| 15 |
|
| 16 | # concat-task-tsv() {
|
| 17 | # local config=${1:-baseline}
|
| 18 | # python3 devtools/tsv_concat.py \
|
| 19 | # $CHROOT_HOME_DIR/oils/_tmp/aports-guest/$config/*.task.tsv
|
| 20 | # }
|
| 21 |
|
| 22 | # proc enter-rootfs() {
|
| 23 | # $CHROOT_DIR/enter-chroot "$@"
|
| 24 | # }
|
| 25 |
|
| 26 | # proc enter-rootfs-user() {
|
| 27 | # enter-rootfs -u udu "$@"
|
| 28 | # }
|
| 29 |
|
| 30 | proc exec-chroot(cmd) {
|
| 31 | sudo chroot $CHROOT_DIR /bin/bash -l -c $cmd
|
| 32 | }
|
| 33 |
|
| 34 | proc exec-chroot-osh(cmd) {
|
| 35 | sudo chroot $DEBIAN_ROOT/osh-as-sh.overlay/merged /bin/bash -l -c $cmd
|
| 36 | }
|
| 37 |
|
| 38 | proc exec-chroot-user(cmd) {
|
| 39 | sudo chroot $CHROOT_DIR su -l udu -c $cmd
|
| 40 | }
|
| 41 |
|
| 42 |
|
| 43 | # enter-overlayfs-user() {
|
| 44 | # local name=$1
|
| 45 | # shift
|
| 46 |
|
| 47 | # # output ends up in the upperdir
|
| 48 | # #local upper="$OVERLAY_BASE_DIR/$name"
|
| 49 | # local upper=_chroot/overlay/upper/$name
|
| 50 |
|
| 51 | # # workdir is scratch space
|
| 52 | # local work=_chroot/overlay/work
|
| 53 | # # "$OVERLAY_BASE_DIR/${name}_work"
|
| 54 |
|
| 55 | # # the unified view we chroot into
|
| 56 | # #local merged="$OVERLAY_BASE_DIR/${name}_merged"
|
| 57 | # local merged=_chroot/overlay/merged
|
| 58 |
|
| 59 | # mkdir -p $upper $work $merged
|
| 60 |
|
| 61 | # # myoverlay is the 'source'
|
| 62 | # sudo mount \
|
| 63 | # -t overlay \
|
| 64 | # myoverlay \
|
| 65 | # -o "lowerdir=$CHROOT_DIR,upperdir=$upper,workdir=$work" \
|
| 66 | # "$merged"
|
| 67 |
|
| 68 | # $merged/enter-chroot -u udu "$@"
|
| 69 |
|
| 70 | # unmount-loop $merged
|
| 71 |
|
| 72 | # }
|
| 73 |
|
| 74 | # unmount-loop() {
|
| 75 | # local merged=$1
|
| 76 |
|
| 77 | # # unmount it in a loop, to ensure that we can re-mount it later
|
| 78 | # while true; do
|
| 79 | # # Lazy umount seems necessary? Otherwise we get 'target is busy'
|
| 80 | # # I suppose processes started inside the chroot may still be running
|
| 81 | # sudo umount -l "$merged"
|
| 82 | # if ! mountpoint --quiet "$merged"; then
|
| 83 | # break
|
| 84 | # fi
|
| 85 | # echo "Waiting to unmount: $merged"
|
| 86 | # sleep 0.1
|
| 87 | # done
|
| 88 | # }
|
| 89 |
|
| 90 | # # Note: these functions aren't used. bwrap is problematic when the container
|
| 91 | # # has multiple UIDs.
|
| 92 | # #
|
| 93 | # # We wanted to replace chroot with bwrap, because 'abuild rootbld' uses bwrap,
|
| 94 | # # and bwrap can't be run inside a chroot.
|
| 95 | # #
|
| 96 | # # But bwrap uses mount(), which requires a new user namespace, which creates a
|
| 97 | # # host/guest UID mapping problem.
|
| 98 | # #
|
| 99 | # # See Zulip for details
|
| 100 |
|
| 101 | # if false; then
|
| 102 | # enter-rootfs() {
|
| 103 | # $CHROOT_DIR/enter-bwrap.sh '' root '' "$@"
|
| 104 | # }
|
| 105 |
|
| 106 | # enter-rootfs-user() {
|
| 107 | # enter-rootfs -u udu "$@"
|
| 108 | # $CHROOT_DIR/enter-bwrap.sh '' udu '' "$@"
|
| 109 | # }
|
| 110 | # fi
|