[csw-devel] SF.net SVN: gar:[11374] csw/mgar/gar/v2/lib/python
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Fri Oct 22 10:00:39 CEST 2010
Revision: 11374
http://gar.svn.sourceforge.net/gar/?rev=11374&view=rev
Author: wahwah
Date: 2010-10-22 08:00:39 +0000 (Fri, 22 Oct 2010)
Log Message:
-----------
mGAR v2: patchpkg, the surgeon class moved to package.py
Modified Paths:
--------------
csw/mgar/gar/v2/lib/python/package.py
csw/mgar/gar/v2/lib/python/patch_package.py
Modified: csw/mgar/gar/v2/lib/python/package.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package.py 2010-10-22 08:00:18 UTC (rev 11373)
+++ csw/mgar/gar/v2/lib/python/package.py 2010-10-22 08:00:39 UTC (rev 11374)
@@ -590,3 +590,58 @@
less_proc.wait()
else:
print "No differences found."
+
+
+class PackageSurgeon(ShellMixin):
+ """Takes an OpenCSW gzipped package and performs surgery on it.
+
+ Sows it up, adjusts checksums, and puts it back together.
+ """
+
+ def __init__(self, pkg_path, debug):
+ self.debug = debug
+ self.pkg_path = pkg_path
+ self.srv4 = 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()
+ 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
+ # - Update the pkgmap file, setting the checksums
+ # - Transform it back to the srv4 form
+ # - gzip it.
Modified: csw/mgar/gar/v2/lib/python/patch_package.py
===================================================================
--- csw/mgar/gar/v2/lib/python/patch_package.py 2010-10-22 08:00:18 UTC (rev 11373)
+++ csw/mgar/gar/v2/lib/python/patch_package.py 2010-10-22 08:00:39 UTC (rev 11374)
@@ -15,55 +15,6 @@
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)
-
-
def main():
parser = optparse.OptionParser()
parser.add_option("--dir", "-d", dest="dir",
@@ -85,7 +36,8 @@
logging_level = logging.DEBUG if options.debug else logging.INFO
logging.basicConfig(level=logging_level)
logging.debug("Start!")
- ps = PackageSurgeon("/home/maciej/tmp/mozilla-1.7.5-SunOS5.8-sparc-CSW.pkg.gz",
+ ps = package.PackageSurgeon(
+ "/home/maciej/tmp/mozilla-1.7.5-SunOS5.8-sparc-CSW.pkg.gz",
debug=options.debug)
# ps.Export("/home/maciej/tmp")
ps.Patch("/home/maciej/tmp/0001-Removing-nspr.m4-and-headers.patch")
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