Bug 416092 - *.pkg.tar.zst files not recognized as zstd-compressed archives
Summary: *.pkg.tar.zst files not recognized as zstd-compressed archives
Status: RESOLVED FIXED
Alias: None
Product: ark
Classification: Applications
Component: plugins (show other bugs)
Version: 19.12.1
Platform: Manjaro Linux
: NOR normal
Target Milestone: ---
Assignee: Ragnar Thomsen
URL:
Keywords:
: 419058 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-01-10 15:02 UTC by Bernhard Landauer
Modified: 2021-06-12 14:44 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bernhard Landauer 2020-01-10 15:02:32 UTC
SUMMARY
archlinux packages are now compressed by default with zstd and file names have extensions *.pkg.tar.zst
Apparently ark does recognize files *.tar.zst as zstd compressed tar-archives, but not with leading *.pkg*

STEPS TO REPRODUCE
Archive > open > set filter to "Tar archive (zstd-compressed)" or even to 'All supported files' will not display any files matching *.pkg.tar.zst

OR
Trying to open a file with extension *.pkg.tar.zst will show
"failed with the following error:
No suitable plugin found. Ark does not seem to support this file type."
while of course libarchive plugin is installed and active.

When I remove the '.pkg' bit from the file name, the archive with extension *.tar.zst is handled just fine.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Manjaro Linux 18.1.5
(available in About System)
KDE Plasma Version: 5.17.5
KDE Frameworks Version: 5.65.0
Qt Version: 5.14.0
Comment 1 Elvis Angelaccio 2020-01-12 17:55:24 UTC
Works for me. Can you run:

    QT_LOGGING_RULES="ark.*.debug=true" ark

and post here the output?
Comment 2 Bernhard Landauer 2020-01-12 19:18:21 UTC
This gives me:

