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