[csw-devel] SF.net SVN: gar:[11401] csw/mgar/gar/v2/lib/python
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Mon Oct 25 23:26:40 CEST 2010
Revision: 11401
http://gar.svn.sourceforge.net/gar/?rev=11401&view=rev
Author: wahwah
Date: 2010-10-25 21:26:40 +0000 (Mon, 25 Oct 2010)
Log Message:
-----------
mGAR v2: merge of a conflict during git svn rebase.
Modified Paths:
--------------
csw/mgar/gar/v2/lib/python/sharedlib_utils.py
csw/mgar/gar/v2/lib/python/sharedlib_utils_test.py
Modified: csw/mgar/gar/v2/lib/python/sharedlib_utils.py
===================================================================
--- csw/mgar/gar/v2/lib/python/sharedlib_utils.py 2010-10-25 21:26:12 UTC (rev 11400)
+++ csw/mgar/gar/v2/lib/python/sharedlib_utils.py 2010-10-25 21:26:40 UTC (rev 11401)
@@ -42,7 +42,39 @@
return False
+def SonameToStringWithChar(s, c):
+ """Sanitization function tailored at package names.
+
+ It only inserts separators where digits of letters would be jammed
+ togeher. For example, foo-0 becomes foo0, but foo-0-0 becomes foo0-0."""
+ def CharType(mychar):
+ if mychar.isalpha():
+ return "alpha"
+ elif mychar.isdigit():
+ return "digit"
+ else:
+ return "unknown"
+ parts = LEGIT_CHAR_RE.findall(s)
+ if "so" in parts:
+ parts.remove("so")
+ prev_type = "unknown"
+ new_parts = []
+ for part in parts:
+ first_type = CharType(part[0])
+ need_sep = False
+ if (first_type == prev_type
+ and
+ (prev_type == "digit" or prev_type == "alpha")):
+ need_sep = True
+ if need_sep:
+ new_parts.append(c)
+ new_parts.append(part)
+ prev_type = first_type
+ return "".join(new_parts).lower()
+
+
def SanitizeWithChar(s, c):
+ """Generic string sanitization function."""
parts = LEGIT_CHAR_RE.findall(s)
if "so" in parts:
parts.remove("so")
@@ -74,8 +106,8 @@
keywords_catalogname = {}
for key in parsed:
if parsed[key]:
- keywords_pkgname[key] = SanitizeWithChar(parsed[key], "-")
- keywords_catalogname[key] = SanitizeWithChar(parsed[key], "_")
+ keywords_pkgname[key] = SonameToStringWithChar(parsed[key], "-")
+ keywords_catalogname[key] = SonameToStringWithChar(parsed[key], "_")
else:
keywords_pkgname[key] = ""
keywords_catalogname[key] = ""
@@ -143,15 +175,15 @@
common_substring_candidates.append(candidate)
lcs = CollectionLongestCommonSubstring(copy.copy(common_substring_candidates))
pkgnames = [
- "CSW" + SanitizeWithChar("lib%s%s" % (lcs, common_version), "-"),
+ "CSW" + SonameToStringWithChar("lib%s%s" % (lcs, common_version), "-"),
]
- dashed = "CSW" + SanitizeWithChar("lib%s-%s" % (lcs, common_version), "-")
+ dashed = "CSW" + SonameToStringWithChar("lib%s-%s" % (lcs, common_version), "-")
if dashed not in pkgnames:
pkgnames.append(dashed)
catalognames = [
- SanitizeWithChar("lib%s%s" % (lcs, common_version), "_"),
+ SonameToStringWithChar("lib%s%s" % (lcs, common_version), "_"),
]
- underscored = SanitizeWithChar("lib%s_%s" % (lcs, common_version), "_")
+ underscored = SonameToStringWithChar("lib%s_%s" % (lcs, common_version), "_")
if underscored not in catalognames:
catalognames.append(underscored)
return pkgnames, catalognames
Modified: csw/mgar/gar/v2/lib/python/sharedlib_utils_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/sharedlib_utils_test.py 2010-10-25 21:26:12 UTC (rev 11400)
+++ csw/mgar/gar/v2/lib/python/sharedlib_utils_test.py 2010-10-25 21:26:40 UTC (rev 11401)
@@ -56,22 +56,30 @@
"opt/csw/share/Adobe/Reader8/Reader/sparcsolaris/lib"
"/libcrypto.so.0.9.6"))
+ def testIsLibraryLinkableInPrefix(self):
+ """This could be considered linkable.
+
+ Reason: It has the form of "/opt/csw/foo/lib/libfoo.so.1"."""
+ self.assertEqual(False, su.IsLibraryLinkable(
+ "opt/csw/boost-gcc/lib"
+ "/libboost_wserialization.so.1.44.0"))
+
class MakePackageNameBySonameUnitTest(unittest.TestCase):
def testMakePackageNameBySonameSimple(self):
soname = "libfoo.so.0"
expected = (
- ["CSWlibfoo0", "CSWlibfoo-0"],
- ["libfoo0", "libfoo_0"],
+ ["CSWlibfoo0"],
+ ["libfoo0"],
)
self.assertEqual(expected, su.MakePackageNameBySoname(soname))
def testMakePackageNameBySonameMinorVersion(self):
soname = "libfoo.so.0.1"
expected = (
- ["CSWlibfoo0-1", "CSWlibfoo-0-1"],
- ["libfoo0_1", "libfoo_0_1"],
+ ["CSWlibfoo0-1"],
+ ["libfoo0_1"],
)
self.assertEqual(expected, su.MakePackageNameBySoname(soname))
@@ -143,6 +151,12 @@
expected = (
['CSWlibgettextlib-0-14-1'],
['libgettextlib_0_14_1'],
+
+ def testMakePackageNameDashesNoDashes(self):
+ soname = "libpyglib-2.0-python.so.0"
+ expected = (
+ ['CSWlibpyglib2-0python0'],
+ ['libpyglib2_0python0'],
)
self.assertEqual(expected,
su.MakePackageNameBySoname(soname))
@@ -195,7 +209,16 @@
def testSanitizeWithChar(self):
self.assertEqual("foo_0", su.SanitizeWithChar("foo-0", "_"))
+ def testSonameToStringWithCharAlphaDigit(self):
+ self.assertEqual("foo0", su.SonameToStringWithChar("foo-0", "_"))
+ def testSonameToStringWithCharDigitDigit(self):
+ self.assertEqual("foo0_0", su.SonameToStringWithChar("foo-0-0", "_"))
+
+ def testSonameToStringWithCharDigitDigit(self):
+ self.assertEqual("foo_bar0_0", su.SonameToStringWithChar("foo-bar-0-0", "_"))
+
+
class GetCommonVersionUnitTest(unittest.TestCase):
def testGetCommonVersionSimple(self):
@@ -220,24 +243,24 @@
def testMakePackageNameBySonameCollectionTwo(self):
sonames = ["libfoo.so.0", "libfoo_util.so.0"]
expected = (
- ["CSWlibfoo0", "CSWlibfoo-0"],
- ["libfoo0", "libfoo_0"],
+ ["CSWlibfoo0"],
+ ["libfoo0"],
)
self.assertEqual(expected, su.MakePackageNameBySonameCollection(sonames))
def testMakePackageNameBySonameCollectionRepeated(self):
sonames = ["libfoo.so.0", "libfoo.so.0"]
expected = (
- ["CSWlibfoo0", "CSWlibfoo-0"],
- ["libfoo0", "libfoo_0"],
+ ["CSWlibfoo0"],
+ ["libfoo0"],
)
self.assertEqual(expected, su.MakePackageNameBySonameCollection(sonames))
def testMakePackageNameBySonameCollectionBdb(self):
sonames = ["libfoo.so.0", "libfoo_util.so.0"]
expected = (
- ["CSWlibfoo0", "CSWlibfoo-0"],
- ["libfoo0", "libfoo_0"],
+ ["CSWlibfoo0"],
+ ["libfoo0"],
)
self.assertEqual(expected, su.MakePackageNameBySonameCollection(sonames))
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