Skip to content

Commit fd07a1b

Browse files
committed
Make sha256 work on macOS as well
1 parent 59075a6 commit fd07a1b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

cloud_archive.bzl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ inside. """
77

88
def validate_checksum(repo_ctx, url, local_path, expected_sha256):
99
# Verify checksum
10-
sha256_path = repo_ctx.which("sha256sum")
10+
if repo_ctx.os.name == "linux":
11+
sha256_cmd = [repo_ctx.which("sha256sum")]
12+
elif repo_ctx.os.name in ["mac os x", "darwin"]:
13+
sha256_cmd = [repo_ctx.which("shasum"), "-a", "256"]
14+
else:
15+
fail("Unsupported OS: " + repo_ctx.os.name)
1116
repo_ctx.report_progress("Checksumming {}.".format(local_path))
12-
sha256_result = repo_ctx.execute([sha256_path, local_path])
17+
sha256_result = repo_ctx.execute(sha256_cmd + [local_path])
1318
if sha256_result.return_code != 0:
1419
fail("Failed to verify checksum: {}".format(sha256_result.stderr))
1520
sha256 = sha256_result.stdout.split(" ")[0]
@@ -127,7 +132,7 @@ def cloud_archive_download(
127132
patch_args[0][2:].isdigit())
128133
strip_n = 0
129134
if only_strip_param:
130-
strip_n = int(patch_args[0][2:])
135+
strip_n = int(patch_args[0][2])
131136

132137
if patch_args == None or only_strip_param:
133138
# OK to use built-in patch.

0 commit comments

Comments
 (0)