Skip to content

Commit 21e55b3

Browse files
author
Jakub Kaczmarzyk
authored
fix: do not rm /tmp/* or /var/tmp/* (#272)
Removing everything beneath these directories causes issues when using singularity. Singularity mounts some build-time directories to /tmp and maybe /var/tmp, so removing these directories attempts to remove those files on the host. See sylabs/singularity#2538 for more info on singularity's intended behavior. See #246 for @yarikoptic discovery and disucssion of the issue.
1 parent ad62560 commit 21e55b3

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

neurodocker/interfaces/_base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
{%- endif -%}
2121
{% endfor %}
2222
apt-get clean
23-
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
23+
rm -rf /var/lib/apt/lists/*
2424
"""
2525
apt_install = jinja2.Template(apt_install)
2626

@@ -33,7 +33,7 @@
3333
{%- endif -%}
3434
{% endfor %}
3535
yum clean packages
36-
rm -rf /var/cache/yum/* /tmp/* /var/tmp/*
36+
rm -rf /var/cache/yum/*
3737
"""
3838
yum_install = jinja2.Template(yum_install)
3939

@@ -44,7 +44,7 @@
4444
{% endfor -%}
4545
apt-get install -f
4646
apt-get clean
47-
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
47+
rm -rf /var/lib/apt/lists/*
4848
"""
4949
deb_install = jinja2.Template(deb_install)
5050

neurodocker/templates/matlabmcr.yaml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,18 @@ generic:
3030
LD_LIBRARY_PATH: "$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu:{{ matlabmcr.install_path }}/{{ matlabmcr.mcr_version }}/runtime/glnxa64:{{ matlabmcr.install_path }}/{{ matlabmcr.mcr_version }}/bin/glnxa64:{{ matlabmcr.install_path }}/{{ matlabmcr.mcr_version }}/sys/os/glnxa64:{{ matlabmcr.install_path }}/{{ matlabmcr.mcr_version }}/extern/bin/glnxa64"
3131
MATLABCMD: "{{ matlabmcr.install_path }}/{{ matlabmcr.mcr_version }}/toolbox/matlab"
3232
instructions: |
33+
export TMPDIR="$(mktemp -d)"
3334
{{ matlabmcr.install_dependencies() }}
3435
echo "Downloading MATLAB Compiler Runtime ..."
3536
{% if matlabmcr.version == "2010a" -%}
3637
{{ matlabmcr.install_debs() }}
37-
curl {{ matlabmcr.curl_opts }} -o /tmp/MCRInstaller.bin {{ matlabmcr.binaries_url }}
38-
chmod +x /tmp/MCRInstaller.bin
39-
/tmp/MCRInstaller.bin -silent -P installLocation="{{ matlabmcr.install_path }}"
38+
curl {{ matlabmcr.curl_opts }} -o "$TMPDIR/MCRInstaller.bin" {{ matlabmcr.binaries_url }}
39+
chmod +x "$TMPDIR/MCRInstaller.bin"
40+
"$TMPDIR/MCRInstaller.bin" -silent -P installLocation="{{ matlabmcr.install_path }}"
4041
{% else -%}
41-
curl {{ matlabmcr.curl_opts }} -o /tmp/mcr.zip {{ matlabmcr.binaries_url }}
42-
unzip -q /tmp/mcr.zip -d /tmp/mcrtmp
43-
/tmp/mcrtmp/install -destinationFolder {{ matlabmcr.install_path }} -mode silent -agreeToLicense yes
42+
curl {{ matlabmcr.curl_opts }} -o "$TMPDIR/mcr.zip" {{ matlabmcr.binaries_url }}
43+
unzip -q "$TMPDIR/mcr.zip" -d "$TMPDIR/mcrtmp"
44+
"$TMPDIR/mcrtmp/install" -destinationFolder {{ matlabmcr.install_path }} -mode silent -agreeToLicense yes
4445
{% endif -%}
45-
rm -rf /tmp/*
46+
rm -rf "$TMPDIR"
47+
unset TMPDIR

neurodocker/templates/minc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ generic:
3131
unzip /tmp/mni_90c.zip -d {{ minc.install_path }}/share/icbm152_model_09c
3232
sed -i 's+MINC_TOOLKIT=/opt/minc+MINC_TOOLKIT={{ minc.install_path }}+g' {{ minc.install_path }}/minc-toolkit-config.sh
3333
sed -i '$isource {{ minc.install_path }}/minc-toolkit-config.sh' $ND_ENTRYPOINT
34-
rm -rf /tmp/*
34+
rm -rf /tmp/mni*

0 commit comments

Comments
 (0)