Skip to content

Commit e850a8a

Browse files
authored
Merge pull request #20861 from github/redsun82/ripunzip
Ripunzip: use releases from github
2 parents 73e72f5 + 87b9afc commit e850a8a

File tree

9 files changed

+70
-200
lines changed

9 files changed

+70
-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+
sha256_linux = "ee0e8a957687a5dc3a66b2a4b25883bf762df4c9c07f0651af527a32a405054b",
278+
sha256_macos_arm = "8a88eea54eac232d162a72a42065e0429b82dbf4f05e9642915dff9d7a81f846",
279+
sha256_macos_intel = "4457a18bfcc5feabe09f5ea3d1157128e07b4873392cb404a870e611924abf64",
280+
sha256_windows = "66d0c1375301bf5ab815348048f43b110631d3fa7200acd50d50a8ed8655ca62",
281+
version = "2.0.3",
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: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
def _ripunzip_archive_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 "linux" in repository_ctx.os.name:
6+
# ripunzip only provides a deb package for Linux: we fish the binary out of it
7+
# a deb archive contains a data.tar.xz one which contains the files to be installed under usr/bin
8+
repository_ctx.download_and_extract(
9+
url = "%s/ripunzip_%s-1_amd64.deb" % (url_prefix, version),
10+
sha256 = repository_ctx.attr.sha256_linux,
11+
canonical_id = "ripunzip-linux",
12+
output = "deb",
13+
)
14+
repository_ctx.extract(
15+
"deb/data.tar.xz",
16+
strip_prefix = "usr/bin",
17+
output = "bin",
18+
)
19+
elif "windows" in repository_ctx.os.name:
20+
repository_ctx.download_and_extract(
21+
url = "%s/ripunzip_v%s_x86_64-pc-windows-msvc.zip" % (url_prefix, version),
22+
canonical_id = "ripunzip-windows",
23+
sha256 = repository_ctx.attr.sha256_windows,
24+
output = "bin",
25+
)
26+
elif "mac os" in repository_ctx.os.name:
27+
arch = repository_ctx.os.arch
28+
if arch == "x86_64":
29+
suffix = "x86_64-apple-darwin"
30+
sha256 = repository_ctx.attr.sha256_macos_intel
31+
canonical_id = "ripunzip-macos-intel"
32+
elif arch == "aarch64":
33+
suffix = "aarch64-apple-darwin"
34+
sha256 = repository_ctx.attr.sha256_macos_arm
35+
canonical_id = "ripunzip-macos-arm"
36+
else:
37+
fail("Unsupported macOS architecture: %s" % arch)
38+
repository_ctx.download_and_extract(
39+
url = "%s/ripunzip_v%s_%s.tar.gz" % (url_prefix, version, suffix),
40+
sha256 = sha256,
41+
canonical_id = canonical_id,
42+
output = "bin",
43+
)
44+
else:
45+
fail("Unsupported OS: %s" % repository_ctx.os.name)
46+
repository_ctx.file("WORKSPACE.bazel")
47+
repository_ctx.symlink(build_file, "BUILD.bazel")
48+
49+
ripunzip_archive = repository_rule(
50+
implementation = _ripunzip_archive_impl,
51+
doc = "Downloads a prebuilt ripunzip binary for the host platform from https://github.com/GoogleChrome/ripunzip/releases",
52+
attrs = {
53+
"version": attr.string(mandatory = True),
54+
"sha256_linux": attr.string(mandatory = True),
55+
"sha256_windows": attr.string(mandatory = True),
56+
"sha256_macos_intel": attr.string(mandatory = True),
57+
"sha256_macos_arm": attr.string(mandatory = True),
58+
},
59+
)

0 commit comments

Comments
 (0)