Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 379899 - [Tracker] Ebuilds calling dosym with directory as second argument
Summary: [Tracker] Ebuilds calling dosym with directory as second argument
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: QAcanfix, Tracker
Depends on: 380269
Blocks: 619102
  Show dependency tree
 
Reported: 2011-08-19 21:04 UTC by Petr Prokhorenkov
Modified: 2022-04-15 08:29 UTC (History)
5 users (show)

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


Attachments
dosym: Make implicit basename a fatal error. (0001-dosym-Make-implicit-basename-a-fatal-error.patch,1.14 KB, patch)
2017-04-15 09:12 UTC, Ulrich Müller
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Prokhorenkov 2011-08-19 21:04:29 UTC
The ebuild goes at lines 142-143:
             dosym /${BASE}/bin/kcm_adobe_flash_player.so \
                 /usr/$(get_libdir)/kde4/
Which looks like incorrect usage of dosym according to http://dev.gentoo.org/~ulm/pms/4/pms.html. Second argument must be full path to intended symlink, not just directory. This very thing breaks install when paludis is used instead of emerge.


Reproducible: Always

Steps to Reproduce:
1.Try to install said package with paludis.
Actual Results:  
Does not install.

Expected Results:  
Installs.
Comment 1 Maxim Koltsov (RETIRED) gentoo-dev 2011-08-19 21:36:19 UTC
Internally dosym just calls 'ln -snf $1 $2', so directory as second argument is acceptable for 'ln'. See /usr/lib/portage/bin/ebuild-helpers/dosym.
Comment 2 Brian Harring (RETIRED) gentoo-dev 2011-08-19 22:05:32 UTC
@maxim: the point of PMS isn't about what portage innards happen to do (which varies across versions/years)- it's about what ebuild authors can *expect*.

The ebuild's wrong; the second arg needs to be the full path (name included), rather than just the directory target.

