From 3d7802afb6fcd2a8e80a48067f0c94cebeedbc9f Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 4 Oct 2018 02:14:09 +0200 Subject: Improve package performance, use one checksum file instead of multiple --- scripts/package.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/package.py b/scripts/package.py index fe3b468..61f12c7 100755 --- a/scripts/package.py +++ b/scripts/package.py @@ -60,6 +60,22 @@ def usage(): print("usage: package.py executable_path program_version destination_path <--bundle|--bundle-install>") exit(1) +def fetch_checksums(url): + checksums = {} + + r = requests.get(url) + if not r.ok: + raise RuntimeError("Failed to fetch checksums from url %s" % url) + + lines = r.text.splitlines() + for line in lines: + split_index = line.find(" ") + checksum = line[0:split_index] + libfile = line[split_index + 1:] + checksums[libfile] = checksum + + return checksums + def main(): if len(sys.argv) <= 4: usage() @@ -95,13 +111,15 @@ def main(): dependencies = [] if package_type == "--bundle-install": new_libs = [] + # TODO: Cache the checksum file at this url + checksums = fetch_checksums("https://raw.githubusercontent.com/DEC05EBA/libraries/master/linux/x86_64/checksums") # Remove libraries from the package that can be downloaded remotely (and which user most likely has if they have another program that uses sibs on their computer) for lib in libs: lib_name = os.path.basename(lib[0]) - r = requests.get("https://raw.githubusercontent.com/DEC05EBA/libraries/master/linux/x86_64/" + lib_name + ".sha1") - # TODO: Remove check if it's so_loader or not, we can use so loader in sibs downloaded lib directory - if r.ok and lib[1] != so_loader: - external_checksum = r.text.splitlines()[0] + # TODO: Remove this check, we can use so loader in sibs downloaded lib directory + lib_checksum = checksums.get(lib_name) + if lib_checksum and lib[1] != so_loader: + external_checksum = lib_checksum file_checksum = file_get_sha1(lib[0]) if external_checksum == file_checksum: mapped_libs.append([ lib_name, lib[1] ]) -- cgit v1.2.3