diff options
author | weisu <weisu@google.com> | 2022-02-09 05:25:16 +0000 |
---|---|---|
committer | Wei Su <weisu@google.com> | 2022-02-12 04:27:44 +0000 |
commit | 8fd84e8513449eebf98c7feca5e98c5023866db3 (patch) | |
tree | 592b3b25b52251a168fe83ee52b4f12637bc779c | |
parent | 6e6370acd6041f11f4159a7911dea88ac1311122 (diff) | |
download | apex-8fd84e8513449eebf98c7feca5e98c5023866db3.tar.gz |
Normalize file permissions for deterministic output
apexer_test could fail under different test runner since different
runner could create intermediate files with different file permissions.
The apexer zipping process kept the file permission information causing
indeterministic output.
The problem exhibits in Bazel where the runner set file permission to
640, different from the golden test data.
Test: atest --bazel-mode --host apexer_test
Test: atest --host apexer_test
Test: atest ApexTestCases
Bug: 217831421
Change-Id: I6086db9e9e6d379940e50809624701482b0dc31c
-rw-r--r-- | apexer/apexer.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/apexer/apexer.py b/apexer/apexer.py index 56fdfd07..a2bbca67 100644 --- a/apexer/apexer.py +++ b/apexer/apexer.py @@ -889,6 +889,10 @@ def MergeZips(zip_files, output_zip): for info in inzip.infolist(): # reset timestamp for deterministic output info.date_time = (1980, 1, 1, 0, 0, 0) + # reset filemode for deterministic output. The high 16 bits are for + # filemode. 0x81A4 corresponds to 0o100644(a regular file with + # '-rw-r--r--' permission). + info.external_attr = 0x81A40000 # "apex_payload.img" should be 4K aligned if info.filename == 'apex_payload.img': data_offset = out.fp.tell() + len(info.FileHeader()) |