diff third_party/mercurial/runtime.bzl @ 249:c5129452493e

[deploy] Bundle Mercurial with hg-web Co-authored-by: Copilot <[email protected]>
author MrJuneJune <me@mrjunejune.com>
date Tue, 04 Aug 2026 04:16:45 -0700
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/third_party/mercurial/runtime.bzl	Tue Aug 04 04:16:45 2026 -0700
@@ -0,0 +1,34 @@
+def _mercurial_runtime_impl(ctx):
+    output = ctx.actions.declare_directory(ctx.label.name)
+    ctx.actions.run_shell(
+        inputs = [ctx.file.archive, ctx.file.launcher],
+        outputs = [output],
+        command = """
+set -e
+mkdir -p {output}/bin
+unzip -q {archive} -d {output}
+cp {output}/mercurial-7.2.3.dist-info/licenses/COPYING {output}/COPYING
+cp {launcher} {output}/bin/hg
+chmod 0555 {output}/bin/hg
+chmod -R a-w {output}/hgdemandimport {output}/hgext {output}/mercurial
+""".format(
+            archive = ctx.file.archive.path,
+            launcher = ctx.file.launcher.path,
+            output = output.path,
+        ),
+        progress_message = "Assembling pure-Python Mercurial runtime",
+    )
+    return [
+        DefaultInfo(
+            files = depset([output]),
+            runfiles = ctx.runfiles(files = [output]),
+        ),
+    ]
+
+mercurial_runtime = rule(
+    implementation = _mercurial_runtime_impl,
+    attrs = {
+        "archive": attr.label(allow_single_file = True, mandatory = True),
+        "launcher": attr.label(allow_single_file = True, mandatory = True),
+    },
+)