net-wireless/crda: x86 stable, bug #582076
[gentoo.git] / sys-libs / db / db-6.2.23.ebuild
1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6 inherit eutils db flag-o-matic java-pkg-opt-2 autotools multilib multilib-minimal versionator toolchain-funcs
7
8 #Number of official patches
9 #PATCHNO=`echo ${PV}|sed -e "s,\(.*_p\)\([0-9]*\),\2,"`
10 PATCHNO=${PV/*.*.*_p}
11 if [[ ${PATCHNO} == "${PV}" ]] ; then
12         MY_PV=${PV}
13         MY_P=${P}
14         PATCHNO=0
15 else
16         MY_PV=${PV/_p${PATCHNO}}
17         MY_P=${PN}-${MY_PV}
18 fi
19
20 S_BASE="${WORKDIR}/${MY_P}"
21 S="${S_BASE}/build_unix"
22 DESCRIPTION="Oracle Berkeley DB"
23 HOMEPAGE="http://www.oracle.com/technology/software/products/berkeley-db/index.html"
24 SRC_URI="http://download.oracle.com/berkeley-db/${MY_P}.tar.gz"
25 for (( i=1 ; i<=${PATCHNO} ; i++ )) ; do
26         export SRC_URI="${SRC_URI} http://www.oracle.com/technology/products/berkeley-db/db/update/${MY_PV}/patch.${MY_PV}.${i}"
27 done
28
29 LICENSE="AGPL-3"
30 SLOT="$(get_version_component_range 1-2)"
31 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~sparc-fbsd ~x86-fbsd"
32 IUSE="doc java cxx tcl test"
33
34 REQUIRED_USE="test? ( tcl )"
35
36 # the entire testsuite needs the TCL functionality
37 DEPEND="tcl? ( >=dev-lang/tcl-8.5.15-r1:0=[${MULTILIB_USEDEP}] )
38         test? ( >=dev-lang/tcl-8.5.15-r1:0=[${MULTILIB_USEDEP}] )
39         java? ( >=virtual/jdk-1.5 )
40         >=sys-devel/binutils-2.16.1"
41 RDEPEND="tcl? ( >=dev-lang/tcl-8.5.15-r1:0=[${MULTILIB_USEDEP}] )
42         java? ( >=virtual/jre-1.5 )"
43
44 MULTILIB_WRAPPED_HEADERS=(
45         /usr/include/db$(get_version_component_range 1-2)/db.h
46 )
47
48 PATCHES=(
49         # bug #510506
50         "${FILESDIR}"/${PN}-4.8.24-java-manifest-location.patch
51
52         # use the includes from the prefix
53         "${FILESDIR}"/${PN}-6.2-jni-check-prefix-first.patch
54         "${FILESDIR}"/${PN}-4.3-listen-to-java-options.patch
55
56         # sqlite configure call has an extra leading ..
57         # upstreamed:5.2.36, missing in 5.3.x/6.x
58         # still needs to be patched in 6.0.20
59         "${FILESDIR}"/${PN}-6.1.19-sqlite-configure-path.patch
60
61         # The upstream testsuite copies .lib and the binaries for each parallel test
62         # core, ~300MB each. This patch uses links instead, saves a lot of space.
63         "${FILESDIR}"/${PN}-6.0.20-test-link.patch
64 )
65
66 src_prepare() {
67         cd "${WORKDIR}"/"${MY_P}"
68         for (( i=1 ; i<=${PATCHNO} ; i++ ))
69         do
70                 epatch "${DISTDIR}"/patch."${MY_PV}"."${i}"
71         done
72
73         epatch "${PATCHES[@]}"
74         epatch_user
75
76         # Upstream release script grabs the dates when the script was run, so lets
77         # end-run them to keep the date the same.
78         export REAL_DB_RELEASE_DATE="$(awk \
79                 '/^DB_VERSION_STRING=/{ gsub(".*\\(|\\).*","",$0); print $0; }' \
80                 "${S_BASE}"/dist/configure)"
81         sed -r -i \
82                 -e "/^DB_RELEASE_DATE=/s~=.*~='${REAL_DB_RELEASE_DATE}'~g" \
83                 "${S_BASE}"/dist/RELEASE || die
84
85         # Include the SLOT for Java JAR files
86         # This supersedes the unused jarlocation patches.
87         sed -r -i \
88                 -e '/jarfile=.*\.jar$/s,(.jar$),-$(LIBVERSION)\1,g' \
89                 "${S_BASE}"/dist/Makefile.in || die
90
91         cd "${S_BASE}"/dist || die
92         rm -f aclocal/libtool.m4
93         sed -i \
94                 -e '/AC_PROG_LIBTOOL$/aLT_OUTPUT' \
95                 configure.ac || die
96         sed -i \
97                 -e '/^AC_PATH_TOOL/s/ sh, none/ bash, none/' \
98                 aclocal/programs.m4 || die
99         AT_M4DIR="aclocal aclocal_java" eautoreconf
100         # Upstream sucks - they do autoconf and THEN replace the version variables.
101         . ./RELEASE
102         for v in \
103                 DB_VERSION_{FAMILY,LETTER,RELEASE,MAJOR,MINOR} \
104                 DB_VERSION_{PATCH,FULL,UNIQUE_NAME,STRING,FULL_STRING} \
105                 DB_VERSION \
106                 DB_RELEASE_DATE ; do
107                 local ev="__EDIT_${v}__"
108                 sed -i -e "s/${ev}/${!v}/g" configure || die
109         done
110 }
111
112 multilib_src_configure() {
113         local myconf=()
114
115         tc-ld-disable-gold #470634
116
117         # compilation with -O0 fails on amd64, see bug #171231
118         if [[ ${ABI} == amd64 ]]; then
119                 local CFLAGS=${CFLAGS} CXXFLAGS=${CXXFLAGS}
120                 replace-flags -O0 -O2
121                 is-flagq -O[s123] || append-flags -O2
122         fi
123
124         # Add linker versions to the symbols. Easier to do, and safer than header file
125         # mumbo jumbo.
126         if use userland_GNU ; then
127                 append-ldflags -Wl,--default-symver
128         fi
129
130         # use `set` here since the java opts will contain whitespace
131         if multilib_is_native_abi && use java ; then
132                 myconf+=(
133                         --with-java-prefix="${JAVA_HOME}"
134                         --with-javac-flags="$(java-pkg_javac-args)"
135                 )
136         fi
137
138         # Bug #270851: test needs TCL support
139         if use tcl || use test ; then
140                 myconf+=(
141                         --enable-tcl
142                         --with-tcl=/usr/$(get_libdir)
143                 )
144         else
145                 myconf+=(--disable-tcl )
146         fi
147
148         # sql_compat will cause a collision with sqlite3
149         # --enable-sql_compat
150         ECONF_SOURCE="${S_BASE}"/dist \
151         STRIP="true" \
152         econf \
153                 --enable-compat185 \
154                 --enable-dbm \
155                 --enable-o_direct \
156                 --without-uniquename \
157                 --enable-sql \
158                 --enable-sql_codegen \
159                 --disable-sql_compat \
160                 $([[ ${ABI} == arm ]] && echo --with-mutex=ARM/gcc-assembly) \
161                 $([[ ${ABI} == amd64 ]] && echo --with-mutex=x86/gcc-assembly) \
162                 $(use_enable cxx) \
163                 $(use_enable cxx stl) \
164                 $(multilib_native_use_enable java) \
165                 "${myconf[@]}" \
166                 $(use_enable test)
167 }
168
169 multilib_src_install() {
170         emake install DESTDIR="${D}"
171
172         db_src_install_headerslot
173
174         db_src_install_usrlibcleanup
175
176         if multilib_is_native_abi && use java; then
177                 java-pkg_regso "${D}"/usr/"$(get_libdir)"/libdb_java*.so
178                 java-pkg_dojar "${D}"/usr/"$(get_libdir)"/*.jar
179                 rm -f "${D}"/usr/"$(get_libdir)"/*.jar
180         fi
181 }
182
183 multilib_src_install_all() {
184         db_src_install_usrbinslot
185
186         db_src_install_doc
187
188         dodir /usr/sbin
189         # This file is not always built, and no longer exists as of db-4.8
190         if [[ -f "${D}"/usr/bin/berkeley_db_svc ]] ; then
191                 mv "${D}"/usr/bin/berkeley_db_svc \
192                         "${D}"/usr/sbin/berkeley_db"${SLOT/./}"_svc || die
193         fi
194 }
195
196 pkg_postinst() {
197         multilib_foreach_abi db_fix_so
198 }
199
200 pkg_postrm() {
201         multilib_foreach_abi db_fix_so
202 }
203
204 src_test() {
205         # db_repsite is impossible to build, as upstream strips those sources.
206         # db_repsite is used directly in the setup_site_prog,
207         # setup_site_prog is called from open_site_prog
208         # which is called only from tests in the multi_repmgr group.
209         #sed -ri \
210         #       -e '/set subs/s,multi_repmgr,,g' \
211         #       "${S_BASE}/test/testparams.tcl"
212         sed -ri \
213                 -e '/multi_repmgr/d' \
214                 "${S_BASE}/test/tcl/test.tcl" || die
215
216         # This is the only failure in 5.2.28 so far, and looks like a false positive.
217         # Repmgr018 (btree): Test of repmgr stats.
218         #     Repmgr018.a: Start a master.
219         #     Repmgr018.b: Start a client.
220         #     Repmgr018.c: Run some transactions at master.
221         #         Rep_test: btree 20 key/data pairs starting at 0
222         #         Rep_test.a: put/get loop
223         # FAIL:07:05:59 (00:00:00) perm_no_failed_stat: expected 0, got 1
224         sed -ri \
225                 -e '/set parms.*repmgr018/d' \
226                 -e 's/repmgr018//g' \
227                 "${S_BASE}/test/tcl/test.tcl" || die
228
229         multilib-minimal_src_test
230 }
231
232 multilib_src_test() {
233         multilib_is_native_abi || return
234
235         S=${BUILD_DIR} db_src_test
236 }