From a72ef93574a7d675c1b392077898c5f0b4691cfc Mon Sep 17 00:00:00 2001 From: Han Sol Jin Date: Thu, 15 Dec 2022 00:03:07 -0800 Subject: [PATCH] rtwo: update-sha1sums: Add support for multiple proprietary-files lists Change-Id: I1547f58756122de3bcfd6ad7fe4749efdee888c4 --- update-sha1sums.py | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/update-sha1sums.py b/update-sha1sums.py index 69ab8b9..f32975f 100755 --- a/update-sha1sums.py +++ b/update-sha1sums.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # # Copyright (C) 2016 The CyanogenMod Project -# Copyright (C) 2017-2020 The LineageOS Project +# Copyright (C) 2017-2022 The LineageOS Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,13 +23,12 @@ from hashlib import sha1 device='rtwo' vendor='motorola' -with open('proprietary-files.txt', 'r') as f: - lines = f.read().splitlines() -vendorPath = '../../../vendor/' + vendor + '/' + device + '/proprietary' -needSHA1 = False +files = [ + "proprietary-files.txt", + "proprietary-files-carriersettings.txt" +] - -def cleanup(): +def cleanup(lines): for index, line in enumerate(lines): # Skip empty or commented lines if len(line) == 0 or line[0] == '#' or '|' not in line: @@ -37,9 +36,10 @@ def cleanup(): # Drop SHA1 hash, if existing lines[index] = line.split('|')[0] + return lines -def update(): +def update(lines): for index, line in enumerate(lines): # Skip empty lines if len(line) == 0: @@ -62,12 +62,19 @@ def update(): hash = sha1(f.read()).hexdigest() lines[index] = '%s|%s' % (line, hash) + return lines -if len(sys.argv) == 2 and sys.argv[1] == '-c': - cleanup() -else: - update() +for i in files: + with open(i, 'r') as f: + lines = f.read().splitlines() + vendorPath = '../../../vendor/' + vendor + '/' + device + '/proprietary' + needSHA1 = False -with open('proprietary-files.txt', 'w') as file: - file.write('\n'.join(lines) + '\n') + if len(sys.argv) == 2 and sys.argv[1] == '-c': + lines = cleanup(lines) + else: + lines = update(lines) + + with open(i, 'w') as file: + file.write('\n'.join(lines) + '\n')