Skip to content

Commit

Permalink
bazel: create genrules to produce debs and RPMs without arch-specific…
Browse files Browse the repository at this point in the history
… names
  • Loading branch information
ixdy committed Feb 23, 2019
1 parent 5312ade commit a92c26d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 24 deletions.
30 changes: 18 additions & 12 deletions build/debs/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,38 @@ release_filegroup(
name = "debs",
conditioned_srcs = for_platforms(
default = [],
for_client = [":kubectl-{ARCH}.deb"],
for_client = [":kubectl.deb"],
for_node = [
":cri-tools-{ARCH}.deb",
":kubeadm-{ARCH}.deb",
":kubelet-{ARCH}.deb",
":kubernetes-cni-{ARCH}.deb",
":cri-tools.deb",
":kubeadm.deb",
":kubelet.deb",
":kubernetes-cni.deb",
],
only_os = "linux",
),
)

# Create aliases from the non-arch names to the arch-specific names for backwards compatibility
alias(
# Create genrules to copy the arch-specific debs to debs without the arch in their filename.
genrule(
name = "kubectl",
actual = select(for_platforms(
for_client = ":kubectl-{ARCH}",
srcs = select(for_platforms(
for_client = [":kubectl-{ARCH}.deb"],
only_os = "linux",
)),
outs = ["kubectl.deb"],
cmd = "cp $< $@",
output_to_bindir = True,
)

[alias(
[genrule(
name = pkg,
actual = select(for_platforms(
for_node = ":%s-{ARCH}" % pkg,
srcs = select(for_platforms(
for_node = [":%s-{ARCH}.deb" % pkg],
only_os = "linux",
)),
outs = ["%s.deb" % pkg],
cmd = "cp $< $@",
output_to_bindir = True,
) for pkg in [
"cri-tools",
"kubeadm",
Expand Down
30 changes: 18 additions & 12 deletions build/rpms/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,40 @@ release_filegroup(
name = "rpms",
conditioned_srcs = for_platforms(
default = [],
for_client = [":kubectl-{ARCH}"],
for_client = [":kubectl.rpm"],
for_node = [
":cri-tools-{ARCH}",
":kubeadm-{ARCH}",
":kubelet-{ARCH}",
":kubernetes-cni-{ARCH}",
":cri-tools.rpm",
":kubeadm.rpm",
":kubelet.rpm",
":kubernetes-cni.rpm",
],
only_os = "linux",
),
tags = ["manual"],
visibility = ["//visibility:public"],
)

# Create aliases from the non-arch names to the arch-specific names for backwards compatibility
alias(
# Create genrules to copy the arch-specific RPMs to RPMs without the arch in their filename.
genrule(
name = "kubectl",
actual = select(for_platforms(
for_client = ":kubectl-{ARCH}",
srcs = select(for_platforms(
for_client = [":kubectl-{ARCH}.rpm"],
only_os = "linux",
)),
outs = ["kubectl.rpm"],
cmd = "cp $< $@",
output_to_bindir = True,
)

[alias(
[genrule(
name = pkg,
actual = select(for_platforms(
for_client = ":%s-{ARCH}" % pkg,
srcs = select(for_platforms(
for_client = [":%s-{ARCH}.rpm" % pkg],
only_os = "linux",
)),
outs = ["%s.rpm" % pkg],
cmd = "cp $< $@",
output_to_bindir = True,
) for pkg in [
"cri-tools",
"kubeadm",
Expand Down

0 comments on commit a92c26d

Please sign in to comment.