Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • bazel/rules_download
1 result
Show changes
Commits on Source (3)
# [1.0.0-alpha.5](https://git.gitlab.arm.com/bazel/rules_download/compare/v1.0.0-alpha.4...v1.0.0-alpha.5) (2023-12-13)
### Features
- add `symlinks` attribute to rules ([12024cf](https://git.gitlab.arm.com/bazel/rules_download/commit/12024cfe32375a4a074cb4d7fcdc558fe8342e93))
# [1.0.0-alpha.4](https://git.gitlab.arm.com/bazel/rules_download/compare/v1.0.0-alpha.3...v1.0.0-alpha.4) (2023-12-13)
### Bug Fixes
......
module(
name = "rules_download",
version = "1.0.0-alpha.4",
version = "1.0.0-alpha.5",
bazel_compatibility = [
">=7.0.0",
],
......
......@@ -68,6 +68,10 @@ Hermetic commands can be ran against the unpacked repository. Hermetic binaries
By default, the `BUILD.bazel` file exports all files downloaded. This can be controlled with the `srcs` attribute to
customise the files that are exposed to the Bazel build.
### Symlinks
Symlinks can be created in the download repositories by providing the `symlinks` map of target files to link names.
[sri]: https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity
[commands]: lib/commands.bzl
[e2e]: e2e/MODULE.bazel
......@@ -2,13 +2,14 @@ load("//lib:commands.bzl", "commands", _COMMANDS = "ATTRS")
load("//lib:download_and_extract.bzl", "download_and_extract", _DOWNLOAD_AND_EXTRACT = "ATTRS")
load("//lib:patch.bzl", "patch", _PATCH = "ATTRS")
load("//lib:build.bzl", "build", _BUILD = "ATTRS")
load("//lib:symlinks.bzl", "symlinks", _SYMLINKS = "ATTRS")
visibility("//download/...")
DOC = """
"""
ATTRS = _COMMANDS | _DOWNLOAD_AND_EXTRACT | _PATCH | _BUILD
ATTRS = _COMMANDS | _DOWNLOAD_AND_EXTRACT | _PATCH | _BUILD | _SYMLINKS
def implementation(rctx):
canonical = {a: getattr(rctx.attr, a) for a in ATTRS} | {"name": rctx.name}
......@@ -16,6 +17,7 @@ def implementation(rctx):
canonical |= download_and_extract(rctx)
canonical |= build(rctx)
canonical |= patch(rctx)
canonical |= symlinks(rctx)
canonical |= commands(rctx)
return canonical
......
......@@ -2,13 +2,14 @@ load("//lib:commands.bzl", "commands", _COMMANDS = "ATTRS")
load("//lib:download_and_extract.bzl", "download_and_extract", _DOWNLOAD_AND_EXTRACT = "ATTRS")
load("//lib:patch.bzl", "patch", _PATCH = "ATTRS")
load("//lib:build.bzl", "build", _BUILD = "ATTRS")
load("//lib:symlinks.bzl", "symlinks", _SYMLINKS = "ATTRS")
visibility("//download/...")
DOC = """
"""
ATTRS = _COMMANDS | _DOWNLOAD_AND_EXTRACT | _PATCH | _BUILD
ATTRS = _COMMANDS | _DOWNLOAD_AND_EXTRACT | _PATCH | _BUILD | _SYMLINKS
def implementation(rctx):
canonical = {a: getattr(rctx.attr, a) for a in ATTRS} | {"name": rctx.name}
......@@ -16,6 +17,7 @@ def implementation(rctx):
canonical |= download_and_extract(rctx, nested = ("data.tar.xz", "data.tar.zst"))
canonical |= build(rctx)
canonical |= patch(rctx)
canonical |= symlinks(rctx)
canonical |= commands(rctx)
return canonical
......
......@@ -2,13 +2,14 @@ load("//lib:commands.bzl", "commands", _COMMANDS = "ATTRS")
load("//lib:download.bzl", "download", _DOWNLOAD = "ATTRS")
load("//lib:patch.bzl", "patch", _PATCH = "ATTRS")
load("//lib:build.bzl", "build", _BUILD = "ATTRS")
load("//lib:symlinks.bzl", "symlinks", _SYMLINKS = "ATTRS")
visibility("//download/...")
DOC = """
"""
ATTRS = _COMMANDS | _DOWNLOAD | _PATCH | _BUILD | {
ATTRS = _COMMANDS | _DOWNLOAD | _PATCH | _BUILD | _SYMLINKS | {
"build": attr.label(
doc = "The template for the `BUILD.bazel` file.",
default = ":BUILD.tmpl.bazel",
......@@ -21,6 +22,7 @@ def implementation(rctx):
canonical |= download(rctx)
canonical |= build(rctx)
canonical |= patch(rctx)
canonical |= symlinks(rctx)
canonical |= commands(rctx)
return canonical
......
......@@ -22,7 +22,7 @@ archive(
"$(location @coreutils)",
"ln",
"fixture.txt",
"hardlink.txt",
"symlink.txt",
],
},
integrity = "sha256-PWscbDJ+esMLMe4/ix5LTP+lsR1piMNe7r9eHsx/KOg=",
......@@ -55,6 +55,9 @@ deb(
patches = [
"//deb:fixture.patch",
],
symlinks = {
"etc/test/fixture.txt": "symlink.txt",
},
urls = ["file://%workspace%/test_1.0-1_all.deb"],
)
......
{
"lockFileVersion": 3,
"moduleFileHash": "43b094ab776a45db40a0dd9af19fd637e8904d849e059a54de0af51a3e9499b1",
"moduleFileHash": "c998b4413750a9c8e661232959b2f884c42a4f86af2141ffc878f51b68bf7990",
"flags": {
"cmdRegistries": [
"https://bcr.bazel.build",
......@@ -54,7 +54,7 @@
"$(location @coreutils)",
"ln",
"fixture.txt",
"hardlink.txt"
"symlink.txt"
]
},
"integrity": "sha256-PWscbDJ+esMLMe4/ix5LTP+lsR1piMNe7r9eHsx/KOg=",
......@@ -103,6 +103,9 @@
"patches": [
"//deb:fixture.patch"
],
"symlinks": {
"etc/test/fixture.txt": "symlink.txt"
},
"urls": [
"file://%workspace%/test_1.0-1_all.deb"
],
......@@ -129,7 +132,7 @@
"devDependency": false,
"location": {
"file": "@@//:MODULE.bazel",
"line": 61,
"line": 64,
"column": 8
}
},
......@@ -147,7 +150,7 @@
"devDependency": false,
"location": {
"file": "@@//:MODULE.bazel",
"line": 69,
"line": 72,
"column": 8
}
},
......@@ -175,7 +178,7 @@
"devDependency": false,
"location": {
"file": "@@//:MODULE.bazel",
"line": 77,
"line": 80,
"column": 8
}
},
......@@ -192,7 +195,7 @@
"devDependency": false,
"location": {
"file": "@@//:MODULE.bazel",
"line": 95,
"line": 98,
"column": 7
}
}
......@@ -888,7 +891,7 @@
"moduleExtensions": {
"//:MODULE.bazel%_repo_rules": {
"general": {
"bzlTransitiveDigest": "+/g1CVwHm1KuxlBP10o0j7OG7WClgxSn0Al/WRbMNPw=",
"bzlTransitiveDigest": "omJnSRpWwkQFbXUOaQ2BelTgvcmUZLFBpBF+aKjZMkg=",
"accumulatedFileDigests": {},
"envVariables": {},
"generatedRepoSpecs": {
......@@ -901,7 +904,7 @@
"$(location @coreutils)",
"ln",
"fixture.txt",
"hardlink.txt"
"symlink.txt"
]
},
"integrity": "sha256-PWscbDJ+esMLMe4/ix5LTP+lsR1piMNe7r9eHsx/KOg=",
......@@ -940,6 +943,9 @@
"patches": [
"@@//deb:fixture.patch"
],
"symlinks": {
"etc/test/fixture.txt": "symlink.txt"
},
"urls": [
"file://%workspace%/test_1.0-1_all.deb"
],
......
......@@ -10,6 +10,6 @@ diff_test(
diff_test(
name = "symlink",
size = "small",
file1 = "@archive//:hardlink.txt",
file1 = "@archive//:symlink.txt",
file2 = ":fixture.txt",
)
......@@ -6,3 +6,10 @@ diff_test(
file1 = "@deb//:etc/test/fixture.txt",
file2 = ":fixture.txt",
)
diff_test(
name = "symlink",
size = "small",
file1 = "@deb//:symlink.txt",
file2 = ":fixture.txt",
)
visibility("//download/...")
ATTRS = {
"symlinks": attr.string_dict(
doc = 'Creates symlinks in the downloaded repository as `{"<target>": "<link>"}`',
),
}
def symlinks(rctx):
"""
A mixin for `download` repository rules that creates symlinks.
Args:
rctx: The download repository context.
Returns:
A map of canonical arguments
"""
for target, link in rctx.attr.symlinks.items():
rctx.symlink(target, link)
return {}