Skip to content

Commit f6302ca

Browse files
committed
BIN: Update build/sandbox-venv
1 parent e3c54eb commit f6302ca

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

build/sandbox-venv

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
# Also re‑wrap any new scripts post installation by pip etc.
55
# shellcheck disable=SC2317
66
set -eu
7+
# shellcheck disable=SC3040
8+
case "$(set -o)" in *pipefail*) set -o pipefail ;; esac
79

810
for arg; do case "$arg" in -h|-\?|--help) echo "Usage: ${0##*/} [VENV_DIR] [BWRAP_OPTS] # Dir defaults to .venv"; exit ;; esac; done
911

@@ -60,7 +62,8 @@ import shutil
6062
import subprocess
6163
import sys
6264
if __name__ == '__main__':
63-
subprocess.run([shutil.which('/bin/bash') or '/bin/sh', *sys.argv[1:]])
65+
shell = shutil.which('/bin/bash') or '/bin/sh'
66+
sys.exit(subprocess.run([shell, *sys.argv[1:]]).returncode)
6467
EOF
6568
}
6669

@@ -101,6 +104,8 @@ exit 0
101104
# sandbox-venv: Secure container sandbox venv wrapper (GENERATED CODE)
102105
# pip wrapper: Re-run sandbox-venv after every pip installation
103106
set -u
107+
# shellcheck disable=SC3040
108+
case "$(set -o)" in *pipefail*) set -o pipefail ;; esac
104109
alias realpath='realpath --no-symlinks'
105110

106111
venv="$(realpath "${0%/*}/..")"
@@ -144,7 +149,8 @@ exit $pip_return_status
144149
#!/bin/sh
145150
# sandbox-venv: Secure container sandbox venv wrapper (GENERATED CODE)
146151
set -eu
147-
152+
# shellcheck disable=SC3040
153+
case "$(set -o)" in *pipefail*) set -o pipefail ;; esac
148154
alias realpath='realpath --no-symlinks'
149155
warn () { echo "sandbox-venv/wrapper: $*" >&2; }
150156
@@ -170,18 +176,23 @@ executables="
170176
/usr/bin/python3
171177
172178
/usr/bin/git
179+
/usr/bin/git-receive-pack
180+
/usr/bin/git-upload-archive
181+
/usr/bin/git-upload-pack
173182
174183
/bin/bash
175184
/bin/env
176185
/bin/ls
177-
/bin/sh"
186+
/bin/sh
187+
/bin/uname
188+
"
178189
179190
case $- in *x*) xtrace=-x ;; *) xtrace=+x ;; esac; set +x
180191
181192
# Collect binaries' lib dependencies
182193
lib_deps () {
183-
readelf -l "$1" | awk '/interpreter/ {print $NF}' | tr -d '[]'
184-
ldd "$1" | awk '/=>/ { print $3 }' | { grep -E '^/' || true; }
194+
{ readelf -l "$1" 2>/dev/null || true; } | awk '/interpreter/ {print $NF}' | tr -d '[]'
195+
{ ldd "$1" 2>/dev/null || true; } | awk '/=>/ { print $3 }' | { grep -E '^/' || true; }
185196
}
186197
collect="$executables"
187198
for exe in $executables; do
@@ -193,6 +204,7 @@ done
193204
root_so_lib_dirs="
194205
/usr/lib/python3*/lib-dynload
195206
/usr/lib64/python3*/lib-dynload"
207+
# XXX: If some `git` tools are failing, add $(find /usr/lib/git-core -type f)
196208
for exe in $(find "$venv/lib" $root_so_lib_dirs -name '*.so' 2>/dev/null || true); do
197209
collect="$collect
198210
$(lib_deps "$exe")"
@@ -208,9 +220,14 @@ git_libs="
208220
/usr/lib*/git-core
209221
"
210222
ro_bind_extra="
223+
/etc/hosts
211224
/etc/resolv.conf
212-
/usr/share/locale/
225+
226+
/etc/ld.so.cache
227+
/etc/os-release
228+
/usr/share/locale
213229
/usr/share/zoneinfo
230+
214231
/usr/share/ca-certificates*
215232
/etc/pki
216233
/etc/ssl
@@ -281,7 +298,7 @@ set -- --bind "$venv/cache" "$home/.cache" \
281298
--bind "$pip_cache" "$home/.cache/pip" "$@"
282299
283300
# Pass our own redacted copy of env
284-
for var in $(env | grep -E '^(USER|LOGNAME|UID|SHLVL|SHELL|TERM|LANG|LC_.*|HOSTNAME)$'); do
301+
for var in $(env | grep -E '^(USER|LOGNAME|UID|PATH|TERM|LANGUAGE|LANG|LC_.*?|HOSTNAME)='); do
285302
set -- --setenv "${var%%=*}" "${var#*=}" "$@"
286303
done
287304

0 commit comments

Comments
 (0)