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

chninkel at users.sourceforge.net chninkel at users.sourceforge.net
Mon Apr 22 09:29:52 CEST 2013


Revision: 20835
          http://gar.svn.sourceforge.net/gar/?rev=20835&view=rev
Author:   chninkel
Date:     2013-04-22 07:29:50 +0000 (Mon, 22 Apr 2013)
Log Message:
-----------
pkgdb: Move the machine_id data to a common place

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/common_constants.py
    csw/mgar/gar/v2/lib/python/package_checks.py
    csw/mgar/gar/v2/lib/python/pkgdb.py
    csw/mgar/gar/v2/lib/python/sharedlib_utils.py

Modified: csw/mgar/gar/v2/lib/python/common_constants.py
===================================================================
--- csw/mgar/gar/v2/lib/python/common_constants.py	2013-04-21 21:51:20 UTC (rev 20834)
+++ csw/mgar/gar/v2/lib/python/common_constants.py	2013-04-22 07:29:50 UTC (rev 20835)
@@ -91,3 +91,109 @@
 
 # The directory with shared, architecture independent data files.
 OPENCSW_SHARE = "/opt/csw/share/opencsw"
+
+SPARCV8_PATHS = (
+    'sparcv8',
+    'sparcv8-fsmuld',
+    'sparcv7',
+    'sparc')
+SPARCV8PLUS_PATHS = (
+    'sparcv8plus+vis2',
+    'sparcv8plus+vis',
+    'sparcv8plus')
+SPARCV9_PATHS = (
+    'sparcv9+vis2',
+    'sparcv9+vis',
+    'sparcv9')
+INTEL_386_PATHS = (
+    'i486',
+    'i386',
+    'i86')
+INTEL_PENTIUM_PATHS = (
+    'pentium_pro+mmx',
+    'pentium_pro',
+    'pentium+mmx',
+    'pentium')
+AMD64_PATHS = ('amd64',)
+
+# Settings for binary placements: which architectures can live in which
+# directories.
+BASE_BINARY_PATHS = ('bin', 'sbin', 'lib', 'libexec', 'cgi-bin')
+
+MACHINE_ID_METADATA = {
+    # id: (name, allowed_paths, disallowed_paths)
+    -1: {"name": "Unknown",
+         "allowed": {
+           OS_REL_58: (),
+           OS_REL_59: (),
+           OS_REL_510: (),
+           OS_REL_511: (),
+         }, "disallowed": (),
+         "type": "unknown"},
+     2: {"name": "sparcv8",
+         "type": ARCH_SPARC,
+         "allowed": {
+           OS_REL_58: BASE_BINARY_PATHS + SPARCV8_PATHS,
+           OS_REL_59: BASE_BINARY_PATHS + SPARCV8_PATHS,
+           OS_REL_510: BASE_BINARY_PATHS + SPARCV8_PATHS,
+           OS_REL_511: BASE_BINARY_PATHS + SPARCV8_PATHS,
+         },
+         "disallowed": SPARCV9_PATHS + INTEL_386_PATHS + AMD64_PATHS,
+        },
+     # pentium_pro binaries are also identified as 3.
+     3: {"name": "i386",
+         "type": ARCH_i386,
+         "allowed": {
+           OS_REL_58: BASE_BINARY_PATHS + INTEL_386_PATHS,
+           OS_REL_59: BASE_BINARY_PATHS + INTEL_386_PATHS,
+           OS_REL_510: BASE_BINARY_PATHS + INTEL_386_PATHS,
+           OS_REL_511: BASE_BINARY_PATHS + INTEL_386_PATHS,
+         },
+         "disallowed": SPARCV8_PATHS + SPARCV8PLUS_PATHS +
+                       SPARCV9_PATHS + AMD64_PATHS,
+        },
+     6: {"name": "i486",
+         "type": ARCH_i386,
+         "allowed": {
+           OS_REL_58: INTEL_386_PATHS,
+           OS_REL_59: INTEL_386_PATHS,
+           OS_REL_510: INTEL_386_PATHS,
+           OS_REL_511: INTEL_386_PATHS,
+         },
+         "disallowed": SPARCV8_PATHS + SPARCV8PLUS_PATHS +
+                       SPARCV9_PATHS + AMD64_PATHS,
+         },
+    18: {"name": "sparcv8+",
+         "type": ARCH_SPARC,
+         "allowed": {
+           OS_REL_58: SPARCV8PLUS_PATHS,
+           OS_REL_59: SPARCV8PLUS_PATHS,
+           # We allow sparcv8+ as the base architecture on Solaris 10+.
+           OS_REL_510: BASE_BINARY_PATHS + SPARCV8PLUS_PATHS,
+           OS_REL_511: BASE_BINARY_PATHS + SPARCV8PLUS_PATHS,
+         },
+         "disallowed": SPARCV8_PATHS + SPARCV9_PATHS +
+                       AMD64_PATHS + INTEL_386_PATHS,
+        },
+    43: {"name": "sparcv9",
+         "type": ARCH_SPARC,
+         "allowed": {
+           OS_REL_58: SPARCV9_PATHS,
+           OS_REL_59: SPARCV9_PATHS,
+           OS_REL_510: SPARCV9_PATHS,
+           OS_REL_511: SPARCV9_PATHS,
+         },
+         "disallowed": INTEL_386_PATHS + AMD64_PATHS,
+        },
+    62: {"name": "amd64",
+         "type": ARCH_i386,
+         "allowed": {
+           OS_REL_58: AMD64_PATHS,
+           OS_REL_59: AMD64_PATHS,
+           OS_REL_510: AMD64_PATHS,
+           OS_REL_511: AMD64_PATHS,
+         },
+         "disallowed": SPARCV8_PATHS + SPARCV8PLUS_PATHS +
+                       SPARCV9_PATHS,
+        },
+}

