[csw-devel] SF.net SVN: gar:[11211] csw/mgar/gar/v2/lib/python
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Sun Oct 10 22:31:59 CEST 2010
Revision: 11211
http://gar.svn.sourceforge.net/gar/?rev=11211&view=rev
Author: wahwah
Date: 2010-10-10 20:31:59 +0000 (Sun, 10 Oct 2010)
Log Message:
-----------
mGAR v2: checkpkg, added support for more soname cases, the new check can now process the whole catalog.
Modified Paths:
--------------
csw/mgar/gar/v2/lib/python/package_checks.py
csw/mgar/gar/v2/lib/python/sharedlib_utils.py
csw/mgar/gar/v2/lib/python/sharedlib_utils_test.py
Property Changed:
----------------
csw/mgar/gar/v2/lib/python/sharedlib_utils_test.py
Modified: csw/mgar/gar/v2/lib/python/package_checks.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks.py 2010-10-10 20:31:29 UTC (rev 11210)
+++ csw/mgar/gar/v2/lib/python/package_checks.py 2010-10-10 20:31:59 UTC (rev 11211)
@@ -102,14 +102,6 @@
VENDORURL_RE = r"^(http|ftp)s?\://.+\..+$"
BASE_BINARY_PATHS = ('bin', 'sbin', 'lib', 'libexec', 'cgi-bin')
-SPARCV8_PATHS = ('sparcv8', 'sparcv8-fsmuld',
- 'sparcv7', 'sparc')
-SPARCV8PLUS_PATHS = ('sparcv8plus+vis2', 'sparcv8plus+vis', 'sparcv8plus')
-SPARCV9_PATHS = ('sparcv9+vis2', 'sparcv9+vis', 'sparcv9')
-INTEL_386_PATHS = ('pentium_pro+mmx', 'pentium_pro',
- 'pentium+mmx', 'pentium',
- 'i486', 'i386', 'i86')
-AMD64_PATHS = ('amd64',)
HACHOIR_MACHINES = {
# id: (name, allowed_paths, disallowed_paths)
-1: {"name": "Unknown",
@@ -117,33 +109,33 @@
"type": "unknown"},
2: {"name": "sparcv8",
"type": opencsw.ARCH_SPARC,
- "allowed": BASE_BINARY_PATHS + SPARCV8_PATHS,
- "disallowed": SPARCV9_PATHS + INTEL_386_PATHS + AMD64_PATHS,
+ "allowed": BASE_BINARY_PATHS + su.SPARCV8_PATHS,
+ "disallowed": su.SPARCV9_PATHS + su.INTEL_386_PATHS + su.AMD64_PATHS,
},
3: {"name": "i386",
"type": opencsw.ARCH_i386,
- "allowed": BASE_BINARY_PATHS + INTEL_386_PATHS,
- "disallowed": SPARCV8_PATHS + SPARCV8PLUS_PATHS + SPARCV9_PATHS + AMD64_PATHS,
+ "allowed": BASE_BINARY_PATHS + su.INTEL_386_PATHS,
+ "disallowed": su.SPARCV8_PATHS + su.SPARCV8PLUS_PATHS + su.SPARCV9_PATHS + su.AMD64_PATHS,
},
6: {"name": "i486",
"type": opencsw.ARCH_i386,
- "allowed": INTEL_386_PATHS,
- "disallowed": SPARCV8_PATHS + SPARCV8PLUS_PATHS + SPARCV9_PATHS + AMD64_PATHS,
+ "allowed": su.INTEL_386_PATHS,
+ "disallowed": su.SPARCV8_PATHS + su.SPARCV8PLUS_PATHS + su.SPARCV9_PATHS + su.AMD64_PATHS,
},
18: {"name": "sparcv8+",
"type": opencsw.ARCH_SPARC,
- "allowed": SPARCV8PLUS_PATHS,
- "disallowed": SPARCV8_PATHS + SPARCV9_PATHS + AMD64_PATHS + INTEL_386_PATHS,
+ "allowed": su.SPARCV8PLUS_PATHS,
+ "disallowed": su.SPARCV8_PATHS + su.SPARCV9_PATHS + su.AMD64_PATHS + su.INTEL_386_PATHS,
},
43: {"name": "sparcv9",
"type": opencsw.ARCH_SPARC,
- "allowed": SPARCV9_PATHS,
- "disallowed": INTEL_386_PATHS + AMD64_PATHS,
+ "allowed": su.SPARCV9_PATHS,
+ "disallowed": su.INTEL_386_PATHS + su.AMD64_PATHS,
},
62: {"name": "amd64",
"type": opencsw.ARCH_i386,
- "allowed": AMD64_PATHS,
- "disallowed": SPARCV8_PATHS + SPARCV8PLUS_PATHS + SPARCV9_PATHS,
+ "allowed": su.AMD64_PATHS,
+ "disallowed": su.SPARCV8_PATHS + su.SPARCV8PLUS_PATHS + su.SPARCV9_PATHS,
},
}
@@ -1017,3 +1009,21 @@
"to, need to be separated out into own packages. "
"In this case, the suggested package names are %s."
% policy_pkgname_list)
+
+def CheckSharedLibraryPkgDoesNotHaveTheSoFile(pkg_data, error_mgr, logger, messenger):
+ """If it's a package with shared libraries, it should not contain the .so file.
+
+ For example, libfoo.so.1 should not be in the same package as libfoo.so,
+ because the latter is used for linking during compilation, and the former is
+ a shared object that needs to be phased out at some point.
+ """
+ placement_re = re.compile("/opt/csw/lib")
+ pkgname = pkg_data["basic_stats"]["pkgname"]
+ shared_libs = set(su.GetSharedLibs(pkg_data))
+ if shared_libs:
+ # If the package contains shared libraries, it must not contain
+ # corrersponding .so files, which are used during linking.
+ pass
+
+def CheckPackagesWithHeaderFilesMustContainTheSoFile(pkg_data, error_mgr, logger, messenger):
+ pass
Modified: csw/mgar/gar/v2/lib/python/sharedlib_utils.py
===================================================================
--- csw/mgar/gar/v2/lib/python/sharedlib_utils.py 2010-10-10 20:31:29 UTC (rev 11210)
+++ csw/mgar/gar/v2/lib/python/sharedlib_utils.py 2010-10-10 20:31:59 UTC (rev 11211)
@@ -3,27 +3,78 @@
import re
import os.path
+SPARCV8_PATHS = ('sparcv8', 'sparcv8-fsmuld',
+ 'sparcv7', 'sparc')
+SPARCV8PLUS_PATHS = ('sparcv8plus+vis2', 'sparcv8plus+vis', 'sparcv8plus')
+SPARCV9_PATHS = ('sparcv9+vis2', 'sparcv9+vis', 'sparcv9')
+INTEL_386_PATHS = ('pentium_pro+mmx', 'pentium_pro',
+ 'pentium+mmx', 'pentium',
+ 'i486', 'i386', 'i86')
+AMD64_PATHS = ('amd64',)
+LEGIT_CHAR_RE = re.compile(r"[a-zA-Z0-9\+]+")
+
+class SonameParsingException(Exception):
+ pass
+
def IsLibraryLinkable(file_path):
- linkable_re = re.compile(r"^opt/csw(/[\w\.]+)*/lib(/[\w\+]+)?$")
+ arch_subdirs = (SPARCV8_PATHS + SPARCV8PLUS_PATHS + SPARCV9_PATHS
+ + INTEL_386_PATHS + 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(/[^\/]+)*/lib(/(%s))?$"
+ % "|".join(arch_subdirs))
file_dir, file_basename = os.path.split(file_path)
return bool(linkable_re.match(file_dir))
+
+def SanitizeWithChar(s, c):
+ parts = LEGIT_CHAR_RE.findall(s)
+ if "so" in parts:
+ parts.remove("so")
+ return c.join(parts).lower()
+
+
def MakePackageNameBySoname(soname):
"""Find the package name based on the soname.
Returns a pair of pkgname, catalogname.
"""
- soname_re = re.compile(r"(?P<basename>[\w-]+)\.so\.(?P<version>\d+)(\..*)?$")
+ soname_re = re.compile(r"(?P<basename>[\w\+]+([\.\-]+[\w\+]+)*)"
+ r"\.so"
+ r"(\.(?P<version>\d+)(\..*)?)?"
+ r"$")
m = soname_re.match(soname)
- keywords = m.groupdict()
+ if not m:
+ # There was no ".so" component, so it's hardo to figure out which one is
+ # the name, but we'll try to figure out the numeric part of the soname.
+ digits = "".join(re.findall(r"[0-9]+", soname))
+ alnum = "".join(re.findall(r"[a-zA-Z]+", soname))
+ parsed = {
+ "basename": alnum,
+ "version": digits,
+ }
+ else:
+ parsed = m.groupdict()
+ keywords_pkgname = {}
+ keywords_catalogname = {}
+ for key in parsed:
+ if parsed[key]:
+ keywords_pkgname[key] = SanitizeWithChar(parsed[key], "-")
+ keywords_catalogname[key] = SanitizeWithChar(parsed[key], "_")
+ else:
+ keywords_pkgname[key] = ""
+ keywords_catalogname[key] = ""
pkgname_list = [
- "CSW%(basename)s%(version)s" % keywords,
- "CSW%(basename)s-%(version)s" % keywords,
+ "CSW%(basename)s%(version)s" % keywords_pkgname,
]
catalogname_list = [
- "%(basename)s%(version)s" % keywords,
- "%(basename)s-%(version)s" % keywords,
+ "%(basename)s%(version)s" % keywords_catalogname,
]
+ if keywords_pkgname["version"]:
+ catalogname_list.append(
+ "%(basename)s_%(version)s" % keywords_catalogname)
+ pkgname_list.append(
+ "CSW%(basename)s-%(version)s" % keywords_pkgname)
return pkgname_list, catalogname_list
Modified: csw/mgar/gar/v2/lib/python/sharedlib_utils_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/sharedlib_utils_test.py 2010-10-10 20:31:29 UTC (rev 11210)
+++ csw/mgar/gar/v2/lib/python/sharedlib_utils_test.py 2010-10-10 20:31:59 UTC (rev 11211)
@@ -1,4 +1,4 @@
-#!opt/csw/bin/python2.6
+#!/opt/csw/bin/python2.6
# $Id$
import re
@@ -9,8 +9,7 @@
class UtilitiesUnitTest(unittest.TestCase):
def testIsLibraryLinkableTrue(self):
- p = "opt/csw/lib/libfoo.so.0.2"
- self.assertTrue(su.IsLibraryLinkable(p))
+ self.assertTrue(su.IsLibraryLinkable("opt/csw/lib/libfoo.so.0.2"))
def testIsLibraryLinkableNeonTrue(self):
p = "opt/csw/lib/libneon.so.26.0.4"
@@ -21,12 +20,11 @@
self.assertEqual(True, su.IsLibraryLinkable(p))
def testIsLibraryLinkableSparcPlusVis(self):
- p = "opt/csw/lib/sparcv9+vis/libfoo.so.0.2"
+ p = "opt/csw/lib/sparcv8plus+vis/libfoo.so.0.2"
self.assertEqual(True, su.IsLibraryLinkable(p))
def testIsLibraryLinkableAmd64(self):
- p = "opt/csw/lib/amd64/libfoo.so.0.2"
- self.assertTrue(su.IsLibraryLinkable(p))
+ self.assertTrue(su.IsLibraryLinkable("opt/csw/lib/amd64/libfoo.so.0.2"))
def testIsLibraryLinkablePrefix(self):
p = "opt/csw/customprefix/lib/libfoo.so.0.2"
@@ -40,11 +38,15 @@
p = "opt/csw/share/bar"
self.assertEqual(False, su.IsLibraryLinkable(p))
+ def testIsLibraryLinkableSubdir(self):
+ p = "opt/csw/lib/gnucash/libgncmod-stylesheets.so.0.0.0"
+ self.assertEqual(False, su.IsLibraryLinkable(p))
+
def testMakePackageNameBySonameSimple(self):
soname = "libfoo.so.0"
expected = (
["CSWlibfoo0", "CSWlibfoo-0"],
- ["libfoo0", "libfoo-0"],
+ ["libfoo0", "libfoo_0"],
)
self.assertEqual(expected, su.MakePackageNameBySoname(soname))
@@ -52,11 +54,68 @@
soname = "libapr-1.so.0"
expected = (
['CSWlibapr-10', 'CSWlibapr-1-0'],
- ['libapr-10', 'libapr-1-0']
+ ['libapr_10', 'libapr_1_0']
)
self.assertEqual(expected,
su.MakePackageNameBySoname(soname))
+ def testMakePackageNameBySonameDot(self):
+ soname = "libbabl-0.1.so.0"
+ expected = (
+ ['CSWlibbabl-0-10', 'CSWlibbabl-0-1-0'],
+ ['libbabl_0_10', 'libbabl_0_1_0']
+ )
+ self.assertEqual(expected,
+ su.MakePackageNameBySoname(soname))
+ def testMakePackageNameBySonameMoreDot(self):
+ soname = "libgettextlib-0.14.1.so"
+ expected = (
+ ['CSWlibgettextlib-0-14-1'],
+ ['libgettextlib_0_14_1'],
+ )
+ self.assertEqual(expected,
+ su.MakePackageNameBySoname(soname))
+
+ def testMakePackageNameBySonameComplexApr(self):
+ soname = "libapr-1.so.10.0.0"
+ expected = (
+ ['CSWlibapr-110', 'CSWlibapr-1-10'],
+ ['libapr_110', 'libapr_1_10']
+ )
+ self.assertEqual(expected,
+ su.MakePackageNameBySoname(soname))
+
+ def testMakePackageNameBySonamePlus(self):
+ soname = "libstdc++.so.6"
+ expected = (
+ ['CSWlibstdc++6', 'CSWlibstdc++-6'],
+ ['libstdc++6', 'libstdc++_6']
+ )
+ self.assertEqual(expected,
+ su.MakePackageNameBySoname(soname))
+
+ def testMakePackageNameBySonamePlus(self):
+ soname = "libdnet.1"
+ expected = (
+ ['CSWlibdnet1', 'CSWlibdnet-1'],
+ ['libdnet1', 'libdnet_1']
+ )
+ self.assertEqual(expected,
+ su.MakePackageNameBySoname(soname))
+
+ def testMakePackageNameUppercase(self):
+ soname = "libUpperCase.so.1"
+ expected = (
+ ['CSWlibuppercase1', 'CSWlibuppercase-1'],
+ ['libuppercase1', 'libuppercase_1']
+ )
+ self.assertEqual(expected,
+ su.MakePackageNameBySoname(soname))
+
+ def testSanitizeWithChar(self):
+ self.assertEqual("foo_0", su.SanitizeWithChar("foo-0", "_"))
+
+
if __name__ == '__main__':
unittest.main()
Property changes on: csw/mgar/gar/v2/lib/python/sharedlib_utils_test.py
___________________________________________________________________
Added: svn:executable
+ *
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