Skip to content

Commit

Permalink
comics: add support for singularity 3.*, drop version 2.* support
Browse files Browse the repository at this point in the history
  * 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.
  • Loading branch information
robert102 committed Apr 1, 2022
1 parent 5997c61 commit fc66eab
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions scripts/comics
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ LONG_OPTIONS=bind:container-image:keep-env,keep-env-modules,keep-prompt,list,nor
handle_options () {
if [ "$#" -gt 0 ]; then
case "$1" in
(-B|--bind) BIND_PATHS+=("$2"); return 2;;
(-B|--bind) BIND_PATHS_EXTRA+=("$2"); return 2;;
(-i|--container-image)
IMAGE=$2
USER_SPECIFIED_IMAGE=true
Expand Down Expand Up @@ -165,6 +165,7 @@ BIND_PATHS=(
/etc/passwd
/etc/group
)
BIND_PATHS_EXTRA=()
NORC=false
OLD_START_UP=false
# by default run bash without --rcfile unless we do the old start style
Expand Down Expand Up @@ -274,10 +275,9 @@ if $UPDATE; then
[[ -d "$sandbox" ]] || abort "Sandbox does not exists: $sandbox"
local_temp_image=/tmp/${image_name}.new
[[ -e "$local_temp_image" ]] && rm -- "$local_temp_image"
info "Checking sandbox..."
singularity check "$sandbox"
info "Building local temp image at $local_temp_image ..."
fakeroot singularity build "$local_temp_image" "$sandbox"
info "Need to be root to run build command:"
sudo singularity build "$local_temp_image" "$sandbox"
info "Build done, moving to destination..."
new_image=${image}.new
mv -v -- "$local_temp_image" "$new_image"
Expand All @@ -289,7 +289,16 @@ if $UPDATE; then
exit
fi

for i in "${BIND_PATHS[@]}"; do
bind_paths=()
if ! $WRITE && [[ -v BIND_PATHS[@] ]]; then
# skip default bind paths for sandboxes (/etc/passwd/group interferes with apt)
bind_paths+=("${BIND_PATHS[@]}")
fi
if [[ -v BIND_PATHS_EXTRA[@] ]]; then
bind_paths+=("${BIND_PATHS_EXTRA[@]}")
fi

for i in "${bind_paths[@]:-()}"; do
# assume no colon in pathname
if [[ -e "${i%%:*}" ]]; then
SINGULARITY_ARGS+=(-B "$i")
Expand Down

0 comments on commit fc66eab

Please sign in to comment.