rtwo: update-sha1sums: Add support for multiple proprietary-files lists

Change-Id: I1547f58756122de3bcfd6ad7fe4749efdee888c4
This commit is contained in:
Han Sol Jin
2022-12-15 00:03:07 -08:00
committed by Marc Bourgoin
parent a7c8568307
commit a72ef93574

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# #
# Copyright (C) 2016 The CyanogenMod Project # 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"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@@ -23,13 +23,12 @@ from hashlib import sha1
device='rtwo' device='rtwo'
vendor='motorola' vendor='motorola'
with open('proprietary-files.txt', 'r') as f: files = [
lines = f.read().splitlines() "proprietary-files.txt",
vendorPath = '../../../vendor/' + vendor + '/' + device + '/proprietary' "proprietary-files-carriersettings.txt"
needSHA1 = False ]
def cleanup(lines):
def cleanup():
for index, line in enumerate(lines): for index, line in enumerate(lines):
# Skip empty or commented lines # Skip empty or commented lines
if len(line) == 0 or line[0] == '#' or '|' not in line: if len(line) == 0 or line[0] == '#' or '|' not in line:
@@ -37,9 +36,10 @@ def cleanup():
# Drop SHA1 hash, if existing # Drop SHA1 hash, if existing
lines[index] = line.split('|')[0] lines[index] = line.split('|')[0]
return lines
def update(): def update(lines):
for index, line in enumerate(lines): for index, line in enumerate(lines):
# Skip empty lines # Skip empty lines
if len(line) == 0: if len(line) == 0:
@@ -62,12 +62,19 @@ def update():
hash = sha1(f.read()).hexdigest() hash = sha1(f.read()).hexdigest()
lines[index] = '%s|%s' % (line, hash) lines[index] = '%s|%s' % (line, hash)
return lines
if len(sys.argv) == 2 and sys.argv[1] == '-c': for i in files:
cleanup() with open(i, 'r') as f:
else: lines = f.read().splitlines()
update() vendorPath = '../../../vendor/' + vendor + '/' + device + '/proprietary'
needSHA1 = False
with open('proprietary-files.txt', 'w') as file: if len(sys.argv) == 2 and sys.argv[1] == '-c':
file.write('\n'.join(lines) + '\n') lines = cleanup(lines)
else:
lines = update(lines)
with open(i, 'w') as file:
file.write('\n'.join(lines) + '\n')