Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 931673 - x11-misc/xdg-utils: Commands "xdg-mime [query] default" STILL PRODUCES WRONG RESULTS.
Summary: x11-misc/xdg-utils: Commands "xdg-mime [query] default" STILL PRODUCES WRONG ...
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: x86 Linux
: Normal normal
Assignee: Freedesktop bugs
URL:
Whiteboard:
Keywords: UPSTREAM
Depends on:
Blocks:
 
Reported: 2024-05-10 13:44 UTC by Rainer W
Modified: 2024-08-16 00:32 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 Rainer W 2024-05-10 13:44:54 UTC
See test script below.

Reproducible: Always

Steps to Reproduce:
#! /bin/bash
cd /tmp
export XDG_CONFIG_HOME=$PWD XDG_DATA_DIRS=$PWD XDG_DATA_HOME=$PWD
mkdir                           applications
echo 'Exec=true a %u'        >  applications/a.desktop
echo 'MimeType=x/a;x/b;x/c;' >> applications/a.desktop
echo 'Exec=true b %u'        >  applications/b.desktop
echo 'MimeType=x/a;x/b;x/c;' >> applications/b.desktop
xdg-mime query default x/a
xdg-mime default b.desktop x/a
xdg-mime query default x/a
rm -rf applications

Actual Results:  
a.desktop
a.desktop


Expected Results:  
a.desktop
b.desktop