@Zac: that invocation should be changed to -T; as is, mkdir foon; dosym blah /foon would invalidly succeed going by a quick read...
Comment 3 Zac Medico gentoo-dev 2011-08-19 22:18:59 UTC
(In reply to comment #2)
> @Zac: that invocation should be changed to -T; as is, mkdir foon; dosym blah
> /foon would invalidly succeed going by a quick read...

Looking at the single-unix docs, I'm not sure if -T is portable:

  http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ln.html

Anyway, we can easily emulate -T a line or two of shell code.
Comment 4 Brian Harring (RETIRED) gentoo-dev 2011-08-19 22:22:26 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > @Zac: that invocation should be changed to -T; as is, mkdir foon; dosym blah
> > /foon would invalidly succeed going by a quick read...
> 
> Looking at the single-unix docs, I'm not sure if -T is portable:
> 
>   http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ln.html
> 
> Anyway, we can easily emulate -T a line or two of shell code.

The '-n' usage in portage also isn't covered PMS wise; I'd be inclined to retroactively update the spec on that one if it's desirable (it's been in portage that way for a while afaik).
Comment 5 Ulrich Müller gentoo-dev 2011-08-20 07:57:12 UTC
(In reply to comment #2)
> The ebuild's wrong; the second arg needs to be the full path (name included),
> rather than just the directory target.

Looks like PMS is not accurate here, as Portage has always accepted a directory as second argument. IMO we should mention that case in the spec.
Comment 6 David Leverton 2011-08-21 12:14:07 UTC
Just for the record, the precise reason why this fails in Paludis is that when automatically creating the destination directory, Paludis uses $(dirname ${2}) whereas Portage uses ${2/%}.  If ${2} ends in a /, then the Portage version is essentially equivalent to ${2} itself, so Portage creates the required directory and then the ln command creates the symlink as expected.  However, the Paludis version only creates the parent of the desired directory, and then ln fails because it's sensitive to the trailing / and expects it to name an existing directory.

If we do want to allow this in the spec, then the wording will need to cover this carefully as it's fairly subtle.
Comment 7 Ulrich Müller gentoo-dev 2011-08-21 13:40:34 UTC
"If the second parameter is a directory or ends with a slash, then append the last pathname component of the first parameter, before doing any further action."?
Comment 8 Zac Medico gentoo-dev 2011-08-21 16:20:03 UTC
The current portage behavior dates back to v2.1_pre8:

  http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=2f4af673720d8230c31fb72e5686fcae6bbd1ec8
Comment 9 Brian Harring (RETIRED) gentoo-dev 2011-08-22 11:22:04 UTC
(In reply to comment #5)
> (In reply to comment #2)
> > The ebuild's wrong; the second arg needs to be the full path (name included),
> > rather than just the directory target.
> 
> Looks like PMS is not accurate here, as Portage has always accepted a directory
> as second argument. IMO we should mention that case in the spec.

If PMS behaviour conflicted with portage, that line of thought would apply; what PMS specifies is a controlled subset of portage behaviour.  The PMS form works fine w/ portage- portage (and pkgcore up until a recent rev) were loose in what they allowed however, while paludis wasn't.  That notion strongly makes me think the ebuilds need fixing rather than the spec.

Offhand, there are ~4800 dosym invocations in the tree; a quick scan of it, about ~80 versions that look to rely on the second arg as a directory (only ~30 w/ explicit / to force it).

Mind you, those are *rough* stats, but I'm seeing ~2% potential, w/ <1% confirmed... well, makes me think the ebuilds need a fixin instead ;)
Comment 10 Ulrich Müller gentoo-dev 2011-08-22 11:59:36 UTC
(In reply to comment #9)
> If PMS behaviour conflicted with portage, that line of thought would apply;
> what PMS specifies is a controlled subset of portage behaviour.  The PMS form
> works fine w/ portage- portage (and pkgcore up until a recent rev) were loose
> in what they allowed however, while paludis wasn't.  That notion strongly
> makes me think the ebuilds need fixing rather than the spec.

The problem is that we cannot prevent such usage in the tree, unless Portage will flag an error for the second argument being a directory. And if it is made an error, then breakage will occur for the non-conforming packages.
Comment 11 Ciaran McCreesh 2011-08-22 12:04:07 UTC
Non-conforming packages are already broken. All making it error out would do is make that breakage visible so it can be fixed.
Comment 12 Ulrich Müller gentoo-dev 2011-08-22 12:15:32 UTC
They may be broken, but for most users that doesn't have any effect. Making it "visible" means that we break users' stable systems.
Comment 13 Ciaran McCreesh 2011-08-22 12:19:19 UTC
Making it visible means breakage gets identified and fixed.
Comment 15 Ulrich Müller gentoo-dev 2011-08-22 17:06:46 UTC
(In reply to comment #14)
> I've added a QA Notice to portage:
> 
> http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=05b3e2b245630505fa5f581fbdf0531d00cb0b93

Shouldn't it also warn if ${D}$2 is an existing directory?
Comment 16 Zac Medico gentoo-dev 2011-08-22 17:36:25 UTC
(In reply to comment #15)
> (In reply to comment #14)
> > I've added a QA Notice to portage:
> > 
> > http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=05b3e2b245630505fa5f581fbdf0531d00cb0b93
> 
> Shouldn't it also warn if ${D}$2 is an existing directory?

Okay, done:

http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=3534aa843f22e84f5dd79a8306605d5178ec76c3
Comment 17 Brian Harring (RETIRED) gentoo-dev 2011-08-24 08:41:52 UTC
it visible"; making it a qa warning is wrong; it's not QA, it's broken, and the list of offending packages include quite a few crufty ones which aren't going to get updated anytime soon I'd expect.

In that respect Ulm, I very much disagree about "we must never break the tree"; the tree is *broken* for 2/3 managers for those packages.  Admittedly that percentile of users (versus portage) is less, but the line of thought being pursued there is basically "shit on the compliant implementations" which isn't exactly a great reward for doing things right.  Recall EAPI0 was passed, and ebuilds were supposed to match it; those are broke ebuilds.  It happens, but you really should be looking at the tree from that angle rather than the angle you/zac are pursuing.

As for 3534aa843f22e84f5dd79a8306605d5178ec76c3, the rules of dosym replacing an existing sym/file/whatever are fairly vague; this is an area we should tighten PMS up on.

Either way, my stance is convert it into an error; portage sits in unstable for a while upon release, during that interval the offending packages must be updated (I'll generate that list later in the week); regardless of portage, they need updating since they're incorrect and causing breakage.
Comment 18 Brian Harring (RETIRED) gentoo-dev 2011-08-24 08:42:47 UTC
(In reply to comment #17)
> it visible"; making it a qa warning is wrong; it's not QA, it's broken, and the
> list of offending packages include quite a few crufty ones which aren't going
> to get updated anytime soon I'd expect.

Pardon the crap at the front of the comment; unix copy/paste strikes again... ;)
Comment 19 SpanKY gentoo-dev 2011-08-24 15:34:43 UTC
i would consider this a useful feature worth adding to the PMS so that things do work in future EAPIs.  `dosym` is analogous to `ln`, and `ln` allows dir arguments where the filename is implicit based on the source basename, so keeping things "least surprise" and "just works" is a good thing.
Comment 20 Ulrich Müller gentoo-dev 2011-08-24 16:23:53 UTC
(In reply to comment #17)
> In that respect Ulm, I very much disagree about "we must never break the
> tree"; the tree is *broken* for 2/3 managers for those packages. Admittedly
> that percentile of users (versus portage) is less, but the line of thought
> being pursued there is basically "shit on the compliant implementations"
> which isn't exactly a great reward for doing things right. Recall EAPI0 was
> passed, and ebuilds were supposed to match it; those are broke ebuilds. It
> happens, but you really should be looking at the tree from that angle rather
> than the angle you/zac are pursuing.

First, I agree that ebuilds must be fixed. Second, the point is not about "not breaking the tree", but about imposing such breakage on our users.

Therefore, it should stay a QA warning until we think that we have fixed all non-compliant cases (which is trivial once they've been identified). Only _then_ the warning should be changed into an error.
Comment 21 Jim Ramsay (lack) (RETIRED) gentoo-dev 2011-08-31 16:16:11 UTC
Perhaps the devmanual (http://devmanual.gentoo.org/function-reference/install-functions/index.html) could also be updated to make note of this specific difference between 'ln -s' and 'dosym'?
Comment 22 Brian Harring (RETIRED) gentoo-dev 2011-11-17 09:23:34 UTC
...what's going on with this?  I'm seeing *new* ebuilds showing up with it...
Comment 23 Zac Medico gentoo-dev 2011-11-17 14:49:23 UTC
(In reply to comment #22)
> ...what's going on with this?  I'm seeing *new* ebuilds showing up with it...

Well, the QA notice isn't in stable portage yet. It was released in portage-2.1.10.12 and 2.2.0_alpha52.
Comment 24 Brian Harring (RETIRED) gentoo-dev 2011-11-17 21:39:42 UTC
(In reply to comment #23)
> (In reply to comment #22)
> > ...what's going on with this?  I'm seeing *new* ebuilds showing up with it...
> 
> Well, the QA notice isn't in stable portage yet. It was released in
> portage-2.1.10.12 and 2.2.0_alpha52.

Being that it's been 3 months, situation hasn't improved, and realistically this isn't going to be sorted in the next 6,  well... adhering to the spec, instead of just changing the fucking spec to be accurate is costing us a lot of pain here.

As such, pkgcore 0.7.5-r2 will land in the tree shortly supporting the "2nd arg is a directory" form of dosym.  Consider that my strong suggestion that the spec be changed to match reality (since cleaning the tree requires a full tinderbox run), and if people actually want this crap, to add it in EAPI5.

Either way, seen enough breakage adhering to the spec, so... y'all sort it out.
Comment 25 Ulrich Müller gentoo-dev 2017-04-15 09:04:18 UTC
The QA warning is in place since more than 5 years, so maybe it is time to make this a fatal error?
Comment 26 Ulrich Müller gentoo-dev 2017-04-15 09:12:51 UTC
Created attachment 470084 [details, diff]
dosym: Make implicit basename a fatal error.
Comment 27 Toralf Förster gentoo-dev 2017-04-17 08:43:20 UTC
(In reply to Ulrich Müller from comment #26)
$ fgrep -Hr 'QA Notice: dosym target omits basename:' ~/img?/*/var/log/portage/elog/ | cut -f1-2 -d':'  | xargs -n1 basename | sort -u
app-emacs:slime-2.0_p20101103
media-gfx:nip2-7.26.4
media-gfx:nip2-7.38.1
www-apps:novnc-0.6.1
www-apps:novnc-0.6.2

;)
Comment 28 Ulrich Müller gentoo-dev 2017-04-17 10:04:46 UTC
(In reply to Toralf Förster from comment #27)
> app-emacs:slime-2.0_p20101103
> media-gfx:nip2-7.26.4
> media-gfx:nip2-7.38.1
> www-apps:novnc-0.6.1
> www-apps:novnc-0.6.2

Thank you.

All fixed:
f41039250c57 www-apps/novnc: [QA] Use complete path as second argument of dosym.
182444c044c9 media-gfx/nip2: [QA] Use complete path as second argument of dosym.
62a4ef94dfcc app-emacs/slime: Use complete path as second argument of dosym.
Comment 29 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-04-15 08:07:26 UTC
(In reply to Ulrich Müller from comment #26)
> Created attachment 470084 [details, diff] [details, diff]
> dosym: Make implicit basename a fatal error.

hm, did we never commit this?
Comment 30 Ulrich Müller gentoo-dev 2022-04-15 08:13:20 UTC
(In reply to Sam James from comment #29)
> (In reply to Ulrich Müller from comment #26)
> > Created attachment 470084 [details, diff] [details, diff] [details, diff]
> > dosym: Make implicit basename a fatal error.
> 
> hm, did we never commit this?

https://gitweb.gentoo.org/proj/portage.git/commit/?id=c40c39537d584f57e449d3525e92fafbe85517fd
Comment 31 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-04-15 08:18:02 UTC
(In reply to Ulrich Müller from comment #30)
> (In reply to Sam James from comment #29)
> > (In reply to Ulrich Müller from comment #26)
> > > Created attachment 470084 [details, diff] [details, diff] [details, diff] [details, diff]
> > > dosym: Make implicit basename a fatal error.
> > 
> > hm, did we never commit this?
> 
> https://gitweb.gentoo.org/proj/portage.git/commit/
> ?id=c40c39537d584f57e449d3525e92fafbe85517fd

Thanks!