mirror of
https://github.com/Evolution-X-Devices/device_motorola_rtwo
synced 2026-01-27 07:50:05 +00:00
rtwo: update-sha1sums: Add support for multiple proprietary-files lists
Change-Id: I1547f58756122de3bcfd6ad7fe4749efdee888c4
This commit is contained in:
committed by
Marc Bourgoin
parent
a7c8568307
commit
a72ef93574
@@ -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
|
||||||
|
|
||||||
|
|
||||||
|
for i in files:
|
||||||
|
with open(i, 'r') as f:
|
||||||
|
lines = f.read().splitlines()
|
||||||
|
vendorPath = '../../../vendor/' + vendor + '/' + device + '/proprietary'
|
||||||
|
needSHA1 = False
|
||||||
|
|
||||||
if len(sys.argv) == 2 and sys.argv[1] == '-c':
|
if len(sys.argv) == 2 and sys.argv[1] == '-c':
|
||||||
cleanup()
|
lines = cleanup(lines)
|
||||||
else:
|
else:
|
||||||
update()
|
lines = update(lines)
|
||||||
|
|
||||||
with open('proprietary-files.txt', 'w') as file:
|
with open(i, 'w') as file:
|
||||||
file.write('\n'.join(lines) + '\n')
|
file.write('\n'.join(lines) + '\n')
|
||||||
|
|||||||
Reference in New Issue
Block a user