Optimize cert merging script 88/304288/1 accepted/tizen_8.0_unified accepted/tizen_9.0_unified accepted/tizen_unified accepted/tizen_unified_dev accepted/tizen_unified_riscv tizen_8.0 tizen_9.0 accepted/tizen/8.0/unified/20240117.162922 accepted/tizen/9.0/unified/20241031.000028 accepted/tizen/unified/20240116.155532 accepted/tizen/unified/dev/20240620.005602 accepted/tizen/unified/riscv/20240117.041600 tizen_9.0_m2_release
authorTomasz Swierczek <t.swierczek@samsung.com>
Mon, 15 Jan 2024 12:25:08 +0000 (13:25 +0100)
committerTomasz Swierczek <t.swierczek@samsung.com>
Mon, 15 Jan 2024 12:28:37 +0000 (13:28 +0100)
No need to check if file is a cert AND separately calculate SHA1

Change-Id: I031d674ff35db828e9afce6dff2e47edb2742add

scripts/merge-certs-info.py

index e7ab2b8f8108e13edebf945f59031ffe05af98ac..c6b105bfe5ee18cdbba24ec8f8ebcde1dc0312bd 100755 (executable)
@@ -1,6 +1,6 @@
 ####################################################
 #
-# Copyright (c) 2018 - 2023 Samsung Electronics Co., Ltd All Rights Reserved
+# Copyright (c) 2018 - 2024 Samsung Electronics Co., Ltd All Rights Reserved
 #
 #    Licensed under the Apache License, Version 2.0 (the "License");
 #    you may not use this file except in compliance with the License.
@@ -66,12 +66,6 @@ def getEndDate(path):
         return output[0].strip()
     return ""
 
-####################################################
-#   Returns true if path points to certificate file
-####################################################
-def isCert(path):
-    return len(consoleCommand("openssl x509 -in " + path + "  -subject_hash_old -noout")) > 0;
-
 ####################################################
 #  Returns true if certificate under path is not expired
 ####################################################
@@ -80,7 +74,7 @@ def isCertValid(path):
     return endDate > datetime.now()
 
 ####################################################
-#   Returns sha1 fingerprint of DER or PEM cert, empty string on error
+#   Returns sha1 fingerprint of DER or PEM cert, empty string on error (ie. file is not a certificate)
 ####################################################
 def calculateCertSHA1(path):
     output = consoleCommand("openssl x509 -noout -fingerprint -sha1 -inform pem -in " + path + " | sed -e 's/Fingerprint=//g'")
@@ -154,11 +148,11 @@ for directory in directories:
     files = consoleCommand("ls -1 " + directory)
     for f in files:
         f = f.strip()
-        if isCert(directory + "/" + f):
-            sha1 = calculateCertSHA1(directory + "/" + f)
-            if len(sha1) > 0:
-                sha1ToName[sha1] = f;
-                allSha1ToAnyPath[sha1] = directory + "/" + f
+        path = directory + "/" + f
+        sha1 = calculateCertSHA1(path)
+        if len(sha1) > 0:
+            sha1ToName[sha1] = f;
+            allSha1ToAnyPath[sha1] = path
     dirToSha1ToName[directory] = sha1ToName;
 
 if outputDir != "":