| The Gaudi Framework v28r2-patches (bc4ad17a)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

svn_tag_release.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 """
3 Small script to prepare the tags and the distribution special directory for a
4 release of Gaudi.
5 See https://twiki.cern.ch/twiki/bin/view/Gaudi/GaudiSVNRepository for a
6 description of the repository structure.
7 """
8 __author__ = "Marco Clemencic <Marco.Clemencic@cern.ch>"
9
10 import os, re, sys, tempfile, shutil
11 from subprocess import Popen, PIPE
12 from ConfigParser import ConfigParser
13
14 def svn(*args, **kwargs):
15 print "> svn", " ".join(args)
16 return apply(Popen, (["svn"] + list(args),), kwargs)
17
18 def svn_ls(url):
19 return svn("ls", url, stdout = PIPE).communicate()[0].splitlines()
20
21 def basename(url):
22 return url.rsplit("/", 1)[-1]
23
24 def dirname(url):
25 return url.rsplit("/", 1)[1]
26
27 def svn_exists(url):
28 d,b = url.rsplit("/", 1)
29 l = [x.rstrip("/") for x in svn_ls(d)]
30 return b in l
31
32 def checkout_structure(url, proj, branch):
33 def checkout_level(base):
34 dirs = ["%s/%s" % (base, d) for d in svn_ls(base) if d.endswith("/")]
35 apply(svn, ["up", "-N"] + dirs).wait()
36 return dirs
37
38 root = basename(url)
39 svn("co","-N", url, root).wait()
40 old_dir = os.getcwd()
41 os.chdir(root)
42 svn("up", "-N", proj).wait()
43 br = [proj] + branch.split("/")
44 for base in [ "/".join(br[:n+1]) for n in range(len(br))]:
45 checkout_level(base)
46 checkout_level(proj + "/tags")
47 os.chdir(old_dir)
48 return root
49
50 def main():
51 from optparse import OptionParser
52 parser = OptionParser()
53 parser.add_option("--pre", action = "store_true",
54 help = "Create -pre tags instead of final tags.")
55 parser.add_option("-b", "--branch",
56 help = "Use the given (global) branch as source for the tags instead of the trunk")
57 opts, args = parser.parse_args()
58 if opts.branch:
59 opts.branch = "/".join(["branches", "GAUDI", opts.branch])
60 else:
61 opts.branch = "trunk"
62
63 url = "svn+ssh://svn.cern.ch/reps/gaudi"
64 proj = "Gaudi"
65 container = "GaudiRelease"
66 project_info = ConfigParser()
67 project_info.optionxform = str # make options case sensitive
68 project_info.read('project.info')
69 packages = dict(project_info.items('Packages'))
70 tempdir = tempfile.mkdtemp()
71 try:
72 os.chdir(tempdir)
73 # prepare repository structure (and move to its top level)
74 os.chdir(checkout_structure(url, proj, opts.branch))
75
76 # note that the project does not have "-pre"
77 pvers = "%s_%s" % (proj.upper(), packages[container])
78
79 # prepare project tag
80 ptagdir = "%s/tags/%s/%s" % (proj, proj.upper(), pvers)
81 if not svn_exists(ptagdir):
82 svn('cp', '/'.join([proj, opts.branch]), ptagdir).wait()
83
84 # prepare package tags
85 tag_re = re.compile(r"^v(\d+)r(\d+)(?:p(\d+))?$")
86 for p in packages:
87 tag = packages[p]
88 pktagdir = "%s/tags/%s/%s" % (proj, p, tag)
89 # I have to make the tag if it doesn't exist and (if we use -pre tags)
90 # neither the -pre tag exists.
91 no_tag = not svn_exists(pktagdir)
92 make_tag = no_tag or (opts.pre and no_tag and not svn_exists(pktagdir + "-pre"))
93 if make_tag:
94 if opts.pre:
95 pktagdir += "-pre"
96 svn("cp", "/".join([proj, opts.branch, p]), pktagdir).wait()
97 # Atlas type of tag
98 tagElements = tag_re.match(tag)
99 if tagElements:
100 tagElements = "-".join([ "%02d" % int(el or "0") for el in tagElements.groups() ])
101 pktagdir = "%s/tags/%s/%s-%s" % (proj, p, p, tagElements)
102 svn("cp", "/".join([proj, opts.branch, p]), pktagdir).wait()
103 else:
104 if not no_tag:
105 svn("up", "--depth=empty", pktagdir).wait() # needed for the copy in the global tag
106
107 svn("ci").wait()
108
109 finally:
110 shutil.rmtree(tempdir, ignore_errors = True)
111
112 return 0
113
114 if __name__ == '__main__':
115 sys.exit(main())
Gaudi::Functional::details::zip::range
decltype(auto) range(Args &&...args)
Zips multiple containers together to form a single range.
Definition: FunctionalDetails.h:57
svn_tag_release.dirname
def dirname(url)
Definition: svn_tag_release.py:24
svn_tag_release.main
def main()
Definition: svn_tag_release.py:50
svn_tag_release.svn_exists
def svn_exists(url)
Definition: svn_tag_release.py:27
svn_tag_release.svn
def svn(args, kwargs)
Definition: svn_tag_release.py:14
svn_tag_release.svn_ls
def svn_ls(url)
Definition: svn_tag_release.py:18
Gaudi::Functional::details::apply
constexpr void apply(const Fun &, Container &, Args...)
Definition: FunctionalDetails.h:444
svn_tag_release.basename
def basename(url)
Definition: svn_tag_release.py:21
svn_tag_release.checkout_structure
def checkout_structure(url, proj, branch)
Definition: svn_tag_release.py:32