[csw-devel] SF.net SVN: gar:[8654] csw/mgar/gar/v2

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Thu Feb 18 16:18:20 CET 2010


Revision: 8654
          http://gar.svn.sourceforge.net/gar/?rev=8654&view=rev
Author:   wahwah
Date:     2010-02-18 15:18:19 +0000 (Thu, 18 Feb 2010)

Log Message:
-----------
mGAR v2: A bugfix for the archall check and a unit test for it.

Modified Paths:
--------------
    csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-archall.py
    csw/mgar/gar/v2/lib/python/package_checks.py
    csw/mgar/gar/v2/lib/python/package_checks_test.py

Added Paths:
-----------
    csw/mgar/gar/v2/lib/python/testdata/example-1-pkginfo.yml
    csw/mgar/gar/v2/lib/python/testdata/example-1-pkgmap.yml

Property Changed:
----------------
    csw/mgar/gar/v2/lib/python/package_checks_test.py

Modified: csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-archall.py
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-archall.py	2010-02-18 14:59:35 UTC (rev 8653)
+++ csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-archall.py	2010-02-18 15:18:19 UTC (rev 8654)
@@ -16,44 +16,8 @@
              "..", "..", "lib", "python"]
 sys.path.append(os.path.join(*path_list))
 import checkpkg
+import package_checks
 
-ARCH_RE = re.compile(r"(sparcv(8|9)|i386|amd64)")
-
-def CheckArchitectureVsContents(pkg_data, debug):
-  """Verifies the relationship between package contents and architecture."""
-  errors = []
-  binaries = pkg_data["binaries"]
-  pkginfo = pkg_data["pkginfo"]
-  pkgmap = pkg.GetPkgmap()
-  arch = pkginfo["ARCH"]
-  pkgname = pkg_data["basic_stats"]["pkgname"]
-  reasons_to_be_arch_specific = []
-  for pkgmap_path in pkgmap.entries_by_path:
-    # print "pkgmap_path", repr(pkgmap_path), type(pkgmap_path)
-    if re.search(ARCH_RE, str(pkgmap_path)):
-      reasons_to_be_arch_specific.append((
-          "archall-with-arch-paths",
-          pkgmap_path,
-          "path %s looks arch-specific" % pkgmap_path))
-  for binary in binaries:
-    reasons_to_be_arch_specific.append((
-        "archall-with-binaries",
-        binary,
-        "package contains binary %s" % binary))
-  if arch == "all":
-    for tag, param, desc in reasons_to_be_arch_specific:
-      errors.append(checkpkg.CheckpkgTag(pkgname, tag, param))
-  elif not reasons_to_be_arch_specific:
-    # This is not a clean way of handling messages for the user, but there's
-    # not better way at the moment.
-    print "Package %s does not contain any binaries." % pkgname
-    print "Consider making it ARCHALL = 1 instead of %s:" % arch
-    print "ARCHALL_%s = 1" % pkgname
-    print ("However, be aware that there might be other reasons "
-           "to keep it architecture-specific.")
-  return errors
-
-
 def main():
   options, args = checkpkg.GetOptions()
   md5sums = args
@@ -64,8 +28,8 @@
                                            md5sums,
                                            options.debug)
 
-  check_manager.RegisterIndividualCheck(CheckArchitectureVsContents)
-
+  check_manager.RegisterIndividualCheck(
+      package_checks.CheckArchitectureVsContents)
   exit_code, screen_report, tags_report = check_manager.Run()
   f = open(options.output, "w")
   f.write(tags_report)

Modified: csw/mgar/gar/v2/lib/python/package_checks.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks.py	2010-02-18 14:59:35 UTC (rev 8653)
+++ csw/mgar/gar/v2/lib/python/package_checks.py	2010-02-18 15:18:19 UTC (rev 8654)
@@ -4,6 +4,8 @@
 import checkpkg
 import re
 
+ARCH_RE = re.compile(r"(sparcv(8|9)|i386|amd64)")
+
 def CatalognameLowercase(pkg_data, debug):
   errors = []
   # Here's how to report an error:
