Skip to content

pkg_rpm build fails if the source paths contain whitespaces #732

@k0walik

Description

@k0walik

While experimenting with pkg_rpm I noticed the rpmbuild will fail to create the package if the source paths (files, symbolic links, directories) contain whitespaces in their paths. Consider the following example:

$ tree test
test
├── BUILD.bazel
├── foo bar
└── foobar
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "pkg_mkdirs", "pkg_mklink")
load("@rules_pkg//pkg:rpm.bzl", "pkg_rpm")

pkg_files(
    name = "files",
    srcs = [
        "foo bar",
        "foobar",
    ],
)

pkg_mklink(
    name = "symlinks",
    link_name = "sym link",
    target = "/foobar",
)

pkg_mkdirs(
    name = "directories",
    dirs = ["dire ctory"],
)

pkg_rpm(
    name = "test",
    package_name = "test",
    srcs = [
        # Comment out sources and observe failing behavior
        ":directories",
        ":files",
        ":symlinks",
    ],
    description = "description",
    license = "license",
    release = "0",
    summary = "summary",
    version = "0.0.0",
)

The above will fail with the following error message (stops at first error):

Error calling rpmbuild:
Executing(%install): /bin/sh -e /tmp/tmpqxx5wk6d/TMP/rpm-tmp.B9Hhpr
+ umask 022
+ cd /tmp/tmpqxx5wk6d/BUILD
+ /bin/rm -rf /tmp/tmpqxx5wk6d/BUILDROOT
+ /bin/mkdir -p /tmp/tmpqxx5wk6d
+ /bin/mkdir /tmp/tmpqxx5wk6d/BUILDROOT
+ install -d /tmp/tmpqxx5wk6d/BUILDROOT//dire ctory
+ dirname /foo bar
+ install -d /tmp/tmpqxx5wk6d/BUILDROOT// .
+ cp dev/foo bar /tmp/tmpqxx5wk6d/BUILDROOT//foo bar
cp: target 'bar' is not a directory
error: Bad exit status from /tmp/tmpqxx5wk6d/TMP/rpm-tmp.B9Hhpr (%install)


RPM build errors:
    Bad exit status from /tmp/tmpqxx5wk6d/TMP/rpm-tmp.B9Hhpr (%install)

No RPM file created.

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