#1310 Fix type error preventing inclusion of custom SRPMs when running on F31/Rawhide.
Merged 4 years ago by mprahl. Opened 4 years ago by merlinm.
Unknown source kobo-rpmlib-decode  into  master

@@ -400,7 +400,7 @@

              # Get package name from rpm headers

              try:

                  rpm_hdr = kobo.rpmlib.get_rpm_header(source)

-                 rpm_name = kobo.rpmlib.get_header_field(rpm_hdr, "name").decode("utf-8")

+                 rpm_name = to_text_type(kobo.rpmlib.get_header_field(rpm_hdr, "name"))

              except Exception:

                  raise ValueError("Provided srpm is invalid: {}".format(source))

  

Attempts to locally build a module on Rawhide (F31) that includes a custom SRPM (via the --srpm option) results in a failure such as the following:

2019-06-26 13:30:51,848 - PoolThread-twisted.internet.reactor-0 - MBS.scheduler.handlers.modules - ERROR - Provided srpm is invalid: /home/merlinm/fedpkg/_fork/merlinm/python-avocado/python-avocado-70.0-1.fc30.src.rpm                                                                                                                                                               
Traceback (most recent call last):                                                                                                                                                          
  File "/usr/lib/python3.7/site-packages/module_build_service/utils/submit.py", line 403, in get_module_srpm_overrides                                                                      
    rpm_name = kobo.rpmlib.get_header_field(rpm_hdr, "name").decode("utf-8")                                                                                                                
AttributeError: 'str' object has no attribute 'decode'                                                                                                                                      

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/module_build_service/scheduler/handlers/modules.py", line 161, in init
    record_component_builds(mmd, build, session=session)
  File "/usr/lib/python3.7/site-packages/module_build_service/utils/submit.py", line 471, in record_component_builds
    srpm_overrides = get_module_srpm_overrides(module)
  File "/usr/lib/python3.7/site-packages/module_build_service/utils/submit.py", line 405, in get_module_srpm_overrides
    raise ValueError("Provided srpm is invalid: {}".format(source))
ValueError: Provided srpm is invalid: /home/merlinm/fedpkg/_fork/merlinm/python-avocado/python-avocado-70.0-1.fc30.src.rpm

This turns out to be caused by a change introduced when python3-kobo-rpmlib was updated to version 10.0-1 in Rawhide: https://github.com/release-engineering/kobo/pull/115

With that change, kobo.rpmlib.get_header_field() returns type str. Older versions returned type bytes. This fix allows either return type by only attempting to decode() the returned value if it is type bytes.

Could you do the following instead to match the rest of the MBS code for these situations?

rpm_name = to_text_type(kobo.rpmlib.get_header_field(rpm_hdr, "name"))

rebased onto 9f269c3

4 years ago

@mprahl Of course! I should have noticed that utility function earlier.

Build #192 failed (commit: 85136b4992e0140b43274dbe07f9521e67f2d9c3).
Rebase or make new commits to rebuild.

pretty please pagure-ci rebuild

4 years ago

Hmmm. CI seems to be broken (timeout errors).

Commit 1282a77 fixes this pull-request

Pull-Request has been merged by mprahl

4 years ago

Pull-Request has been merged by mprahl

4 years ago