This patch adds an '--old-release' option which allows in combination
with '--release' to replace already set disttags.

This patch requires the 'warning' patch.

2003-12-03  Enrico Scholz  <enrico.scholz@informatik.tu-chemnitz.de>
	* rediffed

2003-11-13  Enrico Scholz  <enrico.scholz@informatik.tu-chemnitz.de>

	* created initially

--- mach.cvs/scripts/mach.in~disttag	2003-12-03 01:34:45.000000000 +0100
+++ mach.cvs/scripts/mach.in	2003-12-03 01:37:54.000000000 +0100
@@ -31,6 +31,7 @@
   -c, --collect			collect packages and relevant files to .
   -q, --quiet			no spinners, minimal output
   --traditional                 use tradional, non-strict behavior
+  --old-release=(tag)		remove the old release tag
   --release=(tag)		add given tag to release tag
   --canonify			just output the canonical root name and exit
 
@@ -64,6 +65,7 @@
   'sign': 0,
   'collect': 0,
   'release': 0,
+  'old-release': 0,
   'quiet': 0,
   'defaultroot': 'redhat-9-i386', # FIXME: based on configure's distro check
 
@@ -827,6 +829,14 @@
             version = h[rpm.RPMTAG_VERSION]
             release = h[rpm.RPMTAG_RELEASE]
             # if the release tag needs mangling, do it here as well
+            if self.config['old-release']:
+                if release.endswith(".%s" % self.config['old-release']):
+                    pos = len(release)-len(self.config['old-release'])-1
+                    release=release[:pos]
+                else:
+                    warning("old release tag '%s' could not be detected in release '%s'" %
+                            (self.config['old-release'], release))
+
             if self.config['release']:
                 fullname = '%s-%s-%s.%s' % (name, version, release,
                                             self.config['release'])
@@ -852,7 +862,9 @@
                 release = spec.tag ("release")
                 debug ("Release of spec file to mangle is %s" % release)
                 if not release.endswith ('.' + self.config['release']):
-                    command = 'sed -e "s,^\\\\(Release\\\\s*:.*[^\\\\s]\\\\)\\\\s*$,\\\\1.%s,i" /tmp/%s > /usr/src/rpm/SPECS/%s' % (self.config['release'], specfile, specfile)
+                    suffix=""
+                    if self.config['old-release']: suffix = "\\\\." + self.config['old-release']
+                    command = 'sed -e "s,^\\\\(Release\\\\s*:.*[^\\\\s]\\\\)%s\\\\s*$,\\\\1.%s,i" /tmp/%s > /usr/src/rpm/SPECS/%s' % (suffix, self.config['release'], specfile, specfile)
                     debug ("mangling with %s" % command)
                     self.do_chroot (command)
                 else:
@@ -1563,7 +1575,7 @@
     try:
         opts, args = getopt.getopt (args, 'r:hdfkscq',
                                     ['root=', 'help', 'debug', 'force', 'keep',
-                                     'sign', 'collect', 'quiet', 'release=',
+                                     'sign', 'collect', 'quiet', 'release=', 'old-release=',
                                      'canonify', 'traditional'])
     except getopt.error, exc:
         sys.stderr.write ('error: %s\n' % str (exc))
@@ -1601,6 +1613,8 @@
             canonify = 1
         elif opt == '--traditional':
             warning = warningWarn
+        elif opt == '--old-release':
+            config['old-release'] = arg
 
     # resolve root aliases to real root names
     for name in aliases.keys ():

