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:
dianlujitao 2020-01-31 12:19:35 +08:00 committed by dodyirawan85
parent 0e310f4b18
commit 070e5ca3bc

View file

@ -1,7 +1,7 @@
#!/usr/bin/env python
#
# 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");
# you may not use this file except in compliance with the License.
@ -22,16 +22,14 @@ import sys
device = 'X6833B'
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'
needSHA1 = False
def cleanup():
for index, line in enumerate(lines):
# Remove '\n' character
line = line[:-1]
# Skip empty or commented lines
if len(line) == 0 or line[0] == '#':
continue
@ -39,14 +37,11 @@ def cleanup():
# Drop SHA1 hash, if existing
if '|' in line:
line = line.split('|')[0]
lines[index] = '%s\n' % (line)
lines[index] = '%s' % (line)
def update():
for index, line in enumerate(lines):
# Remove '\n' character
line = line[:-1]
# Skip empty lines
if len(line) == 0:
continue
@ -68,7 +63,7 @@ def update():
file = open('%s/%s' % (vendorPath, filePath), 'rb').read()
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':
@ -77,7 +72,4 @@ else:
update()
with open('proprietary-files.txt', 'w') as file:
for line in lines:
file.write(line)
file.close()
file.write('\n'.join(lines) + '\n')