bazelbuild / rules_pkg

Bazel rules for creating packages of many types (zip, tar, deb, rpm, ...)
Apache License 2.0
216 stars 174 forks source link

pkg_rpm fails trying to create an empty rpm package #711

Closed nacl closed 4 months ago

nacl commented 1 year ago

Given the following:

pkg_files(
    name = "empty",
    srcs = [],
)

pkg_rpm(
    name = "empty_rpm",
    srcs = [
        ":empty",
    ],
    architecture = "noarch",
    description = """description""",
    license = "Apache 2.0",
    summary = "summary",
    version = "1.0",
)

empty_rpm will eventually fail to build with:

error: Empty %files file /tmp/tmpa07nyy51/BUILD/empty_rpm.spec.files

Creating an empty package should be possible. For example, one could wish to create a package consisting entirely of metadata that requires other packages. There are two ways users could hit this issue:

IMO, making srcs non-mandatory is not a good idea, as requiring its presence (even if it is an empty value) makes the intent clearer.

Other packages (debian packages?) may also have this need as well.

209 may help to simplify the fix here, but it is not necessary to address this problem.