openSUSE / osc

The Command Line Interface to work with an Open Build Service

Home Page:http://openbuildservice.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

updatepacmetafromspec throws an exception

cryptomilk opened this issue · comments

Describe the bug

home:gladiac/neocmakelsp > osc updatepacmetafromspec
Traceback (most recent call last):
  File "/usr/bin/osc", line 33, in <module>
    sys.exit(load_entry_point('osc==1.6.1', 'console_scripts', 'osc')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/osc/babysitter.py", line 226, in main
    sys.exit(run(commandline.OscMainCommand()))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/osc/babysitter.py", line 69, in run
    prg.main(argv)
  File "/usr/lib/python3.11/site-packages/osc/commandline.py", line 558, in main
    cmd.run(args)
  File "/usr/lib/python3.11/site-packages/osc/commandline.py", line 246, in run
    cmd.run(args)
  File "/usr/lib/python3.11/site-packages/osc/commandline.py", line 502, in run
    self.func(args.command, args, *args.positional_args)
  File "/usr/lib/python3.11/site-packages/osc/commandline.py", line 4612, in do_updatepacmetafromspec
    p.read_meta_from_spec(specfile)
  File "/usr/lib/python3.11/site-packages/osc/core.py", line 2328, in read_meta_from_spec
    data = read_meta_from_spec(specfile, 'Summary', 'Url', '%description')
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/osc/core.py", line 4381, in read_meta_from_spec
    for line in lines[start:]:
                      ^^^^^
UnboundLocalError: cannot access local variable 'start' where it is not associated with a value

Versions

  • Operating system: openSUSE Tumbleweed
  • Packages: osc-1.6.1-1.1.noarch

To Reproduce
Steps to reproduce the behavior:

  1. Run command osc updatepacmetafromspec
  2. See error

Expected behavior
Update description

Not only is there a problem in the code, that start is not defined. The other problem is that the spec uses a variable for the descriptions:

%global _description %{expand:
Lsp for cmake.}

%description %{_description}

You should actually run rpmspec -P <specfile> and parse the output instead of directly reading the spec file.

Well rpmspec -P might be a step forward already but it isnt guaranteed to work all the time either as it requires that you can expand all macros.

The patch only solves the crash, migrating the code to rpmspec -P should be done later, it's going to be a bigger change.

Well, fallback to parsing the spec file, if rpmspec -P specfile fails.