Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/publish_to_bcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
uses: "bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@v1.1.0"
with:
tag_name: "${{ inputs.version }}"
tag_prefix: ""
tag_prefix: "rules_pkg_providers-"
registry_fork: "bazel-contrib/bazel-central-registry"
draft: false
secrets:
Expand Down
10 changes: 7 additions & 3 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
module(
name = "rules_pkg",
version = "", # set by release pipeline from version.bzl.
compatibility_level = 1,
repo_name = "rules_pkg",
)

local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository")

local_repository(
name = "rules_pkg_providers",
path = "providers",
)

# Do not update to newer versions until you need a specific new feature.
bazel_dep(name = "rules_license", version = "1.0.0")
bazel_dep(name = "rules_python", version = "1.7.0")
Expand Down Expand Up @@ -36,8 +42,6 @@ register_toolchains(
dev_dependency = True,
)

local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository")

local_repository(
name = "mappings_test_external_repo",
path = "tests/mappings/external_repo",
Expand Down
1 change: 1 addition & 0 deletions distro/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ py_test(
":distro",
":small_module",
"//:standard_package",
"@rules_pkg_providers//:providers.bzl",
],
env_inherit = ["PATH"],
imports = [".."],
Expand Down
1 change: 1 addition & 0 deletions distro/packaging_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def _module_bazel_lines(self, local_path, sha256):
'module(name = "test_rules_pkg_packaging")',
f'bazel_dep(name = "{self.source_repo}", version = "{self.version}", repo_name = "{self.dest_repo}")',
f'archive_override(module_name = "{self.source_repo}", sha256 = "{sha256}", url = "file://{local_path}")',
f'bazel_dep(name = "rules_pkg_providers", version = "1.0.0")',
)

def _workspace_lines(self, local_path, sha256):
Expand Down
87 changes: 14 additions & 73 deletions pkg/providers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,78 +14,19 @@

"""Packaging related providers."""

PackageArtifactInfo = provider(
doc = """Metadata about a package artifact.""",
fields = {
"file": "File object for said artifact",
"file_name": "DEPRECATED (use fields of file instead): The file name of the artifact.",
"label": "Label which produced it",
},
load(
"@rules_pkg_providers//:providers.bzl",
_PackageArtifactInfo = "PackageArtifactInfo",
_PackageDirsInfo = "PackageDirsInfo",
_PackageFilegroupInfo = "PackageFilegroupInfo",
_PackageFilesInfo = "PackageFilesInfo",
_PackageSymlinkInfo = "PackageSymlinkInfo",
_PackageVariablesInfo = "PackageVariablesInfo",
)

PackageVariablesInfo = provider(
doc = """Variables which may be substituted into package names and content.""",
fields = {
"values": "Dict of name/value pairs",
},
)

PackageFilesInfo = provider(
doc = """Provider representing the installation of one or more files to destination with attributes""",
fields = {
"attributes": """Attribute information, represented as a `dict`.

Keys are strings representing attribute identifiers, values are
arbitrary data structures that represent the associated data. These are
most often strings, but are not explicitly defined.

For known attributes and data type expectations, see the Common
Attributes documentation in the `rules_pkg` reference.
""",

# This is a mapping of destinations to sources to allow for the same
# target to be installed to multiple locations within a package within a
# single provider.
"dest_src_map": """Map of file destinations to sources.

Sources are represented by bazel `File` structures.""",
},
)

PackageDirsInfo = provider(
doc = """Provider representing the creation of one or more directories in a package""",
fields = {
"attributes": """See `attributes` in PackageFilesInfo.""",
"dirs": """string list: installed directory names""",
},
)

PackageSymlinkInfo = provider(
doc = """Provider representing the creation of a single symbolic link in a package""",
fields = {
"attributes": """See `attributes` in PackageFilesInfo.""",
"destination": """string: Filesystem link 'name'""",
"target": """string or Label: Filesystem link 'target'.

TODO(nacl): Label sources not yet supported.
""",
},
)

# Grouping provider: the only one that needs to be consumed by packaging (or
# other) rules that materialize paths.
PackageFilegroupInfo = provider(
doc = """Provider representing a collection of related packaging providers,

In the "fields" documentation, "origin" refers to the label identifying the
where the provider was originally defined. This can be used by packaging
rules to provide better diagnostics related to where packaging rules were
created.

""",
fields = {
"pkg_files": "list of tuples of (PackageFilesInfo, origin)",
"pkg_dirs": "list of tuples of (PackageDirsInfo, origin)",
"pkg_symlinks": "list of tuples of (PackageSymlinkInfo, origin)",
},
)
PackageArtifactInfo = _PackageArtifactInfo
PackageDirsInfo = _PackageDirsInfo
PackageFilegroupInfo = _PackageFilegroupInfo
PackageFilesInfo = _PackageFilesInfo
PackageSymlinkInfo = _PackageSymlinkInfo
PackageVariablesInfo = _PackageVariablesInfo
1 change: 0 additions & 1 deletion providers/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module(
name = "rules_pkg_providers",
version = "", # set by release pipeline from version.bzl.
compatibility_level = 1,
repo_name = "rules_pkg_providers",
)

Expand Down
Loading