1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 18:17:52 -05:00
v2fly/infra/bazel/gpg.bzl

24 lines
855 B
Python
Raw Normal View History

2019-02-10 13:04:11 -05:00
def _gpg_sign_impl(ctx):
output_file = ctx.actions.declare_file(ctx.file.base.basename + ctx.attr.suffix, sibling = ctx.file.base)
if not ctx.configuration.default_shell_env.get("GPG_PASS"):
ctx.actions.write(output_file, "")
else:
command = "echo ${GPG_PASS} | gpg --pinentry-mode loopback --digest-algo SHA512 --passphrase-fd 0 --output %s --detach-sig %s" % (output_file.path, ctx.file.base.path)
ctx.actions.run_shell(
command = command,
use_default_shell_env = True,
inputs = [ctx.file.base],
outputs = [output_file],
progress_message = "Signing binary",
mnemonic = "gpg",
)
return [DefaultInfo(files = depset([output_file]))]
gpg_sign = rule(
implementation = _gpg_sign_impl,
attrs = {
"base": attr.label(allow_single_file=True),
"suffix": attr.string(default=".sig"),
},
)