0

I'm trying to create soft link in the %setup section of the Singularity recipe file. If the link is relative, it does not work. For example:

ln -s ${SINGULARITY_ROOTFS}../python2/2.7.5a ${SINGULARITY_ROOTFS}/usr/pkgs/python/2.7.5

It creates:

lrwxrwxrwx 1 root root 49 Apr 24 06:33 /tmp/build-temp-976030219/rootfs/usr/pkgs/python/2.7.5 -> /tmp/build-temp-976030219/rootfs../python2/2.7.5a

The /tmp/build-temp-976030219/rootfs../python2/2.7.5a is of course invalid path. I don't want to start getting the realpath because I could get other links on the way. How to make it work with relative paths? Am I not using the ${SINGULARITY_ROOTFS} properly?

vesii
  • 101

1 Answers1

0

To make it work with relative paths, give ln a relative path:

ln -s ../python2/2.7.5a ${SINGULARITY_ROOTFS}/usr/pkgs/python/2.7.5

The parameter will become the symlink target exactly as specified, so you have to use something that is already relative to the symlink's location.

u1686_grawity
  • 426,297
  • 64
  • 894
  • 966
  • The problem with that solution is that if I have another link on the way like `/usr/pkgs/python/2.7.5/lib/some_link` then it will fail because it already exists in the "regular env", meaning that path already points to `/usr/pkgs/python2/2.7.5a/lib/some_link`. So `ln -s aaa ${SINGULARITY_ROOTFS}/usr/pkgs/python/2.7.5/lib/some_link` will fail. Is there a better solution? – vesii Apr 28 '21 at 14:44