[csw-devel] SF.net SVN: gar:[8300] csw/mgar/gar/v2
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Tue Feb 2 12:08:00 CET 2010
Revision: 8300
http://gar.svn.sourceforge.net/gar/?rev=8300&view=rev
Author: wahwah
Date: 2010-02-02 11:08:00 +0000 (Tue, 02 Feb 2010)
Log Message:
-----------
mGAR v2: checkpkg, the presence of the license file
Modified Paths:
--------------
csw/mgar/gar/v2/bin/checkpkg.d/README
csw/mgar/gar/v2/lib/python/opencsw.py
Added Paths:
-----------
csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-license.py
Modified: csw/mgar/gar/v2/bin/checkpkg.d/README
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg.d/README 2010-02-02 10:25:49 UTC (rev 8299)
+++ csw/mgar/gar/v2/bin/checkpkg.d/README 2010-02-02 11:08:00 UTC (rev 8300)
@@ -6,6 +6,6 @@
To see the required flags, issue:
-./checkpkg-dummy.py -h
+./checkpkg-you-can-write-your-own.py -h
Each test's file name must begin with "checkpkg-".
Added: csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-license.py
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-license.py (rev 0)
+++ csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-license.py 2010-02-02 11:08:00 UTC (rev 8300)
@@ -0,0 +1,51 @@
+#!/opt/csw/bin/python2.6
+# $Id$
+
+"""Checks for the existence of the license file."""
+
+import logging
+import os.path
+import sys
+
+CHECKPKG_MODULE_NAME = "license presence"
+
+# The following bit of code sets the correct path to Python libraries
+# distributed with GAR.
+path_list = [os.path.dirname(__file__),
+ "..", "..", "lib", "python"]
+sys.path.append(os.path.join(*path_list))
+import checkpkg
+import opencsw
+
+LICENSE_TMPL = "/opt/csw/share/doc/%s/license"
+
+def CheckLicenseFile(pkg):
+ """Checks for the presence of the license file."""
+ errors = []
+ pkgmap = pkg.GetPkgmap()
+ catalogname = pkg.GetCatalogname()
+ license_path = LICENSE_TMPL % catalogname
+ if license_path not in pkgmap.entries_by_path:
+ errors.append(
+ opencsw.PackageError(
+ "%s file not present in the %s package"
+ % (repr(license_path), pkg.pkgname)))
+ return errors
+
+
+def main():
+ options, args = checkpkg.GetOptions()
+ pkgnames = args
+ check_manager = checkpkg.CheckpkgManager(CHECKPKG_MODULE_NAME,
+ options.extractdir,
+ pkgnames,
+ options.debug)
+ # Registering functions defined above.
+ check_manager.RegisterIndividualCheck(CheckLicenseFile)
+ exit_code, report = check_manager.Run()
+ print report.strip()
+ sys.exit(exit_code)
+
+
+if __name__ == '__main__':
+ main()
Property changes on: csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-license.py
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:keywords
+ Id
Modified: csw/mgar/gar/v2/lib/python/opencsw.py
===================================================================
--- csw/mgar/gar/v2/lib/python/opencsw.py 2010-02-02 10:25:49 UTC (rev 8299)
+++ csw/mgar/gar/v2/lib/python/opencsw.py 2010-02-02 11:08:00 UTC (rev 8300)
@@ -538,6 +538,15 @@
self.pkgname = os.path.split(directory)[1]
self.pkginfo_dict = None
+ def GetCatalogname(self):
+ """Returns the catalog name of the package.
+
+ A bit hacky. Looks for the first word of the NAME field in the package.
+ """
+ pkginfo = self.GetParsedPkginfo()
+ words = re.split(WS_RE, pkginfo["NAME"])
+ return words[0]
+
def GetParsedPkginfo(self):
if not self.pkginfo_dict:
pkginfo_fd = open(self.GetPkginfoFilename(), "r")
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