gooftool: log hash of factory PAR if running PAR
LogSourceHashes tries to compute hash value of each python source code.
However, when python is running using PAR (python archive), we only need to
compute hash value of entire PAR file.
TEST=manual test
BUG=None
Change-Id: Ic4f85a5379479a6de686235a2d03b44815bbae2c
Reviewed-on: https://chromium-review.googlesource.com/340483
Commit-Ready: Wei-Han Chen <stimim@chromium.org>
Tested-by: Wei-Han Chen <stimim@chromium.org>
Reviewed-by: Chih-Yu Huang <akahuang@chromium.org>
diff --git a/py/gooftool/commands.py b/py/gooftool/commands.py
index a51e870..3344dfa 100755
--- a/py/gooftool/commands.py
+++ b/py/gooftool/commands.py
@@ -48,6 +48,7 @@
from cros.factory.test.rules import phase
from cros.factory.test.rules.privacy import FilterDict
from cros.factory.utils import file_utils
+from cros.factory.utils import sys_utils
from cros.factory.utils.debug_utils import SetupLogging
from cros.factory.utils.process_utils import Spawn
from cros.factory.utils.type_utils import Error
@@ -797,9 +798,15 @@
# of the factory software. Do not remove or modify it.
#
# 警告:此行会验证工厂软件的完整性,禁止删除或修改。
- event_log.Log(
- 'source_hashes',
- **file_utils.HashSourceTree(os.path.join(paths.FACTORY_PATH, 'py')))
+ factory_par = sys_utils.GetRunningFactoryPythonArchivePath()
+ if factory_par:
+ event_log.Log(
+ 'source_hashes',
+ **file_utils.HashPythonArchive(factory_par))
+ else:
+ event_log.Log(
+ 'source_hashes',
+ **file_utils.HashSourceTree(os.path.join(paths.FACTORY_PATH, 'py')))
@Command('log_system_details')