[csw-devel] SF.net SVN: gar:[21904] csw/mgar/gar/v2/lib/python/dependency_checks.py
chninkel at users.sourceforge.net
chninkel at users.sourceforge.net
Tue Sep 10 21:09:17 CEST 2013
Revision: 21904
http://gar.svn.sourceforge.net/gar/?rev=21904&view=rev
Author: chninkel
Date: 2013-09-10 19:09:16 +0000 (Tue, 10 Sep 2013)
Log Message:
-----------
add support for per-os-release allowed library versions dependencies
The check for usage of forbidden library version interface must take
into account the os release to accomodate differences between releases.
For example it's fine to only allowed libc version < SUNW_1.22.6 under
Solaris 10, but it doesn't make sense under Solaris 11 as SUNW_1.23
was provided from the very first release.
This patch also include a new comparison function to be able to compare
version dependencies so that we do not have to declare all versions
(SUNW_0.8, SUNW_0.9...) but only the maximal version allowed.
Modified Paths:
--------------
csw/mgar/gar/v2/lib/python/dependency_checks.py
Modified: csw/mgar/gar/v2/lib/python/dependency_checks.py
===================================================================
--- csw/mgar/gar/v2/lib/python/dependency_checks.py 2013-09-10 14:40:10 UTC (rev 21903)
+++ csw/mgar/gar/v2/lib/python/dependency_checks.py 2013-09-10 19:09:16 UTC (rev 21904)
@@ -55,19 +55,51 @@
])
ALLOWED_VERSION_DEPENDENCIES = {
- "libc.so.1": ['SYSVABI_1.3', 'SUNWprivate_1.1', 'SUNW_1.22.6',
- 'SUNW_1.22.5', 'SUNW_1.22.4', 'SUNW_1.22.3', 'SUNW_1.22.2',
- 'SUNW_1.22.1', 'SUNW_1.22', 'SUNW_1.21.3', 'SUNW_1.21.2',
- 'SUNW_1.21.1', 'SUNW_1.21', 'SUNW_1.20.4', 'SUNW_1.20.1',
- 'SUNW_1.20', 'SUNW_1.19', 'SUNW_1.18.1', 'SUNW_1.18',
- 'SUNW_1.17', 'SUNW_1.16', 'SUNW_1.15', 'SUNW_1.14',
- 'SUNW_1.13', 'SUNW_1.12', 'SUNW_1.11', 'SUNW_1.10',
- 'SUNW_1.9', 'SUNW_1.8', 'SUNW_1.7', 'SUNW_1.6', 'SUNW_1.5',
- 'SUNW_1.4', 'SUNW_1.3', 'SUNW_1.2', 'SUNW_1.1', 'SUNW_0.9',
- 'SUNW_0.8', 'SUNW_0.7', 'SISCD_2.3'],
+ "libc.so.1": {
+ u'SunOS5.11': ['SYSVABI_1.3', 'SUNWprivate_1.1', 'SUNW_1.23', 'SISCD_2.3'],
+ u'SunOS5.10': ['SYSVABI_1.3', 'SUNWprivate_1.1', 'SUNW_1.22.6', 'SISCD_2.3'],
+ },
}
+def CompareLibraryVersions(version1, version2):
+ """Compare two library versions
+
+ Library versions often have the following forms:
+ PREFIX_NUMBER1.NUMBER2.NUMBER3 (e.g. SUNW_1.22.3)
+ with the more recent one having the highest numbers.
+
+ It is useful to compare two versions of this form and
+ this function will do this job as long as the given
+ versions have the same format and same prefix.
+
+ Returns:
+ 0 if two versions are equal
+ 1 if version1 > version2
+ -1 if version1 < version2
+ None if two versions are completely differents
+ and can't be compared
+ """
+ version1_parts = re.findall('([^_.]+)', version1)
+ version2_parts = re.findall('([^_.]+)', version2)
+
+ for part1, part2 in zip(version1_parts, version2_parts):
+ if part1.isdigit() and part2.isdigit():
+ comp_value = cmp(int(part1), int(part2))
+ if comp_value != 0:
+ return comp_value
+ elif part1 != part2:
+ # Not equal string means not the same form
+ # or prefix so we can't compare them
+ return None
+
+ # if we are here it means all parts compared are equal.
+ # if there are some remaining parts, it means one version is longer.
+ # The longest is the most recent (1.22.1 is more recent than 1.22)
+ # so we just compare the size
+ return cmp(len(version1_parts), len(version2_parts))
+
+
def ProcessSoname(
ldd_emulator,
soname, path_and_pkg_by_basename, binary_info, isalist, binary_path, logger,
@@ -259,10 +291,21 @@
# We should then emulate ldd but that will not be for today...
pass
+ osrel = pkg_data['basic_stats']['parsed_basename']['osrel']
for version_dep in binary_elf_info['version needed']:
- if (version_dep['soname'] in ALLOWED_VERSION_DEPENDENCIES and
- not version_dep['version'] in
- ALLOWED_VERSION_DEPENDENCIES[version_dep['soname']]):
+ soname = version_dep['soname']
+ if not soname in ALLOWED_VERSION_DEPENDENCIES:
+ continue
+
+ allowed = False
+ versions_allowed = ALLOWED_VERSION_DEPENDENCIES[soname][osrel]
+ for version_ref in versions_allowed:
+ ret = CompareLibraryVersions(version_dep['version'], version_ref)
+ if ret is not None and ret <= 0:
+ allowed = True
+ break
+
+ if not allowed:
messenger.Message(
"Binary %s requires interface version %s in library %s which is"
" only available in recent Solaris releases."
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