From 25545a7a3702c0b624b802b795d631534977979b Mon Sep 17 00:00:00 2001 From: Bogdano Arendartchuk Date: Wed, 24 Jan 2007 15:26:48 +0000 Subject: Added "repsys.macros" configuration file. It will contain macros overriding the local system ones. The reason for it is to make changelogs generated in kenobi (2007.0) having the cooker release number (in the case 2007.1). --- RepSys/log.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'RepSys/log.py') diff --git a/RepSys/log.py b/RepSys/log.py index 2651d19..6d7bde0 100644 --- a/RepSys/log.py +++ b/RepSys/log.py @@ -60,8 +60,12 @@ 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) command = (("rpm -q --qf '%%{VERSION}-%%{RELEASE}\n' " - "--specfile %s 2>/dev/null") % specpath) + "--specfile %s %s 2>/dev/null") % + (specpath, options)) status, output = execcmd(command) if status != 0: raise Error, "Error in command %s: %s" % (command, output) @@ -77,6 +81,25 @@ def getrelease(pkgdirurl, rev=None): 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 -- cgit v1.2.1