[csw-devel] SF.net SVN: gar:[17285] csw/mgar/gar/v2/lib/python
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Sun Mar 4 00:25:14 CET 2012
Revision: 17285
http://gar.svn.sourceforge.net/gar/?rev=17285&view=rev
Author: wahwah
Date: 2012-03-03 23:25:14 +0000 (Sat, 03 Mar 2012)
Log Message:
-----------
checkpkg: Remove soname grouping guesswork
Checkpkg used to guess that if multiple libraries share the same soname
version, they should go into a single package.
libfoo-something.so.1
libfoo-otherthing.so.1
=> CSWlibfoo suggested
This caused increased checkpkg code complexity and guesses were often wrong
and/or confusing. It is simpler to take each soname separately without trying
to create package groups. Less magic in checkpkg allows maintainers to have
a clearer understanding of what and why checkpkg suggests.
In the rather rare cases when multiple libraries are bundled in one package,
overrides can be used. These cases are rather rare, because the main package
which used to bundle libraries is Boost, and it will be split into
one-lib-per-package anyway. Other cases are rather marginal, and often involve
bundline libraries with different soname versions (e.g. Kerberos private
libs).
Modified Paths:
--------------
csw/mgar/gar/v2/lib/python/package_checks.py
csw/mgar/gar/v2/lib/python/sharedlib_utils.py
Modified: csw/mgar/gar/v2/lib/python/package_checks.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks.py 2012-03-03 23:24:36 UTC (rev 17284)
+++ csw/mgar/gar/v2/lib/python/package_checks.py 2012-03-03 23:25:14 UTC (rev 17285)
@@ -1033,106 +1033,48 @@
else:
soname = os.path.split(binary_info["path"])[1]
linkable_shared_libs.append((soname, binary_info))
- check_names = True
logging.debug("CheckSharedLibraryNamingPolicy(): "
"linkable shared libs of %s: %s"
% (pkgname, linkable_shared_libs))
- if len(linkable_shared_libs) > 1:
- sonames = sorted(set([x[0] for x in linkable_shared_libs]))
- tmp = su.MakePackageNameBySonameCollection(sonames)
- if tmp:
- multilib_pkgnames, multilib_catalogname = tmp
- else:
- multilib_pkgnames, multilib_catalogname = (None, None)
- if not multilib_pkgnames:
+ for soname, binary_info in linkable_shared_libs:
+ tmp = su.MakePackageNameBySoname(soname)
+ policy_pkgname_list, policy_catalogname_list = tmp
+ if pkgname not in policy_pkgname_list:
error_mgr.ReportError(
- "non-uniform-lib-versions-in-package",
- "sonames=%s"
- % (",".join(sonames)))
- messenger.Message(
- "Package %s contains shared libraries, and their soname "
- "versions are not in sync: %s. This means that "
- "each soname is likely to be retired at a different time "
- "and each soname is best placed in a separate package, "
- "named after soname and version. "
- % (pkgname, sonames))
- # If the sonames aren't uniform, there's no point in trying to match
- # sonames versus pkgname.
- messenger.SuggestGarLine(
- "# Suggesting how to separate out shared libraries.")
- messenger.SuggestGarLine(
- "# You will most probably need to further edit these lines. "
- "Use with caution!")
- for soname, binary_info in linkable_shared_libs:
- lib_path, lib_basename = os.path.split(binary_info["path"])
- tmp = su.MakePackageNameBySoname(soname)
- policy_pkgname_list, policy_catalogname_list = tmp
- pkginfo = pkg_data["pkginfo"]
- description = " ".join(pkginfo["NAME"].split(" ")[2:])
- depchecks.SuggestLibraryPackage(error_mgr, messenger,
- policy_pkgname_list[0],
- policy_catalogname_list[0],
- description,
- lib_path, lib_basename, soname,
- pkgname)
+ "shared-lib-pkgname-mismatch",
+ "file=%s "
+ "soname=%s "
+ "pkgname=%s "
+ "expected=%s"
+ % (binary_info["path"],
+ soname, pkgname,
+ ",".join(policy_pkgname_list)))
- check_names = False
- else: # len(linkable_shared_libs) > 1
- if pkgname not in multilib_pkgnames:
- error_mgr.ReportError(
- "shared-lib-pkgname-mismatch",
- "sonames=%s "
- "pkgname=%s "
- "expected=%s "
- % (",".join(sonames), pkgname, ",".join(multilib_pkgnames)))
- messenger.Message(
- "The collection of sonames (%s) "
- "is expected to be in package "
- "named %s, but the package name is %s. "
- "More information: "
- "http://wiki.opencsw.org/checkpkg-error-tags"
- % (sonames, multilib_pkgnames, pkgname))
- check_names = False
- if check_names:
- for soname, binary_info in linkable_shared_libs:
- tmp = su.MakePackageNameBySoname(soname)
- policy_pkgname_list, policy_catalogname_list = tmp
- if pkgname not in policy_pkgname_list:
- error_mgr.ReportError(
- "shared-lib-pkgname-mismatch",
- "file=%s "
- "soname=%s "
- "pkgname=%s "
- "expected=%s"
- % (binary_info["path"],
- soname, pkgname,
- ",".join(policy_pkgname_list)))
+ suggested_pkgname = policy_pkgname_list[0]
+ lib_path, lib_basename = os.path.split(binary_info["path"])
+ pkginfo = pkg_data["pkginfo"]
+ description = " ".join(pkginfo["NAME"].split(" ")[2:])
+ depchecks.SuggestLibraryPackage(error_mgr, messenger,
+ suggested_pkgname,
+ policy_catalogname_list[0],
+ description,
+ lib_path, lib_basename, soname,
+ pkgname)
- suggested_pkgname = policy_pkgname_list[0]
- lib_path, lib_basename = os.path.split(binary_info["path"])
- pkginfo = pkg_data["pkginfo"]
- description = " ".join(pkginfo["NAME"].split(" ")[2:])
- depchecks.SuggestLibraryPackage(error_mgr, messenger,
- suggested_pkgname,
- policy_catalogname_list[0],
- description,
- lib_path, lib_basename, soname,
- pkgname)
+ messenger.OneTimeMessage(
+ soname,
+ "This shared library (%s) is in a directory indicating that it "
+ "is likely to be linked to by other programs. If this is the "
+ "case, the library is best packaged separately, in a package "
+ "with a library-specific name. Examples of such names include: "
+ "%s. If this library is not meant to be linked to by other "
+ "packages, it's best moved to a 'private' directory. "
+ "For example, instead of /opt/csw/lib/foo.so, "
+ "try /opt/csw/lib/projectname/foo.so. "
+ "More information: http://wiki.opencsw.org/checkpkg-error-tags"
+ % (binary_info["path"], policy_pkgname_list))
- messenger.OneTimeMessage(
- soname,
- "This shared library (%s) is in a directory indicating that it "
- "is likely to be linked to by other programs. If this is the "
- "case, the library is best packaged separately, in a package "
- "with a library-specific name. Examples of such names include: "
- "%s. If this library is not meant to be linked to by other "
- "packages, it's best moved to a 'private' directory. "
- "For example, instead of /opt/csw/lib/foo.so, "
- "try /opt/csw/lib/projectname/foo.so. "
- "More information: http://wiki.opencsw.org/checkpkg-error-tags"
- % (binary_info["path"], 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.
Modified: csw/mgar/gar/v2/lib/python/sharedlib_utils.py
===================================================================
--- csw/mgar/gar/v2/lib/python/sharedlib_utils.py 2012-03-03 23:24:36 UTC (rev 17284)
+++ csw/mgar/gar/v2/lib/python/sharedlib_utils.py 2012-03-03 23:25:14 UTC (rev 17285)
@@ -171,70 +171,6 @@
return shared_libs
-def GetCommonVersion(sonames):
- versions = []
- for soname in sonames:
- m = SONAME_VERSION_RE.search(soname)
- if m:
- versions.append(m.groupdict()["version"])
- else:
- versions.append("")
- versions_set = set(versions)
- if len(versions_set) > 1 or not versions_set:
- return (False, None)
- else:
- return (True, versions_set.pop())
-
-
-def ValidateCollectionName(l):
- letters = "".join(re.findall(r"[a-zA-Z]", l))
- # Special case for libz
- if len(letters) == 1 and letters[0] == 'z': return True
- if len(letters) <= 1:
- return False
- return True
-
-
-def MakePackageNameBySonameCollection(sonames):
- """Finds a name for a collection of sonames.
-
- Try to find the largest common prefix in the sonames, and establish
- whether there is a common version to them.
- """
- common_version_exists, common_version = GetCommonVersion(sonames)
- if not common_version_exists:
- # If the sonames don't have a common version, they shouldn't be together
- # in one package.
- return None
- common_substring_candidates = []
- for soname in sonames:
- candidate = soname
- # We always want such package to start with the prefix "lib". Therefore,
- # we're stripping the prefix "lib" if it exists, and we're adding it back
- # to the pkgname and soname at the end of the function.
- if candidate.startswith("lib"):
- candidate = candidate[3:]
- m = re.search("\.so", candidate)
- candidate = re.sub("\.so.*$", "", candidate)
- common_substring_candidates.append(candidate)
- lcs = CollectionLongestCommonSubstring(copy.copy(common_substring_candidates))
- if not ValidateCollectionName(lcs):
- return None
- pkgnames = [
- "CSW" + SonameToStringWithChar("lib%s%s" % (lcs, common_version), "-"),
- ]
- dashed = "CSW" + SonameToStringWithChar("lib%s-%s" % (lcs, common_version), "-")
- if dashed not in pkgnames:
- pkgnames.append(dashed)
- catalognames = [
- SonameToStringWithChar("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
-
-
def LongestCommonSubstring(S, T):
"""Stolen from Wikibooks
@@ -256,16 +192,6 @@
return LCS
-def CollectionLongestCommonSubstring(collection):
- current_substring = collection.pop()
- while collection and current_substring:
- substring_set = LongestCommonSubstring(current_substring,
- collection.pop())
- if substring_set:
- current_substring = list(substring_set)[0]
- return current_substring
-
-
def IsBinary(file_info):
"""Returns True or False depending on file metadata."""
is_a_binary = False
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