[csw-devel] SF.net SVN: gar:[11375] csw/mgar/gar/v2/lib/python

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Fri Oct 22 10:00:58 CEST 2010


Revision: 11375
          http://gar.svn.sourceforge.net/gar/?rev=11375&view=rev
Author:   wahwah
Date:     2010-10-22 08:00:58 +0000 (Fri, 22 Oct 2010)

Log Message:
-----------
mGAR v2: patchpkg, first version that actually does anything, but still has no user interface.

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/opencsw.py
    csw/mgar/gar/v2/lib/python/package.py

Modified: csw/mgar/gar/v2/lib/python/opencsw.py
===================================================================
--- csw/mgar/gar/v2/lib/python/opencsw.py	2010-10-22 08:00:39 UTC (rev 11374)
+++ csw/mgar/gar/v2/lib/python/opencsw.py	2010-10-22 08:00:58 UTC (rev 11375)
@@ -116,6 +116,16 @@
   return data
 
 
+def ComposeVersionString(version, revision_info):
+  if revision_info:
+    version += ","
+    rev_lst = []
+    for key in sorted(revision_info.keys()):
+      rev_lst.append("%s=%s" % (key, revision_info[key]))
+    version += "_".join(rev_lst)
+  return version
+
+
 def ComposePackageFileName(parsed_filename):
   """Composes package name, based on a parsed filename data structure.
 
@@ -125,12 +135,7 @@
   tmpl = "%(catalogname)s-%(new_version)s-%(osrel)s-%(arch)s-%(vendortag)s.pkg"
   version_string = parsed_filename["version"]
   revision_info = parsed_filename["revision_info"]
-  if revision_info:
-    version_string += ","
-    rev_lst = []
-    for key in sorted(revision_info.keys()):
-      rev_lst.append("%s=%s" % (key, revision_info[key]))
-    version_string += "_".join(rev_lst)
+  version_string = ComposeVersionString(version_string, revision_info)
   new_data = copy.copy(parsed_filename)
   new_data["new_version"] = version_string
   return tmpl % new_data

Modified: csw/mgar/gar/v2/lib/python/package.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package.py	2010-10-22 08:00:39 UTC (rev 11374)
+++ csw/mgar/gar/v2/lib/python/package.py	2010-10-22 08:00:58 UTC (rev 11375)
@@ -100,7 +100,7 @@
       pkg_suffix = ".pkg"
       if self.pkg_path.endswith("%s%s" % (pkg_suffix, gzip_suffix)):
         # Causing the class to stat the .gz file.  This call throws away the
-        # result, but the result will be cached as a class instance member.
+        # result, but the result will be cached as a object member.
         self.GetMtime()
         base_name_gz = os.path.split(self.pkg_path)[1]
         shutil.copy(self.pkg_path, self.GetWorkDir())
@@ -264,8 +264,11 @@
     """Guesses the Srv4FileName based on the package directory contents."""
     return opencsw.PkginfoToSrv4Name(self.GetParsedPkginfo())
 
-  def ToSrv4(self, target_dir):
-    target_file_name = self.GetSrv4FileName()
+  def ToSrv4(self, target_dir, file_name=None):
+    if not file_name:
+      target_file_name = self.GetSrv4FileName()
+    else:
+      target_file_name = file_name
     target_path = os.path.join(target_dir, target_file_name)
     if os.path.exists(target_path):
       return target_path
@@ -637,11 +640,18 @@
   def ToSrv4(self, dest_dir):
     self.Transform()
     pkginfo = self.dir_pkg.GetParsedPkginfo()
-    date_str = datetime.datetime.now().strftime("%Y-%m-%d")
+    date_str = datetime.datetime.now().strftime("%Y.%m.%d")
     self.parsed_filename["revision_info"]["REV"] = date_str
     new_filename = opencsw.ComposePackageFileName(self.parsed_filename)
     # Plan:
     # - Update the version in the pkginfo
+    version_string = opencsw.ComposeVersionString(
+        self.parsed_filename["version"],
+        self.parsed_filename["revision_info"])
+    logging.debug("New version string: %s", repr(version_string))
+    self.dir_pkg.SetPkginfoEntry("VERSION", version_string)
     # - Update the pkgmap file, setting the checksums
     # - Transform it back to the srv4 form
-    # - gzip it.
+    target_dir, old_path = os.path.split(self.pkg_path)
+    logging.debug("Transforming into %s", new_filename)
+    self.dir_pkg.ToSrv4(target_dir, new_filename)


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