ark.kerfuffle: Mimetype for filename extension ( "application/x-alpm-package" ) did not match mimetype for content ( "application/zstd" ). Using content-based mimetype.
ark.kerfuffle: Could not find a plugin to handle "foo.pkg.tar.zst"
Comment 3 Elvis Angelaccio 2020-01-19 11:27:09 UTC
(In reply to Bernhard Landauer from comment #2)
> This gives me:
> 
> ark.kerfuffle: Mimetype for filename extension (
> "application/x-alpm-package" ) 

This is the problem. Your *.pkg.tar.zst files are being detected with this mimetype, which is not supported by Ark.

From a quick google search, application/x-alpm-package seems to be a Manjaro-specific mimetype installed by their pamac tool.

Since they associate this mimetype to multiple glob patterns (no idea why), I don't think we can support it from the Ark side.
Comment 4 Bernhard Landauer 2020-01-19 12:34:34 UTC
This is not Manjaro specific, since Archlinux has switched to this new package format, all Arch-based distros will have the same issue.
Comment 5 Elvis Angelaccio 2020-01-19 14:51:39 UTC
I don't know, I'm on arch and I don't have that mimetype installed. Do you have some reference link?
Comment 6 Elvis Angelaccio 2020-04-05 15:36:42 UTC
*** Bug 419058 has been marked as a duplicate of this bug. ***
Comment 7 mirh 2020-04-14 10:56:34 UTC
https://gitlab.manjaro.org/applications/pamac/-/blob/master/data/mime/x-alpm-package.xml

Yes this is manjaro specific, made for the GUI package manager to install stuff just with a click. 

But I'm missing why Ark could not fallback to trying anyway with magic sniffing or extension matching, or ship itself with a supported MIME types xml?
https://specifications.freedesktop.org/shared-mime-info-spec/latest/ar01s02.html#idm46096015324960
Comment 8 Elvis Angelaccio 2020-07-18 17:24:32 UTC
The manjaro-specific mimetype should inherit a supported mimetype, probably application/x-tar. Then ark should be able to open those files.
Comment 9 o.hase3 2020-10-21 20:36:38 UTC
(In reply to Elvis Angelaccio from comment #8)
> The manjaro-specific mimetype should inherit a supported mimetype, probably
> application/x-tar. Then ark should be able to open those files.

I have tried this with a custom mimetype defined in ~/.local/share/mime/packages/Override.xml`, but Ark still wouldn’t open my files.

I have also created an issue on the Pamac bug tracker for this issue:
https://gitlab.manjaro.org/applications/pamac/-/issues/902

LOG
$ QT_LOGGING_RULES="ark.*.debug=true" ark <file>.pkg.tar.zst
ark.main: Trying to open QUrl("file://<file>.pkg.tar.zst")
ark.part: Attempting to open archive "<file>.pkg.tar.zst"
ark.kerfuffle: Going to create archive "<file>.pkg.tar.zst"
ark.kerfuffle: Validated filename of compressed tar "<file>.pkg.tar.zst" into filename "<file>.pkg.tar.zst"
ark.kerfuffle: Mimetype for filename extension ( "application/x-zstd-compressed-alpm-package" ) did not match mimetype for content ( "application/zstd" ). Using content-based mimetype.
ark.kerfuffle: Could not find a plugin to handle "<file>.pkg.tar.zst"
ark.kerfuffle: Created archive instance with error
ark.kerfuffle: Created job instance
ark.main: Entering application loop
ark.kerfuffle: Job finished, result: false , time: 4 ms

MIMETYPE
<mime-type type="application/x-zstd-compressed-alpm-package">
  <comment>ALPM Package (Zstandard-compressed)</comment>
  <generic-icon name="package-x-generic" />
  <sub-class-of type="application/x-alpm-package" />
  <sub-class-of type="application/x-zstd-compressed-tar" />
  <glob pattern="*.pkg.tar.zst" weight="55" />
</mime-type>
Comment 10 o.hase3 2020-10-21 21:17:57 UTC
I have looked through the Ark sources and I believe these lines are the reason the solution using custom mimetypes does not work:
https://github.com/KDE/ark/blob/108ade3b57f1eca792a54843e9c646eb1322a7ef/kerfuffle/mimetypes.cpp#L96

Would it be possible to change these lines

    (mimeFromExtension == db.mimeTypeForName(QStringLiteral("...")) &&

to lines like this?

    (mimeFromExtension.inherits(db.mimeTypeForName(QStringLiteral("..."))) &&

Note the use of inherits() instead of operator==().
Comment 11 Elvis Angelaccio 2020-10-23 18:01:02 UTC
Does it work if you use this instead?

<sub-class-of type="application/x-tar" />
Comment 12 o.hase3 2020-10-24 14:45:22 UTC
(In reply to Elvis Angelaccio from comment #11)
> Does it work if you use this instead?
> 
> <sub-class-of type="application/x-tar" />

It does not. It fails with the same log output I posted in comment #9 (minus the custom mimetype of course). This was one of the first things I tried, but I forgot to mention it.

I have however found a fix that is working for me. I have created custom application/x-*-compressed-alpm-package mimetypes that inherit from both application/x-alpm-package and application/x-*-compressed-tar and have patched Ark to change these lines
    (mimeFromExtension == db.mimeTypeForName(QStringLiteral("...")) &&
into these lines
    (mimeFromExtension.inherits(QStringLiteral("...")) &&
in https://github.com/KDE/ark/blob/108ade3b57f1eca792a54843e9c646eb1322a7ef/kerfuffle/mimetypes.cpp#L96.

Software/OS Versions:
Linux Version: Manjaro 20.1.2
KDE Plasma Version: 5.19.5
KDE Frameworks Version: 5.74.0
Qt Version: 5.15.1
Ark Version: 20.08.1
Comment 13 Elvis Angelaccio 2021-01-05 17:38:39 UTC
(In reply to o.hase3 from comment #12)
> (In reply to Elvis Angelaccio from comment #11)
> > Does it work if you use this instead?
> > 
> > <sub-class-of type="application/x-tar" />
> 
> It does not. It fails with the same log output I posted in comment #9 (minus
> the custom mimetype of course). This was one of the first things I tried,
> but I forgot to mention it.
> 
> I have however found a fix that is working for me. I have created custom
> application/x-*-compressed-alpm-package mimetypes that inherit from both
> application/x-alpm-package and application/x-*-compressed-tar and have
> patched Ark to change these lines
>     (mimeFromExtension == db.mimeTypeForName(QStringLiteral("...")) &&
> into these lines
>     (mimeFromExtension.inherits(QStringLiteral("...")) &&
> in
> https://github.com/KDE/ark/blob/108ade3b57f1eca792a54843e9c646eb1322a7ef/
> kerfuffle/mimetypes.cpp#L96.
> 
> Software/OS Versions:
> Linux Version: Manjaro 20.1.2
> KDE Plasma Version: 5.19.5
> KDE Frameworks Version: 5.74.0
> Qt Version: 5.15.1
> Ark Version: 20.08.1

Feel free to submit a Merge Request with this patch and we'll see if it makes sense to merge upstream.
Comment 14 o.hase3 2021-01-11 02:55:05 UTC
I have created a merge request with this patch.
See https://invent.kde.org/utilities/ark/-/merge_requests/22.
Comment 15 Justin Zobel 2021-01-15 06:46:16 UTC
(In reply to o.hase3 from comment #14)
> I have created a merge request with this patch.
> See https://invent.kde.org/utilities/ark/-/merge_requests/22.

Thank you for the patch. If you mention in the description of the MR "BUG 416092" it will automatically update the bug you mention. :)
Comment 16 Elvis Angelaccio 2021-01-31 19:10:47 UTC
(In reply to o.hase3 from comment #14)
> I have created a merge request with this patch.
> See https://invent.kde.org/utilities/ark/-/merge_requests/22.

Merged, thanks.
Comment 17 mirh 2021-03-29 13:00:30 UTC
Not really fixed as you can see in the last comments of the MR.
Comment 18 Elvis Angelaccio 2021-04-04 21:44:35 UTC
(In reply to mirh from comment #17)
> Not really fixed as you can see in the last comments of the MR.

Which comments?
Comment 19 mirh 2021-04-06 18:11:36 UTC
(In reply to Elvis Angelaccio from comment #18)
> (In reply to mirh from comment #17)
> > Not really fixed as you can see in the last comments of the MR.
> 
> Which comments?

https://invent.kde.org/utilities/ark/-/merge_requests/22#note_176062