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

Contents of /eclass/db-use.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.11 - (show annotations) (download)
Sun Jul 21 09:23:45 2013 UTC (17 months ago) by pacho
Branch: MAIN
Changes since 1.10: +3 -3 lines
Cleanup due #231248

1 # Copyright 1999-2013 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.10 2011/12/27 17:55:12 fauli 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 if [ $# -ne 1 ]; then
31 eerror "Function db_findver needs one argument" >&2
32 eerror "args given:" >&2
33 for f in $@
34 do
35 eerror " - \"$@\"" >&2
36 done
37 return 1
38 fi
39
40 PKG="$(best_version $1)"
41 VER="$(get_version_component_range 1-2 "${PKG/*db-/}")"
42 if [ -d /usr/include/db$(db_ver_to_slot "$VER") ]; then
43 #einfo "Found db version ${VER}" >&2
44 echo -n "$VER"
45 return 0
46 else
47 return 1
48 fi
49 }
50
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.
55
56 db_includedir() {
57 if [ $# -eq 0 ]; then
58 VER="$(db_findver sys-libs/db)" || return 1
59 VER="$(db_ver_to_slot "$VER")"
60 echo "include version ${VER}" >&2
61 if [ -d "/usr/include/db${VER}" ]; then
62 echo -n "/usr/include/db${VER}"
63 return 0
64 else
65 eerror "sys-libs/db package requested, but headers not found" >&2
66 return 1
67 fi
68 else
69 #arguments given
70 for x in $@
71 do
72 if VER=$(db_findver "=sys-libs/db-${x}*") &&
73 [ -d "/usr/include/db$(db_ver_to_slot $VER)" ]; then
74 echo -n "/usr/include/db$(db_ver_to_slot $VER)"
75 return 0
76 fi
77 done
78 eerror "No suitable db version found"
79 return 1
80 fi
81 }
82
83
84 # Get the library name for berkeley db. Something like "db-4.2" will be the
85 # outcome. This function has two modes. Without any arguments it will give
86 # the best version available. With arguments that form the versions of db
87 # packages to test for, it will aim to find the library corresponding to it.
88
89 db_libname() {
90 if [ $# -eq 0 ]; then
91 VER="$(db_findver sys-libs/db)" || return 1
92 if [ -e "/usr/$(get_libdir)/libdb-${VER}.so" ]; then
93 echo -n "db-${VER}"
94 return 0
95 else
96 eerror "sys-libs/db package requested, but library not found" >&2
97 return 1
98 fi
99 else
100 #arguments given
101 for x in $@
102 do
103 if VER=$(db_findver "=sys-libs/db-${x}*"); then
104 if [ -e "/usr/$(get_libdir)/libdb-${VER}.so" ]; then
105 echo -n "db-${VER}"
106 return 0
107 fi
108 fi
109 done
110 eerror "No suitable db version found" >&2
111 return 1
112 fi
113 }

  ViewVC Help
Powered by ViewVC 1.1.20