| The Gaudi Framework v29r1 (5cd95fa2)

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