Merge lp:~gesha/linaro-license-protection/1210113 into lp:~linaro-automation/linaro-license-protection/trunk

Proposed by Georgy Redkozubov
Status: Merged
Approved by: Milo Casagrande
Approved revision: 210
Merged at revision: 218
Proposed branch: lp:~gesha/linaro-license-protection/1210113
Merge into: lp:~linaro-automation/linaro-license-protection/trunk
Diff against target: 86 lines (+25/-22)
2 files modified
license_protected_downloads/buildinfo.py (+12/-11)
scripts/publish_to_snapshots.py (+13/-11)
To merge this branch: bzr merge lp:~gesha/linaro-license-protection/1210113
Reviewer Review Type Date Requested Status
Milo Casagrande (community) Approve
Review via email: mp+186783@code.launchpad.net

Description of the change

This branch adds several checks on BUILD-INFO.txt which should not allow to create BUILD-INFO.txt with invalid format.

To post a comment you must log in.
Revision history for this message
Milo Casagrande (milo) wrote :

Looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'license_protected_downloads/buildinfo.py'
--- license_protected_downloads/buildinfo.py 2013-06-04 18:21:53 +0000
+++ license_protected_downloads/buildinfo.py 2013-09-20 13:14:26 +0000
@@ -194,17 +194,18 @@
194194
195 @classmethod195 @classmethod
196 def write_from_array(cls, build_info_array, file_path):196 def write_from_array(cls, build_info_array, file_path):
197 with open(file_path, "w") as outfile:197 if len(build_info_array[0]):
198 outfile.write("Format-Version: 0.5\n\n")198 with open(file_path, "w") as outfile:
199 for key in build_info_array[0]:199 outfile.write("Format-Version: 0.5\n\n")
200 if key != "format-version":200 for key in build_info_array[0]:
201 outfile.write("Files-Pattern: %s\n" % key)201 if key != "format-version":
202 for item in build_info_array[0][key][0]:202 outfile.write("Files-Pattern: %s\n" % key)
203 text = build_info_array[0][key][0][item]203 for item in build_info_array[0][key][0]:
204 if item == "license-text":204 text = build_info_array[0][key][0][item]
205 text = text.replace("\n", "\n ")205 if item == "license-text":
206 outfile.write("%s: %s\n" % (item, text))206 text = text.replace("\n", "\n ")
207 outfile.write("\n")207 outfile.write("%s: %s\n" % (item, text))
208 outfile.write("\n")
208209
209210
210if __name__ == "__main__":211if __name__ == "__main__":
211212
=== modified file 'scripts/publish_to_snapshots.py'
--- scripts/publish_to_snapshots.py 2013-04-29 18:07:04 +0000
+++ scripts/publish_to_snapshots.py 2013-09-20 13:14:26 +0000
@@ -35,27 +35,28 @@
35 ]35 ]
36open_buildinfo_files = [36open_buildinfo_files = [
37 'MANIFEST',37 'MANIFEST',
38 '*manifest.xml',38 '*manifest*.xml',
39 'MD5SUMS',39 'MD5SUMS',
40 '*build_cmds.sh',40 '*build_cmds.sh',
41 'kernel_config',41 'kernel_config',
42 'HOWTO_*',42 'HOWTO_*',
43 'lava-job-info*'43 'lava-job-info*'
44 ]44 ]
45open_buildinfo = 'Files-Pattern: %s\nLicense-Type: open\n'45open_buildinfo = '\nFiles-Pattern: %s\nLicense-Type: open\n'
4646
4747
48def append_open_buildinfo(buildinfo_path, files=open_buildinfo_files):48def append_open_buildinfo(buildinfo_path, files=open_buildinfo_files):
49 """Append BUILD-INFO.txt with open section for open_buildinfo_files"""49 """Append BUILD-INFO.txt with open section for open_buildinfo_files"""
50 try:50 if os.path.exists(os.path.join(buildinfo_path, buildinfo)):
51 bifile = open(os.path.join(buildinfo_path, buildinfo), "a")
52 try:51 try:
53 bifile.write(open_buildinfo % ', '.join(files))52 bifile = open(os.path.join(buildinfo_path, buildinfo), "a")
54 finally:53 try:
55 bifile.close()54 bifile.write(open_buildinfo % ', '.join(files))
56 except IOError:55 finally:
57 print "Unable to write to BUILD-INFO.txt"56 bifile.close()
58 pass57 except IOError:
58 print "Unable to write to BUILD-INFO.txt"
59 pass
5960
6061
61def setup_parser():62def setup_parser():
@@ -469,7 +470,8 @@
469 print "Move Failed"470 print "Move Failed"
470 return FAIL471 return FAIL
471 else:472 else:
472 shutil.copy(tmp_bi, os.path.join(target_dir_path, buildinfo))473 if os.path.getsize(tmp_bi) > 0:
474 shutil.copy(tmp_bi, os.path.join(target_dir_path, buildinfo))
473 os.remove(tmp_bi)475 os.remove(tmp_bi)
474 append_open_buildinfo(target_dir_path)476 append_open_buildinfo(target_dir_path)
475 bi = SpliceBuildInfos([target_dir_path])477 bi = SpliceBuildInfos([target_dir_path])

Subscribers

People subscribed via source and target branches