1 # Copyright 1999-2014 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 # This is a common location for functions that aid the use of sys-libs/db
6 # Bugs: maintainer-needed@gentoo.org
8 inherit versionator multilib
10 #Convert a version to a db slot
13 eerror "Function db_ver_to_slot needs one argument" >&2
14 eerror "args given:" >&2
17 eerror " - \"$@\"" >&2
21 # 5.0.x uses 5.0 as slot value, so this replacement will break it;
22 # older sys-libs/db might have been using this but it's no longer
23 # the case, so make it work for latest rather than older stuff.
28 #Find the version that correspond to the given atom
30 has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
32 eerror "Function db_findver needs one argument" >&2
33 eerror "args given:" >&2
36 eerror " - \"$@\"" >&2
41 PKG="$(best_version $1)"
42 VER="$(get_version_component_range 1-2 "${PKG/*db-/}")"
43 if [ -d "${EPREFIX}"/usr/include/db$(db_ver_to_slot "$VER") ]; then
44 #einfo "Found db version ${VER}" >&2
52 # Get the include dir for berkeley db.
53 # This function has two modes. Without any arguments it will give the best
54 # version available. With arguments that form the versions of db packages
55 # to test for, it will aim to find the library corresponding to it.
58 has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
60 VER="$(db_findver sys-libs/db)" || return 1
61 VER="$(db_ver_to_slot "$VER")"
62 echo "include version ${VER}" >&2
63 if [ -d "${EPREFIX}/usr/include/db${VER}" ]; then
64 echo -n "${EPREFIX}/usr/include/db${VER}"
67 eerror "sys-libs/db package requested, but headers not found" >&2
74 if VER=$(db_findver "=sys-libs/db-${x}*") &&
75 [ -d "${EPREFIX}/usr/include/db$(db_ver_to_slot $VER)" ]; then
76 echo -n "${EPREFIX}/usr/include/db$(db_ver_to_slot $VER)"
80 eerror "No suitable db version found"
86 # Get the library name for berkeley db. Something like "db-4.2" will be the
87 # outcome. This function has two modes. Without any arguments it will give
88 # the best version available. With arguments that form the versions of db
89 # packages to test for, it will aim to find the library corresponding to it.
92 has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
94 VER="$(db_findver sys-libs/db)" || return 1
95 if [ -e "${EPREFIX}/usr/$(get_libdir)/libdb-${VER}$(get_libname)" ]; then
99 eerror "sys-libs/db package requested, but library not found" >&2
106 if VER=$(db_findver "=sys-libs/db-${x}*"); then
107 if [ -e "${EPREFIX}/usr/$(get_libdir)/libdb-${VER}$(get_libname)" ]; then
113 eerror "No suitable db version found" >&2