From 6c5653fa385292ff54c8d70ac902af04d972c72b Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Mon, 15 Aug 2016 12:18:43 +0200 Subject: msm8996-common: Add script to update sha1sums of kanged blobs Change-Id: Id2e8cfb8d3b6f65f69c91a89bacd615fdcc45753 --- update-sha1sums.py | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 update-sha1sums.py (limited to 'update-sha1sums.py') diff --git a/update-sha1sums.py b/update-sha1sums.py new file mode 100755 index 0000000..8d8e4bf --- /dev/null +++ b/update-sha1sums.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python +# +# Copyright (C) 2016 The CyanogenMod Project +# Copyright (C) 2017 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +from hashlib import sha1 + +device='gemini' +vendor='xiaomi' + +lines = [ line for line in open('proprietary-files.txt', 'r') ] +vendorPath = '../../../vendor/' + vendor + '/' + device + '/proprietary' +needSHA1 = False + +for index, line in enumerate(lines): + # Remove '\n' character + line = line[:-1] + + # Skip empty lines + if len(line) == 0: + continue + + # Check if we need to set SHA1 hash for the next files + if line[0] == '#': + needSHA1 = (' - from' in line) + continue + + if needSHA1: + # Remove existing SHA1 hash + line = line.split('|')[0] + + if line[0] == '-': + file = open('%s/%s' % (vendorPath, line[1:]), 'rb').read() + else: + file = open('%s/%s' % (vendorPath, line), 'rb').read() + + hash = sha1(file).hexdigest() + lines[index] = '%s|%s\n' % (line, hash) + +with open('proprietary-files.txt', 'w') as file: + for line in lines: + file.write(line) + + file.close() -- cgit v1.2.3 From 22b9c4d045d0623e82fa2ddd7139616b785b14a9 Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Tue, 9 Jan 2018 00:59:02 +0100 Subject: msm8996-common: Handle moved blobs in update-sha1sums.py script Change-Id: Iccab8c8620c7ff680768aac2d9cbf5b5067af8d7 --- update-sha1sums.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'update-sha1sums.py') diff --git a/update-sha1sums.py b/update-sha1sums.py index 8d8e4bf..cbbb587 100755 --- a/update-sha1sums.py +++ b/update-sha1sums.py @@ -41,11 +41,12 @@ for index, line in enumerate(lines): if needSHA1: # Remove existing SHA1 hash line = line.split('|')[0] + filePath = line.split(':')[1] if len(line.split(':')) == 2 else line - if line[0] == '-': - file = open('%s/%s' % (vendorPath, line[1:]), 'rb').read() + if filePath[0] == '-': + file = open('%s/%s' % (vendorPath, filePath[1:]), 'rb').read() else: - file = open('%s/%s' % (vendorPath, line), 'rb').read() + file = open('%s/%s' % (vendorPath, filePath), 'rb').read() hash = sha1(file).hexdigest() lines[index] = '%s|%s\n' % (line, hash) -- cgit v1.2.3 From 00275e039fe33b6b17294b50fd5d3e1e169e13dd Mon Sep 17 00:00:00 2001 From: Bruno Martins Date: Thu, 15 Feb 2018 16:28:43 +0000 Subject: msm8996-common: Add unpinning support to update-sha1sums.py script Change-Id: I9035b449cea6d78927a459dc247075b3d4512e46 --- update-sha1sums.py | 55 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 17 deletions(-) (limited to 'update-sha1sums.py') diff --git a/update-sha1sums.py b/update-sha1sums.py index cbbb587..02a263c 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 The LineageOS Project +# Copyright (C) 2017-2018 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. @@ -17,6 +17,7 @@ # from hashlib import sha1 +import sys device='gemini' vendor='xiaomi' @@ -25,34 +26,54 @@ lines = [ line for line in open('proprietary-files.txt', 'r') ] vendorPath = '../../../vendor/' + vendor + '/' + device + '/proprietary' needSHA1 = False -for index, line in enumerate(lines): +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 + + # Drop SHA1 hash, if existing + if '|' in line: + line = line.split('|')[0] + lines[index] = '%s\n' % (line) + +def update(): + for index, line in enumerate(lines): # Remove '\n' character line = line[:-1] # Skip empty lines if len(line) == 0: - continue + continue # Check if we need to set SHA1 hash for the next files if line[0] == '#': - needSHA1 = (' - from' in line) - continue + needSHA1 = (' - from' in line) + continue if needSHA1: - # Remove existing SHA1 hash - line = line.split('|')[0] - filePath = line.split(':')[1] if len(line.split(':')) == 2 else line + # Remove existing SHA1 hash + line = line.split('|')[0] + filePath = line.split(':')[1] if len(line.split(':')) == 2 else line + + if filePath[0] == '-': + file = open('%s/%s' % (vendorPath, filePath[1:]), 'rb').read() + else: + file = open('%s/%s' % (vendorPath, filePath), 'rb').read() - if filePath[0] == '-': - file = open('%s/%s' % (vendorPath, filePath[1:]), 'rb').read() - else: - file = open('%s/%s' % (vendorPath, filePath), 'rb').read() + hash = sha1(file).hexdigest() + lines[index] = '%s|%s\n' % (line, hash) - hash = sha1(file).hexdigest() - lines[index] = '%s|%s\n' % (line, hash) +if len(sys.argv) == 2 and sys.argv[1] == '-c': + cleanup() +else: + update() with open('proprietary-files.txt', 'w') as file: - for line in lines: - file.write(line) + for line in lines: + file.write(line) - file.close() + file.close() -- cgit v1.2.3 From 224e68eecb66b580dff9759c7eca7acd68dfcec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cosme=20Dom=C3=ADnguez=20D=C3=ADaz?= Date: Thu, 1 Mar 2018 23:36:02 +0100 Subject: msm8996-common: Set zuk and msm8996-common in update-sha1sums.py --- update-sha1sums.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'update-sha1sums.py') diff --git a/update-sha1sums.py b/update-sha1sums.py index 02a263c..2595d21 100755 --- a/update-sha1sums.py +++ b/update-sha1sums.py @@ -19,8 +19,8 @@ from hashlib import sha1 import sys -device='gemini' -vendor='xiaomi' +device='msm8996-common' +vendor='zuk' lines = [ line for line in open('proprietary-files.txt', 'r') ] vendorPath = '../../../vendor/' + vendor + '/' + device + '/proprietary' -- cgit v1.2.3