Skip to content

Commit

Permalink
Buildified
Browse files Browse the repository at this point in the history
  • Loading branch information
jiceatscion committed Sep 27, 2024
1 parent 640db4f commit 262a063
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion dist/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
load(":package.bzl", "scion_pkg_deb", "scion_pkg_ipk", "scion_pkg_rpm")

load(":platform.bzl", "multiplatform_filegroup")
load(":git_version.bzl", "git_version")

Expand All @@ -9,6 +8,7 @@ DEB_PLATFORMS = [
"@io_bazel_rules_go//go/toolchain:linux_386",
"@io_bazel_rules_go//go/toolchain:linux_arm",
]

RPM_PLATFORMS = [
"@io_bazel_rules_go//go/toolchain:linux_amd64",
]
Expand Down
33 changes: 22 additions & 11 deletions dist/package.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ load("@rules_pkg//pkg:pkg.bzl", "pkg_deb", "pkg_tar")
load("@rules_pkg//pkg:rpm.bzl", "pkg_rpm")
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
load("@rules_pkg//pkg:providers.bzl", "PackageVariablesInfo")
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "pkg_attributes")
load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_files")

SCION_PKG_HOMEPAGE = "https://github.com/scionproto/scion"
SCION_PKG_MAINTAINER = "SCION Contributors"
Expand Down Expand Up @@ -79,20 +79,31 @@ def scion_pkg_rpm(name, package, executables = {}, systemds = [], configs = [],

# Note that our "executables" parameter is a dictionary label->file_name; exactly what pkg_files
# wants for its "renames" param.
pkg_files(name="%s_configs" % name, prefix="/etc/scion/", srcs=configs)
pkg_files(name="%s_systemds" % name, prefix="/lib/systemd/system/", srcs=systemds)
pkg_files(name="%s_execs" % name, prefix="/usr/bin/", srcs=executables.keys(),
attributes=pkg_attributes(mode = "0755"), renames=executables)
pkg_files(name = "%s_configs" % name, prefix = "/etc/scion/", srcs = configs)
pkg_files(name = "%s_systemds" % name, prefix = "/lib/systemd/system/", srcs = systemds)
pkg_files(
name = "%s_execs" % name,
prefix = "/usr/bin/",
srcs = executables.keys(),
attributes = pkg_attributes(mode = "0755"),
renames = executables,
)

if kwargs.get("version_file"):
native.genrule(name="%s_version" % name,
srcs=[kwargs["version_file"]], outs=["%s_version_file" % name],
cmd="sed 's/-/^/g' < $< > $@")
native.genrule(
name = "%s_version" % name,
srcs = [kwargs["version_file"]],
outs = ["%s_version_file" % name],
cmd = "sed 's/-/^/g' < $< > $@",
)
kwargs.pop("version_file")
elif kwargs.get("version"):
native.genrule(name="%s_version" % name,
srcs=[], outs=["%s_version_file" % name],
cmd="echo \"%s\" | sed 's/-/^/g' > $@" % kwargs["version"])
native.genrule(
name = "%s_version" % name,
srcs = [],
outs = ["%s_version_file" % name],
cmd = "echo \"%s\" | sed 's/-/^/g' > $@" % kwargs["version"],
)
kwargs.pop("version")

# Use ethe same attributes as scion_pkg_deb, in view of may-be simplifying BUILD.bazel later.
Expand Down

0 comments on commit 262a063

Please sign in to comment.