|
Gaudi Framework, version v22r2 |
| Home | Generated: Tue May 10 2011 |
Functions | |
| def | extract_version |
| def | change_version |
| def | gather_new_versions |
| def | extract_recent_rel_notes |
| def | add_release_separator_bar |
| def | main |
Variables | |
| string | __author__ = "Marco Clemencic <Marco.Clemencic@cern.ch>" |
| string | __version__ = "$Id: update_versions.py,v 1.3 2008/11/10 19:43:31 marcocle Exp $" |
| tuple | _req_version_pattern = re.compile(r"^\s*version\s*(v[0-9]+r[0-9]+(?:p[0-9]+)?)\s*$") |
| tuple | _use_pattern = re.compile(r"^\s*use\s*(\w+)\s*(v[0-9]+r[0-9]+(?:p[0-9]+)?)\s*(\w+)?\s*$") |
| def update_versions::add_release_separator_bar | ( | filename, | |
| pkg, | |||
| version | |||
| ) |
Definition at line 82 of file update_versions.py.
00083 : 00084 changelog_entry = re.compile(r'^(! [0-9]{4}-[0-9]{2}-[0-9]{2} -)|============') 00085 title = " %s %s " % (pkg, version) 00086 letf_chars = (78 - len(title)) / 2 00087 right_chars = 78 - letf_chars - len(title) 00088 separator = ("=" * letf_chars) + title + ("=" * right_chars) + "\n" 00089 out = [] 00090 found = False 00091 for l in open(filename): 00092 # looking for the first changelog entry 00093 if not found: 00094 if changelog_entry.match(l): 00095 out.append(separator) 00096 found = True 00097 # if found, just go on appending lines 00098 out.append(l) 00099 if found: 00100 open(filename,"w").writelines(out) 00101 else: 00102 print "Warning: could not update release.notes in %s" % pkg
| def update_versions::change_version | ( | packagedir, | |
| newversion | |||
| ) |
Compare the version of the package with the new one and update the package if needed. Returns true if the package have been modified.
Definition at line 23 of file update_versions.py.
00024 : 00025 """ 00026 Compare the version of the package with the new one and update the package if 00027 needed. 00028 00029 Returns true if the package have been modified. 00030 """ 00031 global _req_version_pattern 00032 changed = False 00033 out = [] 00034 req = os.path.join(packagedir,"requirements") 00035 for l in open(req): 00036 m = _req_version_pattern.match(l) 00037 if m: 00038 if m.group(1) != newversion: 00039 print "%s: %s -> %s"%(packagedir,m.group(1),newversion) 00040 l = l.replace(m.group(1),newversion) 00041 changed = True 00042 out.append(l) 00043 if changed: 00044 open(req,"w").writelines(out) 00045 # verify the version.cmt file 00046 ver = os.path.join(packagedir,"version.cmt") 00047 if os.path.exists(ver): 00048 current = open(ver).read().strip() 00049 if current != newversion: 00050 open(ver,"w").write(newversion + "\n") 00051 return changed
| def update_versions::extract_recent_rel_notes | ( | filename ) |
Definition at line 62 of file update_versions.py.
00063 : 00064 changelog_entry = re.compile(r'^(! [0-9]{4}-[0-9]{2}-[0-9]{2} -)|============') 00065 separator_entry = re.compile(r'^============') 00066 notes = [] 00067 state = "searching" 00068 for l in open(filename): 00069 # looking for the first changelog entry 00070 if state == "searching": 00071 if changelog_entry.match(l): 00072 state = "found" 00073 # when found, we start collecting lines until the next separator 00074 if state == "found": 00075 if not separator_entry.match(l): 00076 notes.append(l) 00077 else: 00078 break 00079 # remove trailing empty lines 00080 while notes and not notes[-1].strip(): notes.pop() 00081 return "".join(notes)
| def update_versions::extract_version | ( | f ) |
Find the version number in a requirements file.
Definition at line 12 of file update_versions.py.
| def update_versions::gather_new_versions | ( | f ) |
Definition at line 53 of file update_versions.py.
| def update_versions::main | ( | ) |
Definition at line 103 of file update_versions.py.
00104 : 00105 00106 # Find the version of LCGCMT 00107 m = re.search("use\s*LCGCMT\s*LCGCMT_(\S*)",open(os.path.join("..","..","cmt","project.cmt")).read()) 00108 if m: 00109 LCGCMTVers = m.group(1) 00110 print "Using LCGCMT", LCGCMTVers 00111 else: 00112 print "Cannot find LCGCMT version" 00113 sys.exit(1) 00114 00115 # Collect all the packages in the project with their directory 00116 # (I want to preserve the order that cmt broadcast gives) 00117 all_packages_tmp = [] 00118 exec(os.popen(r"""cmt broadcast 'echo "all_packages_tmp.append((\"<package>\"", \"$PWD\""))"'""","r").read()) 00119 all_packages_names = [] 00120 all_packages = {} 00121 for k,v in all_packages_tmp: 00122 all_packages_names.append(k) 00123 all_packages[k] = v 00124 00125 # Packages which version must match the version of the project 00126 special_packages = ["Gaudi", "GaudiExamples", "GaudiSys", "GaudiRelease"] 00127 00128 # Ask for the version of the project 00129 old_version = extract_version("requirements") 00130 new_version = raw_input("The old version of the project is %s, which is the new one? " % old_version) 00131 00132 old_versions = {} 00133 release_notes = {} 00134 new_versions = {} 00135 # for each package in the project check if there were changes and ask for the new version number 00136 for pkg in all_packages_names: 00137 reqfile = os.path.join(all_packages[pkg], "requirements") 00138 relnotefile = os.path.join(all_packages[pkg], "..", "doc", "release.notes") 00139 old_versions[pkg] = extract_version(reqfile) 00140 if os.path.exists(relnotefile): # ignore missing release.notes 00141 release_notes[pkg] = extract_recent_rel_notes(relnotefile) 00142 else: 00143 release_notes[pkg] = "" 00144 if pkg in special_packages: 00145 new_versions[pkg] = new_version 00146 else: 00147 if release_notes[pkg]: 00148 new_versions[pkg] = raw_input("\nThe old version of %s is %s, this are the changes:\n%s\nWhich version you want (old is %s)? " % (pkg, old_versions[pkg], release_notes[pkg], old_versions[pkg])) 00149 else: 00150 new_versions[pkg] = old_versions[pkg] 00151 # update infos 00152 if new_versions[pkg] != old_versions[pkg]: 00153 change_version(all_packages[pkg], new_versions[pkg]) 00154 if os.path.exists(relnotefile): 00155 add_release_separator_bar(relnotefile, pkg, new_versions[pkg]) 00156 print "=" * 80 00157 # The changes in the GaudiRelease requirements for the other packages can be postponed to now 00158 reqfile = os.path.join(all_packages["GaudiRelease"], "requirements") 00159 out = [] 00160 for l in open(reqfile): 00161 sl = l.strip().split() 00162 if sl and sl[0] == "use": 00163 if sl[1] in new_versions: 00164 if sl[2] != new_versions[sl[1]]: 00165 l = l.replace(sl[2], new_versions[sl[1]]) 00166 out.append(l) 00167 open(reqfile, "w").writelines(out) 00168 00169 # update the global release notes 00170 new_lines = [] 00171 new_lines.append("<!-- ====================================================================== -->") 00172 data = { "vers": new_version, "date": time.strftime("%Y-%m-%d") } 00173 new_lines.append('<h2><a name="%(vers)s">Gaudi %(vers)s</a> (%(date)s)</h2>' % data) 00174 data = { "vers": LCGCMTVers } 00175 new_lines.append('<h3>Externals version: <a href="http://lcgsoft.cern.ch/index.py?page=cfg_overview&cfg=%(vers)s">LCGCMT_%(vers)s</a></h3>' % data) 00176 new_lines.append("<h3>General Changes</h3>") 00177 new_lines.append('<ul>\n<li><br/>\n (<span class="author"></span>)</li>\n</ul>') 00178 new_lines.append("<h3>Packages Changes</h3>") 00179 new_lines.append("<ul>") 00180 for pkg in all_packages_names: 00181 if release_notes[pkg]: 00182 new_lines.append('<li>%s (%s):\n<ul>\n<li><br/>\n (<span class="author"></span>)</li>\n</ul>\n<pre>'%(pkg,new_versions[pkg])) 00183 new_lines.append(release_notes[pkg].replace('&','&') \ 00184 .replace('<','<') \ 00185 .replace('>','>') + "</pre>") 00186 new_lines.append("</li>") 00187 new_lines.append("</ul>") 00188 00189 global_rel_notes = os.path.join("..", "doc", "release.notes.html") 00190 out = [] 00191 separator = re.compile("<!-- =+ -->") 00192 block_added = False 00193 for l in open(global_rel_notes): 00194 if not block_added and separator.match(l.strip()): 00195 out.append("\n".join(new_lines) + "\n") 00196 block_added = True 00197 out.append(l) 00198 open(global_rel_notes, "w").writelines(out)
| string update_versions::__author__ = "Marco Clemencic <Marco.Clemencic@cern.ch>" |
Definition at line 3 of file update_versions.py.
| string update_versions::__version__ = "$Id: update_versions.py,v 1.3 2008/11/10 19:43:31 marcocle Exp $" |
Definition at line 4 of file update_versions.py.
| tuple update_versions::_req_version_pattern = re.compile(r"^\s*version\s*(v[0-9]+r[0-9]+(?:p[0-9]+)?)\s*$") |
Definition at line 11 of file update_versions.py.
| tuple update_versions::_use_pattern = re.compile(r"^\s*use\s*(\w+)\s*(v[0-9]+r[0-9]+(?:p[0-9]+)?)\s*(\w+)?\s*$") |
Definition at line 52 of file update_versions.py.