chore: buildifier format all files (#775)

This commit is contained in:
Alex Eagle 2023-11-06 10:29:07 -08:00 committed by GitHub
parent a2250d999f
commit eb46104bc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 175 additions and 173 deletions

2
BUILD
View File

@ -22,7 +22,7 @@ package(
license( license(
name = "license", name = "license",
license_kinds = [ license_kinds = [
"@rules_license//licenses/spdx:Apache-2.0" "@rules_license//licenses/spdx:Apache-2.0",
], ],
license_text = "LICENSE", license_text = "LICENSE",
) )

View File

@ -1,8 +1,8 @@
module( module(
name = "rules_pkg", name = "rules_pkg",
version = "0.10.0", # Must sync with version.bzl. version = "0.10.0", # Must sync with version.bzl.
repo_name = "rules_pkg",
compatibility_level = 1, compatibility_level = 1,
repo_name = "rules_pkg",
) )
# Do not update to newer versions until you need a specific new feature. # Do not update to newer versions until you need a specific new feature.
@ -18,4 +18,8 @@ bazel_dep(name = "rules_cc", version = "0.0.9", dev_dependency = True)
# Find the system rpmbuild if one is available. # Find the system rpmbuild if one is available.
find_rpm = use_extension("//toolchains/rpm:rpmbuild_configure.bzl", "find_system_rpmbuild_bzlmod", dev_dependency = True) find_rpm = use_extension("//toolchains/rpm:rpmbuild_configure.bzl", "find_system_rpmbuild_bzlmod", dev_dependency = True)
use_repo(find_rpm, "rules_pkg_rpmbuild") use_repo(find_rpm, "rules_pkg_rpmbuild")
register_toolchains("@rules_pkg_rpmbuild//:all", dev_dependency = True)
register_toolchains(
"@rules_pkg_rpmbuild//:all",
dev_dependency = True,
)

View File

@ -36,11 +36,11 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive( http_archive(
name = "platforms", name = "platforms",
sha256 = "3a561c99e7bdbe9173aa653fd579fe849f1d8d67395780ab4770b1f381431d51",
urls = [ urls = [
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz", "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz",
"https://github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz", "https://github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz",
], ],
sha256 = "3a561c99e7bdbe9173aa653fd579fe849f1d8d67395780ab4770b1f381431d51",
) )
# Find rpmbuild if it exists. # Find rpmbuild if it exists.
@ -74,10 +74,11 @@ stardoc_repositories()
http_archive( http_archive(
name = "rules_cc", name = "rules_cc",
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.9/rules_cc-0.0.9.tar.gz"],
sha256 = "2037875b9a4456dce4a79d112a8ae885bbc4aad968e6587dca6e64f3a0900cdf", sha256 = "2037875b9a4456dce4a79d112a8ae885bbc4aad968e6587dca6e64f3a0900cdf",
strip_prefix = "rules_cc-0.0.9", strip_prefix = "rules_cc-0.0.9",
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.9/rules_cc-0.0.9.tar.gz"],
) )
load("@rules_cc//cc:repositories.bzl", "rules_cc_dependencies", "rules_cc_toolchains") load("@rules_cc//cc:repositories.bzl", "rules_cc_dependencies", "rules_cc_toolchains")
rules_cc_dependencies() rules_cc_dependencies()

View File

@ -12,12 +12,11 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
load("@rules_python//python:defs.bzl", "py_test")
load("//:version.bzl", "version") load("//:version.bzl", "version")
load("//pkg:tar.bzl", "pkg_tar") load("//pkg:tar.bzl", "pkg_tar")
load("//pkg/releasing:defs.bzl", "print_rel_notes") load("//pkg/releasing:defs.bzl", "print_rel_notes")
load("//pkg/releasing:git.bzl", "git_changelog") load("//pkg/releasing:git.bzl", "git_changelog")
load("@rules_python//python:defs.bzl", "py_test")
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
package( package(
default_applicable_licenses = ["//:license"], default_applicable_licenses = ["//:license"],
@ -83,12 +82,12 @@ py_test(
"packaging_test.py", "packaging_test.py",
":release_version.py", ":release_version.py",
], ],
imports = [".."],
data = [ data = [
"testdata/BUILD.tpl", "testdata/BUILD.tpl",
":distro", ":distro",
"//:standard_package", "//:standard_package",
], ],
imports = [".."],
local = True, local = True,
python_version = "PY3", python_version = "PY3",
tags = [ tags = [

View File

@ -21,7 +21,6 @@ How to:
load("@bazel_skylib//:bzl_library.bzl", "bzl_library") load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bazel_stardoc//stardoc:stardoc.bzl", "stardoc") load("@bazel_stardoc//stardoc:stardoc.bzl", "stardoc")
load("@rules_python//python:defs.bzl", "py_library")
load("//:version.bzl", "version") load("//:version.bzl", "version")
package(default_applicable_licenses = ["//:license"]) package(default_applicable_licenses = ["//:license"])
@ -50,16 +49,16 @@ exports_files(
# pairs of rule name and the source file to get it from # pairs of rule name and the source file to get it from
# buildifier: leave-alone, do not sort # buildifier: leave-alone, do not sort
ORDER = [ ORDER = [
("toc", None), ("toc", None),
("common", None), ("common", None),
("pkg_deb", "//pkg/private/deb:deb.bzl"), ("pkg_deb", "//pkg/private/deb:deb.bzl"),
("pkg_deb_impl", "//pkg/private/deb:deb.bzl"), ("pkg_deb_impl", "//pkg/private/deb:deb.bzl"),
("pkg_rpm", "//pkg:rpm_pfg.bzl"), ("pkg_rpm", "//pkg:rpm_pfg.bzl"),
("pkg_tar", "//pkg/private/tar:tar.bzl"), ("pkg_tar", "//pkg/private/tar:tar.bzl"),
("pkg_tar_impl", "//pkg/private/tar:tar.bzl"), ("pkg_tar_impl", "//pkg/private/tar:tar.bzl"),
("pkg_zip", "//pkg/private/zip:zip.bzl"), ("pkg_zip", "//pkg/private/zip:zip.bzl"),
("pkg_zip_impl", "//pkg/private/zip:zip.bzl"), ("pkg_zip_impl", "//pkg/private/zip:zip.bzl"),
("mappings", None), ("mappings", None),
("legacy_pkg_rpm", None), ("legacy_pkg_rpm", None),
] ]

View File

@ -13,12 +13,12 @@
# limitations under the License. # limitations under the License.
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
licenses(["notice"])
load("@rules_pkg//pkg:deb.bzl", "pkg_deb") load("@rules_pkg//pkg:deb.bzl", "pkg_deb")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar") load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load(":package_upload.bzl", "debian_upload")
load(":my_package_name.bzl", "basic_naming", "name_part_from_command_line", "names_from_toolchains") load(":my_package_name.bzl", "basic_naming", "name_part_from_command_line", "names_from_toolchains")
load(":package_upload.bzl", "debian_upload")
licenses(["notice"])
config_setting( config_setting(
name = "special_build", name = "special_build",
@ -97,7 +97,7 @@ pkg_tar(
) )
# #
# #
# #
pkg_tar( pkg_tar(
name = "using_variable_from_ctx_var", name = "using_variable_from_ctx_var",

View File

@ -27,7 +27,7 @@ rules_pkg_dependencies()
http_archive( http_archive(
name = "rules_cc", name = "rules_cc",
url = "https://github.com/bazelbuild/rules_cc/archive/b1c40e1de81913a3c40e5948f78719c28152486d.zip",
sha256 = "d0c573b94a6ef20ef6ff20154a23d0efcb409fb0e1ff0979cec318dfe42f0cdd", sha256 = "d0c573b94a6ef20ef6ff20154a23d0efcb409fb0e1ff0979cec318dfe42f0cdd",
strip_prefix = "rules_cc-b1c40e1de81913a3c40e5948f78719c28152486d", strip_prefix = "rules_cc-b1c40e1de81913a3c40e5948f78719c28152486d",
url = "https://github.com/bazelbuild/rules_cc/archive/b1c40e1de81913a3c40e5948f78719c28152486d.zip",
) )

View File

@ -14,8 +14,8 @@
"""Example rules to show package naming techniques.""" """Example rules to show package naming techniques."""
load("@rules_pkg//pkg:providers.bzl", "PackageVariablesInfo")
load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cc_toolchain") load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cc_toolchain")
load("@rules_pkg//pkg:providers.bzl", "PackageVariablesInfo")
def _basic_naming_impl(ctx): def _basic_naming_impl(ctx):
values = {} values = {}
@ -97,6 +97,7 @@ names_from_toolchains = rule(
# #
def _name_part_from_command_line_naming_impl(ctx): def _name_part_from_command_line_naming_impl(ctx):
values = {"name_part": ctx.build_setting_value} values = {"name_part": ctx.build_setting_value}
# Just pass the value from the command line through. An implementation # Just pass the value from the command line through. An implementation
# could also perform validation, such as done in # could also perform validation, such as done in
# https://github.com/bazelbuild/bazel-skylib/blob/master/rules/common_settings.bzl # https://github.com/bazelbuild/bazel-skylib/blob/master/rules/common_settings.bzl

View File

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_filegroup", "pkg_files", "pkg_mkdirs", "strip_prefix") load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup", "pkg_files", "strip_prefix")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar") load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load("@rules_pkg//pkg:zip.bzl", "pkg_zip") load("@rules_pkg//pkg:zip.bzl", "pkg_zip")

View File

@ -27,10 +27,11 @@ rules_pkg_dependencies()
http_archive( http_archive(
name = "rules_cc", name = "rules_cc",
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.9/rules_cc-0.0.9.tar.gz"],
sha256 = "2037875b9a4456dce4a79d112a8ae885bbc4aad968e6587dca6e64f3a0900cdf", sha256 = "2037875b9a4456dce4a79d112a8ae885bbc4aad968e6587dca6e64f3a0900cdf",
strip_prefix = "rules_cc-0.0.9", strip_prefix = "rules_cc-0.0.9",
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.9/rules_cc-0.0.9.tar.gz"],
) )
load("@rules_cc//cc:repositories.bzl", "rules_cc_dependencies", "rules_cc_toolchains") load("@rules_cc//cc:repositories.bzl", "rules_cc_dependencies", "rules_cc_toolchains")
rules_cc_dependencies() rules_cc_dependencies()

View File

@ -2,6 +2,9 @@
filegroup( filegroup(
name = "docs", name = "docs",
srcs = glob(["**/*"], exclude=["BUILD"]), srcs = glob(
["**/*"],
exclude = ["BUILD"],
),
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )

View File

@ -14,7 +14,6 @@
load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_filegroup", "pkg_files", "strip_prefix") load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_filegroup", "pkg_files", "strip_prefix")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar") load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load("@rules_pkg//pkg:zip.bzl", "pkg_zip")
load("//:foo_defs.bzl", "shared_object_path_selector") load("//:foo_defs.bzl", "shared_object_path_selector")
# There are localized message catalogs for all the components. # There are localized message catalogs for all the components.

View File

@ -15,7 +15,6 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_filegroup", "pkg_files", "pkg_mkdirs") load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_filegroup", "pkg_files", "pkg_mkdirs")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar") load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load("//:foo_defs.bzl", "shared_object_path_selector")
cc_library( cc_library(
name = "foolib", name = "foolib",

View File

@ -13,10 +13,10 @@
# limitations under the License. # limitations under the License.
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
licenses(["notice"])
load("@rules_pkg//pkg:tar.bzl", "pkg_tar") load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
licenses(["notice"])
pkg_tar( pkg_tar(
name = "never_stamped", name = "never_stamped",
srcs = [ srcs = [

View File

@ -14,8 +14,6 @@
workspace(name = "rich_structure") workspace(name = "rich_structure")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
local_repository( local_repository(
name = "rules_pkg", name = "rules_pkg",
path = "../..", path = "../..",

View File

@ -22,6 +22,7 @@
def format(target): def format(target):
provider_map = providers(target) provider_map = providers(target)
output_group_info = provider_map["OutputGroupInfo"] output_group_info = provider_map["OutputGroupInfo"]
# Look at the attributes of the provider. Visit the depsets. # Look at the attributes of the provider. Visit the depsets.
ret = [] ret = []
for attr in dir(output_group_info): for attr in dir(output_group_info):

View File

@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
load("@rules_pkg//pkg/private:make_starlark_library.bzl", "starlark_library")
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
load("@rules_python//python:defs.bzl", "py_binary", "py_library") load("@rules_python//python:defs.bzl", "py_binary", "py_library")
load("@rules_pkg//pkg/private:make_starlark_library.bzl", "starlark_library")
package(default_applicable_licenses = ["//:license"]) package(default_applicable_licenses = ["//:license"])

View File

@ -36,10 +36,10 @@ def _pkg_rpm_impl(ctx):
tools = [] tools = []
args = ["--name=" + ctx.label.name] args = ["--name=" + ctx.label.name]
if ctx.attr.debug: if ctx.attr.debug:
args += ["--debug"] args.append("--debug")
if ctx.attr.rpmbuild_path: if ctx.attr.rpmbuild_path:
args += ["--rpmbuild=" + ctx.attr.rpmbuild_path] args.append("--rpmbuild=" + ctx.attr.rpmbuild_path)
# buildifier: disable=print # buildifier: disable=print
print("rpmbuild_path is deprecated. See the README for instructions on how" + print("rpmbuild_path is deprecated. See the README for instructions on how" +
@ -50,7 +50,7 @@ def _pkg_rpm_impl(ctx):
fail("The rpmbuild_toolchain is not properly configured: " + fail("The rpmbuild_toolchain is not properly configured: " +
toolchain.name) toolchain.name)
if toolchain.path: if toolchain.path:
args += ["--rpmbuild=" + toolchain.path] args.append("--rpmbuild=" + toolchain.path)
else: else:
executable_files = toolchain.label[DefaultInfo].files_to_run executable_files = toolchain.label[DefaultInfo].files_to_run
tools.append(executable_files) tools.append(executable_files)
@ -60,31 +60,31 @@ def _pkg_rpm_impl(ctx):
if ctx.attr.version_file: if ctx.attr.version_file:
if ctx.attr.version: if ctx.attr.version:
fail("Both version and version_file attributes were specified") fail("Both version and version_file attributes were specified")
args += ["--version=@" + ctx.file.version_file.path] args.append("--version=@" + ctx.file.version_file.path)
files += [ctx.file.version_file] files.append(ctx.file.version_file)
elif ctx.attr.version: elif ctx.attr.version:
args += ["--version=" + ctx.attr.version] args.append("--version=" + ctx.attr.version)
# Release can be specified by a file or inlined. # Release can be specified by a file or inlined.
if ctx.attr.release_file: if ctx.attr.release_file:
if ctx.attr.release: if ctx.attr.release:
fail("Both release and release_file attributes were specified") fail("Both release and release_file attributes were specified")
args += ["--release=@" + ctx.file.release_file.path] args.append("--release=@" + ctx.file.release_file.path)
files += [ctx.file.release_file] files.append(ctx.file.release_file)
elif ctx.attr.release: elif ctx.attr.release:
args += ["--release=" + ctx.attr.release] args.append("--release=" + ctx.attr.release)
# SOURCE_DATE_EPOCH can be specified by a file or inlined. # SOURCE_DATE_EPOCH can be specified by a file or inlined.
if ctx.attr.source_date_epoch_file: if ctx.attr.source_date_epoch_file:
if ctx.attr.source_date_epoch: if ctx.attr.source_date_epoch:
fail("Both source_date_epoch and source_date_epoch_file attributes were specified") fail("Both source_date_epoch and source_date_epoch_file attributes were specified")
args += ["--source_date_epoch=@" + ctx.file.source_date_epoch_file.path] args.append("--source_date_epoch=@" + ctx.file.source_date_epoch_file.path)
files += [ctx.file.source_date_epoch_file] files.append(ctx.file.source_date_epoch_file)
elif ctx.attr.source_date_epoch != None: elif ctx.attr.source_date_epoch != None:
args += ["--source_date_epoch=" + str(ctx.attr.source_date_epoch)] args.append("--source_date_epoch=" + str(ctx.attr.source_date_epoch))
if ctx.attr.architecture: if ctx.attr.architecture:
args += ["--arch=" + ctx.attr.architecture] args.append("--arch=" + ctx.attr.architecture)
if not ctx.attr.spec_file: if not ctx.attr.spec_file:
fail("spec_file was not specified") fail("spec_file was not specified")
@ -102,19 +102,19 @@ def _pkg_rpm_impl(ctx):
output = spec_file, output = spec_file,
substitutions = substitutions, substitutions = substitutions,
) )
args += ["--spec_file=" + spec_file.path] args.append("--spec_file=" + spec_file.path)
files += [spec_file] files.append(spec_file)
args += ["--out_file=" + ctx.outputs.rpm.path] args.append("--out_file=" + ctx.outputs.rpm.path)
# Add data files. # Add data files.
if ctx.file.changelog: if ctx.file.changelog:
files += [ctx.file.changelog] files.append(ctx.file.changelog)
args += [ctx.file.changelog.path] args.append(ctx.file.changelog.path)
files += ctx.files.data files += ctx.files.data
for f in ctx.files.data: for f in ctx.files.data:
args += [f.path] args.append(f.path)
# Call the generator script. # Call the generator script.
ctx.actions.run( ctx.actions.run(

View File

@ -27,8 +27,8 @@ Rules that actually make use of the outputs of the above rules are not specified
here. here.
""" """
load("//pkg:providers.bzl", "PackageDirsInfo", "PackageFilegroupInfo", "PackageFilesInfo", "PackageSymlinkInfo")
load("@bazel_skylib//lib:paths.bzl", "paths") load("@bazel_skylib//lib:paths.bzl", "paths")
load("//pkg:providers.bzl", "PackageDirsInfo", "PackageFilegroupInfo", "PackageFilesInfo", "PackageSymlinkInfo")
# TODO(#333): strip_prefix module functions should produce unique outputs. In # TODO(#333): strip_prefix module functions should produce unique outputs. In
# particular, this one and `_sp_from_pkg` can overlap. # particular, this one and `_sp_from_pkg` can overlap.

View File

@ -16,6 +16,6 @@
def add_ctx_variables(ctx, values): def add_ctx_variables(ctx, values):
"""Add selected variables from ctx.""" """Add selected variables from ctx."""
values['target_cpu'] = ctx.var.get("TARGET_CPU") values["target_cpu"] = ctx.var.get("TARGET_CPU")
values['compilation_mode'] = ctx.var.get("COMPILATION_MODE") values["compilation_mode"] = ctx.var.get("COMPILATION_MODE")
return values return values

View File

@ -50,39 +50,39 @@ def _pkg_deb_impl(ctx):
if ctx.attr.architecture_file: if ctx.attr.architecture_file:
if ctx.attr.architecture != "all": if ctx.attr.architecture != "all":
fail("Both architecture and architecture_file attributes were specified") fail("Both architecture and architecture_file attributes were specified")
args += ["--architecture=@" + ctx.file.architecture_file.path] args.append("--architecture=@" + ctx.file.architecture_file.path)
files += [ctx.file.architecture_file] files.append(ctx.file.architecture_file)
else: else:
args += ["--architecture=" + ctx.attr.architecture] args.append("--architecture=" + ctx.attr.architecture)
if ctx.attr.preinst: if ctx.attr.preinst:
args += ["--preinst=@" + ctx.file.preinst.path] args.append("--preinst=@" + ctx.file.preinst.path)
files += [ctx.file.preinst] files.append(ctx.file.preinst)
if ctx.attr.postinst: if ctx.attr.postinst:
args += ["--postinst=@" + ctx.file.postinst.path] args.append("--postinst=@" + ctx.file.postinst.path)
files += [ctx.file.postinst] files.append(ctx.file.postinst)
if ctx.attr.prerm: if ctx.attr.prerm:
args += ["--prerm=@" + ctx.file.prerm.path] args.append("--prerm=@" + ctx.file.prerm.path)
files += [ctx.file.prerm] files.append(ctx.file.prerm)
if ctx.attr.postrm: if ctx.attr.postrm:
args += ["--postrm=@" + ctx.file.postrm.path] args.append("--postrm=@" + ctx.file.postrm.path)
files += [ctx.file.postrm] files.append(ctx.file.postrm)
if ctx.attr.config: if ctx.attr.config:
args += ["--config=@" + ctx.file.config.path] args.append("--config=@" + ctx.file.config.path)
files += [ctx.file.config] files.append(ctx.file.config)
if ctx.attr.templates: if ctx.attr.templates:
args += ["--templates=@" + ctx.file.templates.path] args.append("--templates=@" + ctx.file.templates.path)
files += [ctx.file.templates] files.append(ctx.file.templates)
if ctx.attr.triggers: if ctx.attr.triggers:
args += ["--triggers=@" + ctx.file.triggers.path] args.append("--triggers=@" + ctx.file.triggers.path)
files += [ctx.file.triggers] files.append(ctx.file.triggers)
# Conffiles can be specified by a file or a string list # Conffiles can be specified by a file or a string list
if ctx.attr.conffiles_file: if ctx.attr.conffiles_file:
if ctx.attr.conffiles: if ctx.attr.conffiles:
fail("Both conffiles and conffiles_file attributes were specified") fail("Both conffiles and conffiles_file attributes were specified")
args += ["--conffile=@" + ctx.file.conffiles_file.path] args.append("--conffile=@" + ctx.file.conffiles_file.path)
files += [ctx.file.conffiles_file] files.append(ctx.file.conffiles_file)
elif ctx.attr.conffiles: elif ctx.attr.conffiles:
args += ["--conffile=%s" % cf for cf in ctx.attr.conffiles] args += ["--conffile=%s" % cf for cf in ctx.attr.conffiles]
@ -90,55 +90,55 @@ def _pkg_deb_impl(ctx):
if ctx.attr.version_file: if ctx.attr.version_file:
if ctx.attr.version: if ctx.attr.version:
fail("Both version and version_file attributes were specified") fail("Both version and version_file attributes were specified")
args += ["--version=@" + ctx.file.version_file.path] args.append("--version=@" + ctx.file.version_file.path)
files += [ctx.file.version_file] files.append(ctx.file.version_file)
elif ctx.attr.version: elif ctx.attr.version:
args += ["--version=" + ctx.attr.version] args.append("--version=" + ctx.attr.version)
else: else:
fail("Neither version_file nor version attribute was specified") fail("Neither version_file nor version attribute was specified")
if ctx.attr.description_file: if ctx.attr.description_file:
if ctx.attr.description: if ctx.attr.description:
fail("Both description and description_file attributes were specified") fail("Both description and description_file attributes were specified")
args += ["--description=@" + ctx.file.description_file.path] args.append("--description=@" + ctx.file.description_file.path)
files += [ctx.file.description_file] files.append(ctx.file.description_file)
elif ctx.attr.description: elif ctx.attr.description:
args += ["--description=" + ctx.attr.description] args.append("--description=" + ctx.attr.description)
else: else:
fail("Neither description_file nor description attribute was specified") fail("Neither description_file nor description attribute was specified")
if ctx.attr.changelog: if ctx.attr.changelog:
args += ["--changelog=@" + ctx.file.changelog.path] args.append("--changelog=@" + ctx.file.changelog.path)
files += [ctx.file.changelog] files.append(ctx.file.changelog)
# Built using can also be specified by a file or inlined (but is not mandatory) # Built using can also be specified by a file or inlined (but is not mandatory)
if ctx.attr.built_using_file: if ctx.attr.built_using_file:
if ctx.attr.built_using: if ctx.attr.built_using:
fail("Both build_using and built_using_file attributes were specified") fail("Both build_using and built_using_file attributes were specified")
args += ["--built_using=@" + ctx.file.built_using_file.path] args.append("--built_using=@" + ctx.file.built_using_file.path)
files += [ctx.file.built_using_file] files.append(ctx.file.built_using_file)
elif ctx.attr.built_using: elif ctx.attr.built_using:
args += ["--built_using=" + ctx.attr.built_using] args.append("--built_using=" + ctx.attr.built_using)
if ctx.attr.depends_file: if ctx.attr.depends_file:
if ctx.attr.depends: if ctx.attr.depends:
fail("Both depends and depends_file attributes were specified") fail("Both depends and depends_file attributes were specified")
args += ["--depends=@" + ctx.file.depends_file.path] args.append("--depends=@" + ctx.file.depends_file.path)
files += [ctx.file.depends_file] files.append(ctx.file.depends_file)
elif ctx.attr.depends: elif ctx.attr.depends:
args += ["--depends=" + d for d in ctx.attr.depends] args += ["--depends=" + d for d in ctx.attr.depends]
if ctx.attr.priority: if ctx.attr.priority:
args += ["--priority=" + ctx.attr.priority] args.append("--priority=" + ctx.attr.priority)
if ctx.attr.section: if ctx.attr.section:
args += ["--section=" + ctx.attr.section] args.append("--section=" + ctx.attr.section)
if ctx.attr.homepage: if ctx.attr.homepage:
args += ["--homepage=" + ctx.attr.homepage] args.append("--homepage=" + ctx.attr.homepage)
if ctx.attr.license: if ctx.attr.license:
args += ["--license=" + ctx.attr.license] args.append("--license=" + ctx.attr.license)
args += ["--distribution=" + ctx.attr.distribution] args.append("--distribution=" + ctx.attr.distribution)
args += ["--urgency=" + ctx.attr.urgency] args.append("--urgency=" + ctx.attr.urgency)
args += ["--suggests=" + d for d in ctx.attr.suggests] args += ["--suggests=" + d for d in ctx.attr.suggests]
args += ["--enhances=" + d for d in ctx.attr.enhances] args += ["--enhances=" + d for d in ctx.attr.enhances]
args += ["--conflicts=" + d for d in ctx.attr.conflicts] args += ["--conflicts=" + d for d in ctx.attr.conflicts]
@ -229,14 +229,14 @@ pkg_deb_impl = rule(
"changelog": attr.label( "changelog": attr.label(
doc = """The package changelog. doc = """The package changelog.
See https://www.debian.org/doc/debian-policy/ch-source.html#s-dpkgchangelog.""", See https://www.debian.org/doc/debian-policy/ch-source.html#s-dpkgchangelog.""",
allow_single_file = True allow_single_file = True,
), ),
"description": attr.string( "description": attr.string(
doc = """The package description. Must not be used with `description_file`.""", doc = """The package description. Must not be used with `description_file`.""",
), ),
"description_file": attr.label( "description_file": attr.label(
doc = """The package description. Must not be used with `description`.""", doc = """The package description. Must not be used with `description`.""",
allow_single_file = True allow_single_file = True,
), ),
"distribution": attr.string( "distribution": attr.string(
doc = """"distribution: See http://www.debian.org/doc/debian-policy.""", doc = """"distribution: See http://www.debian.org/doc/debian-policy.""",
@ -277,11 +277,11 @@ pkg_deb_impl = rule(
allow_single_file = True, allow_single_file = True,
), ),
"built_using": attr.string( "built_using": attr.string(
doc="""The tool that were used to build this package provided either inline (with built_using) or from a file (with built_using_file).""" doc = """The tool that were used to build this package provided either inline (with built_using) or from a file (with built_using_file).""",
), ),
"built_using_file": attr.label( "built_using_file": attr.label(
doc="""The tool that were used to build this package provided either inline (with built_using) or from a file (with built_using_file).""", doc = """The tool that were used to build this package provided either inline (with built_using) or from a file (with built_using_file).""",
allow_single_file = True allow_single_file = True,
), ),
"conffiles": attr.string_list( "conffiles": attr.string_list(
doc = """The list of conffiles or a file containing one conffile per line. Each item is an absolute path on the target system where the deb is installed. doc = """The list of conffiles or a file containing one conffile per line. Each item is an absolute path on the target system where the deb is installed.
@ -303,7 +303,6 @@ See https://www.debian.org/doc/debian-policy/ch-files.html#s-config-files.""",
), ),
"homepage": attr.string(doc = """The homepage of the project."""), "homepage": attr.string(doc = """The homepage of the project."""),
"license": attr.string(doc = """The license of the project."""), "license": attr.string(doc = """The license of the project."""),
"breaks": attr.string_list( "breaks": attr.string_list(
doc = """See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.""", doc = """See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.""",
default = [], default = [],
@ -349,7 +348,7 @@ See https://www.debian.org/doc/debian-policy/ch-files.html#s-config-files.""",
# Common attributes # Common attributes
"out": attr.output( "out": attr.output(
doc = """See [Common Attributes](#out)""", doc = """See [Common Attributes](#out)""",
mandatory = True mandatory = True,
), ),
"package_file_name": attr.string( "package_file_name": attr.string(
doc = """See [Common Attributes](#package_file_name). doc = """See [Common Attributes](#package_file_name).
@ -373,7 +372,7 @@ See https://www.debian.org/doc/debian-policy/ch-files.html#s-config-files.""",
def pkg_deb(name, out = None, **kwargs): def pkg_deb(name, out = None, **kwargs):
"""@wraps(pkg_deb_impl).""" """@wraps(pkg_deb_impl)."""
if not out: if not out:
out = name + ".deb" out = name + ".deb"
pkg_deb_impl( pkg_deb_impl(
name = name, name = name,
out = out, out = out,

View File

@ -1,5 +1,4 @@
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
load("git.bzl", "git_changelog")
package( package(
default_applicable_licenses = ["//:license"], default_applicable_licenses = ["//:license"],

View File

@ -14,6 +14,7 @@ def print_rel_notes(
mirror_host = None): mirror_host = None):
if not artifact_name: if not artifact_name:
artifact_name = ":%s-%s.tar.gz" % (repo, version) artifact_name = ":%s-%s.tar.gz" % (repo, version)
# Must use Label to get a path relative to the rules_pkg repository, # Must use Label to get a path relative to the rules_pkg repository,
# instead of the calling BUILD file. # instead of the calling BUILD file.
print_rel_notes_helper = Label("//pkg/releasing:print_rel_notes") print_rel_notes_helper = Label("//pkg/releasing:print_rel_notes")
@ -33,6 +34,7 @@ def print_rel_notes(
cmd.append("--toolchains_method=%s" % toolchains_method) cmd.append("--toolchains_method=%s" % toolchains_method)
if changelog: if changelog:
cmd.append("--changelog=$(location %s)" % changelog) cmd.append("--changelog=$(location %s)" % changelog)
# We should depend on a changelog as a tool so that it is always built # We should depend on a changelog as a tool so that it is always built
# for the host configuration. If the changelog is generated on the fly, # for the host configuration. If the changelog is generated on the fly,
# then we would have to run commands against our revision control # then we would have to run commands against our revision control

View File

@ -83,7 +83,6 @@ _git_changelog = rule(
toolchains = ["@rules_pkg//toolchains/git:git_toolchain_type"], toolchains = ["@rules_pkg//toolchains/git:git_toolchain_type"],
) )
def git_changelog(name, **kwargs): def git_changelog(name, **kwargs):
_git_changelog( _git_changelog(
name = name, name = name,
@ -93,5 +92,5 @@ def git_changelog(name, **kwargs):
str(Label("//toolchains/git:have_git")): [], str(Label("//toolchains/git:have_git")): [],
"//conditions:default": ["//:not_compatible"], "//conditions:default": ["//:not_compatible"],
}), }),
**kwargs, **kwargs
) )

View File

@ -29,8 +29,8 @@ The mechanism for choosing between the two is documented in the function itself.
""" """
load("//pkg/legacy:rpm.bzl", pkg_rpm_legacy = "pkg_rpm")
load("//pkg:rpm_pfg.bzl", pkg_rpm_pfg = "pkg_rpm") load("//pkg:rpm_pfg.bzl", pkg_rpm_pfg = "pkg_rpm")
load("//pkg/legacy:rpm.bzl", pkg_rpm_legacy = "pkg_rpm")
def pkg_rpm(name, srcs = None, spec_file = None, **kwargs): def pkg_rpm(name, srcs = None, spec_file = None, **kwargs):
"""pkg_rpm wrapper """pkg_rpm wrapper

View File

@ -670,7 +670,7 @@ def _pkg_rpm_impl(ctx):
output_groups = { output_groups = {
"out": [default_file], "out": [default_file],
"rpm": [output_file], "rpm": [output_file],
"changes": changes "changes": changes,
} }
return [ return [
OutputGroupInfo(**output_groups), OutputGroupInfo(**output_groups),

View File

@ -15,12 +15,12 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
load("@rules_python//python:defs.bzl", "py_test") load("@rules_python//python:defs.bzl", "py_test")
load(":my_package_name.bzl", "my_package_naming")
load(":path_test.bzl", "path_tests")
load("//pkg:deb.bzl", "pkg_deb") load("//pkg:deb.bzl", "pkg_deb")
load("//pkg:mappings.bzl", "pkg_attributes", "pkg_files", "strip_prefix") load("//pkg:mappings.bzl", "pkg_attributes", "pkg_files", "strip_prefix")
load("//pkg:tar.bzl", "pkg_tar") load("//pkg:tar.bzl", "pkg_tar")
load("//pkg:zip.bzl", "pkg_zip") load("//pkg:zip.bzl", "pkg_zip")
load(":my_package_name.bzl", "my_package_naming")
load(":path_test.bzl", "path_tests")
package( package(
default_applicable_licenses = ["//:license"], default_applicable_licenses = ["//:license"],
@ -75,16 +75,16 @@ py_test(
srcs = [ srcs = [
"archive_test.py", "archive_test.py",
], ],
imports = [".."],
data = [ data = [
"//tests:testdata/empty.ar",
"//tests:testdata/a_ab.ar",
"//tests:testdata/a.ar", "//tests:testdata/a.ar",
"//tests:testdata/a_b_ab.ar", "//tests:testdata/a_ab.ar",
"//tests:testdata/a_b.ar", "//tests:testdata/a_b.ar",
"//tests:testdata/a_b_ab.ar",
"//tests:testdata/ab.ar", "//tests:testdata/ab.ar",
"//tests:testdata/b.ar", "//tests:testdata/b.ar",
"//tests:testdata/empty.ar",
], ],
imports = [".."],
python_version = "PY3", python_version = "PY3",
srcs_version = "PY3", srcs_version = "PY3",
deps = [ deps = [

View File

@ -16,11 +16,11 @@
# Tests for pkg_deb specific behavior # Tests for pkg_deb specific behavior
load("@rules_python//python:defs.bzl", "py_test") load("@rules_python//python:defs.bzl", "py_test")
load(":deb_tests.bzl", "package_naming_test")
load("//pkg:mappings.bzl", "pkg_mklink")
load("//pkg:deb.bzl", "pkg_deb") load("//pkg:deb.bzl", "pkg_deb")
load("//pkg:mappings.bzl", "pkg_mklink")
load("//pkg:tar.bzl", "pkg_tar") load("//pkg:tar.bzl", "pkg_tar")
load("//tests:my_package_name.bzl", "my_package_naming") load("//tests:my_package_name.bzl", "my_package_naming")
load(":deb_tests.bzl", "package_naming_test")
package(default_applicable_licenses = ["//:license"]) package(default_applicable_licenses = ["//:license"])
@ -96,11 +96,11 @@ py_test(
srcs = [ srcs = [
"pkg_deb_test.py", "pkg_deb_test.py",
], ],
imports = ["../.."],
data = [ data = [
# The target includes both the .deb and .changes files in DefaultInfo # The target includes both the .deb and .changes files in DefaultInfo
":test_deb", ":test_deb",
], ],
imports = ["../.."],
python_version = "PY3", python_version = "PY3",
deps = [ deps = [
"//pkg/private:archive", "//pkg/private:archive",
@ -130,6 +130,9 @@ py_test(
# Test case for expanding $(var) constructions and for using ctx.var directly # Test case for expanding $(var) constructions and for using ctx.var directly
pkg_deb( pkg_deb(
name = "deb_using_ctxvar", name = "deb_using_ctxvar",
# This does not make sense for architecture, but for testing, compilation
# mode is more stable than cpu.
architecture = "$(COMPILATION_MODE)",
config = "config", config = "config",
data = ":tar_input", data = ":tar_input",
description = "Compiled with $(COMPILATION_MODE)", description = "Compiled with $(COMPILATION_MODE)",
@ -137,9 +140,6 @@ pkg_deb(
maintainer = "soméone@somewhere.com", maintainer = "soméone@somewhere.com",
package = "fizzbuzz", package = "fizzbuzz",
version = "7", version = "7",
# This does not make sense for architecture, but for testing, compilation
# mode is more stable than cpu.
architecture = "$(COMPILATION_MODE)",
) )
package_naming_test( package_naming_test(

View File

@ -23,10 +23,10 @@ py_test(
name = "install_test", name = "install_test",
srcs = ["test.py"], srcs = ["test.py"],
args = ["-v"], args = ["-v"],
imports = ["../.."],
data = [ data = [
":test_installer", ":test_installer",
], ],
imports = ["../.."],
main = "test.py", main = "test.py",
tags = [ tags = [
# TODO(nacl): investigate this. See also # TODO(nacl): investigate this. See also

View File

@ -12,23 +12,21 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
load(
":mappings_test.bzl",
"manifest_golden_test",
"mappings_analysis_tests",
"mappings_unit_tests",
)
load(":mappings_external_repo_test.bzl", "mappings_external_repo_analysis_tests")
load( load(
"//pkg:mappings.bzl", "//pkg:mappings.bzl",
"pkg_attributes", "pkg_attributes",
"pkg_filegroup",
"pkg_files", "pkg_files",
"pkg_mkdirs", "pkg_mkdirs",
"strip_prefix", "strip_prefix",
) )
load("//tests/util:defs.bzl", "directory", "link_tree", "write_content_manifest") load("//tests/util:defs.bzl", "directory", "link_tree", "write_content_manifest")
load("@rules_python//python:defs.bzl", "py_test") load(":mappings_external_repo_test.bzl", "mappings_external_repo_analysis_tests")
load(
":mappings_test.bzl",
"manifest_golden_test",
"mappings_analysis_tests",
"mappings_unit_tests",
)
package(default_applicable_licenses = ["//:license"]) package(default_applicable_licenses = ["//:license"])
@ -137,11 +135,11 @@ write_content_manifest(
) )
alias( alias(
name = "executable_test_expected", name = "executable_test_expected",
actual = select({ actual = select({
"@platforms//os:windows": "executable.manifest.windows.golden", "@platforms//os:windows": "executable.manifest.windows.golden",
"//conditions:default": "executable.manifest.golden", "//conditions:default": "executable.manifest.golden",
}), }),
) )
manifest_golden_test( manifest_golden_test(

View File

@ -13,9 +13,9 @@
# limitations under the License. # limitations under the License.
load("@rules_python//python:defs.bzl", "py_test") load("@rules_python//python:defs.bzl", "py_test")
load(":defs.bzl", "inspect_directory_test")
load("//pkg:mappings.bzl", "filter_directory") load("//pkg:mappings.bzl", "filter_directory")
load("//tests/util:defs.bzl", "directory") load("//tests/util:defs.bzl", "directory")
load(":defs.bzl", "inspect_directory_test")
# TODO: the below tests only check for rule success and confirmation that # TODO: the below tests only check for rule success and confirmation that
# directory structure matches expectations. A more thorough test implementation # directory structure matches expectations. A more thorough test implementation

View File

@ -14,10 +14,7 @@
"""Tests for file mapping routines in pkg/mappings.bzl""" """Tests for file mapping routines in pkg/mappings.bzl"""
load("@bazel_skylib//lib:new_sets.bzl", "sets")
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts", "unittest")
load(":mappings_test.bzl", "pkg_files_contents_test") load(":mappings_test.bzl", "pkg_files_contents_test")
load("//pkg:providers.bzl", "PackageFilegroupInfo", "PackageFilesInfo")
load("//pkg:mappings.bzl", "pkg_files", "strip_prefix") load("//pkg:mappings.bzl", "pkg_files", "strip_prefix")
########## ##########

View File

@ -14,14 +14,9 @@
"""Tests for file mapping routines in pkg/mappings.bzl""" """Tests for file mapping routines in pkg/mappings.bzl"""
load("@bazel_skylib//lib:new_sets.bzl", "sets")
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts", "unittest") load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts", "unittest")
load( load("@rules_python//python:defs.bzl", "py_test")
"//pkg:providers.bzl",
"PackageDirsInfo",
"PackageFilegroupInfo",
"PackageFilesInfo",
"PackageSymlinkInfo",
)
load( load(
"//pkg:mappings.bzl", "//pkg:mappings.bzl",
"REMOVE_BASE_DIRECTORY", "REMOVE_BASE_DIRECTORY",
@ -32,6 +27,13 @@ load(
"pkg_mklink", "pkg_mklink",
"strip_prefix", "strip_prefix",
) )
load(
"//pkg:providers.bzl",
"PackageDirsInfo",
"PackageFilegroupInfo",
"PackageFilesInfo",
"PackageSymlinkInfo",
)
load( load(
"//tests/util:defs.bzl", "//tests/util:defs.bzl",
"directory", "directory",
@ -39,8 +41,6 @@ load(
"generic_base_case_test", "generic_base_case_test",
"generic_negative_test", "generic_negative_test",
) )
load("@bazel_skylib//lib:new_sets.bzl", "sets")
load("@rules_python//python:defs.bzl", "py_test")
########## ##########
# Helpers # Helpers

View File

@ -14,6 +14,7 @@
"""Tests for RPM generation analysis""" """Tests for RPM generation analysis"""
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts")
load( load(
"//pkg:mappings.bzl", "//pkg:mappings.bzl",
"pkg_filegroup", "pkg_filegroup",
@ -21,10 +22,9 @@ load(
"pkg_mkdirs", "pkg_mkdirs",
"pkg_mklink", "pkg_mklink",
) )
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts")
load("//pkg:providers.bzl", "PackageVariablesInfo") load("//pkg:providers.bzl", "PackageVariablesInfo")
load("//pkg:rpm.bzl", "pkg_rpm") load("//pkg:rpm.bzl", "pkg_rpm")
load("//tests/util:defs.bzl", "directory", "generic_base_case_test", "generic_negative_test") load("//tests/util:defs.bzl", "generic_base_case_test", "generic_negative_test")
def _declare_pkg_rpm(name, srcs_ungrouped, tags = None, **kwargs): def _declare_pkg_rpm(name, srcs_ungrouped, tags = None, **kwargs):
pfg_name = "{}_pfg".format(name) pfg_name = "{}_pfg".format(name)

View File

@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
load("@rules_python//python:defs.bzl", "py_test")
load( load(
"//pkg:mappings.bzl", "//pkg:mappings.bzl",
"REMOVE_BASE_DIRECTORY", "REMOVE_BASE_DIRECTORY",
@ -22,7 +23,6 @@ load(
) )
load("//pkg:rpm.bzl", "pkg_rpm") load("//pkg:rpm.bzl", "pkg_rpm")
load("//tests/util:defs.bzl", "directory") load("//tests/util:defs.bzl", "directory")
load("@rules_python//python:defs.bzl", "py_test")
############################################################################ ############################################################################
# Test handling of directory outputs # Test handling of directory outputs
@ -44,11 +44,11 @@ py_test(
name = "layer_with_files", name = "layer_with_files",
srcs = ["rpm_contents_vs_manifest_test.py"], srcs = ["rpm_contents_vs_manifest_test.py"],
data = [":layer_with_files_test_data"], data = [":layer_with_files_test_data"],
env = {"TEST_RPM": "test_dirs_rpm-1.1.1-2222.noarch.rpm"},
main = "rpm_contents_vs_manifest_test.py", main = "rpm_contents_vs_manifest_test.py",
tags = [ tags = [
"no_windows", # Windows doesn't have rpm(8) or rpmbuild(8) "no_windows", # Windows doesn't have rpm(8) or rpmbuild(8)
], ],
env = {"TEST_RPM": "test_dirs_rpm-1.1.1-2222.noarch.rpm"},
deps = [ deps = [
"//tests/rpm:rpm_util", "//tests/rpm:rpm_util",
"@rules_python//python/runfiles", "@rules_python//python/runfiles",
@ -205,8 +205,8 @@ py_test(
name = "treeartifact_ops", name = "treeartifact_ops",
srcs = ["rpm_treeartifact_ops_test.py"], srcs = ["rpm_treeartifact_ops_test.py"],
data = [":treeartifact_ops_rpm_test_data"], data = [":treeartifact_ops_rpm_test_data"],
main = "rpm_treeartifact_ops_test.py",
env = {"TEST_RPM": "treeartifact_ops_rpm-1.1.1-2222.noarch.rpm"}, env = {"TEST_RPM": "treeartifact_ops_rpm-1.1.1-2222.noarch.rpm"},
main = "rpm_treeartifact_ops_test.py",
tags = [ tags = [
"no_windows", # Windows doesn't have rpm(8) or rpmbuild(8) "no_windows", # Windows doesn't have rpm(8) or rpmbuild(8)
], ],

View File

@ -14,15 +14,14 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
"""Tests for pkg_tar.""" """Tests for pkg_tar."""
load("@rules_python//python:defs.bzl", "py_test")
# buildifier: disable=bzl-visibility # buildifier: disable=bzl-visibility
load("//pkg:mappings.bzl", "pkg_attributes") load("//pkg:mappings.bzl", "pkg_attributes", "pkg_files", "pkg_mkdirs", "pkg_mklink")
load("//pkg:mappings.bzl", "pkg_files", "pkg_mkdirs", "pkg_mklink", "strip_prefix")
load("//pkg:verify_archive.bzl", "verify_archive_test") load("//pkg:verify_archive.bzl", "verify_archive_test")
load("//pkg/private/tar:tar.bzl", "SUPPORTED_TAR_COMPRESSIONS", "pkg_tar") load("//pkg/private/tar:tar.bzl", "SUPPORTED_TAR_COMPRESSIONS", "pkg_tar")
load("//tests:my_package_name.bzl", "my_package_naming") load("//tests:my_package_name.bzl", "my_package_naming")
load("//tests/util:defs.bzl", "directory", "fake_artifact", "link_tree") load("//tests/util:defs.bzl", "directory", "fake_artifact", "link_tree")
load("@rules_python//python:defs.bzl", "py_test")
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
package( package(
default_applicable_licenses = ["//:license"], default_applicable_licenses = ["//:license"],
@ -34,7 +33,6 @@ py_test(
srcs = [ srcs = [
"tar_writer_test.py", "tar_writer_test.py",
], ],
imports = ["../.."],
data = [ data = [
":compressor", ":compressor",
":test_tar_compression", ":test_tar_compression",
@ -46,6 +44,7 @@ py_test(
"//tests:testdata/tar_test.tar.xz", "//tests:testdata/tar_test.tar.xz",
"//tests:testdata/test_tar_package_dir_file.txt", "//tests:testdata/test_tar_package_dir_file.txt",
], ],
imports = ["../.."],
python_version = "PY3", python_version = "PY3",
srcs_version = "PY3", srcs_version = "PY3",
deps = [ deps = [
@ -348,7 +347,6 @@ py_test(
srcs = [ srcs = [
"pkg_tar_test.py", "pkg_tar_test.py",
], ],
imports = ["../.."],
data = [ data = [
":test-pkg-tar-from-pkg-files-with-attributes", ":test-pkg-tar-from-pkg-files-with-attributes",
":test-pkg-tar-with-attributes", ":test-pkg-tar-with-attributes",
@ -382,6 +380,7 @@ py_test(
":test-tar-inclusion-%s" % compression ":test-tar-inclusion-%s" % compression
for compression in SUPPORTED_TAR_COMPRESSIONS for compression in SUPPORTED_TAR_COMPRESSIONS
], ],
imports = ["../.."],
python_version = "PY3", python_version = "PY3",
deps = [ deps = [
"//pkg/private/tar:tar_writer", "//pkg/private/tar:tar_writer",

View File

@ -13,12 +13,12 @@
# limitations under the License. # limitations under the License.
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
load("@rules_python//python:defs.bzl", "py_library", "py_test")
load("//pkg:mappings.bzl", "pkg_attributes", "pkg_mkdirs", "pkg_mklink") load("//pkg:mappings.bzl", "pkg_attributes", "pkg_mkdirs", "pkg_mklink")
load("//pkg:zip.bzl", "pkg_zip") load("//pkg:zip.bzl", "pkg_zip")
load("//tests:my_package_name.bzl", "my_package_naming") load("//tests:my_package_name.bzl", "my_package_naming")
load("//tests/util:defs.bzl", "directory", "fake_artifact") load("//tests/util:defs.bzl", "directory")
load("@rules_python//python:defs.bzl", "py_library", "py_test")
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
package(default_applicable_licenses = ["//:license"]) package(default_applicable_licenses = ["//:license"])
@ -242,9 +242,10 @@ pkg_zip(
srcs = [ srcs = [
"//tests:testdata/loremipsum.txt", "//tests:testdata/loremipsum.txt",
], ],
compression_type = "deflated",
compression_level = 3, compression_level = 3,
compression_type = "deflated",
) )
pkg_zip( pkg_zip(
name = "test_zip_bzip2", name = "test_zip_bzip2",
srcs = [ srcs = [
@ -252,6 +253,7 @@ pkg_zip(
], ],
compression_type = "bzip2", compression_type = "bzip2",
) )
pkg_zip( pkg_zip(
name = "test_zip_lzma", name = "test_zip_lzma",
srcs = [ srcs = [
@ -259,6 +261,7 @@ pkg_zip(
], ],
compression_type = "lzma", compression_type = "lzma",
) )
pkg_zip( pkg_zip(
name = "test_zip_stored", name = "test_zip_stored",
srcs = [ srcs = [
@ -278,16 +281,16 @@ py_test(
":test-zip-strip_prefix-none.zip", ":test-zip-strip_prefix-none.zip",
":test-zip-strip_prefix-zipcontent.zip", ":test-zip-strip_prefix-zipcontent.zip",
":test_zip_basic.zip", ":test_zip_basic.zip",
":test_zip_bzip2",
":test_zip_deflated_level_3",
":test_zip_empty.zip", ":test_zip_empty.zip",
":test_zip_lzma",
":test_zip_package_dir0.zip", ":test_zip_package_dir0.zip",
":test_zip_package_dir_substitution.zip", ":test_zip_package_dir_substitution.zip",
":test_zip_permissions.zip", ":test_zip_permissions.zip",
":test_zip_stored",
":test_zip_timestamp.zip", ":test_zip_timestamp.zip",
":test_zip_tree.zip", ":test_zip_tree.zip",
":test_zip_deflated_level_3",
":test_zip_bzip2",
":test_zip_lzma",
":test_zip_stored",
], ],
python_version = "PY3", python_version = "PY3",
deps = [ deps = [
@ -320,7 +323,7 @@ py_test(
pkg_zip( pkg_zip(
name = "unicode_names", name = "unicode_names",
srcs = ["//tests:utf8_files"] srcs = ["//tests:utf8_files"],
) )
py_test( py_test(

View File

@ -16,7 +16,7 @@
# NOTE: this must match the name used by register_toolchains in consuming # NOTE: this must match the name used by register_toolchains in consuming
# MODULE.bazel files. It seems like we should have a better interface that # MODULE.bazel files. It seems like we should have a better interface that
# allows for this module name to be specified from a single point. # allows for this module name to be specified from a single point.
NAME="rules_pkg_rpmbuild" NAME = "rules_pkg_rpmbuild"
def _write_build(rctx, path, version): def _write_build(rctx, path, version):
if not path: if not path:
@ -38,7 +38,7 @@ def _build_repo_for_rpmbuild_toolchain_impl(rctx):
if rpmbuild_path: if rpmbuild_path:
print("Found rpmbuild at '%s'" % rpmbuild_path) # buildifier: disable=print print("Found rpmbuild at '%s'" % rpmbuild_path) # buildifier: disable=print
else: else:
print("No system rpmbuild found.") # buildifier: disable=print print("No system rpmbuild found.") # buildifier: disable=print
version = "unknown" version = "unknown"
if rpmbuild_path: if rpmbuild_path:
res = rctx.execute([rpmbuild_path, "--version"]) res = rctx.execute([rpmbuild_path, "--version"])
@ -62,11 +62,11 @@ build_repo_for_rpmbuild_toolchain = repository_rule(
) )
# For use from WORKSPACE # For use from WORKSPACE
def find_system_rpmbuild(name, verbose=False): def find_system_rpmbuild(name, verbose = False):
build_repo_for_rpmbuild_toolchain(name=name, verbose=verbose) build_repo_for_rpmbuild_toolchain(name = name, verbose = verbose)
native.register_toolchains("@%s//:all" % name) native.register_toolchains("@%s//:all" % name)
# For use from MODULE.bzl # For use from MODULE.bzl
find_system_rpmbuild_bzlmod = module_extension( find_system_rpmbuild_bzlmod = module_extension(
implementation = lambda ctx: build_repo_for_rpmbuild_toolchain(name=NAME) implementation = lambda ctx: build_repo_for_rpmbuild_toolchain(name = NAME),
) )