[csw-devel] SF.net SVN: gar:[11370] csw/mgar/gar/v2/lib/python
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Fri Oct 22 09:59:19 CEST 2010
Revision: 11370
http://gar.svn.sourceforge.net/gar/?rev=11370&view=rev
Author: wahwah
Date: 2010-10-22 07:59:19 +0000 (Fri, 22 Oct 2010)
Log Message:
-----------
mGAR v2: patchpkg, new function to compose package names.
Modified Paths:
--------------
csw/mgar/gar/v2/lib/python/opencsw.py
csw/mgar/gar/v2/lib/python/opencsw_test.py
csw/mgar/gar/v2/lib/python/patch_package.py
Modified: csw/mgar/gar/v2/lib/python/opencsw.py
===================================================================
--- csw/mgar/gar/v2/lib/python/opencsw.py 2010-10-22 07:58:57 UTC (rev 11369)
+++ csw/mgar/gar/v2/lib/python/opencsw.py 2010-10-22 07:59:19 UTC (rev 11370)
@@ -116,6 +116,18 @@
return data
+def ComposePackageFileName(parsed_filename):
+ file_name = 'mysql5client-5.0.87,REV=2010.02.28-SunOS5.8-i386-CSW.pkg.gz'
+ tmpl = "%(catalogname)s-%(new_version)s-%(osrel)s-%(arch)s-%(vendortag)s.pkg.gz"
+ version_string = parsed_filename["version"]
+ revision_info = parsed_filename["revision_info"]
+ for key in sorted(revision_info.keys()):
+ version_string += ",%s=%s" % (key, revision_info[key])
+ new_data = copy.copy(parsed_filename)
+ new_data["new_version"] = version_string
+ return tmpl % new_data
+
+
def ParseVersionString(s):
version_bits = re.split("_|,", s)
version_str = version_bits[0]
Modified: csw/mgar/gar/v2/lib/python/opencsw_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/opencsw_test.py 2010-10-22 07:58:57 UTC (rev 11369)
+++ csw/mgar/gar/v2/lib/python/opencsw_test.py 2010-10-22 07:59:19 UTC (rev 11370)
@@ -157,6 +157,14 @@
self.assertEqual("unspecified", parsed["osrel"])
+class ComposePackageFileNameUnitTest(unittest.TestCase):
+
+ def testSimple(self):
+ file_name = 'mysql5client-5.0.87,REV=2010.02.28-SunOS5.8-i386-CSW.pkg.gz'
+ parsed = opencsw.ParsePackageFileName(file_name)
+ self.assertEquals(file_name, opencsw.ComposePackageFileName(parsed))
+
+
class ParseVersionStringTest(unittest.TestCase):
def test_NoRev(self):
Modified: csw/mgar/gar/v2/lib/python/patch_package.py
===================================================================
--- csw/mgar/gar/v2/lib/python/patch_package.py 2010-10-22 07:58:57 UTC (rev 11369)
+++ csw/mgar/gar/v2/lib/python/patch_package.py 2010-10-22 07:59:19 UTC (rev 11370)
@@ -5,6 +5,7 @@
# Usage:
# patchpkg --dir /tmp/foo --patch foo.patch --catalogname foo
+import datetime
import optparse
import logging
import package
@@ -56,8 +57,11 @@
self.Transform()
pkginfo = self.dir_pkg.GetParsedPkginfo()
# version = pkginfo["VERSION"]
- pprint.pprint(pkginfo)
+ date_str = datetime.datetime.now().strftime("%Y-%m-%d")
+ self.parsed_filename["revision_info"]["REV"] = date_str
+ new_filename = opencsw.ComposePackageFileName(self.parsed_filename)
pprint.pprint(self.parsed_filename)
+ pprint.pprint(new_filename)
def main():
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the devel
mailing list