Skip to content

Commit fc66eab

Browse files
committed
comics: add support for singularity 3.*, drop version 2.* support
* check subcommand was dropped from singularity * run build under sudo, singularity 3.7 has some built-in fakeroot going on but it doesn't seem to work well for our use case * fix /etc/passwd /etc/group binding interference with apt/dpkg package installations in sandbox: binding external passwd/group in sandbox broke some package installations (for packages that set up their own osers/groups). So, with this patch we're very careful with the bind path collection algebra, that is we're just skipping over the default binds when entering a sandbox.
1 parent 5997c61 commit fc66eab

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

scripts/comics

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ LONG_OPTIONS=bind:container-image:keep-env,keep-env-modules,keep-prompt,list,nor
107107
handle_options () {
108108
if [ "$#" -gt 0 ]; then
109109
case "$1" in
110-
(-B|--bind) BIND_PATHS+=("$2"); return 2;;
110+
(-B|--bind) BIND_PATHS_EXTRA+=("$2"); return 2;;
111111
(-i|--container-image)
112112
IMAGE=$2
113113
USER_SPECIFIED_IMAGE=true
@@ -165,6 +165,7 @@ BIND_PATHS=(
165165
/etc/passwd
166166
/etc/group
167167
)
168+
BIND_PATHS_EXTRA=()
168169
NORC=false
169170
OLD_START_UP=false
170171
# by default run bash without --rcfile unless we do the old start style
@@ -274,10 +275,9 @@ if $UPDATE; then
274275
[[ -d "$sandbox" ]] || abort "Sandbox does not exists: $sandbox"
275276
local_temp_image=/tmp/${image_name}.new
276277
[[ -e "$local_temp_image" ]] && rm -- "$local_temp_image"
277-
info "Checking sandbox..."
278-
singularity check "$sandbox"
279278
info "Building local temp image at $local_temp_image ..."
280-
fakeroot singularity build "$local_temp_image" "$sandbox"
279+
info "Need to be root to run build command:"
280+
sudo singularity build "$local_temp_image" "$sandbox"
281281
info "Build done, moving to destination..."
282282
new_image=${image}.new
283283
mv -v -- "$local_temp_image" "$new_image"
@@ -289,7 +289,16 @@ if $UPDATE; then
289289
exit
290290
fi
291291

292-
for i in "${BIND_PATHS[@]}"; do
292+
bind_paths=()
293+
if ! $WRITE && [[ -v BIND_PATHS[@] ]]; then
294+
# skip default bind paths for sandboxes (/etc/passwd/group interferes with apt)
295+
bind_paths+=("${BIND_PATHS[@]}")
296+
fi
297+
if [[ -v BIND_PATHS_EXTRA[@] ]]; then
298+
bind_paths+=("${BIND_PATHS_EXTRA[@]}")
299+
fi
300+
301+
for i in "${bind_paths[@]:-()}"; do
293302
# assume no colon in pathname
294303
if [[ -e "${i%%:*}" ]]; then
295304
SINGULARITY_ARGS+=(-B "$i")

0 commit comments

Comments
 (0)