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
1=== modified file 'license_protected_downloads/buildinfo.py'
2--- license_protected_downloads/buildinfo.py 2013-06-04 18:21:53 +0000
3+++ license_protected_downloads/buildinfo.py 2013-09-20 13:14:26 +0000
4@@ -194,17 +194,18 @@
5
6 @classmethod
7 def write_from_array(cls, build_info_array, file_path):
8- with open(file_path, "w") as outfile:
9- outfile.write("Format-Version: 0.5\n\n")
10- for key in build_info_array[0]:
11- if key != "format-version":
12- outfile.write("Files-Pattern: %s\n" % key)
13- for item in build_info_array[0][key][0]:
14- text = build_info_array[0][key][0][item]
15- if item == "license-text":
16- text = text.replace("\n", "\n ")
17- outfile.write("%s: %s\n" % (item, text))
18- outfile.write("\n")
19+ if len(build_info_array[0]):
20+ with open(file_path, "w") as outfile:
21+ outfile.write("Format-Version: 0.5\n\n")
22+ for key in build_info_array[0]:
23+ if key != "format-version":
24+ outfile.write("Files-Pattern: %s\n" % key)
25+ for item in build_info_array[0][key][0]:
26+ text = build_info_array[0][key][0][item]
27+ if item == "license-text":
28+ text = text.replace("\n", "\n ")
29+ outfile.write("%s: %s\n" % (item, text))
30+ outfile.write("\n")
31
32
33 if __name__ == "__main__":
34
35=== modified file 'scripts/publish_to_snapshots.py'
36--- scripts/publish_to_snapshots.py 2013-04-29 18:07:04 +0000
37+++ scripts/publish_to_snapshots.py 2013-09-20 13:14:26 +0000
38@@ -35,27 +35,28 @@
39 ]
40 open_buildinfo_files = [
41 'MANIFEST',
42- '*manifest.xml',
43+ '*manifest*.xml',
44 'MD5SUMS',
45 '*build_cmds.sh',
46 'kernel_config',
47 'HOWTO_*',
48 'lava-job-info*'
49 ]
50-open_buildinfo = 'Files-Pattern: %s\nLicense-Type: open\n'
51+open_buildinfo = '\nFiles-Pattern: %s\nLicense-Type: open\n'
52
53
54 def append_open_buildinfo(buildinfo_path, files=open_buildinfo_files):
55 """Append BUILD-INFO.txt with open section for open_buildinfo_files"""
56- try:
57- bifile = open(os.path.join(buildinfo_path, buildinfo), "a")
58+ if os.path.exists(os.path.join(buildinfo_path, buildinfo)):
59 try:
60- bifile.write(open_buildinfo % ', '.join(files))
61- finally:
62- bifile.close()
63- except IOError:
64- print "Unable to write to BUILD-INFO.txt"
65- pass
66+ bifile = open(os.path.join(buildinfo_path, buildinfo), "a")
67+ try:
68+ bifile.write(open_buildinfo % ', '.join(files))
69+ finally:
70+ bifile.close()
71+ except IOError:
72+ print "Unable to write to BUILD-INFO.txt"
73+ pass
74
75
76 def setup_parser():
77@@ -469,7 +470,8 @@
78 print "Move Failed"
79 return FAIL
80 else:
81- shutil.copy(tmp_bi, os.path.join(target_dir_path, buildinfo))
82+ if os.path.getsize(tmp_bi) > 0:
83+ shutil.copy(tmp_bi, os.path.join(target_dir_path, buildinfo))
84 os.remove(tmp_bi)
85 append_open_buildinfo(target_dir_path)
86 bi = SpliceBuildInfos([target_dir_path])

Subscribers

People subscribed via source and target branches