diff options
author | Paul de Vrieze <pauldv@gentoo.org> | 2006-05-18 09:41:59 +0000 |
---|---|---|
committer | Paul de Vrieze <pauldv@gentoo.org> | 2006-05-18 09:41:59 +0000 |
commit | d06c3121a0a4247131d5ee21fee7a3193134afe4 (patch) | |
tree | e77484545c03ce7765980839387b05b9059c0369 /eclass | |
parent | Add a package.mask'd version for patch testing. (diff) | |
download | gentoo-2-d06c3121a0a4247131d5ee21fee7a3193134afe4.tar.gz gentoo-2-d06c3121a0a4247131d5ee21fee7a3193134afe4.tar.bz2 gentoo-2-d06c3121a0a4247131d5ee21fee7a3193134afe4.zip |
An eclass that helps with the use of berkeley db
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/db-use.eclass | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/eclass/db-use.eclass b/eclass/db-use.eclass new file mode 100644 index 000000000000..26eccc89b9d3 --- /dev/null +++ b/eclass/db-use.eclass @@ -0,0 +1,105 @@ +# Copyright 1999-2004 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/eclass/db-use.eclass,v 1.1 2006/05/18 09:41:59 pauldv Exp $ +# This is a common location for functions used in the sys-libs/db ebuilds + +inherit versionator + +#Convert a version to a db slot +ver_to_slot() { + if [ $# -ne 1 ]; then + eerror "Function ver_to_slot needs one argument" >&2 + eerror "args given:" >&2 + for f in $@ + do + eerror " - \"$@\"" >&2 + done + return 1 + fi + echo -n "${1/.0/}" +} + +#Find the version that correspond to the given atom +findver() { + if [ $# -ne 1 ]; then + eerror "Function findver needs one argument" >&2 + eerror "args given:" >&2 + for f in $@ + do + eerror " - \"$@\"" >&2 + done + return 1 + fi + + PKG="$(best_version $1)" + VER="$(get_version_component_range 1-2 "${PKG/*db-/}")" + if [ -d /usr/include/db$(ver_to_slot "$VER") ]; then + einfo "Found db version ${VER}" >&2 + echo -n "$VER" + return 0 + else + return 1 + fi +} + +# Get the include dir for berkeley db. +# This function has two modes. Without any arguments it will give the best +# version available. With arguments that form the versions of db packages +# to test for, it will aim to find the library corresponding to it. + +db_includedir() { + if [ $# -eq 0 ]; then + VER="$(findver sys-libs/db)" || return 1 + VER="$(ver_to_slot "$VER")" + echo "include version ${VER}" >&2 + if [ -d "/usr/include/db${VER}" ]; then + echo -n "/usr/include/db${VER}" + return 0 + else + eerror "sys-libs/db package requested, but headers not found" >&2 + return 1 + fi + else + #arguments given + for x in $@ + do + if VER=$(findver "=sys-libs/db-${x}*") && + [ -d "/usr/include/db$(ver_to_slot $VER)" ]; then + echo -n "/usr/include/db$(ver_to_slot $VER)" + return 0 + fi + done + eerror "No suitable db version found" + return 1 + fi +} + + +# Get the library name for berkeley db. Something like "db-4.2" will be the +# outcome. This function has two modes. Without any arguments it will give +# the best version available. With arguments that form the versions of db +# packages to test for, it will aim to find the library corresponding to it. + +db_libname() { + if [ $# -eq 0 ]; then + VER="$(findver sys-libs/db)" || return 1 + if [ -e "/usr/lib/libdb-${VER}" ]; then + echo -n "db-${VER}" + return 0 + else + eerror "sys-libs/db package requested, but library not found" >&2 + return 1 + fi + else + #arguments given + for x in $@ + do + if VER=$(findver "=sys-libs/db-${x}*"); then + echo -n "db-${VER}" + return 0 + fi + done + eerror "No suitable db version found" >&2 + return 1 + fi +} |