Skip to content

Commit 59df2b7

Browse files
deps: update rules_oci digest to v2.0.0-beta1 (edgelesssys#3135)
Co-authored-by: Markus Rudy <[email protected]>
1 parent e41bb61 commit 59df2b7

File tree

5 files changed

+89
-10
lines changed

5 files changed

+89
-10
lines changed

MODULE.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
module(name = "constellation")
22

33
bazel_dep(name = "aspect_bazel_lib", version = "2.7.8")
4+
5+
bazel_lib = use_extension("@aspect_bazel_lib//lib:extensions.bzl", "toolchains")
6+
bazel_lib.yq()
7+
use_repo(bazel_lib, "yq_toolchains")
8+
49
bazel_dep(name = "bazel_skylib", version = "1.7.1")
510
bazel_dep(name = "gazelle", version = "0.38.0")
611
bazel_dep(name = "hermetic_cc_toolchain", version = "3.1.0")

MODULE.bazel.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

WORKSPACE.bzlmod

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,9 @@ load("@rules_oci//oci:dependencies.bzl", "rules_oci_dependencies")
215215

216216
rules_oci_dependencies()
217217

218-
load("@rules_oci//oci:repositories.bzl", "LATEST_CRANE_VERSION", "oci_register_toolchains")
218+
load("@rules_oci//oci:repositories.bzl", "oci_register_toolchains")
219219

220-
oci_register_toolchains(
221-
name = "oci",
222-
crane_version = LATEST_CRANE_VERSION,
223-
)
220+
oci_register_toolchains(name = "oci")
224221

225222
load("//bazel/toolchains:container_images.bzl", "containter_image_deps")
226223

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
From d10473f4ac89c23dcd8ea02488b28a649f4a9735 Mon Sep 17 00:00:00 2001
2+
From: Markus Rudy <[email protected]>
3+
Date: Tue, 6 Aug 2024 11:33:29 +0200
4+
Subject: [PATCH] disable Windows support
5+
6+
It's broken and we don't need it, see
7+
https://github.com/bazel-contrib/rules_oci/issues/420.
8+
---
9+
oci/private/image.bzl | 9 ---------
10+
oci/private/util.bzl | 29 +----------------------------
11+
2 files changed, 1 insertion(+), 37 deletions(-)
12+
13+
diff --git a/oci/private/image.bzl b/oci/private/image.bzl
14+
index e8a6ca5..434947c 100644
15+
--- a/oci/private/image.bzl
16+
+++ b/oci/private/image.bzl
17+
@@ -226,15 +226,6 @@ def _oci_image_impl(ctx):
18+
19+
action_env = {}
20+
21+
- # Windows: Don't convert arguments like --entrypoint=/some/bin to --entrypoint=C:/msys64/some/bin
22+
- if ctx.target_platform_has_constraint(ctx.attr._windows_constraint[platform_common.ConstraintValueInfo]):
23+
- # See https://www.msys2.org/wiki/Porting/:
24+
- # > Setting MSYS2_ARG_CONV_EXCL=* prevents any path transformation.
25+
- action_env["MSYS2_ARG_CONV_EXCL"] = "*"
26+
-
27+
- # This one is for Windows Git MSys
28+
- action_env["MSYS_NO_PATHCONV"] = "1"
29+
-
30+
ctx.actions.run(
31+
inputs = depset(inputs, transitive = transitive_inputs),
32+
arguments = [args],
33+
diff --git a/oci/private/util.bzl b/oci/private/util.bzl
34+
index 7c2a2c2..479ca7d 100644
35+
--- a/oci/private/util.bzl
36+
+++ b/oci/private/util.bzl
37+
@@ -141,34 +141,7 @@ def _maybe_wrap_launcher_for_windows(ctx, bash_launcher):
38+
- make sure the bash_launcher is in the inputs to the action
39+
- @bazel_tools//tools/sh:toolchain_type should appear in the rules toolchains
40+
"""
41+
- if not ctx.target_platform_has_constraint(ctx.attr._windows_constraint[platform_common.ConstraintValueInfo]):
42+
- return bash_launcher
43+
-
44+
- win_launcher = ctx.actions.declare_file("wrap_%s.bat" % ctx.label.name)
45+
- ctx.actions.write(
46+
- output = win_launcher,
47+
- content = r"""@echo off
48+
-SETLOCAL ENABLEEXTENSIONS
49+
-SETLOCAL ENABLEDELAYEDEXPANSION
50+
-for %%a in ("{bash_bin}") do set "bash_bin_dir=%%~dpa"
51+
-set PATH=%bash_bin_dir%;%PATH%
52+
-set "parent_dir=%~dp0"
53+
-set "parent_dir=!parent_dir:\=/!"
54+
-set args=%*
55+
-rem Escape \ and * in args before passing it with double quote
56+
-if defined args (
57+
- set args=!args:\=\\\\!
58+
- set args=!args:"=\"!
59+
-)
60+
-"{bash_bin}" -c "%parent_dir%{launcher} !args!"
61+
-""".format(
62+
- bash_bin = ctx.toolchains["@bazel_tools//tools/sh:toolchain_type"].path,
63+
- launcher = paths.relativize(bash_launcher.path, win_launcher.dirname),
64+
- ),
65+
- is_executable = True,
66+
- )
67+
-
68+
- return win_launcher
69+
+ return bash_launcher
70+
71+
def _file_exists(rctx, path):
72+
result = rctx.execute(["stat", path])
73+
--
74+
2.46.0
75+

bazel/toolchains/oci_deps.bzl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ def oci_deps():
77
# Remove this override once https://github.com/bazel-contrib/rules_oci/issues/420 is fixed.
88
http_archive(
99
name = "rules_oci",
10-
strip_prefix = "rules_oci-c622bf79d269473d3d9bc33510e16cfd9a1142bc",
10+
strip_prefix = "rules_oci-2.0.0-beta1",
1111
type = "tar.gz",
1212
urls = [
13-
"https://cdn.confidential.cloud/constellation/cas/sha256/dca0cfa2a8eb4ab79c231617964fc821f6d1a3bb9d996358975a5ceee5b8d25f",
14-
"https://github.com/bazel-contrib/rules_oci/archive/c622bf79d269473d3d9bc33510e16cfd9a1142bc.tar.gz",
13+
"https://cdn.confidential.cloud/constellation/cas/sha256/f70f07f9d0d6c275d7ec7d3c7f236d9b552ba3205e8f37df9c1125031cf967cc",
14+
"https://github.com/bazel-contrib/rules_oci/releases/download/v2.0.0-beta1/rules_oci-v2.0.0-beta1.tar.gz",
1515
],
16-
sha256 = "dca0cfa2a8eb4ab79c231617964fc821f6d1a3bb9d996358975a5ceee5b8d25f",
16+
sha256 = "f70f07f9d0d6c275d7ec7d3c7f236d9b552ba3205e8f37df9c1125031cf967cc",
17+
patches = ["//bazel/toolchains:0001-disable-Windows-support.patch"],
18+
patch_args = ["-p1"],
1719
)

0 commit comments

Comments
 (0)