Skip to content

Commit ddee385

Browse files
committed
Ripunzip: use releases from github
This uses the ripunzip releases from github instead of building them ourselves.
1 parent f4a6ba9 commit ddee385

File tree

9 files changed

+62
-200
lines changed

9 files changed

+62
-200
lines changed

.gitattributes

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@
8282
/csharp/paket.main.bzl linguist-generated=true
8383
/csharp/paket.main_extension.bzl linguist-generated=true
8484

85-
# ripunzip tool
86-
/misc/ripunzip/ripunzip-* filter=lfs diff=lfs merge=lfs -text
87-
8885
# swift prebuilt resources
8986
/swift/third_party/resources/*.zip filter=lfs diff=lfs merge=lfs -text
9087
/swift/third_party/resources/*.tar.zst filter=lfs diff=lfs merge=lfs -text

.github/workflows/build-ripunzip.yml

Lines changed: 0 additions & 169 deletions
This file was deleted.

MODULE.bazel

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -269,24 +269,16 @@ go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
269269
go_deps.from_file(go_mod = "//go/extractor:go.mod")
270270
use_repo(go_deps, "org_golang_x_mod", "org_golang_x_tools")
271271

272-
lfs_archive = use_repo_rule("//misc/bazel:lfs.bzl", "lfs_archive")
272+
ripunzip_archive = use_repo_rule("//misc/ripunzip:ripunzip.bzl", "ripunzip_archive")
273273

274-
lfs_archive(
275-
name = "ripunzip-linux",
276-
src = "//misc/ripunzip:ripunzip-Linux.tar.zst",
277-
build_file = "//misc/ripunzip:BUILD.ripunzip.bazel",
278-
)
279-
280-
lfs_archive(
281-
name = "ripunzip-windows",
282-
src = "//misc/ripunzip:ripunzip-Windows.tar.zst",
283-
build_file = "//misc/ripunzip:BUILD.ripunzip.bazel",
284-
)
285-
286-
lfs_archive(
287-
name = "ripunzip-macos",
288-
src = "//misc/ripunzip:ripunzip-macOS.tar.zst",
289-
build_file = "//misc/ripunzip:BUILD.ripunzip.bazel",
274+
# go to https://github.com/GoogleChrome/ripunzip/releases to find latest version and corresponding sha256s
275+
ripunzip_archive(
276+
name = "ripunzip",
277+
version = "2.0.3",
278+
sha256_linux = "ee0e8a957687a5dc3a66b2a4b25883bf762df4c9c07f0651af527a32a405054b",
279+
sha256_windows = "66d0c1375301bf5ab815348048f43b110631d3fa7200acd50d50a8ed8655ca62",
280+
sha256_macos_intel = "4457a18bfcc5feabe09f5ea3d1157128e07b4873392cb404a870e611924abf64",
281+
sha256_macos_arm = "8a88eea54eac232d162a72a42065e0429b82dbf4f05e9642915dff9d7a81f846",
290282
)
291283

292284
register_toolchains(

misc/ripunzip/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
22

33
alias(
44
name = "ripunzip",
5-
actual = select({"@platforms//os:" + os: "@ripunzip-%s//:ripunzip" % os for os in ("linux", "windows", "macos")}),
5+
actual = "@ripunzip",
66
visibility = ["//visibility:public"],
77
)
88

misc/ripunzip/BUILD.ripunzip.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ load("@bazel_skylib//rules:native_binary.bzl", "native_binary")
22

33
native_binary(
44
name = "ripunzip",
5-
src = glob(["ripunzip-*"])[0],
5+
src = glob(["bin/ripunzip*"])[0],
66
out = "ripunzip" + select({
77
"@platforms//os:windows": ".exe",
88
"//conditions:default": "",

misc/ripunzip/ripunzip-Linux.tar.zst

Lines changed: 0 additions & 3 deletions
This file was deleted.

misc/ripunzip/ripunzip-Windows.tar.zst

Lines changed: 0 additions & 3 deletions
This file was deleted.

misc/ripunzip/ripunzip-macOS.tar.zst

Lines changed: 0 additions & 3 deletions
This file was deleted.

misc/ripunzip/ripunzip.bzl

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
def _impl(repository_ctx):
2+
version = repository_ctx.attr.version
3+
url_prefix = "https://github.com/GoogleChrome/ripunzip/releases/download/v%s" % version
4+
build_file = Label("//misc/ripunzip:BUILD.ripunzip.bazel")
5+
if repository_ctx.os.name == "linux":
6+
repository_ctx.download_and_extract(
7+
url="%s/ripunzip_%s-1_amd64.deb" % (url_prefix, version),
8+
sha256=repository_ctx.attr.sha256_linux,
9+
canonical_id="ripunzip-deb",
10+
output="deb",
11+
)
12+
repository_ctx.extract(
13+
"deb/data.tar.xz",
14+
strip_prefix="usr",
15+
)
16+
elif repository_ctx.os.name == "windows":
17+
repository_ctx.download_and_extract(
18+
url="%s/ripunzip_v%s-x86_64-pc-windows-msvc.zip" % (url_prefix, version),
19+
sha256=repository_ctx.attr.sha256_windows,
20+
output="bin",
21+
)
22+
elif repository_ctx.os.name == "macos":
23+
arch = repository_ctx.os.arch
24+
if arch == "x86_64":
25+
suffix = "x86_64-apple-darwin"
26+
sha256 = repository_ctx.attr.sha256_macos_intel
27+
elif arch == "aarch64":
28+
suffix = "aarch64-apple-darwin"
29+
sha256 = repository_ctx.attr.sha256_macos_arm
30+
else:
31+
fail("Unsupported macOS architecture: %s" % arch)
32+
repository_ctx.download_and_extract(
33+
url="%s/ripunzip_v%s-%s.tar.gz" % (url_prefix, version, suffix),
34+
sha256=sha256,
35+
output="bin",
36+
)
37+
else:
38+
fail("Unsupported OS: %s" % repository_ctx.os.name)
39+
repository_ctx.file("WORKSPACE.bazel")
40+
repository_ctx.symlink(build_file, "BUILD.bazel")
41+
42+
ripunzip_archive = repository_rule(
43+
implementation=_impl,
44+
attrs={
45+
"version": attr.string(mandatory=True),
46+
"sha256_linux": attr.string(mandatory=True),
47+
"sha256_windows": attr.string(mandatory=True),
48+
"sha256_macos_intel": attr.string(mandatory=True),
49+
"sha256_macos_arm": attr.string(mandatory=True),
50+
},
51+
)

0 commit comments

Comments
 (0)