[pkg-boost-commits] r14668 - boost/trunk/debian

Steven Michael Robbins smr at alioth.debian.org
Sat Nov 26 04:44:30 UTC 2011


Author: smr
Date: 2011-11-26 04:44:29 +0000 (Sat, 26 Nov 2011)
New Revision: 14668

Added:
   boost/trunk/debian/update-control.py
Log:
Script to update control file to new version.

Added: boost/trunk/debian/update-control.py
===================================================================
--- boost/trunk/debian/update-control.py	                        (rev 0)
+++ boost/trunk/debian/update-control.py	2011-11-26 04:44:29 UTC (rev 14668)
@@ -0,0 +1,82 @@
+#! /usr/bin/env python
+#
+
+from deb822 import Deb822
+import re
+
+gOldVersion = None
+gNewVersion = None
+
+
+class BoostVersion:
+    def __init__(self, version):
+        (self.Major,self.Minor,self.Revision) = version.split('.')
+        self.PackageVersion = self.Major + '.' + self.Minor
+        self.SharedObjectVersion = version
+    def containsPackageVersion(self, string):
+        '''Return true if 'string' contains the Package version string.'''
+        return re.search(self.PackageVersion, string) is not None
+    def containsSharedObjectVersion(self, string):
+        '''Return true if 'string' contains the Shared Object version string.'''
+        return re.search(self.SharedObjectVersion, string) is not None
+    def stripVersion(self, string):
+        '''Remove PackageVersion or SharedObjectVersion if contained in 'string'.'''
+        return self.replaceVersion(string,'')
+    def replaceVersion(self, string, replacement):
+        '''Replace either PackageVersion or SharedObjectVersion if contained in 'string',
+        with 'replacement'.'''
+        string = re.sub(self.SharedObjectVersion, replacement, string)
+        string = re.sub(self.PackageVersion, replacement, string)
+        return string
+
+def replaceVersion(string, ver1, ver2):
+    '''Search 'string' for a BoostVersion ver1.  If
+    SharedObjectVersion or PackageVersion of ver1 is found, replace by
+    corresponding ver2 version string.  Return the updated string.'''
+    string = re.sub(ver1.SharedObjectVersion, ver2.SharedObjectVersion, string)
+    string = re.sub(ver1.PackageVersion, ver2.PackageVersion, string)
+    return string
+
+def updateVersionedValue(paragraph, key):
+    if not paragraph.has_key(key): return
+    oldValue = paragraph[key]
+    paragraph[key] = replaceVersion(paragraph[key], gOldVersion, gNewVersion)
+    return (oldValue, paragraph[key])
+
+def conflictsWithPrevious(paragraph):
+    if not paragraph.has_key('Conflicts'): return False
+    nameRe = re.sub('\d', '\\d', paragraph['Package'])
+    return re.search(nameRe, paragraph['Conflicts']) is not None
+
+def processSourceParagraph(p):
+    updateVersionedValue(p, 'Source')
+
+def processPackageParagraph(p):
+    (oldPkgName, newPkgName) = updateVersionedValue(p, 'Package')
+    updateVersionedValue(p, 'Depends')
+    updateVersionedValue(p, 'Recommends')
+    updateVersionedValue(p, 'Suggests')
+    if conflictsWithPrevious(p):
+        p['Conflicts'] += ', ' + oldPkgName
+
+def printParagraph(p):
+    for key in p.keys():
+        print "%s: %s" % (key, p[key])
+
+def processControl():
+    firstParagraph = True
+    for paragraph in Deb822.iter_paragraphs(open('control')):
+        if firstParagraph:
+            processSourceParagraph(paragraph)
+            printParagraph(paragraph)
+            firstParagraph = False
+        else:
+            processPackageParagraph(paragraph)
+            print
+            printParagraph(paragraph)
+
+
+
+gOldVersion = BoostVersion('1.46.1')
+gNewVersion = BoostVersion('1.48.0')
+processControl()




More information about the pkg-boost-commits mailing list