Skip to content

pkg_rpm to pkg_tar contains duplicated rpm files #685

Closed
@k0walik

Description

@k0walik

I noticed inconsistent behaviour when we feed pkg_deb and pkg_rpm to pkg_tar:

  • pkg_deb to pkg_tar contains only a single file that matches package_file_name attribute
  • pkg_rpm to pkg_tar contains two files in tarball: one named after the rule, the other one that is named after package_file_name

While putting a single tarball may not have much sense, there are use-cases where one need to ship additional files along with deb/rpm package (i.e. instructions). My initial thought was the difference is lack of OutputGroupInfo in pkg_rpm, but I think the problem is DefaultInfo.files return value. pkg_deb returns only the output file, while pkg_rpm contains two output files: the default output file and output file.

Minimum reproducible example:

# //tests/deb_rpm_tar/BUILD
load("//pkg:deb.bzl", "pkg_deb")
load("//pkg:tar.bzl", "pkg_tar")
load("//pkg:rpm.bzl", "pkg_rpm")
load("//pkg:mappings.bzl", "pkg_files")

genrule(
    name = "gen_foo",
    outs = ["usr/bin/foo"],
    cmd = "touch $@",
)

pkg_tar(
    name = "deb_input",
    srcs = [":gen_foo"],
)

pkg_deb(
    name = "test_deb",
    data = ":deb_input",
    description = "Some package",
    maintainer = "john.doe@example.com",
    package = "debpackage",
    package_file_name = "debpackage-0.0.0.deb",
    version = "0.0.0",
)

pkg_tar(
    name = "deb_tar",
    srcs = [":test_deb"],
)

pkg_files(
    name = "rpm_input",
    srcs = [":gen_foo"],
)

pkg_rpm(
    name = "test_rpm",
    srcs = [":rpm_input"],
    description = "Description",
    license = "Apache 2.0",
    package_file_name = "rpmpackage-0.0.0-0.rpm",
    release = "1",
    summary = "Summary",
    version = "0.0.0",
)

pkg_tar(
    name = "rpm_tar",
    srcs = [":test_rpm"],
)
$ tar tvf bazel-out/k8-fastbuild/bin/tests/deb_rpm_tar/deb_tar.tar
-r-xr-xr-x 0/0           10662 2000-01-01 00:00 debpackage-0.0.0.deb
$ tar tvf bazel-out/k8-fastbuild/bin/tests/deb_rpm_tar/rpm_tar.tar 
-r-xr-xr-x 0/0            6254 2000-01-01 00:00 rpmpackage-0.0.0-1.rpm
-r-xr-xr-x 0/0            6254 2000-01-01 00:00 test_rpm.rpm

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions