Skip to content

Commit 6b1e2f3

Browse files
committed
* Replace multiple / in container name, not just the first one
This makes quay.io containers work * Check for buildroot environment and adjust find appropriately
1 parent b4a017a commit 6b1e2f3

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

docker2singularity.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ image_name=`docker inspect --format="{{.Config.Image}}" $container_id`
4545

4646
# using bash substitution
4747
# removing special chars [perhaps echo + sed would be better for other chars]
48-
image_name=${image_name/\//_}
48+
image_name=${image_name//\//_}
4949
image_name=${image_name/:/_}
5050

5151
# following is the date of the container, not the docker image.
@@ -146,7 +146,14 @@ singularity exec --writable --contain $new_container_name /bin/sh -c "mkdir -p m
146146
# making sure that any user can read and execute everything in the container
147147
echo "(7/9) Fixing permissions..."
148148
singularity exec --writable --contain $new_container_name /bin/sh -c "find /* -maxdepth 0 -not -path '/dev*' -not -path '/proc*' -not -path '/sys*' -exec chmod a+r -R '{}' \;"
149-
singularity exec --writable --contain $new_container_name /bin/sh -c "find / -executable -perm -u+x,o-x -not -path '/dev*' -not -path '/proc*' -not -path '/sys*' -exec chmod a+x '{}' \;"
149+
grep -q Buildroot /etc/issue
150+
if [[ $? -eq 0 ]] ; then
151+
# we're running on a Builroot container and need to use Busybox's find
152+
echo "We're running on BusyBox/Buildroot"
153+
singularity exec --writable --contain $new_container_name /bin/sh -c "find / -type f -or -type d -perm -u+x,o-x -not -path '/dev*' -not -path '/proc*' -not -path '/sys*' -exec chmod a+x '{}' \;"
154+
else
155+
singularity exec --writable --contain $new_container_name /bin/sh -c "find / -executable -perm -u+x,o-x -not -path '/dev*' -not -path '/proc*' -not -path '/sys*' -exec chmod a+x '{}' \;"
156+
fi
150157

151158
echo "(8/9) Stopping and removing the container..."
152159
docker stop $container_id

0 commit comments

Comments
 (0)