def _applyTemplate(self, update, packager, distRelease): content = packager.dist.getSpecfileContent(update.packageName, distRelease.tag) p = re.compile('%changelog') part = p.split(content) specContent = part[0].strip() specChangelogEntries = part[1].strip() # FIXME: It could be better to have a "reference" bundle (the one that give the package version) major, minor, micro, qualifier = utils.parseBundleVersion(update.bundles[0].version) try: m = re.search("Epoch:(\ | \t).*([0-9].*)", specContent, re.IGNORECASE) epoch = m.group(2).strip() if epoch != "": epoch += ":" except: epoch = "" m = re.search("Version:(\ |\t)+", specContent, re.IGNORECASE) g = m.group(0) specContent = re.sub("Version:.*", g + update.bundles[0].version, specContent, re.IGNORECASE) m = re.search("Release:(\ |\t)+", specContent, re.IGNORECASE) g = m.group(0) specContent = re.sub("Release:(\ |\b|)+([0-9]|\.|_|[a-z])+", g + "1", specContent, re.IGNORECASE) specContent = self._setDefineValue(specContent, "major", major) specContent = self._setDefineValue(specContent, "minor", minor) specContent = self._setDefineValue(specContent, "micro", micro) specContent = self._setDefineValue(specContent, "qualifier", qualifier) # used in eclipse-pydev.spec specContent = self._setDefineValue(specContent, "maint", micro) # used in eclipse.spec specContent = self._setDefineValue(specContent, "eclipse_major", major) specContent = self._setDefineValue(specContent, "eclipse_minor", minor) specContent = self._setDefineValue(specContent, "eclipse_micro", micro) template = "${SPEC_CONTENT}\n\n" \ + "%changelog\n" \ + "* ${DATE} ${PACKAGER} <${PACKAGER_MAIL}> ${EPOCH}${VERSION}-1\n" \ + "- bump to ${VERSION}\n\n" \ + "${CHANGELOG_ENTRIES}" result = string.Template(template).safe_substitute( SPEC_CONTENT=specContent, DATE=strftime("%a %b %d %Y", gmtime()), VERSION=major + "." + minor + "." + micro, EPOCH=epoch, PACKAGER=packager.name, PACKAGER_MAIL=packager.mail, CHANGELOG_ENTRIES=specChangelogEntries) return result
def _prepare(self, update, packager, distRelease): # create tmp directory currentDir = commands.getoutput("pwd"); tmpDir = tempfile.mkdtemp("%s-%s_srpm" % (config.APP_NAME, update.packageName)) os.chdir(tmpDir) cvsDir = "%s/%s" % (update.packageName, distRelease.tag) # get sources status = os.system("CVSROOT=:pserver:[email protected]:/cvs/pkgs cvs co %s" % cvsDir) if status != 0: raise # os.chdir(cvsDir) status = os.system("make -C %s" % cvsDir) if status != 0: raise major, minor, micro, qualifier = utils.parseBundleVersion(update.bundles[0].version) specWriter = WriteSpecfile() specWriter.run(update, packager, distRelease) specContent = utils.readFile(specWriter.outputFile) try: m = re.search("source[0|:].*[\ |\t]+(.*)", specContent, re.IGNORECASE) src_url = m.group(1) src_url = src_url.replace("%{major}", major) src_url = src_url.replace("%{minor}", minor) src_url = src_url.replace("%{micro}", micro) # fix eclipse-pydev define?? src_url = src_url.replace("%{maint}", micro) status = os.system("wget %s" % src_url) if status != 0: raise status = os.system("make -C %s srpm" % cvsDir) if status != 0: raise except: # try to grab sources using fetch-* scripts?? raise os.chdir(currentDir)