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

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Tue Oct 26 11:33:13 CEST 2010


Revision: 11413
          http://gar.svn.sourceforge.net/gar/?rev=11413&view=rev
Author:   wahwah
Date:     2010-10-26 09:33:13 +0000 (Tue, 26 Oct 2010)

Log Message:
-----------
mGAR v2: patchpkg, new function to compose package names.

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

Modified: csw/mgar/gar/v2/lib/python/patch_package.py
===================================================================
--- csw/mgar/gar/v2/lib/python/patch_package.py	2010-10-26 09:32:48 UTC (rev 11412)
+++ csw/mgar/gar/v2/lib/python/patch_package.py	2010-10-26 09:33:13 UTC (rev 11413)
@@ -20,6 +20,56 @@
 import pprint
 import opencsw
 
+class PackageSurgeon(package.ShellMixin):
+
+  def __init__(self, pkg_path, debug):
+    self.debug = debug
+    self.pkg_path = pkg_path
+    self.srv4 = package.CswSrv4File(pkg_path)
+    self.dir_pkg = None
+    self.exported_dir = None
+    self.parsed_filename = opencsw.ParsePackageFileName(self.pkg_path)
+
+  def Transform(self):
+    if not self.dir_pkg:
+      self.dir_pkg = self.srv4.GetDirFormatPkg()
+      logging.debug(repr(self.dir_pkg))
+      # subprocess.call(["tree", self.dir_pkg.directory])
+
+  def Export(self, dest_dir):
+    self.Transform()
+    if not self.exported_dir:
+      basedir, pkgname = os.path.split(self.dir_pkg.directory)
+      self.exported_dir = os.path.join(dest_dir, pkgname)
+      shutil.copytree(
+          self.dir_pkg.directory,
+          self.exported_dir)
+      subprocess.call(["git", "init"], cwd=self.exported_dir)
+      subprocess.call(["git", "add", "."], cwd=self.exported_dir)
+      subprocess.call(["git", "commit", "-a", "-m", "Initial commit"],
+                      cwd=self.exported_dir)
+    else:
+      logging.warn("The package was already exported to %s",
+                   self.exported_dir)
+
+  def Patch(self, patch_file):
+    self.Transform()
+    args = ["gpatch", "-p", "1", "-d", self.dir_pkg.directory, "-i", patch_file]
+    logging.debug(args)
+    subprocess.call(args)
+
+  def ToSrv4(self, dest_dir):
+    self.Transform()
+    pkginfo = self.dir_pkg.GetParsedPkginfo()
+    # version = pkginfo["VERSION"]
+    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)
+
+
+>>>>>>> mGAR v2: patchpkg, new function to compose package names.
 def main():
   parser = optparse.OptionParser()
   parser.add_option("--srv4-file", "-s", dest="srv4_file",


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