aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--RepSys/log.py25
-rw-r--r--repsys.conf2
-rw-r--r--repsys.macros6
-rwxr-xr-xsetup.py2
5 files changed, 34 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index e1aa91b..f55bbfe 100644
--- a/Makefile
+++ b/Makefile
@@ -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.spec setup.cfg setup.py RepSys/*.py RepSys/{cgi,commands}/*.py
+ repsys repsys.conf repsys.macros repsys.spec setup.cfg setup.py RepSys/*.py RepSys/{cgi,commands}/*.py
# rules to build a test rpm
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
diff --git a/repsys.conf b/repsys.conf
index af71609..8eeea05 100644
--- a/repsys.conf
+++ b/repsys.conf
@@ -12,6 +12,8 @@ oldurl = svn+ssh://svn.mandriva.com/svn/packages/misc
revision-offset = 0
# commit lines containing this string won't be shown in the changelog:
ignore-string = SILENT
+# see repsys.macros:
+#macros-file = /etc/repsys.macros
[template]
path = /usr/share/repsys/default.chlog
diff --git a/repsys.macros b/repsys.macros
new file mode 100644
index 0000000..83caa21
--- /dev/null
+++ b/repsys.macros
@@ -0,0 +1,6 @@
+# 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
diff --git a/setup.py b/setup.py
index 272ec84..701f8d6 100755
--- a/setup.py
+++ b/setup.py
@@ -28,7 +28,7 @@ setup(name="repsys",
"compatv15.chlog",
"create-srpm",
"rebrand-mdk"]),
- ("/etc/", ["repsys.conf"])]
+ ("/etc/", ["repsys.conf", "repsys.macros"])]
)
# vim:ts=4:sw=4:et