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

Сondition can be split between sections, which breaks the parsing #365

Open
2 tasks
nikitych opened this issue Apr 5, 2024 · 2 comments
Open
2 tasks
Labels
area/general Related to whole service, not a specific part/integration. complexity/single-task Regular task, should be done within days. gain/high This brings a lot of value to (not strictly a lot of) users. impact/low This issue impacts only a few users. kind/bug Something isn't working.

Comments

@nikitych
Copy link
Contributor

nikitych commented Apr 5, 2024

What happened? What is the problem?

In case of pg_auto_failover.spec or xorgxrdp.spec begin of condition remains in main package section while %endif goes to sub-package. So you get IndexError when trying to parse it.

from specfile import Specfile
with Specfile("xorgxrdp.spec") as specfile:
    with specfile.sections() as sections:
        for section in sections:
            if "package" in section.name:
                with specfile.tags(section) as tags:
                    for tag in tags:
                        print(tag.name)
  File "/usr/lib64/python3.9/site-packages/specfile/context_management.py", line 133, in __call__
    self.values[key] = next(self.generators[key])
  File "/usr/lib64/python3.9/site-packages/specfile/specfile.py", line 273, in tags
    tags = Tags.parse(section, context=self)
  File "/usr/lib64/python3.9/site-packages/specfile/tags.py", line 497, in parse
    lines = process_conditions(list(section), macro_definitions, context)
  File "/usr/lib64/python3.9/site-packages/specfile/conditions.py", line 119, in process_conditions
    result.append((line, branches[-2]))
IndexError: list index out of range

What did you expect to happen?

No errors.

May be process conditions before splitting to sections?

Example URL(s)

No response

Steps to reproduce

1. get xorgxrdp.spec
2. try to get package glamor tags
3. IndexError: list index out of range

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!)
@nforro
Copy link
Member

nforro commented Apr 6, 2024

Thanks for the report. This is basically the same issue as #231, but I didn't realize it affects also parsing. Let me think about how to fix this.

@mfocko mfocko added kind/bug Something isn't working. area/general Related to whole service, not a specific part/integration. complexity/single-task Regular task, should be done within days. gain/high This brings a lot of value to (not strictly a lot of) users. impact/low This issue impacts only a few users. labels Apr 8, 2024
@mfocko mfocko moved this from new to backlog in Packit Kanban Board Apr 8, 2024
@kin4stat
Copy link

@mfocko maybe it's reasonable to move this issue to "priority backlog"?

There are a lot of packages with feature macros inside specfile

i.e

%if %{with dane}
%package dane
Summary: A DANE protocol implementation for GnuTLS
Requires: %{name}%{?_isa} = %{version}-%{release}
%endif

%if %{with guile}
%package guile
Summary: Guile bindings for the GNUTLS library
Requires: %{name}%{?_isa} = %{version}-%{release}
Requires: guile22
%endif

For example python3.9, gnutls and others...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/general Related to whole service, not a specific part/integration. complexity/single-task Regular task, should be done within days. gain/high This brings a lot of value to (not strictly a lot of) users. impact/low This issue impacts only a few users. kind/bug Something isn't working.
Projects
Status: backlog
Development

No branches or pull requests

4 participants