Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 771708 - desktop.eclass: make_desktop_entry .desktop naming overlaps for a same command with different arguments
Summary: desktop.eclass: make_desktop_entry .desktop naming overlaps for a same comman...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords: PullRequest
Depends on:
Blocks:
 
Reported: 2021-02-20 09:41 UTC by Sergey Torokhov
Modified: 2022-10-20 06:27 UTC (History)
4 users (show)

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


Attachments
Patch for desktop.eclass (desktop.eclass.diff,942 bytes, patch)
2021-02-21 12:40 UTC, Ulrich Müller
Details | Diff
Patch for desktop.eclass v2 (0001-desktop.eclass-Avoid-file-collisions-in-make_desktop.patch,1.61 KB, patch)
2021-02-21 15:07 UTC, Ulrich Müller
Details | Diff
Special case to avoid foo-foo.desktop (desktop.eclass.diff,1.19 KB, patch)
2022-09-25 09:36 UTC, Ulrich Müller
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sergey Torokhov 2021-02-20 09:41:35 UTC
app-doc/cantera-docs [1] has 2 calls of "make_desktop_entry" function to cteate items for different html files:

make_desktop_entry "/usr/bin/xdg-open /usr/share/cantera/doc/doxygen/html/index.html" "Cantera Doxygen Documentation" "text-html" "Development"
	make_desktop_entry "/usr/bin/xdg-open /usr/share/cantera/doc/sphinx/html/index.html" "Cantera Sphinx Documentation" "text-html" "Development"

But the second call creates .desktop file with the same name as first call, i.e. "/usr/share/applications/xdg-open-cantera-docs.desktop" resulting in rewriting the first created item for Doxygen documentation.

It seems such behaviour takes place after changes in commit [2] for desktop.eclass.

Is it way to force creation of *.desktop items with different names or it's better after call of "make_desktop_entry" to rename desktop item with smth. like:

...
mv xdg-open-{,doxygen-}cantera-docs.desktop
...
mv xdg-open-{,sphinx-}cantera-docs.desktop

?

[1] https://gitweb.gentoo.org/repo/gentoo.git/tree/app-doc/cantera-docs/cantera-docs-2.4.0.ebuild
[2] https://gitweb.gentoo.org/repo/gentoo.git/commit/eclass/desktop.eclass?id=2884bb5a7f44da2fcca598329ce14bff0d12289c

Reproducible: Always
Comment 1 Ionen Wolkens gentoo-dev 2021-02-20 13:01:41 UTC
I'm hesitant to call this a eclass issue given the naming before this eclass change, while safer, was kind of ridiculous:
/usr/share/applications/_usr_bin_xdg-open__usr_share_cantera_doc_doxygen_html_index.html-cantera-docs.desktop
/usr/share/applications/_usr_bin_xdg-open__usr_share_cantera_doc_sphinx_html_index.html-cantera-docs.desktop

Having ebuilds workaround this may(?) make more sense, from a quick look there's only 3 affected packages that use the same command with different arguments:
- app-doc/cantera-docs
- app-misc/oneko
- games-roguelike/angband (if USE=X and USE=sdl at same time)

But I guess it'd be handy if the eclass function let you manually specify the name rather than force-guess and rename after, or perhaps have a failsafe to prevent overwriting.
Comment 2 Ionen Wolkens gentoo-dev 2021-02-20 13:23:43 UTC
Or perhaps incorporating (at least) arguments again would make sense, it's (usually) not that invasive unlike the command's full path.

Those 3 packages would need revbumps to get their desktop entries corrected either way though.
Comment 3 Ulrich Müller gentoo-dev 2021-02-20 20:10:12 UTC
I think the rationale for that eclass change still applies. We don't want filenames like links_-g_%u-links-2.desktop.

