[Uludag-commits] r11912 - trunk/repository-scripts

svn-uludag at uludag.org.tr svn-uludag at uludag.org.tr
8 Oca 2007 Pzt 21:35:57 EET


Author: fduman
Date: Mon Jan  8 21:35:57 2007
New Revision: 11912

Modified:
   trunk/repository-scripts/bump_version.py
Log:
pisi.specfile kullanılsın

Modified: trunk/repository-scripts/bump_version.py
=================================================================
--- trunk/repository-scripts/bump_version.py	(original)
+++ trunk/repository-scripts/bump_version.py	Mon Jan  8 21:35:57 2007
@@ -5,81 +5,76 @@
 import sys
 import time
 
-import piksemel
-
+import pisi.specfile
 
 SUCCESS, FAIL = xrange(2)
 
-NAME = unicode(os.environ.get('NAME', ''))
-EMAIL = os.environ.get('EMAIL', '')
-
+NAME = unicode(os.environ.get("NAME", ""))
+EMAIL = os.environ.get("EMAIL", "")
 
 def buildPspecXML(doc):
     header = '''<?xml version="1.0" ?>
-<!DOCTYPE PISI SYSTEM 'http://www.pardus.org.tr/projeler/pisi/pisi-spec.dtd'>'''
-    return '%s\n\n%s\n' % (header, doc.toPrettyString())
-
+<!DOCTYPE PISI SYSTEM "http://www.pardus.org.tr/projeler/pisi/pisi-spec.dtd">'''
+    return "%s\n\n%s\n" % (header, doc.toPrettyString())
 
 def main():
     if len(sys.argv) != 4:
-        print 'Usage: %s specfile version url' % sys.argv[0]
+        print "Usage: %s specfile version url" % sys.argv[0]
         return FAIL
 
     specfile = sys.argv[1]
     try:
-        doc = piksemel.parse(specfile)
+        spec = pisi.specfile.SpecFile(specfile)
     except:
-        print 'Can\'t parse: %s' % specfile
+        print "Can't parse: %s" % specfile
         return FAIL
 
-    source = doc.getTag('Source')
-    history = doc.getTag('History')
-    package = source.getTagData('Name')
-    release = int(history.getTag('Update').getAttribute('release')) + 1
+    source = spec.source
+    release = int(spec.getSourceRelease()) + 1
 
     version = sys.argv[2] # TODO: validate version
     url = sys.argv[3]
 
-    if version == history.getTag('Update').getTagData('Version'):
-        print 'Already at version %s' % version
+    if version == spec.getSourceVersion():
+        print "Already at version %s" % version
+        return FAIL
+
+    type = ""
+    if url.endswith("bz2"):
+        type = "tarbz2"
+    elif url.endswith("gz"):
+        type = "targz"
+    elif url.endswith("zip"):
+        type = "zip"
+
+    if not type:
+        print "%s file type cannot be determined" % url
         return FAIL
 
-    type = ''
-    if url.endswith('bz2'):
-        type = 'tarbz2'
-    elif url.endswith('gz'):
-        type = 'targz'
-    elif url.endswith('zip'):
-        type = 'zip'
-
-    old_archive = source.getTag('Archive')
-
-    archive = old_archive.appendTag('Archive')
-    archive.insertData(url)
-    archive.setAttribute('sha1sum', '???')
-    archive.setAttribute('type', type)
-
-    old_archive.hide()
-
-    update = history.getTag('Update').prependTag('Update')
-    update.setAttribute('release', str(release))
-    update.insertTag('Date').insertData(time.strftime('%Y-%m-%d'))
-    update.insertTag('Version').insertData(version)
-    update.insertTag('Comment').insertData('Version bump')
-    update.insertTag('Name').insertData(NAME)
-    update.insertTag('Email').insertData(EMAIL)
+    source.archive.uri = url
+    source.archive.sha1sum = "???"
+    source.archive.type = type
+
+    update = pisi.specfile.Update()
+    update.release = str(release)
+    update.date = time.strftime("%Y-%m-%d")
+    update.version = version
+    update.comment = "Version bump"
+    update.name = NAME
+    update.email = EMAIL
+    spec.history.insert(0, update)
 
-    spec = buildPspecXML(doc)
-    del doc
+    spec.write("/dev/null", True)
+    specxml = buildPspecXML(spec.doc)
 
-    f = open(sys.argv[1], 'w')
-    f.write(spec)
+    f = open(sys.argv[1], "w")
+    f.write(specxml)
     f.close()
 
-    print '%s updated.' % specfile
+    print "%s updated." % specfile
 
     return SUCCESS
 
 
-if __name__ == '__main__':
+if __name__ == "__main__":
     sys.exit(main())


Uludag-commits mesaj listesiyle ilgili daha fazla bilgi