@@ -30,3 +32,41 @@
       pkg_data["basic_stats"]["pkgname"],
       "rev-tag-missing-in-filename"))
   return errors
+
+
+def CheckArchitectureVsContents(pkg_data, debug):
+  """Verifies the relationship between package contents and architecture."""
+  errors = []
+  binaries = pkg_data["binaries"]
+  pkginfo = pkg_data["pkginfo"]
+  pkgmap = pkg_data["pkgmap"]
+  arch = pkginfo["ARCH"]
+  pkgname = pkg_data["basic_stats"]["pkgname"]
+  reasons_to_be_arch_specific = []
+  pkgmap_paths = [x["path"] for x in pkgmap]
+  for pkgmap_path in pkgmap_paths:
+    if re.search(ARCH_RE, str(pkgmap_path)):
+      reasons_to_be_arch_specific.append((
+          "archall-with-arch-paths",
+          pkgmap_path,
+          "path %s looks arch-specific" % pkgmap_path))
+  for binary in binaries:
+    reasons_to_be_arch_specific.append((
+        "archall-with-binaries",
+        binary,
+        "package contains binary %s" % binary))
+  if arch == "all":
+    for tag, param, desc in reasons_to_be_arch_specific:
+      errors.append(checkpkg.CheckpkgTag(pkgname, tag, param))
+  elif not reasons_to_be_arch_specific:
+    # This is not a clean way of handling messages for the user, but there's
+    # not better way at the moment.
+    print "Package %s does not contain any binaries." % pkgname
+    print "Consider making it ARCHALL = 1 instead of %s:" % arch
+    print "ARCHALL_%s = 1" % pkgname
+    print ("However, be aware that there might be other reasons "
+           "to keep it architecture-specific.")
+  return errors
+
+
+

Modified: csw/mgar/gar/v2/lib/python/package_checks_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks_test.py	2010-02-18 14:59:35 UTC (rev 8653)
+++ csw/mgar/gar/v2/lib/python/package_checks_test.py	2010-02-18 15:18:19 UTC (rev 8654)
@@ -4,13 +4,18 @@
 
 import unittest
 import package_checks as pc
+import yaml
+import os.path
 
+BASE_DIR = os.path.dirname(__file__)
+TESTDATA_DIR = os.path.join(BASE_DIR, "testdata")
+
 class PackageChecksUnitTest(unittest.TestCase):
 
   def setUp(self):
     self.pkg_data_1 = {
-    	  "basic_stats": {
-    	  	"pkgname": "CSWfoo"
+          "basic_stats": {
+                "pkgname": "CSWfoo"
         }
     }
     self.pkg_data_2 = {
@@ -30,6 +35,13 @@
           'pkg_path': '/tmp/pkg_lL0HDH/python_tk-2.6.4,REV=2010.02.15-SunOS5.8-sparc-CSW.pkg.gz',
           'catalogname': 'python_tk'}}
 
+  def LoadData(self, name):
+    file_name = os.path.join(TESTDATA_DIR, "%s.yml" % name)
+    f = open(file_name, "rb")
+    data = yaml.safe_load(f)
+    f.close()
+    return data
+
   def testCatalogName_1(self):
     self.pkg_data_1["basic_stats"]["catalogname"] = "Foo"
     errors = pc.CatalognameLowercase(self.pkg_data_1, False)
@@ -50,6 +62,13 @@
     errors = pc.FileNameSanity(self.pkg_data_2, False)
     self.failUnless(errors)
 
+  def testCheckArchitectureVsContents(self):
+    self.pkg_data_2["pkgmap"] = self.LoadData("example-1-pkgmap")
+    self.pkg_data_2["binaries"] = []
+    self.pkg_data_2["pkginfo"] = self.LoadData("example-1-pkginfo")
+    errors = pc.CheckArchitectureVsContents(self.pkg_data_2, False)
+    print errors
 
+
 if __name__ == '__main__':
   unittest.main()


Property changes on: csw/mgar/gar/v2/lib/python/package_checks_test.py
___________________________________________________________________
Added: svn:executable
   + *

