Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 708360 - [Future EAPI] dosym -r to create relative symlinks
Summary: [Future EAPI] dosym -r to create relative symlinks
Status: CONFIRMED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: PMS/EAPI (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: PMS/EAPI
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: future-eapi
  Show dependency tree
 
Reported: 2020-02-05 16:41 UTC by Ulrich Müller
Modified: 2020-02-06 11:12 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ulrich Müller gentoo-dev 2020-02-05 16:41:47 UTC
Like "ln -s -r" from GNU coreutils.

Shouldn't be too difficult to emulate this in bash for non-coreutils implementations of ln. For example, eselect is already doing this:
https://gitweb.gentoo.org/proj/eselect.git/tree/libs/path-manipulation.bash.in#n69
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2020-02-05 16:53:46 UTC
It should probably come with a big fat note that it won't figure out symlinks if they get in the way.
Comment 2 Ulrich Müller gentoo-dev 2020-02-05 17:31:51 UTC
(In reply to Michał Górny from comment #1)
> It should probably come with a big fat note that it won't figure out
> symlinks if they get in the way.

Relative symlinks should work, I think, because the paths are canonicalised. If the image in ${D} contains absolute links then you lose of course.
Comment 3 Ulrich Müller gentoo-dev 2020-02-05 17:38:58 UTC
In #gentoo-qa we came up with this:
- dosym without option accepts only a relative path as first argument
- dosym -r expands the first arg relative to the link location
- dosym -l (or -a for "absolute"?) treats the first arg as a literal string
Comment 4 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2020-02-05 17:43:47 UTC
(In reply to Ulrich Müller from comment #2)
> (In reply to Michał Górny from comment #1)
> > It should probably come with a big fat note that it won't figure out
> > symlinks if they get in the way.
> 
> Relative symlinks should work, I think, because the paths are canonicalised.
> If the image in ${D} contains absolute links then you lose of course.

I meant directory symlinks along the way.

E.g.:

ROOT has /a/b -> ../c
D has plain /a/b directory
you 'dosym -r /a/d /a/b/c'
you get ../d as target

I think we should just make it clear that '-d' doesn't work if there are directory symlinks along the way, whether they are reproduced in D or not.
Comment 5 Ulrich Müller gentoo-dev 2020-02-06 11:12:25 UTC
I think the spec would define that both target and directory will be canonicalised by the same algorithm as used in "readlink -f". Portage already has a canonicalize() shell replacement in misc-functions.sh, so we don't have to worry about systems where readlink doesn't support the -f option.

Alternatively, we could canonicalise using "realpath -m -s" from >=coreutils-8.15, which would purely act on the string, without looking at the filesystem. But IMHO that would be inferior to the above method.