aspiers / stow

GNU Stow - mirror of savannah git repository occasionally with more bleeding-edge branches
http://www.gnu.org/s/stow/
GNU General Public License v3.0
589 stars 41 forks source link

Stow a absolute symlink #76

Closed Kamilcuk closed 3 years ago

Kamilcuk commented 3 years ago

Stow doesn't want to stow absolute symlinks because of this code. Why?

To reproduce:

$ mkdir -p /tmp/temp/stow ; cd /tmp/temp/stow
$ mkdir pkg
$ ln -s /run/systemd/resolve/resolv.conf pkg/resolv.conf
$ stow -t /tmp/temp -d . -S pkg
WARNING! stowing pkg would cause conflicts:
  * source is an absolute symlink stow/pkg/resolv.conf => /run/systemd/resolve/resolv.conf
All operations aborted.

$ find /tmp/temp '!' -type d -printf "%p -> %l\n"
/tmp/temp/stow/pkg/resolv.conf -> /run/systemd/resolve/resolv.conf

Well, I can create a temporary directory with this absolute link and make the stow-ed link relative to that link, like:

$ cd /tmp/temp/stow
$ mkdir -p /tmp/temp/stow/somedir
$ ln -s  /run/systemd/resolve/resolv.conf somedir/resolv.conf
$ ln -sf ../somedir/resolv.conf pkg/resolv.conf
$ stow -t /tmp/temp -d . -v -S pkg
LINK: resolv.conf => stow/pkg/resolv.conf

$ find /tmp/temp '!' -type d -printf "%p -> %l\n"
/tmp/temp/resolv.conf -> stow/pkg/resolv.conf
/tmp/temp/stow/stupid/resolv.conf -> /run/systemd/resolve/resolv.conf
/tmp/temp/stow/pkg/resolv.conf -> ../stupid/resolv.conf

but that looks strange as it requires a temporary directory that does nothing really. Alternatively a directory may be added with the absolute symlink, relative symlink to that directory and that directory is listed in --ignore rules.

Is there specific reason why absolute symlinks from stow directory can't be stow-ed? If so, is a symlink to an absolute symlink going to cause any harm? Why care and not just stow a symlink to that absolute symlink just as-if it would be a file?

Another alternative is making my symlink relative to repo location, like ln -s ../../../../constant_count_of_../../../run/systemd/resolve/resolv.conf, but that's assuming I will clone my repo to the same dir.

I tried searching/reading https://lists.gnu.org/archive/html/stow-devel/2009-11/msg00000.html and the issues here, but didn't find anything, I would appreciate some pointers.

aspiers commented 3 years ago

Yeah, this is a known limitation and I think this issue is a duplicate of #51 - does that sound right to you?

See also https://github.com/aspiers/stow/issues/65#issuecomment-816017217.

aspiers commented 3 years ago

Is there specific reason why absolute symlinks from stow directory can't be stow-ed? If so, is a symlink to an absolute symlink going to cause any harm? Why care and not just stow a symlink to that absolute symlink just as-if it would be a file?

I think the simple answer is probably that this simply wasn't tested yet, so it can't be officially supported until it's tested. But as per the last comment, maybe I can fix that soonish.

Kamilcuk commented 3 years ago

does that sound right to you?

Yes! I missed that issue. Thank you ;)