Added: csw/mgar/gar/v2/lib/python/testdata/example-1-pkginfo.yml
===================================================================
--- csw/mgar/gar/v2/lib/python/testdata/example-1-pkginfo.yml	                        (rev 0)
+++ csw/mgar/gar/v2/lib/python/testdata/example-1-pkginfo.yml	2010-02-18 15:18:19 UTC (rev 8654)
@@ -0,0 +1,5 @@
+{ARCH: sparc, CATEGORY: application, CLASSES: none, EMAIL: maciej at opencsw.org, HOTLINE: 'http://www.opencsw.org/bugtrack/',
+  NAME: rsync - utility which provides fast incremental file transfer, OPENCSW_CATALOGNAME: rsync,
+  OPENCSW_MODE64: '32', OPENCSW_REPOSITORY: 'https://gar.svn.sourceforge.net/svnroot/gar/csw/mgar/pkg/rsync/trunk@UNCOMMITTED',
+  PKG: CSWrsync, PSTAMP: maciej at build8s-20100217091032, VENDOR: 'http://rsync.samba.org/
+    packaged for CSW by Maciej Blizinski', VERSION: '3.0.7,REV=2010.02.17', WORKDIR_FIRSTMOD: ../build-isa-sparcv8}

Added: csw/mgar/gar/v2/lib/python/testdata/example-1-pkgmap.yml
===================================================================
--- csw/mgar/gar/v2/lib/python/testdata/example-1-pkgmap.yml	                        (rev 0)
+++ csw/mgar/gar/v2/lib/python/testdata/example-1-pkgmap.yml	2010-02-18 15:18:19 UTC (rev 8654)
@@ -0,0 +1,27 @@
+- {class: null, group: null, line: ': 1 1611', mode: null, path: null, type: '1',
+  user: null}
+- {class: none, group: bin, line: 1 f none /opt/csw/bin/rsync 0755 root bin 585864
+    12576 1266394054, mode: '0755', path: /opt/csw/bin/rsync, type: f, user: root}
+- {class: none, group: bin, line: 1 f none /opt/csw/bin/sparcv9/rsync 0755 root bin 585864
+    12576 1266394054, mode: '0755', path: /opt/csw/bin/rsync, type: f, user: root}
+- {class: none, group: bin, line: 1 d none /opt/csw/share/doc/rsync 0755 root bin,
+  mode: '0755', path: /opt/csw/share/doc/rsync, type: d, user: root}
+- {class: none, group: bin, line: 1 f none /opt/csw/share/doc/rsync/license 0644 root
+    bin 35147 30328 1266394230, mode: '0644', path: /opt/csw/share/doc/rsync/license,
+  type: f, user: root}
+- {class: none, group: bin, line: 1 d none /opt/csw/share/man/man1 0755 root bin,
+  mode: '0755', path: /opt/csw/share/man/man1, type: d, user: root}
+- {class: none, group: bin, line: 1 f none /opt/csw/share/man/man1/rsync.1 0644 root
+    bin 159739 65016 1266394053, mode: '0644', path: /opt/csw/share/man/man1/rsync.1,
+  type: f, user: root}
+- {class: none, group: bin, line: 1 d none /opt/csw/share/man/man5 0755 root bin,
+  mode: '0755', path: /opt/csw/share/man/man5, type: d, user: root}
+- {class: none, group: bin, line: 1 f none /opt/csw/share/man/man5/rsyncd.conf.5 0644
+    root bin 36372 24688 1266394053, mode: '0644', path: /opt/csw/share/man/man5/rsyncd.conf.5,
+  type: f, user: root}
+- {class: null, group: null, line: 1 i copyright 69 6484 1266394230, mode: null, path: null,
+  type: i, user: null}
+- {class: null, group: null, line: 1 i depend 179 15991 1266394232, mode: null, path: null,
+  type: i, user: null}
+- {class: null, group: null, line: 1 i pkginfo 507 42930 1266394235, mode: null, path: null,
+  type: i, user: null}


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