1- def _impl (repository_ctx ):
1+ def _ripunzip_archive_impl (repository_ctx ):
22 version = repository_ctx .attr .version
33 url_prefix = "https://github.com/GoogleChrome/ripunzip/releases/download/v%s" % version
44 build_file = Label ("//misc/ripunzip:BUILD.ripunzip.bazel" )
5- if repository_ctx .os .name == "linux" :
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
68 repository_ctx .download_and_extract (
79 url = "%s/ripunzip_%s-1_amd64.deb" % (url_prefix , version ),
810 sha256 = repository_ctx .attr .sha256_linux ,
@@ -11,16 +13,17 @@ def _impl(repository_ctx):
1113 )
1214 repository_ctx .extract (
1315 "deb/data.tar.xz" ,
14- strip_prefix = "usr" ,
16+ strip_prefix = "usr/bin" ,
17+ output = "bin" ,
1518 )
16- elif repository_ctx .os .name == "windows" :
19+ elif "windows" in repository_ctx .os .name :
1720 repository_ctx .download_and_extract (
1821 url = "%s/ripunzip_v%s_x86_64-pc-windows-msvc.zip" % (url_prefix , version ),
1922 canonical_id = "ripunzip-windows" ,
2023 sha256 = repository_ctx .attr .sha256_windows ,
2124 output = "bin" ,
2225 )
23- elif repository_ctx . os . name == "mac os x" :
26+ elif "mac os" in repository_ctx . os . name :
2427 arch = repository_ctx .os .arch
2528 if arch == "x86_64" :
2629 suffix = "x86_64-apple-darwin"
@@ -44,7 +47,8 @@ def _impl(repository_ctx):
4447 repository_ctx .symlink (build_file , "BUILD.bazel" )
4548
4649ripunzip_archive = repository_rule (
47- implementation = _impl ,
50+ implementation = _ripunzip_archive_impl ,
51+ doc = "Downloads a prebuilt ripunzip binary for the host platform from https://github.com/GoogleChrome/ripunzip/releases" ,
4852 attrs = {
4953 "version" : attr .string (mandatory = True ),
5054 "sha256_linux" : attr .string (mandatory = True ),
0 commit comments