3 Small script to prepare the tags and the distribution special directory for a
5 See https://twiki.cern.ch/twiki/bin/view/Gaudi/GaudiSVNRepository for a
6 description of the repository structure.
8 __author__ =
"Marco Clemencic <Marco.Clemencic@cern.ch>"
10 import os, re, sys, tempfile, shutil
11 from subprocess
import Popen, PIPE
13 _req_version_pattern = re.compile(
r"^\s*version\s*(v[0-9]+r[0-9]+(?:p[0-9]+)?)\s*$")
16 Find the version number in a requirements file.
18 global _req_version_pattern
20 m = _req_version_pattern.match(l)
25 _use_pattern = re.compile(
r"^\s*use\s*(\w+)\s*(v[0-9]+r[0-9]+(?:p[0-9]+)?)\s*(\w+)?\s*$")
30 m = _use_pattern.match(l)
32 versions[m.group(1)] = m.group(2)
35 def svn(*args, **kwargs):
36 print "> svn",
" ".join(args)
37 return apply(Popen, ([
"svn"] + list(args),), kwargs)
40 return svn(
"ls", url, stdout = PIPE).communicate()[0].splitlines()
43 return url.rsplit(
"/", 1)[-1]
46 return url.rsplit(
"/", 1)[1]
49 d,b = url.rsplit(
"/", 1)
50 l = [x.rstrip(
"/")
for x
in svn_ls(d)]
54 def checkout_level(base):
55 dirs = [
"%s/%s" % (base, d)
for d
in svn_ls(base)
if d.endswith(
"/")]
56 apply(svn, [
"up",
"-N"] + dirs).wait()
60 svn(
"co",
"-N", url, root).wait()
63 svn(
"up",
"-N", proj).wait()
64 br = [proj] + branch.split(
"/")
65 for base
in [
"/".join(br[:n+1])
for n
in range(len(br))]:
67 checkout_level(proj +
"/tags")
72 from optparse
import OptionParser
73 parser = OptionParser()
74 parser.add_option(
"--pre", action =
"store_true",
75 help =
"Create -pre tags instead of final tags.")
76 parser.add_option(
"-b",
"--branch",
77 help =
"Use the given (global) branch as source for the tags instead of the trunk")
78 opts, args = parser.parse_args()
80 opts.branch =
"/".join([
"branches",
"GAUDI", opts.branch])
84 url =
"svn+ssh://svn.cern.ch/reps/gaudi"
86 container =
"GaudiRelease"
89 tempdir = tempfile.mkdtemp()
96 pvers =
"%s_%s" % (proj.upper(), packages[container])
99 ptagdir =
"%s/tags/%s/%s" % (proj, proj.upper(), pvers)
101 svn(
'cp',
'/'.join([proj, opts.branch]), ptagdir).wait()
104 tag_re = re.compile(
r"^v(\d+)r(\d+)(?:p(\d+))?$")
107 pktagdir =
"%s/tags/%s/%s" % (proj, p, tag)
111 make_tag = no_tag
or (opts.pre
and no_tag
and not svn_exists(pktagdir +
"-pre"))
115 svn(
"cp",
"/".join([proj, opts.branch, p]), pktagdir).wait()
117 tagElements = tag_re.match(tag)
119 tagElements =
"-".join([
"%02d" % int(el
or "0")
for el
in tagElements.groups() ])
120 pktagdir =
"%s/tags/%s/%s-%s" % (proj, p, p, tagElements)
121 svn(
"cp",
"/".join([proj, opts.branch, p]), pktagdir).wait()
124 svn(
"up",
"--depth=empty", pktagdir).wait()
129 shutil.rmtree(tempdir, ignore_errors =
True)
133 if __name__ ==
'__main__':
NamedRange_< CONTAINER > range(const CONTAINER &cnt, const std::string &name)
simple function to create the named range form arbitrary container