Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternate version matching with string rather than int to handle 0-prefixed numbers (failed ghostscript version check since version 10.01.0) #360

Open
Jehan opened this issue Mar 23, 2023 · 5 comments

Comments

@Jehan
Copy link

Jehan commented Mar 23, 2023

The version checker started to fail for Ghostscript, after release of version 10.01.0. We use the anitya x-data-checker's type (though this issue might happen with other data checkers, I haven't verified) and here is our current manifest code for GIMP:

                    "x-checker-data": {
                        "type": "anitya",
                        "project-id": 1157,
                        "stable-only": true,
                        "url-template": "https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs$major$minor$patch/ghostscript-$version.tar.gz"
                    }

Finally here is an example of failed build log error because of the version check:

ERROR   src.manifest: Failed to check archive ghostscript/ghostscript-10.01.0.tar.xz with AnityaChecker: Error downloading upstream source: 404, message='Not Found', url=URL('https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs1010/ghostscript-10.01.0.tar.gz')

The right URL is: https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs10010/ghostscript-10.01.0.tar.gz

Basically it seems that the substitution code replaces $minor by 1 while the exact scheme for ghostscript apparently expects 01 (i.e. taking the version number as a string as-is, keeping the leading 0, rather than an int), which very likely means that there is a roundtrip to int type.

Though it might be the used scheme in some cases, in others (e.g. for ghostscript), it's not. So we'd need alternative substitution variables to handle such case.

Also do you know if there is a workaround for now (other than removing the version check for this module)? Because right now all builds fail on Flathub because of this.

@Jehan
Copy link
Author

Jehan commented Mar 23, 2023

P.S.: checking the code, looking if such alternate variables already exist, I clearly see the problem:

from distutils.version import LooseVersion
[…]
        version_list = LooseVersion(version).version
[…]
        for i, version_part in enumerate(version_list):

And checking how this module works, testing in a console:

In [4]: l = LooseVersion("10.01.0")

In [5]: l.version
Out[5]: [10, 1, 0]

So in version_list, the leading zeros are already lost.

@wjt
Copy link
Contributor

wjt commented Mar 23, 2023

You can use the json checker as a workaround. Try:

"x-checker-data": {
    "type": "json",
    "url": "https://api.github.com/repos/ArtifexSoftware/ghostpdl-downloads/releases/latest",
    "version-query": ".name | split(\" \") | .[1]",
    "url-query": ".assets[] | select(.name|test(\"^ghostscript-(.*).tar.gz$\")) | .browser_download_url"
}

Jehan pushed a commit to flathub/org.gimp.GIMP that referenced this issue Mar 23, 2023
Our current url-template substitution doesn't work and there seem to be
no alternative right now using anitya checker.
So switching to another checker.

See: flathub-infra/flatpak-external-data-checker#360
@Jehan
Copy link
Author

Jehan commented Mar 23, 2023

Thanks. Works fine!

@gasinvein
Copy link
Collaborator

f-strings are not an option for untrusted input, since it would open up a very simple way to ACE. But maybe there is another library that can be used for string template (something like jinja2 but simpler)?

Jehan pushed a commit to flathub/org.gimp.GIMP that referenced this issue Apr 4, 2023
- poppler: 23.02.0 → 23.04.0
- ghostscript: 10.0.0 → 10.01.0 (also fixes the anitya check, see:
  flathub-infra/flatpak-external-data-checker#360)
- OpenBLAS: 0.3.21 ⇒ 0.3.23
- libheif: 1.15.1 ⇒ 1.15.2
- GEGL: 0.4.42 ⇒ 0.4.44
wjt added a commit that referenced this issue Apr 27, 2023
One of the tests exercises the ability to use parsed components of
versions in URL patterns.

Ghostscript uses version numbers of the form 10.01.0. Since the
components are treated as digits, the $version1 variable is set to "1"
not "01", and so this test fails.

See #360.

To work around this bug to unbreak the test suite, switch to a different
module.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@wjt @Jehan @gasinvein and others