(In reply to Ionen Wolkens from comment #2)
> Or perhaps incorporating (at least) arguments again would make sense, it's
> (usually) not that invasive unlike the command's full path.

Even without the command's path the file would be named xdg-open__usr_share_cantera_doc_doxygen_html_index.html-cantera-docs.desktop. Of course we could try to shorten the arguments in some clever way, but I'd rather not open that can of worms.

Maybe make_desktop_entry() should have an optional sixth argument that would allow to override the filename?
Comment 4 Sergey Torokhov 2021-02-20 20:38:10 UTC
As there are only 3 package I assume it reasonable currently to rename entries after creation. At least if changes in *.desktop files naming aren't planning near future.
Comment 5 Ionen Wolkens gentoo-dev 2021-02-20 22:21:04 UTC
(In reply to Ionen Wolkens from comment #1)
> or perhaps have a failsafe to prevent overwriting.
How about checking if the .desktop file already exists and adding a -2 -3.. to the filename?
Comment 6 Ulrich Müller gentoo-dev 2021-02-21 12:40:50 UTC
Created attachment 687915 [details, diff]
Patch for desktop.eclass

(In reply to Ionen Wolkens from comment #5)
> How about checking if the .desktop file already exists and adding a -2 -3..
> to the filename?

Yeah, that would work too. Can you test attached patch for desktop.eclass?
Comment 7 Ionen Wolkens gentoo-dev 2021-02-21 13:07:55 UTC
(In reply to Ulrich Müller from comment #6)
> Can you test attached patch for desktop.eclass?
LGTM, tried the aforementioned packages and a few other tests (also prefix), and working as expected:
/home/ionen/prefix/usr/share/applications/oneko-oneko.desktop
/home/ionen/prefix/usr/share/applications/oneko-oneko-1.desktop
/home/ionen/prefix/usr/share/applications/killall-oneko.desktop
Comment 8 Ulrich Müller gentoo-dev 2021-02-21 14:35:09 UTC
Posted to gentoo-dev for review:
https://archives.gentoo.org/gentoo-dev/message/bc21732d1dcd5df1abea8e956b901f2d
Comment 9 Ulrich Müller gentoo-dev 2021-02-21 15:06:34 UTC
(In reply to Ionen Wolkens from comment #7)
> /home/ionen/prefix/usr/share/applications/oneko-oneko.desktop
> /home/ionen/prefix/usr/share/applications/oneko-oneko-1.desktop

Thinking about it, this could cause problems for a package with multiple slots, e.g. foo:0 and foo:1.

foo:0 would install these files:
/usr/share/applications/foo-foo.desktop
/usr/share/applications/foo-foo-1.desktop

and foo:1 these:
/usr/share/applications/foo-foo-1.desktop
/usr/share/applications/foo-foo-1-1.desktop

So I guess the counter should be added after the executable name, not after the package name, i.e. foo-foo.desktop, foo-1-foo.desktop etc.
Comment 10 Ulrich Müller gentoo-dev 2021-02-21 15:07:15 UTC
Created attachment 687927 [details, diff]
Patch for desktop.eclass v2
Comment 11 Ionen Wolkens gentoo-dev 2021-02-21 15:33:39 UTC
v2 looks good:
/home/evan/prefix/usr/share/applications/oneko-oneko.desktop
/home/evan/prefix/usr/share/applications/oneko-1-oneko.desktop
/home/evan/prefix/usr/share/applications/killall-oneko.desktop

Dummy test with slot 0,1 and 3 entries for same command + another:
/usr/share/applications/foo-foomatic.desktop
/usr/share/applications/foo-1-foomatic.desktop
/usr/share/applications/foo-2-foomatic.desktop
/usr/share/applications/fnord-foomatic.desktop

/usr/share/applications/foo-foomatic-1.desktop
/usr/share/applications/foo-1-foomatic-1.desktop
/usr/share/applications/foo-2-foomatic-1.desktop
/usr/share/applications/fnord-foomatic-1.desktop
Comment 12 Sergey Torokhov 2021-02-24 14:37:46 UTC
Looks suitable. Waiting for merge before app-doc/cantera-docs-2.5.1 version bump
Comment 13 Larry the Git Cow gentoo-dev 2021-02-24 15:33:33 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f6212ee060d6a2962ac27cf57ffd721d14b64215

commit f6212ee060d6a2962ac27cf57ffd721d14b64215
Author:     Ulrich Müller <ulm@gentoo.org>
AuthorDate: 2021-02-21 14:13:21 +0000
Commit:     Ulrich Müller <ulm@gentoo.org>
CommitDate: 2021-02-24 15:32:07 +0000

    desktop.eclass: Avoid file collisions in make_desktop_entry()
    
    Closes: https://bugs.gentoo.org/771708
    Reported-by: Sergey Torokhov <torokhov-s-a@yandex.ru>
    Suggested-by: Ionen Wolkens <sudinave@gmail.com>
    Signed-off-by: Ulrich Müller <ulm@gentoo.org>

 eclass/desktop.eclass | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
Comment 14 orbea 2022-09-25 05:04:58 UTC
What's up with the 'foo-foo.desktop'? Wouldn't it be better for it to be just 'foo.desktop'?
Comment 15 Ulrich Müller gentoo-dev 2022-09-25 09:36:09 UTC
Created attachment 814063 [details, diff]
Special case to avoid foo-foo.desktop

(In reply to orbea from comment #14)
> What's up with the 'foo-foo.desktop'? Wouldn't it be better for it to be
> just 'foo.desktop'?

Yes, that is somewhat ugly.

We could of course avoid it, as in attached patch. Not sure if it's worthwhile, because it will slightly complicate the code, and there doesn't seen to be any technical problem with the name foo-foo.desktop.
Comment 16 orbea 2022-09-25 16:19:11 UTC
I'm not sure either, but I just want to make it clear I spent maybe half an hour trying to figure out what I was doing wrong before I found this issue. :)
Comment 17 Larry the Git Cow gentoo-dev 2022-10-20 06:27:45 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=21e613fe5efe6cdee4b5f7fc0473de14ff880ed3

commit 21e613fe5efe6cdee4b5f7fc0473de14ff880ed3
Author:     Ulrich Müller <ulm@gentoo.org>
AuthorDate: 2022-10-01 08:28:19 +0000
Commit:     Ulrich Müller <ulm@gentoo.org>
CommitDate: 2022-10-20 06:25:42 +0000

    desktop.eclass: Install files as foo.desktop rather than foo-foo.desktop
    
    Bug: https://bugs.gentoo.org/771708#c14
    Signed-off-by: Ulrich Müller <ulm@gentoo.org>

 eclass/desktop.eclass | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)