Skip to content

Commit 0fc8615

Browse files
committed
1 parent 1b033dd commit 0fc8615

File tree

7 files changed

+100
-1
lines changed

7 files changed

+100
-1
lines changed

examples/MODULE.bazel

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module(
2+
name = "rules_pkg_examples",
3+
version = "0.0.0", # never ships
4+
compatibility_level = 1,
5+
)
6+
7+
local_path_override(
8+
module_name = "rules_pkg",
9+
path = "..",
10+
)
11+
12+
bazel_dep(name = "rules_python", version = "0.24.0")
13+
bazel_dep(name = "rules_cc", version = "0.0.2")
14+
15+
# Find the system rpmbuild if one is available.
16+
find_rpm = use_extension(
17+
"//toolchains/rpm:rpmbuild_configure.bzl",
18+
"find_system_rpmbuild_bzlmod",
19+
dev_dependency = True
20+
)
21+
use_repo(find_rpm, "rules_pkg_rpmbuild")
22+
register_toolchains("@rules_pkg_rpmbuild//:all", dev_dependency = True)

examples/WORKSPACE

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
workspace(name = "rules_pkg_examples")
2+
3+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
4+
5+
local_repository(
6+
name = "rules_pkg",
7+
path = "..",
8+
)
9+
10+
load("@rules_pkg//pkg:deps.bzl", "rules_pkg_dependencies")
11+
12+
rules_pkg_dependencies()
13+
14+
# Find rpmbuild if it exists.
15+
load("@rules_pkg//toolchains/rpm:rpmbuild_configure.bzl", "find_system_rpmbuild")
16+
17+
find_system_rpmbuild(name = "rules_pkg_rpmbuild")

examples/rpm/BUILD

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup")
2+
load("@rules_pkg//pkg:rpm.bzl", "pkg_rpm")
3+
4+
pkg_filegroup(
5+
name = "rpm_filegroup",
6+
srcs = [
7+
"//rpm/main:exe",
8+
],
9+
prefix = "/usr/bin",
10+
)
11+
12+
pkg_rpm(
13+
name = "rpm",
14+
package_name = "example",
15+
license = "example",
16+
summary = "example",
17+
version = "1.0.0",
18+
release = "1",
19+
description = "example",
20+
srcs = [
21+
":rpm_filegroup",
22+
],
23+
)

examples/rpm/main/BUILD

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Package an executable up for distribution
2+
#
3+
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "pkg_attributes")
4+
load("@rules_python//python:defs.bzl", "py_binary")
5+
6+
cc_binary(
7+
name = "hello_world",
8+
srcs = ["hello_world.cc"],
9+
)
10+
11+
py_binary(
12+
name = "hello_world_py",
13+
main = "hello_world.py",
14+
srcs = ["hello_world.py"],
15+
)
16+
17+
pkg_files(
18+
name = "exe",
19+
srcs = [
20+
":hello_world",
21+
":hello_world_py",
22+
],
23+
visibility = ["//visibility:public"],
24+
attributes = pkg_attributes(
25+
mode = "0755",
26+
user = "root",
27+
group = "root",
28+
),
29+
)

examples/rpm/main/hello_world.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include <iostream>
2+
3+
int main(int argc, char *argv[]) {
4+
std::cout << "hello world" << std::endl;
5+
}

examples/rpm/main/hello_world.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
if __name__ == "__main__":
2+
print("hello world")

pkg/rpm_pfg.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ spec_filetype = [".spec", ".spec.in", ".spec.tpl"]
4545
# TODO(nacl, #292): cp -r does not do the right thing with TreeArtifacts
4646
_INSTALL_FILE_STANZA_FMT = """
4747
install -d "%{{buildroot}}/$(dirname '{1}')"
48-
cp '{0}' '%{{buildroot}}/{1}'
48+
ls -ld '{0}' '%{{_topdir}}/BUILD/{0}'
49+
cp '%{{_topdir}}/BUILD/{0}' '%{{buildroot}}/{1}'
4950
""".strip()
5051

5152
# TODO(nacl): __install

0 commit comments

Comments
 (0)