From e023053472e945afd1d175373547a5484d5a4655 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Tue, 5 Jul 2016 22:43:38 +0200 Subject: [PATCH 1/2] add a glibc compat check script --- scripts/glibc_check.py | 61 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 scripts/glibc_check.py diff --git a/scripts/glibc_check.py b/scripts/glibc_check.py new file mode 100644 index 000000000..a400bbd1d --- /dev/null +++ b/scripts/glibc_check.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python3 +""" +Check if all given binaries work with the given glibc version. + +check_glibc.py 2.11 bin [bin ...] +""" + +import re +import subprocess +import sys + +verbose = True +objdump = "objdump -T %s" +glibc_re = re.compile(r'GLIBC_([0-9]\.[0-9]+)') + + +def parse_version(v): + major, minor = v.split('.') + return int(major), int(minor) + + +def format_version(version): + return "%d.%d" % version + + +def main(): + given = parse_version(sys.argv[1]) + filenames = sys.argv[2:] + + overall_versions = set() + for filename in filenames: + try: + output = subprocess.check_output(objdump % filename, shell=True, + stderr=subprocess.STDOUT) + output = output.decode('utf-8') + versions = set(parse_version(match.group(1)) + for match in glibc_re.finditer(output)) + requires_glibc = max(versions) + overall_versions.add(requires_glibc) + if verbose: + print("%s %s" % (filename, format_version(requires_glibc))) + except subprocess.CalledProcessError as e: + if verbose: + print("%s errored." % filename) + + wanted = max(overall_versions) + ok = given >= wanted + + if verbose: + if ok: + print("The binaries work with the given glibc %s." % + format_version(given)) + else: + print("The binaries do not work with the given glibc %s. " + "Minimum is: %s" % (format_version(given), format_version(wanted))) + return ok + + +if __name__ == '__main__': + ok = main() + sys.exit(0 if ok else 1) From e0f549a01d9d1219127decb8dd0c8b7480acef3f Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Tue, 5 Jul 2016 22:45:25 +0200 Subject: [PATCH 2/2] move the hash sizes script also to scripts/ --- {borg => scripts}/hash_sizes.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {borg => scripts}/hash_sizes.py (100%) diff --git a/borg/hash_sizes.py b/scripts/hash_sizes.py similarity index 100% rename from borg/hash_sizes.py rename to scripts/hash_sizes.py