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

Cannot parse vlc.spec #383

Open
2 tasks
xsuchy opened this issue Jun 9, 2024 · 1 comment
Open
2 tasks

Cannot parse vlc.spec #383

xsuchy opened this issue Jun 9, 2024 · 1 comment
Assignees
Labels
kind/bug Something isn't working.

Comments

@xsuchy
Copy link
Contributor

xsuchy commented Jun 9, 2024

What happened? What is the problem?

With this script:

#!/usr/bin/python3                                                                                                                                                                           
from specfile import Specfile
import sys

# this is dump, but do the work
filename = sys.argv[1]
specfile = Specfile(filename, force_parse=True)

with specfile.sections() as sections:
    print(sections.changelog)

I cannot parse vlc.spec from Fedora.

It fails with this TB:

Created dummy sources for nonexistent files:
rpm-specs/macros.vlc
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/specfile/spec_parser.py", line 226, in get_rpm_spec
    return rpm.spec(tmp.name, flags)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: can't parse specfile


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/specfile/spec_parser.py", line 294, in _do_parse
    spec = get_rpm_spec(content, rpm.RPMSPEC_ANYARCH | rpm.RPMSPEC_FORCE)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/specfile/spec_parser.py", line 228, in get_rpm_spec
    raise RPMException(stderr=stderr) from e
specfile.exceptions.RPMException: /tmp/tmp5e9nmd30: line 51: failed to load macro file rpm-specs/macros.vlc

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/specfile/spec_parser.py", line 226, in get_rpm_spec
    return rpm.spec(tmp.name, flags)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: can't parse specfile


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/msuchy/projects/license-validate/./print-spec-changelog.py", line 7, in <module>
    specfile = Specfile(filename, force_parse=True)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/specfile/specfile.py", line 72, in __init__
    self._parser.parse(str(self))
  File "/usr/lib/python3.12/site-packages/specfile/spec_parser.py", line 380, in parse
    self.spec, self.tainted = self._do_parse(content, extra_macros)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/specfile/spec_parser.py", line 319, in _do_parse
    spec = get_rpm_spec(
           ^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/specfile/spec_parser.py", line 228, in get_rpm_spec
    raise RPMException(stderr=stderr) from e
specfile.exceptions.RPMException: file trigger conditions must begin with '/': %{vlc_plugindir}

What did you expect to happen?

Printing changelog of this specfile.

Example URL(s)

No response

Steps to reproduce

No response

Workaround

  • There is an existing workaround that can be used until this issue is fixed.

Participation

  • I am willing to submit a pull request for this issue. (Packit team is happy to help!)
@xsuchy xsuchy added the kind/bug Something isn't working. label Jun 9, 2024
@nforro
Copy link
Member

nforro commented Jun 10, 2024

I don't think there is much that can be done about this - parsing depends on a macro that has to start with a /. For example this will succeed:

spec = Specfile('vlc.spec', force_parse=True, macros=[("vlc_plugindir", "/")])

I think for cases like this it would make sense to make Specfile usable even if rpm parsing failed, as proposed in #233 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working.
Projects
Status: backlog
Development

No branches or pull requests

2 participants