mirror of
https://github.com/Anything-at-25-00/android_device_tecno_LG8n.git
synced 2024-11-23 06:06:27 -08:00
X6833B: update-sha1sums: Better handle line breaks
Change-Id: I15cfda82a5bc6f05c0d7b9db209064ba498dac11 Signed-off-by: dodyirawan85 <40514988+dodyirawan85@users.noreply.github.com>
This commit is contained in:
parent
0e310f4b18
commit
070e5ca3bc
|
@ -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-2018 The LineageOS Project
|
# Copyright (C) 2017-2020 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.
|
||||||
|
@ -22,16 +22,14 @@ import sys
|
||||||
device = 'X6833B'
|
device = 'X6833B'
|
||||||
vendor = 'infinix'
|
vendor = 'infinix'
|
||||||
|
|
||||||
lines = [line for line in open('proprietary-files.txt', 'r')]
|
with open('proprietary-files.txt', 'r') as f:
|
||||||
|
lines = f.read().splitlines()
|
||||||
vendorPath = '../../../vendor/' + vendor + '/' + device + '/proprietary'
|
vendorPath = '../../../vendor/' + vendor + '/' + device + '/proprietary'
|
||||||
needSHA1 = False
|
needSHA1 = False
|
||||||
|
|
||||||
|
|
||||||
def cleanup():
|
def cleanup():
|
||||||
for index, line in enumerate(lines):
|
for index, line in enumerate(lines):
|
||||||
# Remove '\n' character
|
|
||||||
line = line[:-1]
|
|
||||||
|
|
||||||
# Skip empty or commented lines
|
# Skip empty or commented lines
|
||||||
if len(line) == 0 or line[0] == '#':
|
if len(line) == 0 or line[0] == '#':
|
||||||
continue
|
continue
|
||||||
|
@ -39,14 +37,11 @@ def cleanup():
|
||||||
# Drop SHA1 hash, if existing
|
# Drop SHA1 hash, if existing
|
||||||
if '|' in line:
|
if '|' in line:
|
||||||
line = line.split('|')[0]
|
line = line.split('|')[0]
|
||||||
lines[index] = '%s\n' % (line)
|
lines[index] = '%s' % (line)
|
||||||
|
|
||||||
|
|
||||||
def update():
|
def update():
|
||||||
for index, line in enumerate(lines):
|
for index, line in enumerate(lines):
|
||||||
# Remove '\n' character
|
|
||||||
line = line[:-1]
|
|
||||||
|
|
||||||
# Skip empty lines
|
# Skip empty lines
|
||||||
if len(line) == 0:
|
if len(line) == 0:
|
||||||
continue
|
continue
|
||||||
|
@ -68,7 +63,7 @@ def update():
|
||||||
file = open('%s/%s' % (vendorPath, filePath), 'rb').read()
|
file = open('%s/%s' % (vendorPath, filePath), 'rb').read()
|
||||||
|
|
||||||
hash = sha1(file).hexdigest()
|
hash = sha1(file).hexdigest()
|
||||||
lines[index] = '%s|%s\n' % (line, hash)
|
lines[index] = '%s|%s' % (line, hash)
|
||||||
|
|
||||||
|
|
||||||
if len(sys.argv) == 2 and sys.argv[1] == '-c':
|
if len(sys.argv) == 2 and sys.argv[1] == '-c':
|
||||||
|
@ -77,7 +72,4 @@ else:
|
||||||
update()
|
update()
|
||||||
|
|
||||||
with open('proprietary-files.txt', 'w') as file:
|
with open('proprietary-files.txt', 'w') as file:
|
||||||
for line in lines:
|
file.write('\n'.join(lines) + '\n')
|
||||||
file.write(line)
|
|
||||||
|
|
||||||
file.close()
|
|
||||||
|
|
Loading…
Reference in a new issue