diff options
author | 2015-11-10 12:37:23 -0800 | |
---|---|---|
committer | 2015-11-10 12:37:23 -0800 | |
commit | 8ae4984c2c8009e7a08e2a76b1762c2837ad4f64 (patch) | |
tree | c99707d97315794e93bb46464e2452c242d49956 | |
parent | 8b2c37c9533f94f81fd8b15257c56061ce10998c (diff) |
Create reproducible NOTICE collections
Sort the lists of notice files instead of relying on the filesystem
ordering returned by os.walk
Bug: 23972440
Change-Id: Id32be9ce8e540244ad9d67b6fc7883fc2963fe5c
-rwxr-xr-x | tools/generate-notice-files.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/tools/generate-notice-files.py b/tools/generate-notice-files.py index 4571b70df9..5b13bf53de 100755 --- a/tools/generate-notice-files.py +++ b/tools/generate-notice-files.py @@ -99,7 +99,7 @@ def combine_notice_files_html(file_hash, input_dir, output_filename): # most browsers, but href's to table row ids do) id_table = {} id_count = 0 - for value in file_hash.values(): + for value in file_hash: for filename in value: id_table[filename] = id_count id_count += 1 @@ -116,7 +116,7 @@ def combine_notice_files_html(file_hash, input_dir, output_filename): print >> output_file, "<ul>" # Flatten the list of lists into a single list of filenames - sorted_filenames = sorted(itertools.chain.from_iterable(file_hash.values())) + sorted_filenames = sorted(itertools.chain.from_iterable(file_hash)) # Print out a nice table of contents for filename in sorted_filenames: @@ -127,11 +127,11 @@ def combine_notice_files_html(file_hash, input_dir, output_filename): print >> output_file, "</div><!-- table of contents -->" # Output the individual notice file lists print >>output_file, '<table cellpadding="0" cellspacing="0" border="0">' - for value in file_hash.values(): + for value in file_hash: print >> output_file, '<tr id="id%d"><td class="same-license">' % id_table.get(value[0]) print >> output_file, '<div class="label">Notices for file(s):</div>' print >> output_file, '<div class="file-list">' - for filename in sorted(value): + for filename in value: print >> output_file, "%s <br/>" % (SRC_DIR_STRIP_RE.sub(r"\1", filename)) print >> output_file, "</div><!-- file-list -->" print >> output_file @@ -154,10 +154,10 @@ def combine_notice_files_text(file_hash, input_dir, output_filename, file_title) SRC_DIR_STRIP_RE = re.compile(input_dir + "(/.*).txt") output_file = open(output_filename, "wb") print >> output_file, file_title - for value in file_hash.values(): + for value in file_hash: print >> output_file, "============================================================" print >> output_file, "Notices for file(s):" - for filename in sorted(value): + for filename in value: print >> output_file, SRC_DIR_STRIP_RE.sub(r"\1", filename) print >> output_file, "------------------------------------------------------------" print >> output_file, open(value[0]).read() @@ -178,11 +178,12 @@ def main(args): file_md5sum = md5sum(filename) files_with_same_hash[file_md5sum].append(filename) + filesets = [sorted(files_with_same_hash[md5]) for md5 in sorted(files_with_same_hash.keys())] print "Combining NOTICE files into HTML" - combine_notice_files_html(files_with_same_hash, input_dir, html_output_file) + combine_notice_files_html(filesets, input_dir, html_output_file) print "Combining NOTICE files into text" - combine_notice_files_text(files_with_same_hash, input_dir, txt_output_file, file_title) + combine_notice_files_text(filesets, input_dir, txt_output_file, file_title) if __name__ == "__main__": main(args) |