/[gentoo-x86]/eclass/db-use.eclass
Gentoo

Contents of /eclass/db-use.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.12 - (show annotations) (download)
Fri Aug 8 17:57:28 2014 UTC (4 years, 8 months ago) by ottxor
Branch: MAIN
CVS Tags: HEAD
Changes since 1.11: +12 -9 lines
added prefix support

1 # Copyright 1999-2014 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/db-use.eclass,v 1.11 2013/07/21 09:23:45 pacho Exp $
4 # This is a common location for functions that aid the use of sys-libs/db
5 #
6 # Bugs: maintainer-needed@gentoo.org
7
8 inherit versionator multilib
9
10 #Convert a version to a db slot
11 db_ver_to_slot() {
12 if [ $# -ne 1 ]; then
13 eerror "Function db_ver_to_slot needs one argument" >&2
14 eerror "args given:" >&2
15 for f in $@
16 do
17 eerror " - \"$@\"" >&2
18 done
19 return 1
20 fi
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.
24 # echo -n "${1/.0/}"
25 echo -n "$1"
26 }
27
28 #Find the version that correspond to the given atom
29 db_findver() {
30 has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
31 if [ $# -ne 1 ]; then
32 eerror "Function db_findver needs one argument" >&2
33 eerror "args given:" >&2
34 for f in $@
35 do
36 eerror " - \"$@\"" >&2
37 done
38 return 1
39 fi
40
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
45 echo -n "$VER"
46 return 0
47 else
48 return 1
49 fi
50 }
51
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.
56
57 db_includedir() {
58 has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
59 if [ $# -eq 0 ]; then
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}"
65 return 0
66 else
67 eerror "sys-libs/db package requested, but headers not found" >&2
68 return 1
69 fi
70 else
71 #arguments given
72 for x in $@
73 do
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)"
77 return 0
78 fi
79 done
80 eerror "No suitable db version found"
81 return 1
82 fi
83 }
84
85
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.
90
91 db_libname() {
92 has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
93 if [ $# -eq 0 ]; then
94 VER="$(db_findver sys-libs/db)" || return 1
95 if [ -e "${EPREFIX}/usr/$(get_libdir)/libdb-${VER}$(get_libname)" ]; then
96 echo -n "db-${VER}"
97 return 0
98 else
99 eerror "sys-libs/db package requested, but library not found" >&2
100 return 1
101 fi
102 else
103 #arguments given
104 for x in $@
105 do
106 if VER=$(db_findver "=sys-libs/db-${x}*"); then
107 if [ -e "${EPREFIX}/usr/$(get_libdir)/libdb-${VER}$(get_libname)" ]; then
108 echo -n "db-${VER}"
109 return 0
110 fi
111 fi
112 done
113 eerror "No suitable db version found" >&2
114 return 1
115 fi
116 }

  ViewVC Help
Powered by ViewVC 1.1.20