Fails since installing "=x11-misc/xdg-utils-1.2.1-r1".
Definitely worked with "=x11-misc/xdg-utils-1.1.3_p20200220-r1" and most probably also with "=x11-misc/xdg-utils-1.1.3_p20210805-r2".
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-05-11 02:46:33 UTC
Thank you. Reported upstream as https://gitlab.freedesktop.org/xdg/xdg-utils/-/issues/252.
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-05-11 02:50:32 UTC
(In reply to Sam James from comment #1)
> Thank you. Reported upstream as
> https://gitlab.freedesktop.org/xdg/xdg-utils/-/issues/252.

Bisected to https://gitlab.freedesktop.org/xdg/xdg-utils/-/commit/9b7d253ca07b80fbc201c5cf5b7f14a49bd09b3f and reverting it restores the old behaviour...
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-05-12 23:05:04 UTC
Rainer, could you try https://gitlab.freedesktop.org/xdg/xdg-utils/-/merge_requests/115.patch in /etc/portage/patches/x11-misc/xdg-utils/bug931673.patch, re-emerge xdg-utils, and see if it helps? Thanks.
Comment 4 Rainer W 2024-05-13 15:27:17 UTC
Sadly, it didn't work:

# emerge --changed-use --update x11-misc/xdg-utils

[ebuild     U ] x11-misc/xdg-utils-1.2.1-r1 [1.1.3_p20210805-r2]

Would you like to merge these packages? [Yes/No] y
>>> Verifying ebuild manifests
>>> Emerging (1 of 1) x11-misc/xdg-utils-1.2.1-r1::gentoo
>>> Failed to emerge x11-misc/xdg-utils-1.2.1-r1, Log file:
>>>  '/var/log/portage/build/x11-misc/xdg-utils-1.2.1-r1:20240513-143132.log'
 * Error messages for package x11-misc/xdg-utils-1.2.1-r1:
 * ERROR: x11-misc/xdg-utils-1.2.1-r1::gentoo failed (prepare phase):
 *   patch -p1  failed with /etc/portage/patches/x11-misc/xdg-utils/bug931673.patch
 * 
 * Call stack:
 *               ebuild.sh, line  136:  Called src_prepare
 *             environment, line 1674:  Called default
 *      phase-functions.sh, line  872:  Called default_src_prepare
 *      phase-functions.sh, line  948:  Called __eapi8_src_prepare
 *             environment, line  357:  Called eapply_user
 *             environment, line  842:  Called eapply '/etc/portage/patches/x11-misc/xdg-utils/bug931673.patch'
 *             environment, line  805:  Called _eapply_patch '/etc/portage/patches/x11-misc/xdg-utils/bug931673.patch'
 *             environment, line  743:  Called __helpers_die 'patch -p1  failed with /etc/portage/patches/x11-misc/xdg-utils/bug931673.patch'
 *   isolated-functions.sh, line  112:  Called die
 * The specific snippet of code:
 *   		die "$@"
...
#

Not sure what I did wrong.  But afterwards manually applying the patch to the still unchanged file "/var/tmp/.../scripts/xdg-utils-common.in" did succeed.  So the patch WAS applicable :-\

But I'm again back to version 1.1.3_p20210805-r2 which by the way works flawlessly.
Comment 5 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-05-14 02:31:11 UTC
Can you show me the full build.log? It should have more info as to why it failed.

Maybe just try clone it from git and do './configure && make' and point your script to the version it just made?
Comment 6 Rainer W 2024-05-14 09:36:02 UTC
(In reply to Sam James from comment #5)
> Can you show me the full build.log? It should have more info as to why it
> failed.

Not really:

...
 *   		die "$@"
 * 
 * If you need support, post the output of `emerge --info '=x11-misc/xdg-utils-1.2.1-r1::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=x11-misc/xdg-utils-1.2.1-r1::gentoo'`.
 * The complete build log is located at '/var/log/portage/build/x11-misc/xdg-utils-1.2.1-r1:20240513-143132.log'.
 * For convenience, a symlink to the build log is located at '/var/tmp/portage/x11-misc/xdg-utils-1.2.1-r1/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/x11-misc/xdg-utils-1.2.1-r1/temp/environment'.
 * Working directory: '/var/tmp/portage/x11-misc/xdg-utils-1.2.1-r1/work/xdg-utils-v1.2.1'
 * S: '/var/tmp/portage/x11-misc/xdg-utils-1.2.1-r1/work/xdg-utils-v1.2.1'

> 
> Maybe just try clone it from git and do './configure && make' and point your
> script to the version it just made?

Wasn't that what you already successfully did by bisecting using my 12-lines test script and reverting a particular changeset?
Comment 7 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-05-14 09:57:28 UTC
That part you pasted is not the build.log, it's part of the terminal. The build.log (the path of which is given in the output) should include the failed patch output.

wrt testing: I was assuming you had an original case which was worth testing too, and not so simplified. If it really was almost identical to the thing you posted in your first comment, then fair enough, I guess?
Comment 8 Rainer W 2024-05-14 10:30:36 UTC
(In reply to Sam James from comment #7)
> That part you pasted is not the build.log, it's part of the terminal. The
> build.log (the path of which is given in the output) should include the
> failed patch output.

Sorry, no.  Both snippets together make up the complete contents of file
"/var/log/portage/build/x11-misc/xdg-utils-1.2.1-r1:20240513-143132.log".

> wrt testing: I was assuming you had an original case which was worth testing
> too, and not so simplified. If it really was almost identical to the thing
> you posted in your first comment, then fair enough, I guess?

The 12-lines test script was an excerpt from a real test script solely used to
test a script of mine.  This test script failed, and after some head scratching
and experimenting I decided that "xdg-mime default" had just started to do the wrong thing :-)

So there really isn't a "real life case" involved.
Comment 9 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-06-01 03:09:50 UTC
Thank you for explaining!
Comment 10 Larry the Git Cow gentoo-dev 2024-06-01 03:31:08 UTC
The bug has been closed via the following commit(s):

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

commit 43a36b89fbd4f4a108e70381e80c6e261256f407
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-06-01 03:11:41 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-06-01 03:11:41 +0000

    x11-misc/xdg-utils: fix xdg-mime default regression
    
    Closes: https://bugs.gentoo.org/931673
    Signed-off-by: Sam James <sam@gentoo.org>

 .../files/xdg-utils-1.2.1-xdg-mime-default.patch   | 143 +++++++++++++++++++++
 x11-misc/xdg-utils/xdg-utils-1.2.1-r2.ebuild       |  92 +++++++++++++
 2 files changed, 235 insertions(+)
Comment 11 Rainer W 2024-06-01 14:38:16 UTC
Sorry, but I cannot confirm this.

I upgraded to non-stable "=x11-misc/xdg-utils-1.2.1-r2", even booted my system, but my little test script still outputs 

   a.desktop
   a.desktop
Comment 12 Rainer W 2024-06-01 14:58:55 UTC
No, sorry, forget that, it now returns

   b.desktop
   b.desktop

The first (implicit) default setting seems to be (now?) arbitrary.

But explicitly setting

   xdg-mime default a.desktop x/a
   xdg-mime query default x/a

now returns

   a.desktop
Comment 13 Rainer W 2024-06-01 16:10:17 UTC
Seems not to be my day :-(

I now added "xdg-mime --version" to stop the confusion and also added another change of the default:

#! /bin/bash
cd /tmp
export XDG_CONFIG_HOME=$PWD XDG_DATA_DIRS=$PWD XDG_DATA_HOME=$PWD
mkdir                           applications
echo 'Exec=true a %u'        >  applications/a.desktop
echo 'MimeType=x/a;x/b;x/c;' >> applications/a.desktop
echo 'Exec=true b %u'        >  applications/b.desktop
echo 'MimeType=x/a;x/b;x/c;' >> applications/b.desktop
xdg-mime --version
xdg-mime query default x/a
xdg-mime default a.desktop x/a
xdg-mime query default x/a
xdg-mime default b.desktop x/a
xdg-mime query default x/a
rm -rf applications

Results:

xdg-mime 1.2.1
a.desktop
a.desktop
a.desktop

xdg-mime 1.1.3+
b.desktop
a.desktop
b.desktop

I cannot say for sure whether in my earlier tests the first output line (before a default was set) was really "a.desktop".  Could this be undetermined?  But in any case the new version still ignores setting the default.
Comment 14 Rainer W 2024-08-12 09:51:52 UTC
(In reply to Rainer W from comment #13)

I've meanwhile tested x11-misc/xdg-utils-1.2.1-r6 and it still refuses to set the default to "b.desktop" when running the test script below:

> ...
> #! /bin/bash
> cd /tmp
> export XDG_CONFIG_HOME=$PWD XDG_DATA_DIRS=$PWD XDG_DATA_HOME=$PWD
> mkdir                           applications
> echo 'Exec=true a %u'        >  applications/a.desktop
> echo 'MimeType=x/a;x/b;x/c;' >> applications/a.desktop
> echo 'Exec=true b %u'        >  applications/b.desktop
> echo 'MimeType=x/a;x/b;x/c;' >> applications/b.desktop
> xdg-mime --version
> xdg-mime query default x/a
> xdg-mime default a.desktop x/a
> xdg-mime query default x/a
> xdg-mime default b.desktop x/a
> xdg-mime query default x/a
> rm -rf applications
> 
> Results:
> 
> xdg-mime 1.2.1
> a.desktop
> a.desktop
> a.desktop
> 
> xdg-mime 1.1.3+
> b.desktop
> a.desktop
> b.desktop

So I've again downgraded to x11-misc/xdg-utils-1.1.3_p20210805-r2 :-(
Comment 15 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-08-12 09:59:41 UTC
Please report it upstream.
Comment 16 Rainer W 2024-08-15 11:50:26 UTC
(In reply to Sam James from comment #15)
> Please report it upstream.

No longer necessary.

I've meanwhile searched the Web for XDG documentation and internals and
found a few hints what could have gone wrong with my test scripts.  As
usual all hints but the last did not help, and that last hint eventually
uncovered that "xdg-utils" version 1.2.1 is just more picky with respect
to what it regards a valid desktop file: while old version 1.1.3 accepts
my minimalistic desktop files which only contained the two assignments
"Exec=..." and "MimeType=...", new version 1.2.1 now rejects these
desktop files because they don't start with the line "[Desktop Entry]"
(though it doesn't bother throwing any error messages).

So prefixing my two test desktop files with this line finally made my
test script work with both versions.

Sorry for the noise ...
Comment 17 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-08-16 00:32:20 UTC
Thank you for the closure/update!