Merge lp:~gesha/linaro-license-protection/splice-build-infos into lp:~linaro-automation/linaro-license-protection/trunk

Proposed by Georgy Redkozubov
Status: Merged
Approved by: Stevan Radaković
Approved revision: 185
Merged at revision: 185
Proposed branch: lp:~gesha/linaro-license-protection/splice-build-infos
Merge into: lp:~linaro-automation/linaro-license-protection/trunk
Diff against target: 85 lines (+49/-0)
1 file modified
scripts/publish_to_snapshots.py (+49/-0)
To merge this branch: bzr merge lp:~gesha/linaro-license-protection/splice-build-infos
Reviewer Review Type Date Requested Status
Stevan Radaković Approve
Review via email: mp+161010@code.launchpad.net

Description of the change

This branch adds ability of merging BUILD-INFO.txt when publishing artifacts. It takes all BUILD-INFO.txt found in directory being published and merges them together and, if needed, merges with BUILD-INFO.txt from directory where artifacts will be published.

To post a comment you must log in.
Revision history for this message
Stevan Radaković (stevanr) wrote :

Looks good.
Approve +1.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'scripts/publish_to_snapshots.py'
2--- scripts/publish_to_snapshots.py 2013-04-25 19:31:13 +0000
3+++ scripts/publish_to_snapshots.py 2013-04-25 20:35:37 +0000
4@@ -7,6 +7,12 @@
5 import os.path
6 import shutil
7 import sys
8+import tempfile
9+
10+sys.path.append(
11+ os.path.abspath(os.path.join(os.path.dirname(__file__),
12+ "../license_protected_downloads")))
13+from splice_build_infos import SpliceBuildInfos
14
15 uploads_path = '/srv/snapshots.linaro.org/uploads/'
16 target_path = '/srv/snapshots.linaro.org/www/'
17@@ -27,6 +33,28 @@
18 'openembedded',
19 'binaries'
20 ]
21+open_buildinfo_files = [
22+ 'MANIFEST',
23+ '*manifest.xml',
24+ 'MD5SUMS',
25+ '*build_cmds.sh',
26+ 'kernel_config',
27+ 'HOWTO_*'
28+ ]
29+open_buildinfo = 'Files-Pattern: %s\nLicense-Type: open\n'
30+
31+
32+def append_open_buildinfo(buildinfo_path, files=open_buildinfo_files):
33+ """Append BUILD-INFO.txt with open section for open_buildinfo_files"""
34+ try:
35+ bifile = open(os.path.join(buildinfo_path, buildinfo), "a")
36+ try:
37+ bifile.write(open_buildinfo % ', '.join(files))
38+ finally:
39+ bifile.close()
40+ except IOError:
41+ print "Unable to write to BUILD-INFO.txt"
42+ pass
43
44
45 def setup_parser():
46@@ -393,6 +421,19 @@
47 raise BuildInfoException(
48 "BUILD-INFO.txt is not present for build being published.")
49
50+ def combine_buildinfo(self, build_dir_path, target_dir_path, tmp_bi):
51+ bi_path = os.path.join(target_dir_path, buildinfo)
52+ bi_dirs = []
53+ for path, subdirs, files in os.walk(build_dir_path):
54+ for filename in files:
55+ if buildinfo in filename:
56+ bi_dirs.append(path)
57+ if os.path.exists(bi_path):
58+ bi_dirs.append(target_dir_path)
59+ if bi_dirs:
60+ common_bi = SpliceBuildInfos(bi_dirs)
61+ common_bi.splice(tmp_bi)
62+
63
64 def main():
65 global uploads_path
66@@ -418,11 +459,19 @@
67 except BuildInfoException as e:
68 print e.value
69 return FAIL
70+ fd, tmp_bi = tempfile.mkstemp()
71+ os.close(fd)
72+ publisher.combine_buildinfo(build_dir_path, target_dir_path, tmp_bi)
73 ret = publisher.move_artifacts(args, build_dir_path, target_dir_path)
74 if ret != PASS:
75 print "Move Failed"
76 return FAIL
77 else:
78+ shutil.copy(tmp_bi, os.path.join(target_dir_path, buildinfo))
79+ os.remove(tmp_bi)
80+ append_open_buildinfo(target_dir_path)
81+ bi = SpliceBuildInfos([target_dir_path])
82+ bi.splice(os.path.join(target_dir_path, buildinfo))
83 print "Move succeeded"
84 return PASS
85 except Exception, details:

Subscribers

People subscribed via source and target branches