cat-in-136 / cargo-generate-rpm

Cargo helper command to generate a binary RPM package
MIT License
87 stars 19 forks source link

RPM is not readable by rpmlint #89

Closed rakus closed 1 year ago

rakus commented 1 year ago

A RPM created with cargo generate-rpm is installable, but cannot be investigated with rpmlint.

$ rpmlint target/generate-rpm/hello-world-0.1.0-1.x86_64.rpm 
(none): E: fatal error while reading target/generate-rpm/hello-world-0.1.0-1.x86_64.rpm: list index out of range

With verbose output, the following is printed:

$ rpmlint -v target/generate-rpm/hello-world-0.1.0-1.x86_64.rpm 
files over 4GB not supported by cpio, use rpm2archive instead
cpio: premature end of archive
(none): E: fatal error while reading target/generate-rpm/hello-world-0.1.0-1.x86_64.rpm: list index out of range
Traceback (most recent call last):
  File "/bin/rpmlint", line 8, in <module>
    sys.exit(lint())
             ^^^^^^
  File "/usr/lib/python3.11/site-packages/rpmlint/cli.py", line 177, in lint
    sys.exit(lint.run())
             ^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/rpmlint/lint.py", line 105, in run
    return self._run()
           ^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/rpmlint/lint.py", line 76, in _run
    self.validate_files(self.options['rpmfile'])
  File "/usr/lib/python3.11/site-packages/rpmlint/lint.py", line 237, in validate_files
    self.validate_file(pkg, pkg == packages[-1])
  File "/usr/lib/python3.11/site-packages/rpmlint/lint.py", line 261, in validate_file
    raise e
  File "/usr/lib/python3.11/site-packages/rpmlint/lint.py", line 251, in validate_file
    with Pkg(pname, self.config.configuration['ExtractDir'],
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/rpmlint/pkg.py", line 423, in __init__
    self.files = self._gather_files_info()
                 ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/rpmlint/pkg.py", line 576, in _gather_files_info
    pkgfile.size = sizes[idx]
                   ~~~~~^^^^^
IndexError: list index out of range

To reproduce: Create a new project using cargo new hello-world. Then adjust the Cargo.toml like this:

[package]
name = "hello-world"
version = "0.1.0"
edition = "2021"
authors = ["Cargo"]
description = "A hello-world program"
license = "MIT"
homepage = "https://my-hello-world.com"
repository = "https://github.com/fake/hello-world"

[package.metadata.generate-rpm]
assets = [
    { source = "target/release/hello-world", dest = "/usr/bin/hello-world", mode = "755" }
]

Finally generate the RPM and try to lint it with rpmlint.

Or am I'm doing something wrong here?


Environment:

rakus commented 1 year ago

Just build and tested PR #83. This would solve the problem, due to using version 0.12.0 of the rpm crate.

The verbose error message above contains "files over 4GB not supported by cpio" and the changelog vor rpm 0.12.0 has this entry:

CentOS 7 support by using long sizes only for packages bigger than 4 GiB

Also this does not mention rpmlint or Fedora 38, rpm 0.12.0 seems to fix the problem.

Close this ticket or leave it open until #83 is merged?

cat-in-136 commented 1 year ago

Thank you for information. I've confirmed #83 fixes this issue.

Note that: we need to continue our efforts to reduce rpmlint warnings, bacause there is some feature missing in the rpm crate and my crate so lots of warnings in rpmlint shown as of now.

dralley commented 1 year ago

Just dropping in to mention that we would welcome rpmlint tests being committed upstream https://github.com/rpm-rs/rpm/issues/28

@cat-in-136 Is there anything blocking the associated PR from merging? Can it be merged?

cat-in-136 commented 1 year ago

In the part that resolves this issue, #83 is fine. #83 is a PR that is also mixed with other issue resolutions, #83 is blocked by other issues.