Skip to content

Commit f271464

Browse files
authored
Merge pull request #75 from singularityhub/fix/extra-shifts
Removing extra shifts
2 parents 5d4d48d + ca97793 commit f271464

File tree

2 files changed

+31
-13
lines changed

2 files changed

+31
-13
lines changed

README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ USAGE: docker2singularity [-m "/mount_point1 /mount_point2"] [options] docker_im
2020
OPTIONS:
2121

2222
Image Format
23-
-f: build development sandbox (folder)
24-
-w: non-production writable image (ext3)
25-
26-
Default is squashfs (recommended)
27-
23+
--folder -f build development sandbox (folder)
24+
--option -o add a custom option to build (-o --fakeroot or -option 'section post' )
25+
--writable -w non-production writable image (ext3)
26+
Default is squashfs (recommended) (deprecated)
27+
--name -n provide basename for the container (default based on URI)
28+
--mount -m provide list of custom mount points (in quotes!)
29+
--help -h show this help and exit
2830
```
2931

3032
### Options
@@ -41,6 +43,17 @@ Note that you are able to convert easily from a folder or ext3 image using Singu
4143

4244
- `-m` specify one or more mount points to create in the image.
4345

46+
**Options**
47+
48+
If you look at `singularity build --help` there are a variety of options available.
49+
You can specify some custom option to the command using the `--option` flag. Make sure
50+
that each option that you specify is captured as a single string. E.g.,:
51+
52+
```bash
53+
--option --fakeroot
54+
--option '--section post'
55+
```
56+
4457
**Image Name**
4558

4659
The last argument (without a letter) is the name of the docker image, as you would specify to run with Docker (e.g., `docker run ubuntu:latest`)

docker2singularity.sh

100644100755
Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ function usage() {
4444
4545
Image Format
4646
--folder -f build development sandbox (folder)
47+
--option -o add a custom option to build (-o --fakeroot or -option 'section post' )
4748
--writable -w non-production writable image (ext3)
48-
Default is squashfs (recommended)
49+
Default is squashfs (recommended) (deprecated)
4950
--name -n provide basename for the container (default based on URI)
5051
--mount -m provide list of custom mount points (in quotes!)
5152
--help -h show this help and exit
@@ -61,6 +62,7 @@ fi
6162
mount_points="/oasis /projects /scratch /local-scratch /work /home1 /corral-repl /corral-tacc /beegfs /share/PI /extra /data /oak"
6263
image_format="squashfs"
6364
new_container_name=""
65+
options=""
6466

6567
while true; do
6668
case ${1:-} in
@@ -78,15 +80,18 @@ while true; do
7880
mount_points="${1:-}"
7981
shift
8082
;;
83+
-o|--option)
84+
shift
85+
options="${1:-} ${options}"
86+
shift
87+
;;
8188
-f|--folder)
8289
shift
8390
image_format="sandbox"
84-
shift
8591
;;
8692
-w|--writable)
8793
shift
8894
image_format="writable"
89-
shift
9095
;;
9196
:) printf "missing argument for -%s\n" "$option" >&2
9297
usage
@@ -107,7 +112,7 @@ while true; do
107112
esac
108113
done
109114

110-
image=$1
115+
image=${1}
111116

112117
echo ""
113118
echo "Image Format: ${image_format}"
@@ -313,11 +318,11 @@ docker rm $container_id >> /dev/null
313318
# Build a final image from the sandbox
314319
echo "(9/10) Building ${image_format} container..."
315320
if [ "$image_format" == "squashfs" ]; then
316-
new_container_name=${new_container_name}.simg
317-
singularity build ${new_container_name} $build_sandbox
321+
new_container_name=${new_container_name}.sif
322+
singularity build ${options} ${new_container_name} $build_sandbox
318323
elif [ "$image_format" == "writable" ]; then
319-
new_container_name=${new_container_name}.img
320-
singularity build --writable ${new_container_name} $build_sandbox
324+
new_container_name=${new_container_name}.simg
325+
singularity build ${options} --writable ${new_container_name} $build_sandbox
321326
else
322327
mv $build_sandbox $new_container_name
323328
fi

0 commit comments

Comments
 (0)