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
=== modified file 'scripts/publish_to_snapshots.py'
--- scripts/publish_to_snapshots.py 2013-04-25 19:31:13 +0000
+++ scripts/publish_to_snapshots.py 2013-04-25 20:35:37 +0000
@@ -7,6 +7,12 @@
7import os.path7import os.path
8import shutil8import shutil
9import sys9import sys
10import tempfile
11
12sys.path.append(
13 os.path.abspath(os.path.join(os.path.dirname(__file__),
14 "../license_protected_downloads")))
15from splice_build_infos import SpliceBuildInfos
1016
11uploads_path = '/srv/snapshots.linaro.org/uploads/'17uploads_path = '/srv/snapshots.linaro.org/uploads/'
12target_path = '/srv/snapshots.linaro.org/www/'18target_path = '/srv/snapshots.linaro.org/www/'
@@ -27,6 +33,28 @@
27 'openembedded',33 'openembedded',
28 'binaries'34 'binaries'
29 ]35 ]
36open_buildinfo_files = [
37 'MANIFEST',
38 '*manifest.xml',
39 'MD5SUMS',
40 '*build_cmds.sh',
41 'kernel_config',
42 'HOWTO_*'
43 ]
44open_buildinfo = 'Files-Pattern: %s\nLicense-Type: open\n'
45
46
47def append_open_buildinfo(buildinfo_path, files=open_buildinfo_files):
48 """Append BUILD-INFO.txt with open section for open_buildinfo_files"""
49 try:
50 bifile = open(os.path.join(buildinfo_path, buildinfo), "a")
51 try:
52 bifile.write(open_buildinfo % ', '.join(files))
53 finally:
54 bifile.close()
55 except IOError:
56 print "Unable to write to BUILD-INFO.txt"
57 pass
3058
3159
32def setup_parser():60def setup_parser():
@@ -393,6 +421,19 @@
393 raise BuildInfoException(421 raise BuildInfoException(
394 "BUILD-INFO.txt is not present for build being published.")422 "BUILD-INFO.txt is not present for build being published.")
395423
424 def combine_buildinfo(self, build_dir_path, target_dir_path, tmp_bi):
425 bi_path = os.path.join(target_dir_path, buildinfo)
426 bi_dirs = []
427 for path, subdirs, files in os.walk(build_dir_path):
428 for filename in files:
429 if buildinfo in filename:
430 bi_dirs.append(path)
431 if os.path.exists(bi_path):
432 bi_dirs.append(target_dir_path)
433 if bi_dirs:
434 common_bi = SpliceBuildInfos(bi_dirs)
435 common_bi.splice(tmp_bi)
436
396437
397def main():438def main():
398 global uploads_path439 global uploads_path
@@ -418,11 +459,19 @@
418 except BuildInfoException as e:459 except BuildInfoException as e:
419 print e.value460 print e.value
420 return FAIL461 return FAIL
462 fd, tmp_bi = tempfile.mkstemp()
463 os.close(fd)
464 publisher.combine_buildinfo(build_dir_path, target_dir_path, tmp_bi)
421 ret = publisher.move_artifacts(args, build_dir_path, target_dir_path)465 ret = publisher.move_artifacts(args, build_dir_path, target_dir_path)
422 if ret != PASS:466 if ret != PASS:
423 print "Move Failed"467 print "Move Failed"
424 return FAIL468 return FAIL
425 else:469 else:
470 shutil.copy(tmp_bi, os.path.join(target_dir_path, buildinfo))
471 os.remove(tmp_bi)
472 append_open_buildinfo(target_dir_path)
473 bi = SpliceBuildInfos([target_dir_path])
474 bi.splice(os.path.join(target_dir_path, buildinfo))
426 print "Move succeeded"475 print "Move succeeded"
427 return PASS476 return PASS
428 except Exception, details:477 except Exception, details:

Subscribers

People subscribed via source and target branches