Skip to content

Commit

Permalink
Pre commit autoupdate and format files (#913)
Browse files Browse the repository at this point in the history
* chore(deps): pre-commit autoupdate

* format files
  • Loading branch information
hofbi authored Jan 19, 2025
1 parent 0482d31 commit b0b1d47
Show file tree
Hide file tree
Showing 19 changed files with 104 additions and 91 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
repos:
# Check formatting and lint for starlark code
- repo: https://github.com/keith/pre-commit-buildifier
rev: 6.3.3
rev: 8.0.0
hooks:
- id: buildifier
- id: buildifier-lint
Expand Down
1 change: 1 addition & 0 deletions WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ experimental_find_system_git_bzlmod(
name = "rules_pkg_git",
verbose = False,
)

register_toolchains(
"@rules_pkg_git//:git_auto_toolchain",
"//toolchains/git:git_missing_toolchain",
Expand Down
11 changes: 5 additions & 6 deletions examples/rpm/debuginfo/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@
# limitations under the License.
# -*- coding: utf-8 -*-


load("@rules_pkg//pkg:mappings.bzl", "pkg_files")
load("@rules_pkg//pkg:rpm.bzl", "pkg_rpm")

cc_binary(
name = "test",
copts = ["-g"],
srcs = [
"test.c",
],
copts = ["-g"],
)

pkg_files(
Expand All @@ -37,12 +36,12 @@ pkg_rpm(
srcs = [
":rpm_files",
],
release = "0",
version = "1",
debuginfo = True,
description = "Description",
license = "Some license",
release = "0",
summary = "Summary",
description = "Description",
debuginfo = True,
version = "1",
)

# If you have rpmbuild, you probably have rpm2cpio too.
Expand Down
1 change: 0 additions & 1 deletion examples/rpm/debuginfo/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
module(name = "rules_pkg_example_rpm_system_rpmbuild_bzlmod")

bazel_dep(name = "rules_pkg")

local_path_override(
module_name = "rules_pkg",
path = "../../..",
Expand Down
14 changes: 7 additions & 7 deletions examples/rpm/nospecfile/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ pkg_rpm(
srcs = [
":rpm_files",
],
release = "0",
version = "1",
summary = "rules_pkg example RPM",
architecture = "x86_64",
description = "This is a package description.",
license = "Apache License, v2.0",
architecture = "x86_64",
requires = [
"somerpm",
],
provides = [
"somefile",
],
release = "0",
requires = [
"somerpm",
],
summary = "rules_pkg example RPM",
version = "1",
)

# If you have rpmbuild, you probably have rpm2cpio too.
Expand Down
1 change: 0 additions & 1 deletion examples/rpm/nospecfile/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
module(name = "rules_pkg_example_rpm_system_rpmbuild_bzlmod")

bazel_dep(name = "rules_pkg")

local_path_override(
module_name = "rules_pkg",
path = "../../..",
Expand Down
2 changes: 1 addition & 1 deletion examples/rpm/prebuilt_rpmbuild/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ pkg_rpm(
name = "test-rpm",
data = [
"BUILD",
"WORKSPACE",
"README.md",
"WORKSPACE",
"test_rpm.spec",
],
release = "0",
Expand Down
28 changes: 14 additions & 14 deletions examples/rpm/subrpm/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# -*- coding: utf-8 -*-

load("@rules_pkg//pkg:mappings.bzl", "pkg_files")
load("@rules_pkg//pkg:rpm.bzl", "pkg_sub_rpm", "pkg_rpm")
load("@rules_pkg//pkg:rpm.bzl", "pkg_rpm", "pkg_sub_rpm")

pkg_files(
name = "subrpm_files",
Expand All @@ -26,17 +26,17 @@ pkg_files(
pkg_sub_rpm(
name = "subrpm",
package_name = "subrpm",
summary = "Test subrpm",
description = "Test subrpm description",
requires = [
"somerpm",
srcs = [
":subrpm_files",
],
description = "Test subrpm description",
provides = [
"someprovision",
],
srcs = [
":subrpm_files",
requires = [
"somerpm",
],
summary = "Test subrpm",
)

pkg_files(
Expand All @@ -52,21 +52,21 @@ pkg_rpm(
srcs = [
":rpm_files",
],
release = "0",
version = "1",
summary = "rules_pkg example RPM",
architecture = "x86_64",
description = "This is a package description.",
license = "Apache License, v2.0",
architecture = "x86_64",
requires = [
"somerpm",
],
provides = [
"somefile",
],
release = "0",
requires = [
"somerpm",
],
subrpms = [
":subrpm",
],
summary = "rules_pkg example RPM",
version = "1",
)

# If you have rpmbuild, you probably have rpm2cpio too.
Expand Down
1 change: 0 additions & 1 deletion examples/rpm/subrpm/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
module(name = "rules_pkg_example_rpm_system_rpmbuild_bzlmod")

bazel_dep(name = "rules_pkg")

local_path_override(
module_name = "rules_pkg",
path = "../../..",
Expand Down
2 changes: 1 addition & 1 deletion examples/rpm/system_rpmbuild/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ pkg_rpm(
name = "test-rpm",
data = [
"BUILD",
"WORKSPACE",
"README.md",
"WORKSPACE",
"test_rpm.spec",
],
release = "0",
Expand Down
2 changes: 1 addition & 1 deletion examples/rpm/system_rpmbuild/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ load(
"find_system_rpmbuild",
)

find_system_rpmbuild(name="my_rpmbuild")
find_system_rpmbuild(name = "my_rpmbuild")
1 change: 0 additions & 1 deletion examples/rpm/system_rpmbuild_bzlmod/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
module(name = "rules_pkg_example_rpm_system_rpmbuild_bzlmod")

bazel_dep(name = "rules_pkg")

local_path_override(
module_name = "rules_pkg",
path = "../../..",
Expand Down
2 changes: 1 addition & 1 deletion mappings.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

load(
"//pkg:mappings.bzl",
_REMOVE_BASE_DIRECTORY = "REMOVE_BASE_DIRECTORY",
_filter_directory = "filter_directory",
_pkg_attributes = "pkg_attributes",
_pkg_filegroup = "pkg_filegroup",
_pkg_files = "pkg_files",
_pkg_mkdirs = "pkg_mkdirs",
_pkg_mklink = "pkg_mklink",
_strip_prefix = "strip_prefix",
_REMOVE_BASE_DIRECTORY = "REMOVE_BASE_DIRECTORY",
)

REMOVE_BASE_DIRECTORY = _REMOVE_BASE_DIRECTORY
Expand Down
4 changes: 2 additions & 2 deletions pkg/private/tar/tar.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ pkg_tar_impl = rule(
"symlinks": attr.string_dict(),
"empty_files": attr.string_list(),
"include_runfiles": attr.bool(
doc = ("""Include runfiles for executables. These appear as they would in bazel-bin."""
+ """For example: 'path/to/myprog.runfiles/path/to/my_data.txt'."""),
doc = ("""Include runfiles for executables. These appear as they would in bazel-bin.""" +
"""For example: 'path/to/myprog.runfiles/path/to/my_data.txt'."""),
),
"empty_dirs": attr.string_list(),
"remap_paths": attr.string_dict(),
Expand Down
2 changes: 1 addition & 1 deletion pkg/rpm.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def pkg_rpm(name, srcs = None, spec_file = None, subrpms = None, **kwargs):
pkg_rpm_pfg(
name = name,
srcs = srcs,
subrpms = subrpms,
subrpms = subrpms,
**kwargs
)
elif spec_file:
Expand Down
37 changes: 22 additions & 15 deletions pkg/rpm_pfg.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def _make_absolute_if_not_already_or_is_macro(path):
# this can be inlined easily.
return path if path.startswith(("/", "%")) else "/" + path

def _make_rpm_filename(rpm_name, version, architecture, package_name=None, release=None):
def _make_rpm_filename(rpm_name, version, architecture, package_name = None, release = None):
prefix = "%s-%s"
items = [rpm_name, version]

Expand All @@ -185,7 +185,7 @@ def _make_rpm_filename(rpm_name, version, architecture, package_name=None, relea

if release:
prefix += "-%s"
items += [release]
items.append(release)

fmt = prefix + ".%s.rpm"

Expand Down Expand Up @@ -315,7 +315,7 @@ def _process_dep(dep, rpm_ctx, debuginfo_type):
dep.label,
file_base,
rpm_ctx,
debuginfo_type
debuginfo_type,
)
for entry, origin in pfg_info.pkg_dirs:
file_base = _make_filetags(entry.attributes, "%dir")
Expand Down Expand Up @@ -351,25 +351,25 @@ def _process_subrpm(ctx, rpm_name, rpm_info, rpm_ctx, debuginfo_type):
]

if rpm_info.architecture:
rpm_lines += ["BuildArch: %s" % rpm_info.architecture]
rpm_lines.append("BuildArch: %s" % rpm_info.architecture)

if rpm_info.epoch:
rpm_lines += ["Epoch: %s" % rpm_info.epoch]
rpm_lines.append("Epoch: %s" % rpm_info.epoch)

if rpm_info.version:
rpm_lines += ["Version: %s" % rpm_info.version]
rpm_lines.append("Version: %s" % rpm_info.version)

for r in rpm_info.requires:
rpm_lines += ["Requires: %s" % r]
rpm_lines.append("Requires: %s" % r)

for p in rpm_info.provides:
rpm_lines += ["Provides: %s" % p]
rpm_lines.append("Provides: %s" % p)

for c in rpm_info.conflicts:
rpm_lines += ["Conflicts: %s" % c]
rpm_lines.append("Conflicts: %s" % c)

for o in rpm_info.obsoletes:
rpm_lines += ["Obsoletes: %s" % o]
rpm_lines.append("Obsoletes: %s" % o)

rpm_lines += [
"",
Expand All @@ -394,10 +394,10 @@ def _process_subrpm(ctx, rpm_name, rpm_info, rpm_ctx, debuginfo_type):

# rpmbuild will be unhappy if we have no files so we stick
# default file mode in for that scenario
rpm_lines += [DEFAULT_FILE_MODE]
rpm_lines.append(DEFAULT_FILE_MODE)
rpm_lines += sub_rpm_ctx.rpm_files_list

rpm_lines += [""]
rpm_lines.append("")

rpm_ctx.install_script_pieces.extend(sub_rpm_ctx.install_script_pieces)
rpm_ctx.packaged_directories.extend(sub_rpm_ctx.packaged_directories)
Expand Down Expand Up @@ -726,7 +726,12 @@ def _pkg_rpm_impl(ctx):
subrpm_lines = []
for s in ctx.attr.subrpms:
subrpm_lines.extend(_process_subrpm(
ctx, rpm_name, s[PackageSubRPMInfo], rpm_ctx, debuginfo_type))
ctx,
rpm_name,
s[PackageSubRPMInfo],
rpm_ctx,
debuginfo_type,
))

subrpm_file = ctx.actions.declare_file(
"{}.spec.subrpms".format(rpm_name),
Expand All @@ -740,7 +745,8 @@ def _pkg_rpm_impl(ctx):

if debuginfo_type != "none":
debuginfo_default_file = ctx.actions.declare_file(
"{}-debuginfo.rpm".format(rpm_name))
"{}-debuginfo.rpm".format(rpm_name),
)
debuginfo_package_file_name = _make_rpm_filename(
rpm_name,
ctx.attr.version,
Expand All @@ -757,7 +763,8 @@ def _pkg_rpm_impl(ctx):

rpm_ctx.output_rpm_files.append(debuginfo_output_file)
rpm_ctx.make_rpm_args.append(
"--subrpm_out_file=debuginfo:%s" % debuginfo_output_file.path )
"--subrpm_out_file=debuginfo:%s" % debuginfo_output_file.path,
)

#### Procedurally-generated scripts/lists (%install, %files)

Expand Down
3 changes: 1 addition & 2 deletions tests/mappings/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_python//python:defs.bzl", "py_library")
load(
"//pkg:mappings.bzl",
"pkg_attributes",
Expand All @@ -27,8 +28,6 @@ load(
"mappings_analysis_tests",
"mappings_unit_tests",
)
load("@rules_python//python:defs.bzl", "py_library")


package(default_applicable_licenses = ["//:license"])

Expand Down
Loading

0 comments on commit b0b1d47

Please sign in to comment.