1 # Copyright 1999-2014 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # This is a common location for functions that aid the use of sys-libs/db
5 # Bugs: maintainer-needed@gentoo.org
7 inherit versionator multilib
9 #Convert a version to a db slot
12 eerror "Function db_ver_to_slot needs one argument" >&2
13 eerror "args given:" >&2
16 eerror " - \"$@\"" >&2
20 # 5.0.x uses 5.0 as slot value, so this replacement will break it;
21 # older sys-libs/db might have been using this but it's no longer
22 # the case, so make it work for latest rather than older stuff.
27 #Find the version that correspond to the given atom
29 has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
31 eerror "Function db_findver needs one argument" >&2
32 eerror "args given:" >&2
35 eerror " - \"$@\"" >&2
40 PKG="$(best_version $1)"
41 VER="$(get_version_component_range 1-2 "${PKG/*db-/}")"
42 if [ -d "${EPREFIX}"/usr/include/db$(db_ver_to_slot "$VER") ]; then
43 #einfo "Found db version ${VER}" >&2
51 # Get the include dir for berkeley db.
52 # This function has two modes. Without any arguments it will give the best
53 # version available. With arguments that form the versions of db packages
54 # to test for, it will aim to find the library corresponding to it.
57 has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
59 VER="$(db_findver sys-libs/db)" || return 1
60 VER="$(db_ver_to_slot "$VER")"
61 echo "include version ${VER}" >&2
62 if [ -d "${EPREFIX}/usr/include/db${VER}" ]; then
63 echo -n "${EPREFIX}/usr/include/db${VER}"
66 eerror "sys-libs/db package requested, but headers not found" >&2
73 if VER=$(db_findver "=sys-libs/db-${x}*") &&
74 [ -d "${EPREFIX}/usr/include/db$(db_ver_to_slot $VER)" ]; then
75 echo -n "${EPREFIX}/usr/include/db$(db_ver_to_slot $VER)"
79 eerror "No suitable db version found"
85 # Get the library name for berkeley db. Something like "db-4.2" will be the
86 # outcome. This function has two modes. Without any arguments it will give
87 # the best version available. With arguments that form the versions of db
88 # packages to test for, it will aim to find the library corresponding to it.
91 has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
93 VER="$(db_findver sys-libs/db)" || return 1
94 if [ -e "${EPREFIX}/usr/$(get_libdir)/libdb-${VER}$(get_libname)" ]; then
98 eerror "sys-libs/db package requested, but library not found" >&2
105 if VER=$(db_findver "=sys-libs/db-${x}*"); then
106 if [ -e "${EPREFIX}/usr/$(get_libdir)/libdb-${VER}$(get_libname)" ]; then
112 eerror "No suitable db version found" >&2