diff options
author | Bogdano Arendartchuk <bogdano@mandriva.org> | 2007-01-29 18:14:56 +0000 |
---|---|---|
committer | Bogdano Arendartchuk <bogdano@mandriva.org> | 2007-01-29 18:14:56 +0000 |
commit | a493be252f25b57767023930d4ed927b37816e71 (patch) | |
tree | e25eb71eba2146cac6dd8dc4bbb4b7c043d65076 | |
parent | d4d9914ec004a9ad1b767bc177d45af6694080be (diff) | |
download | mgarepo-a493be252f25b57767023930d4ed927b37816e71.tar mgarepo-a493be252f25b57767023930d4ed927b37816e71.tar.gz mgarepo-a493be252f25b57767023930d4ed927b37816e71.tar.bz2 mgarepo-a493be252f25b57767023930d4ed927b37816e71.tar.xz mgarepo-a493be252f25b57767023930d4ed927b37816e71.zip |
Removed bogus macros files and added [macros ..] sections to repsys.conf.
These sections are referenced by the "rpm-macros" option in
[submit ..] sections and contain the RPM macros to be used with the
target of the package being generated. These macros are defined using
--define option of rpm.
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | RepSys/cgiutil.py | 24 | ||||
-rw-r--r-- | RepSys/log.py | 36 | ||||
-rw-r--r-- | RepSys/rpmutil.py | 13 | ||||
-rwxr-xr-x | create-srpm | 3 | ||||
-rw-r--r-- | repsys.conf | 18 | ||||
-rw-r--r-- | repsys.macros | 6 | ||||
-rwxr-xr-x | setup.py | 2 |
8 files changed, 58 insertions, 46 deletions
@@ -14,7 +14,7 @@ TAG := $(shell echo "V$(VERSION)_$(RELEASE)" | tr -- '-.' '__') FILES = ChangeLog Makefile MANIFEST.in PKG-INFO create-srpm getsrpm-mdk rebrand-mdk \ {compatv15,default,oldfashion,revno}.chlog \ - repsys repsys.conf repsys.macros repsys.spec setup.cfg setup.py RepSys/*.py RepSys/{cgi,commands}/*.py + repsys repsys.conf repsys.spec setup.cfg setup.py RepSys/*.py RepSys/{cgi,commands}/*.py # rules to build a test rpm diff --git a/RepSys/cgiutil.py b/RepSys/cgiutil.py index 6dda91e..35c5efb 100644 --- a/RepSys/cgiutil.py +++ b/RepSys/cgiutil.py @@ -1,6 +1,7 @@ #!/usr/bin/python from RepSys import Error, config from RepSys.svn import SVN +from RepSys.ConfigParser import NoSectionError import time import re @@ -10,11 +11,23 @@ class SubmitTarget: def __init__(self): self.name = "" self.target = "" + self.macros = [] self.allowed = [] self.scripts = [] TARGETS = [] +def parse_macrosref(refs, config): + macros = [] + for name in refs: + secname = "macros %s" % name + try: + macros.extend(config.walk(secname, raw=True)) + except NoSectionError: + raise Error, "missing macros section " \ + "%r in configuration" % secname + return macros + def get_targets(): global TARGETS if not TARGETS: @@ -27,12 +40,11 @@ def get_targets(): target = SubmitTarget() target.name = m.group(1) for option, value in config.walk(section): - if option == "target": - target.target = value.split() - elif option == "allowed": - target.allowed = value.split() - elif option == "scripts": - target.scripts = value.split() + if option in ("target", "allowed", "scripts"): + setattr(target, option, value.split()) + elif option == "rpm-macros": + refs = value.split() + target.macros = parse_macrosref(refs, config) else: raise Error, "unknown [%s] option %s" % (section, option) TARGETS.append(target) diff --git a/RepSys/log.py b/RepSys/log.py index 6d7bde0..3645fdd 100644 --- a/RepSys/log.py +++ b/RepSys/log.py @@ -42,13 +42,14 @@ default_template = """ #end for """ -def getrelease(pkgdirurl, rev=None): +def getrelease(pkgdirurl, rev=None, macros=[]): """Tries to obtain the version-release of the package for a yet-not-markrelease revision of the package. Is here where things should be changed if "automatic release increasing" will be used. """ + from RepSys.rpmutil import rpm_macros_defs svn = SVN(baseurl=pkgdirurl) tmpdir = tempfile.mktemp() try: @@ -60,9 +61,7 @@ def getrelease(pkgdirurl, rev=None): found = glob.glob(os.path.join(tmpdir, "*.spec")) if found: specpath = found[0] - fmt = "--define \"%s %s\"" - macros = (fmt % macro for macro in parse_macros()) - options = " ".join(macros) + options = rpm_macros_defs(macros) command = (("rpm -q --qf '%%{VERSION}-%%{RELEASE}\n' " "--specfile %s %s 2>/dev/null") % (specpath, options)) @@ -80,26 +79,6 @@ def getrelease(pkgdirurl, rev=None): if os.path.isdir(tmpdir): shutil.rmtree(tmpdir) - -def parse_macros(): - path = config.get("log", "macros-file", None) - if not path: - # if the user did not declated where is the file, ignore it - return - if not os.path.isfile(path): - # complain when declared and not found - sys.stderr.write("warning: could not open macros file: %s\n" % - path) - return - for line in open(path): - line = line.strip() - if line.startswith("#") or not line: - continue - name, value = line.split(None, 1) - # trying to have the same format from rpm macros files - name = name[1:] - yield (name, value) - class _Revision: lines = [] date = None @@ -331,7 +310,8 @@ def parse_markrelease_log(relentry): return version, release, from_rev -def svn2rpm(pkgdirurl, rev=None, size=None, submit=False, template=None): +def svn2rpm(pkgdirurl, rev=None, size=None, submit=False, + template=None, macros=[]): concat = config.get("log", "concat", "").split() revoffset = get_revision_offset() svn = SVN(baseurl=pkgdirurl) @@ -394,7 +374,7 @@ def svn2rpm(pkgdirurl, rev=None, size=None, submit=False, template=None): if notsubmitted: # if they are not submitted yet, what we have to do is to add # a release/version number from getrelease() - version, release = getrelease(pkgdirurl) + version, release = getrelease(pkgdirurl, macros=macros) toprelease = make_release(entries=notsubmitted, released=False, version=version, release=release) releases.append(toprelease) @@ -405,7 +385,7 @@ def svn2rpm(pkgdirurl, rev=None, size=None, submit=False, template=None): def specfile_svn2rpm(pkgdirurl, specfile, rev=None, size=None, - submit=False, template=None): + submit=False, template=None, macros=[]): newlines = [] found = 0 @@ -422,7 +402,7 @@ def specfile_svn2rpm(pkgdirurl, specfile, rev=None, size=None, # Create new changelog newlines.append("\n\n%changelog\n") newlines.append(svn2rpm(pkgdirurl, rev=rev, size=size, submit=submit, - template=template)) + template=template, macros=macros)) # Merge old changelog, if available oldurl = config.get("log", "oldurl") diff --git a/RepSys/rpmutil.py b/RepSys/rpmutil.py index 968470c..367fd45 100644 --- a/RepSys/rpmutil.py +++ b/RepSys/rpmutil.py @@ -25,6 +25,11 @@ def get_spec(pkgdirurl, targetdir=".", submit=False): if os.path.isdir(tmpdir): shutil.rmtree(tmpdir) +def rpm_macros_defs(macros): + defs = ("--define \"%s %s\"" % macro for macro in macros) + args = " ".join(defs) + return args + def get_srpm(pkgdirurl, mode = "current", targetdirs = None, @@ -37,6 +42,7 @@ def get_srpm(pkgdirurl, scripts = [], submit = False, template = None, + macros = [], verbose = 0): svn = SVN(baseurl=pkgdirurl) tmpdir = tempfile.mktemp() @@ -68,7 +74,7 @@ def get_srpm(pkgdirurl, if svnlog: submit = not not revision specfile_svn2rpm(pkgdirurl, spec, revision, submit=submit, - template=template) + template=template, macros=macros) revisionreal = svn.revision(pkgdirurl) for script in scripts: status, output = execcmd(script, tmpdir, spec, str(revision), @@ -78,9 +84,10 @@ def get_srpm(pkgdirurl, if packager: packager = " --define 'packager %s'" % packager - execcmd("rpm -bs --nodeps %s %s %s %s %s %s %s %s %s" % + defs = rpm_macros_defs(macros) + execcmd("rpm -bs --nodeps %s %s %s %s %s %s %s %s %s %s" % (topdir, builddir, rpmdir, sourcedir, specdir, - srcrpmdir, patchdir, packager, spec)) + srcrpmdir, patchdir, packager, spec, defs)) if revision and revisionreal: srpm = glob.glob(os.path.join(srpmsdir, "*.src.rpm"))[0] diff --git a/create-srpm b/create-srpm index fc235bf..5223d45 100755 --- a/create-srpm +++ b/create-srpm @@ -52,7 +52,8 @@ class CmdIface: packager=packager, revname=1, svnlog=1, - scripts=target.scripts) + scripts=target.scripts, + macros=target.macros) uploadsrpm = get_helper("upload-srpm") if uploadsrpm: diff --git a/repsys.conf b/repsys.conf index 8eeea05..dce1fe3 100644 --- a/repsys.conf +++ b/repsys.conf @@ -40,3 +40,21 @@ default = Cooker target = /export/home/repsys allowed = svn+ssh://svn.mandriva.com/svn/packages/cooker scripts = /usr/share/repsys/rebrand-mdk +## +## rpm-macros refers to the sections containing the macros used for this +## target. The values will be used to build the rpmbuild command line. For +## example: +## +## [macros cooker] +## a = b +## c = %a +## +## will render in the command line: --define "a b" --define "c %a". +## +#rpm-macros = global cooker + +#[macros global] +#distsuffix = mdv + +#[macros cooker] +#mandriva_release = 2007.1 diff --git a/repsys.macros b/repsys.macros deleted file mode 100644 index 83caa21..0000000 --- a/repsys.macros +++ /dev/null @@ -1,6 +0,0 @@ -# Use this file to override the macros from the machine where repsys is -# being run. It is used when retrieving version-release to be used in the -# changelog of a package not released yet. - -#%mandriva_release 2007.1 -#%distsuffix mdv @@ -28,7 +28,7 @@ setup(name="repsys", "compatv15.chlog", "create-srpm", "rebrand-mdk"]), - ("/etc/", ["repsys.conf", "repsys.macros"])] + ("/etc/", ["repsys.conf"])] ) # vim:ts=4:sw=4:et |