1 # Copyright 1999-2013 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 # This is a common location for functions used in the sys-libs/db ebuilds
6 # Bugs: maintainer-needed@gentoo.org
8 inherit eutils multilib
10 IUSE="doc test examples"
12 EXPORT_FUNCTIONS src_test
14 DEPEND="test? ( >=dev-lang/tcl-8.4 )"
19 LIB="${ROOT}/usr/$(get_libdir)"
23 # first clean up old symlinks
24 find "${LIB}" -maxdepth 1 -type l -name 'libdb[1._-]*so' -exec rm \{} \;
25 find "${LIB}" -maxdepth 1 -type l -name 'libdb[1._-]*so.[23]' -exec rm \{} \;
26 find "${LIB}" -maxdepth 1 -type l -name 'libdb[1._-]*a' -exec rm \{} \;
28 # now rebuild all the correct ones
30 for name in libdb libdb_{cxx,tcl,java,sql,stl}; do
31 target=`find . -maxdepth 1 -type f -name "${name}-*.${ext}" |sort -n |tail -n 1`
32 [ -n "${target}" ] && ln -sf ${target//.\//} ${name}.${ext}
36 # db[23] gets some extra-special stuff
37 if [ -f libdb1.so.2 ]; then
38 ln -sf libdb1.so.2 libdb.so.2
39 ln -sf libdb1.so.2 libdb1.so
40 ln -sf libdb1.so.2 libdb-1.so
42 # what do we do if we ever get 3.3 ?
43 for i in libdb libdb_{cxx,tcl,java,sql,stl}; do
44 if [ -f $i-3.2.so ]; then
45 ln -sf $i-3.2.so $i-3.so
46 ln -sf $i-3.2.so $i.so.3
50 # do the same for headers now
51 # but since there are only two of them, just overwrite them
52 cd "${ROOT}"/usr/include
53 target=`find . -maxdepth 1 -type d -name 'db[0-9]*' | sort -n |cut -d/ -f2- | tail -n1`
54 if [ -n "${target}" ] && [ -e "${target}/db.h" ] && ( ! [[ -e db.h ]] || [[ -h db.h ]] ); then
55 einfo "Creating db.h symlinks to ${target}"
56 ln -sf "${target}"/db.h .
57 ln -sf "${target}"/db_185.h .
58 elif [ ! -e "${target}/db.h" ]; then
59 if [ -n "${target}" ]; then
60 ewarn "Could not find ${target}/db.h"
61 elif [ -h db.h ]; then
62 einfo "Apparently you just removed the last instance of $PN. Removing the symlinks"
68 db_src_install_doc() {
69 # not everybody wants this wad of documentation as it is primarily API docs
71 dodir /usr/share/doc/${PF}/html
72 mv "${D}"/usr/docs/* "${D}"/usr/share/doc/${PF}/html/
73 rm -rf "${D}"/usr/docs
75 rm -rf "${D}"/usr/docs
78 db_src_install_examples
81 db_src_install_examples() {
82 if use examples ; then
83 local langs="c cxx stl"
84 [[ "${IUSE/java}" != "${IUSE}" ]] \
86 && langs="${langs} java"
88 destdir="/usr/share/doc/${PF}/"
89 src="${S}/../examples_${i}/"
90 if [ -f "${src}" ]; then
92 cp -ra "${src}" "${D}${destdir}/"
98 db_src_install_usrbinslot() {
99 # slot all program names to avoid overwriting
100 for fname in "${D}"/usr/bin/db*
102 dn="$(dirname "${fname}")"
103 bn="$(basename "${fname}")"
104 bn="${bn/db/db${SLOT}}"
105 mv "${fname}" "${dn}/${bn}" || \
106 die "Failed to rename ${fname} to ${dn}/${bn}"
110 db_src_install_headerslot() {
111 # install all headers in a slotted location
112 dodir /usr/include/db${SLOT}
113 mv "${D}"/usr/include/*.h "${D}"/usr/include/db${SLOT}/
116 db_src_install_usrlibcleanup() {
117 LIB="${D}/usr/$(get_libdir)"
118 # Clean out the symlinks so that they will not be recorded in the
119 # contents (bug #60732)
121 if [ "${D}" = "" ]; then
122 die "Calling clean_links while \$D not defined"
125 if [ -e "${LIB}"/libdb.a ] && [ ! -e "${LIB}"/libdb-${SLOT}.a ]; then
126 einfo "Moving libdb.a to a versioned name"
127 mv "${LIB}/libdb.a" "${LIB}/libdb-${SLOT}.a"
130 if [ -e "${LIB}"/libdb_cxx.a ] && [ ! -e "${LIB}"/libdb_cxx-${SLOT}.a ]; then
131 einfo "Moving libdb_cxx.a to a versioned name"
132 mv "${LIB}/libdb_cxx.a" "${LIB}/libdb_cxx-${SLOT}.a"
135 find "${LIB}" -maxdepth 1 -type l -name 'libdb[1._-]*so' -exec rm \{} \;
136 find "${LIB}" -maxdepth 1 -type l -name 'libdb[1._-]*so.[23]' -exec rm \{} \;
137 einfo "removing unversioned static archives"
138 find "${LIB}" -maxdepth 1 -type l -name 'libdb[1._-]*a' -exec rm \{} \;
141 "${D}"/usr/include/{db,db_185}.h \
142 "${LIB}"/libdb{,_{cxx,sql,stl,java,tcl}}.a
146 if [[ $UID -eq 0 ]]; then
147 M="You must run the testsuite as non-root, skipping"
154 einfo "Running sys-libs/db testsuite"
155 ewarn "This can take 6+ hours on modern machines"
156 # Fix stuff that fails with relative paths, and upstream moving files
158 local test_parallel=''
160 "${S}"/test/parallel.tcl \
161 "${S}"/../test/parallel.tcl \
162 "${S}"/test/tcl/parallel.tcl \
163 "${S}"/../test/tcl/parallel.tcl \
165 [[ -f "${t}" ]] && test_parallel="${t}" && break
169 -e '/regsub .test_path ./s,(regsub),#\1,g' \
170 -e '/regsub .src_root ./s,(regsub),#\1,g' \
171 -e '/regsub .tcl_utils ./s,(regsub),#\1,g' \
176 ../test/tcl/test.tcl \
178 [[ -f "${t}" ]] && testbase="${t}" && break
180 echo "source ${t}" > testrunner.tcl
181 echo "run_parallel $(makeopts_jobs) run_std" >> testrunner.tcl
184 egrep -qs '^FAIL' ALL.OUT* && die "Some tests failed, please see ${S}/ALL.OUT*"
186 eerror "You must have USE=tcl to run the sys-libs/db testsuite."