Modified: csw/mgar/gar/v2/lib/python/package_checks.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks.py	2013-04-21 21:51:20 UTC (rev 20834)
+++ csw/mgar/gar/v2/lib/python/package_checks.py	2013-04-22 07:29:50 UTC (rev 20835)
@@ -119,86 +119,7 @@
 # Valid URLs in the VENDOR field in pkginfo
 VENDORURL_RE = r"^(http|ftp)s?\://.+\..+$"
 
-# Settings for binary placements: which architectures can live in which
-# directories.
-BASE_BINARY_PATHS = ('bin', 'sbin', 'lib', 'libexec', 'cgi-bin')
-HACHOIR_MACHINES = {
-    # id: (name, allowed_paths, disallowed_paths)
-    -1: {"name": "Unknown",
-         "allowed": {
-           common_constants.OS_REL_58: (),
-           common_constants.OS_REL_59: (),
-           common_constants.OS_REL_510: (),
-           common_constants.OS_REL_511: (),
-         }, "disallowed": (),
-         "type": "unknown"},
-     2: {"name": "sparcv8",
-         "type": common_constants.ARCH_SPARC,
-         "allowed": {
-           common_constants.OS_REL_58: BASE_BINARY_PATHS + su.SPARCV8_PATHS,
-           common_constants.OS_REL_59: BASE_BINARY_PATHS + su.SPARCV8_PATHS,
-           common_constants.OS_REL_510: BASE_BINARY_PATHS + su.SPARCV8_PATHS,
-           common_constants.OS_REL_511: BASE_BINARY_PATHS + su.SPARCV8_PATHS,
-         },
-         "disallowed": su.SPARCV9_PATHS + su.INTEL_386_PATHS + su.AMD64_PATHS,
-        },
-     # pentium_pro binaries are also identified as 3.
-     3: {"name": "i386",
-         "type": common_constants.ARCH_i386,
-         "allowed": {
-           common_constants.OS_REL_58: BASE_BINARY_PATHS + su.INTEL_386_PATHS,
-           common_constants.OS_REL_59: BASE_BINARY_PATHS + su.INTEL_386_PATHS,
-           common_constants.OS_REL_510: BASE_BINARY_PATHS + su.INTEL_386_PATHS,
-           common_constants.OS_REL_511: BASE_BINARY_PATHS + su.INTEL_386_PATHS,
-         },
-         "disallowed": su.SPARCV8_PATHS + su.SPARCV8PLUS_PATHS +
-                       su.SPARCV9_PATHS + su.AMD64_PATHS,
-        },
-     6: {"name": "i486",
-         "type": common_constants.ARCH_i386,
-         "allowed": {
-           common_constants.OS_REL_58: su.INTEL_386_PATHS,
-           common_constants.OS_REL_59: su.INTEL_386_PATHS,
-           common_constants.OS_REL_510: su.INTEL_386_PATHS,
-           common_constants.OS_REL_511: su.INTEL_386_PATHS,
-         },
-         "disallowed": su.SPARCV8_PATHS + su.SPARCV8PLUS_PATHS +
-                       su.SPARCV9_PATHS + su.AMD64_PATHS,
-         },
-    18: {"name": "sparcv8+",
-         "type": common_constants.ARCH_SPARC,
-         "allowed": {
-           common_constants.OS_REL_58: su.SPARCV8PLUS_PATHS,
-           common_constants.OS_REL_59: su.SPARCV8PLUS_PATHS,
-           # We allow sparcv8+ as the base architecture on Solaris 10+.
-           common_constants.OS_REL_510: BASE_BINARY_PATHS + su.SPARCV8PLUS_PATHS,
-           common_constants.OS_REL_511: BASE_BINARY_PATHS + su.SPARCV8PLUS_PATHS,
-         },
-         "disallowed": su.SPARCV8_PATHS + su.SPARCV9_PATHS +
-                       su.AMD64_PATHS + su.INTEL_386_PATHS,
-        },
-    43: {"name": "sparcv9",
-         "type": common_constants.ARCH_SPARC,
-         "allowed": {
-           common_constants.OS_REL_58: su.SPARCV9_PATHS,
-           common_constants.OS_REL_59: su.SPARCV9_PATHS,
-           common_constants.OS_REL_510: su.SPARCV9_PATHS,
-           common_constants.OS_REL_511: su.SPARCV9_PATHS,
-         },
-         "disallowed": su.INTEL_386_PATHS + su.AMD64_PATHS,
-        },
-    62: {"name": "amd64",
-         "type": common_constants.ARCH_i386,
-         "allowed": {
-           common_constants.OS_REL_58: su.AMD64_PATHS,
-           common_constants.OS_REL_59: su.AMD64_PATHS,
-           common_constants.OS_REL_510: su.AMD64_PATHS,
-           common_constants.OS_REL_511: su.AMD64_PATHS,
-         },
-         "disallowed": su.SPARCV8_PATHS + su.SPARCV8PLUS_PATHS +
-                       su.SPARCV9_PATHS,
-        },
-}
+MACHINE_ID_METADATA = common_constants.MACHINE_ID_METADATA
 
 
 ALLOWED_STARTING_PATHS = frozenset([
@@ -537,7 +458,7 @@
 
 
 # TODO: Verify that architecture type of binaries matches the actual binaries.
-# Correlate architecture type from files_metadata and HACHOIR_MACHINES with
+# Correlate architecture type from files_metadata and MACHINE_ID_METADATA with
 # pkginfo.
 
 
@@ -926,14 +847,14 @@
       continue
     logger.debug("CheckArchitecture(): %s", metadata)
     machine_id = metadata["machine_id"]
-    if machine_id not in HACHOIR_MACHINES:
+    if machine_id not in MACHINE_ID_METADATA:
       error_mgr.ReportError(
           "binary-architecture-unknown",
           "file=%s arch_id=%s" % (
             metadata["path"],
             metadata["machine_id"]))
       continue
-    machine_data = HACHOIR_MACHINES[machine_id]
+    machine_data = MACHINE_ID_METADATA[machine_id]
     cpu_type = machine_data["name"]
     # allowed_paths needs to depend on the OS release. The OS release is
     # only available from the file name.
@@ -990,7 +911,7 @@
   files_metadata = pkg_data["files_metadata"]
   for file_metadata in files_metadata:
     if su.IsBinary(file_metadata):
-      machine = HACHOIR_MACHINES[file_metadata["machine_id"]]
+      machine = MACHINE_ID_METADATA[file_metadata["machine_id"]]
       if machine["type"] != pkginfo_arch:
         error_mgr.ReportError(
             "binary-wrong-architecture",
@@ -1318,7 +1239,10 @@
     binaries_path = 'lib|libexec'
 
   if binaries:
-    paths_64 = { 'i386': su.AMD64_PATHS, 'sparc': su.SPARCV9_PATHS }
+    paths_64 = {
+    	  'i386': common_constants.AMD64_PATHS,
+        'sparc': common_constants.SPARCV9_PATHS,
+    }
     paths_64_re = re.compile(r"opt/csw/(%s)/(%s)" %
                              (binaries_path,
                               '|'.join(paths_64[pkginfo['ARCH']])))

Modified: csw/mgar/gar/v2/lib/python/pkgdb.py
===================================================================
--- csw/mgar/gar/v2/lib/python/pkgdb.py	2013-04-21 21:51:20 UTC (rev 20834)
+++ csw/mgar/gar/v2/lib/python/pkgdb.py	2013-04-22 07:29:50 UTC (rev 20835)
@@ -149,7 +149,7 @@
     tmpl_str = open(tmpl_filename, "r").read()
     t = Template(tmpl_str, searchList=[{
       "pkgstats": pkgstats,
-      "hachoir_machines": package_checks.HACHOIR_MACHINES,
+      "hachoir_machines": common_constants.MACHINE_ID_METADATA,
     }])
     return unicode(t)
 

Modified: csw/mgar/gar/v2/lib/python/sharedlib_utils.py
===================================================================
--- csw/mgar/gar/v2/lib/python/sharedlib_utils.py	2013-04-21 21:51:20 UTC (rev 20834)
+++ csw/mgar/gar/v2/lib/python/sharedlib_utils.py	2013-04-22 07:29:50 UTC (rev 20835)
@@ -12,30 +12,6 @@
 class DataError(Error):
   """There's a problem with data."""
 
-# TODO: Merge with common_constants
-SPARCV8_PATHS = (
-    'sparcv8',
-    'sparcv8-fsmuld',
-    'sparcv7',
-    'sparc')
-SPARCV8PLUS_PATHS = (
-    'sparcv8plus+vis2',
-    'sparcv8plus+vis',
-    'sparcv8plus')
-SPARCV9_PATHS = (
-    'sparcv9+vis2',
-    'sparcv9+vis',
-    'sparcv9')
-INTEL_386_PATHS = (
-    'i486',
-    'i386',
-    'i86')
-INTEL_PENTIUM_PATHS = (
-    'pentium_pro+mmx',
-    'pentium_pro',
-    'pentium+mmx',
-    'pentium')
-AMD64_PATHS = ('amd64',)
 LEGIT_CHAR_RE = re.compile(r"[a-zA-Z0-9\+]+")
 SONAME_VERSION_RE = re.compile("^(?P<name>.*)\.so\.(?P<version>[\d\.]+)$")
 BIN_MIMETYPES = (
@@ -57,8 +33,12 @@
 
 
 def ParseLibPath(directory):
-  arch_subdirs = (SPARCV8_PATHS + SPARCV8PLUS_PATHS + SPARCV9_PATHS
-                  + INTEL_386_PATHS + AMD64_PATHS)
+  arch_subdirs = (
+      common_constants.SPARCV8_PATHS
+      + common_constants.SPARCV8PLUS_PATHS
+      + common_constants.SPARCV9_PATHS
+      + common_constants.INTEL_386_PATHS
+      + common_constants.AMD64_PATHS)
   # Need to escape the plus signs because of the regex usage below.
   arch_subdirs = [x.replace(r"+", r"\+") for x in arch_subdirs]
   linkable_re = re.compile(r"^/?opt/csw"

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