diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /comm/third_party/botan/botan_configure.py | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-x | comm/third_party/botan/botan_configure.py | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/comm/third_party/botan/botan_configure.py b/comm/third_party/botan/botan_configure.py new file mode 100755 index 0000000000..858c1e63d3 --- /dev/null +++ b/comm/third_party/botan/botan_configure.py @@ -0,0 +1,121 @@ +#!python3 +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +from __future__ import print_function, absolute_import, unicode_literals +import os +import sys +import subprocess +from mozbuild.util import system_encoding + +# This script is a wrapper for Botan's configure.py to adapt it for moz.build. +# Its main purpose is to return some output on stdout for mozbuild to handle, +# but secondary to that is to set --enable-modules. Mozbuild/Make mangle +# the list otherwise due to the embedded commas. + +botan_modules = ",".join( + ( + "aead", + "aes", + "auto_rng", + "bigint", + "blowfish", + "camellia", + "cast128", + "cbc", + "cfb", + "crc24", + "curve25519", + "des", + "dl_group", + "dsa", + "eax", + "ec_group", + "ecdh", + "ecdsa", + "ed25519", + "elgamal", + "eme_pkcs1", + "emsa_pkcs1", + "emsa_raw", + "ffi", + "hash", + "hmac", + "hmac_drbg", + "idea", + "kdf", + "md5", + "ocb", + "pgp_s2k", + "pubkey", + "rfc3394", + "rmd160", + "rsa", + "sha1", + "sha2_32", + "sha2_64", + "sha3", + "sm2", + "sm3", + "sm4", + "sp800_56a", + "system_rng", + "twofish", + ) +) + +## +here = os.path.abspath(os.path.dirname(__file__)) +configure = os.path.join(here, "configure.py") + + +# A wrapper to obtain a process' output and return code. +# Returns a tuple (retcode, stdout, stderr). +# from build/moz.configure/util.configure +def get_cmd_output(*args, **kwargs): + proc = subprocess.Popen( + args, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + close_fds=os.name != "nt", + encoding=system_encoding, + errors="replace", + ) + stdout, stderr = proc.communicate() + return proc.wait(), stdout, stderr + + +def _run_configure(argv): + """Call Botan's configure.py. Arguments are passed "shell-style".""" + args = [sys.executable] + [configure] + list(argv) # passed as a tuple + botan_modules_arg = "--enable-modules={}".format(botan_modules) + args.append(botan_modules_arg) + + try: + rv = get_cmd_output(*args) + except Exception: + raise + + return rv + + +def main(output, *args): + rv = _run_configure(args) + if rv[0] == 0: + # GENERATED_FILES expects this script to write something back to output + if os.path.isfile(output.name): + with open(output.name, "r") as fp: + data = fp.read() + output.write(data) + else: + # Probably an error + raise Exception("Unable to locate real output at {}".format(output.name)) + else: + return rv + + return rv[0] + + +if __name__ == "__main__": + main(*sys.argv) |