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 "%setup -q -n %(tar ft %SOURCE0|head -n1|sed s,/,,)" #233

Open
2 tasks
xsuchy opened this issue May 31, 2023 · 6 comments
Open
2 tasks

Cannot parse "%setup -q -n %(tar ft %SOURCE0|head -n1|sed s,/,,)" #233

xsuchy opened this issue May 31, 2023 · 6 comments
Labels
kind/bug Something isn't working.

Comments

@xsuchy
Copy link
Contributor

xsuchy commented May 31, 2023

What happened? What is the problem?

During parsing dl_poly.spec I get

  File "/usr/lib/python3.11/site-packages/specfile/spec_parser.py", line 201, 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/specfile/tests/test-parsing/./parse.py", line 8, in <module>
    specfile = Specfile(filename, force_parse=True)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/specfile/specfile.py", line 71, in __init__
    self._parser.parse(str(self))
  File "/usr/lib/python3.11/site-packages/specfile/spec_parser.py", line 353, in parse
    self.spec, self.tainted = self._do_parse(content, extra_macros)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/specfile/spec_parser.py", line 318, in _do_parse
    return get_rpm_spec(content, rpm.RPMSPEC_ANYARCH), tainted
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/specfile/spec_parser.py", line 203, in get_rpm_spec
    raise RPMException(stderr=stderr) from e
specfile.exceptions.RPMException: line 106: Bad %setup option -n: missing argument

The specific line in that spec file is:

%setup -q -n %(tar ft %SOURCE0|head -n1|sed s,/,,)

What did you expect to happen?

No response

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 May 31, 2023
@nforro
Copy link
Member

nforro commented Jun 1, 2023

Thanks, this is certainly a bug.

@nforro
Copy link
Member

nforro commented Jun 13, 2023

This could be solved by creating a dummy source that would be a complete compressed tar archive containing a top-level directory rather than just a file header to fool rpm file type detection. However, I'm not sure it's worth doing for a single package.

@nforro
Copy link
Member

nforro commented Jun 13, 2023

To be consistent it would make sense to do this for all supported (by rpm) archive types, but that would bring a substantial amount of additional dependencies.

@xsuchy
Copy link
Contributor Author

xsuchy commented Jun 13, 2023

I think this does not need to be a fatal error. The warning will be enough. I am querying the preamble. I can live with partial parsing.

@nforro
Copy link
Member

nforro commented Jun 13, 2023

Ok, I suppose it would be possible to define a state where a Specfile instance would be partially functional even though rpm parsing failed. You couldn't use rpm_spec and parsed_sections, and macro expansion could/would be unreliable, but if you can live with that, I can try to implement it.

@nforro nforro mentioned this issue Jun 10, 2024
2 tasks
@nforro
Copy link
Member

nforro commented Jul 4, 2024

Still relevant.

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