dev-vcs/subversion: stable 1.10.4 for sparc, bug #676094
[gentoo.git] / dev-vcs / subversion / subversion-1.9.7-r1.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 PYTHON_COMPAT=( python2_7 )
7 USE_RUBY="ruby23 ruby22 ruby21"
8 DISTUTILS_OPTIONAL=1
9 WANT_AUTOMAKE="none"
10 GENTOO_DEPEND_ON_PERL="no"
11
12 inherit autotools bash-completion-r1 db-use depend.apache distutils-r1 elisp-common eutils flag-o-matic java-pkg-opt-2 libtool multilib perl-module ruby-single xdg-utils
13
14 MY_P="${P/_/-}"
15 DESCRIPTION="Advanced version control system"
16 HOMEPAGE="https://subversion.apache.org/"
17 SRC_URI="mirror://apache/${PN}/${MY_P}.tar.bz2
18         https://dev.gentoo.org/~mgorny/dist/${PN}-1.8.18-patchset.tar.bz2"
19 S="${WORKDIR}/${MY_P}"
20
21 LICENSE="Subversion GPL-2"
22 SLOT="0"
23 KEYWORDS="alpha amd64 arm ~arm64 hppa ia64 ~mips ppc ppc64 s390 ~sh sparc x86 ~ppc-aix ~x64-cygwin ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
24 IUSE="apache2 berkdb ctypes-python debug doc +dso extras gnome-keyring +http java kwallet nls perl python ruby sasl test vim-syntax"
25
26 COMMON_DEPEND="
27         app-arch/bzip2
28         >=dev-db/sqlite-3.7.12
29         >=dev-libs/apr-1.3:1
30         >=dev-libs/apr-util-1.3:1
31         dev-libs/expat
32         sys-apps/file
33         sys-libs/zlib
34         berkdb? ( >=sys-libs/db-4.0.14:= )
35         ctypes-python? ( ${PYTHON_DEPS} )
36         gnome-keyring? (
37                 dev-libs/glib:2
38                 gnome-base/libgnome-keyring
39                 sys-apps/dbus
40         )
41         http? ( >=net-libs/serf-1.3.4 )
42         kwallet? (
43                 dev-qt/qtcore:5
44                 dev-qt/qtdbus:5
45                 dev-qt/qtgui:5
46                 kde-frameworks/kcoreaddons:5
47                 kde-frameworks/ki18n:5
48                 kde-frameworks/kwallet:5
49                 sys-apps/dbus
50         )
51         perl? ( dev-lang/perl:= )
52         python? ( ${PYTHON_DEPS} )
53         ruby? ( ${RUBY_DEPS} )
54         sasl? ( dev-libs/cyrus-sasl )"
55 RDEPEND="${COMMON_DEPEND}
56         apache2? ( www-servers/apache[apache2_modules_dav] )
57         java? ( >=virtual/jre-1.5 )
58         nls? ( virtual/libintl )
59         perl? ( dev-perl/URI )"
60 # Note: ctypesgen doesn't need PYTHON_USEDEP, it's used once
61 DEPEND="${COMMON_DEPEND}
62         !!<sys-apps/sandbox-1.6
63         ctypes-python? ( dev-python/ctypesgen )
64         doc? ( app-doc/doxygen )
65         gnome-keyring? ( virtual/pkgconfig )
66         http? ( virtual/pkgconfig )
67         java? ( >=virtual/jdk-1.5 )
68         kwallet? (
69                 kde-frameworks/kdelibs4support:5
70                 virtual/pkgconfig
71         )
72         nls? ( sys-devel/gettext )
73         test? ( ${PYTHON_DEPS} )"
74
75 REQUIRED_USE="
76         ctypes-python? ( ${PYTHON_REQUIRED_USE} )
77         python? ( ${PYTHON_REQUIRED_USE} )
78         test? (
79                 ${PYTHON_REQUIRED_USE}
80                 !dso
81         )"
82
83 PATCHES=(
84         "${WORKDIR}"/${PN}-1.8.18-patchset/${PN}-1.5.4-interix.patch
85         "${WORKDIR}"/${PN}-1.8.18-patchset/${PN}-1.5.6-aix-dso.patch
86         "${WORKDIR}"/${PN}-1.8.18-patchset/${PN}-1.8.0-hpux-dso.patch
87         "${WORKDIR}"/${PN}-1.8.18-patchset/${PN}-fix-parallel-build-support-for-perl-bindings.patch
88         "${WORKDIR}"/${PN}-1.8.18-patchset/${PN}-1.8.1-revert_bdb6check.patch
89         "${WORKDIR}"/${PN}-1.8.18-patchset/${PN}-1.8.16-javadoc-nolint.patch
90         "${FILESDIR}"/${P}-kf5.patch
91         "${FILESDIR}"/${PN}-1.9.7-fix-wc-queries-test-test.patch
92 )
93
94 want_apache
95
96 pkg_setup() {
97         if use berkdb ; then
98                 local apu_bdb_version="$(${EPREFIX}/usr/bin/apu-1-config --includes \
99                         | grep -Eoe '-I${EPREFIX}/usr/include/db[[:digit:]]\.[[:digit:]]' \
100                         | sed 's:.*b::')"
101                 einfo
102                 if [[ -z "${SVN_BDB_VERSION}" ]] ; then
103                         if [[ -n "${apu_bdb_version}" ]] ; then
104                                 SVN_BDB_VERSION="${apu_bdb_version}"
105                                 einfo "Matching db version to apr-util"
106                         else
107                                 SVN_BDB_VERSION="$(db_ver_to_slot "$(db_findver sys-libs/db 2>/dev/null)")"
108                                 einfo "SVN_BDB_VERSION variable isn't set. You can set it to enforce using of specific version of Berkeley DB."
109                         fi
110                 fi
111                 einfo "Using: Berkeley DB ${SVN_BDB_VERSION}"
112                 einfo
113
114                 if [[ -n "${apu_bdb_version}" && "${SVN_BDB_VERSION}" != "${apu_bdb_version}" ]]; then
115                         eerror "APR-Util is linked against Berkeley DB ${apu_bdb_version}, but you are trying"
116                         eerror "to build Subversion with support for Berkeley DB ${SVN_BDB_VERSION}."
117                         eerror "Rebuild dev-libs/apr-util or set SVN_BDB_VERSION=\"${apu_bdb_version}\"."
118                         eerror "Aborting to avoid possible run-time crashes."
119                         die "Berkeley DB version mismatch"
120                 fi
121         fi
122
123         depend.apache_pkg_setup
124
125         java-pkg-opt-2_pkg_setup
126
127         if ! use http ; then
128                 ewarn "WebDAV support is disabled. You need WebDAV to"
129                 ewarn "access repositories through the HTTP protocol."
130                 ewarn "Consider enabling \"http\" USE flag"
131                 echo -ne "\a"
132         fi
133
134         if use debug ; then
135                 append-cppflags -DSVN_DEBUG -DAP_DEBUG
136         fi
137
138         # http://mail-archives.apache.org/mod_mbox/subversion-dev/201306.mbox/%3C51C42014.3060700@wandisco.com%3E
139         [[ ${CHOST} == *-solaris2* ]] && append-cppflags -D__EXTENSIONS__
140
141         # Allow for custom repository locations.
142         SVN_REPOS_LOC="${SVN_REPOS_LOC:-${EPREFIX}/var/svn}"
143
144         if use ruby ; then
145                 local rbslot
146                 RB_VER=""
147                 for rbslot in $(sed 's@\([[:digit:]]\+\)\([[:digit:]]\)@\1.\2@g' <<< ${USE_RUBY//ruby}) ; do
148                         if has_version dev-lang/ruby:${rbslot} ;  then
149                                 RB_VER="${rbslot/.}"
150                                 break
151                         fi
152                 done
153                 [[ -z "${RB_VER}" ]] && die "No useable ruby version found"
154         fi
155 }
156
157 src_prepare() {
158         default
159
160         fperms +x build/transform_libtool_scripts.sh
161
162         sed -i \
163                 -e "s/\(BUILD_RULES=.*\) bdb-test\(.*\)/\1\2/g" \
164                 -e "s/\(BUILD_RULES=.*\) test\(.*\)/\1\2/g" configure.ac
165
166         # this bites us in particular on Solaris
167         sed -i -e '1c\#!/usr/bin/env sh' build/transform_libtool_scripts.sh || \
168                 die "/bin/sh is not POSIX shell!"
169
170         eautoconf
171         elibtoolize
172
173         sed -e 's/\(libsvn_swig_py\)-\(1\.la\)/\1-$(EPYTHON)-\2/g' \
174                 -i build-outputs.mk || die "sed failed"
175
176         if use python ; then
177                 # XXX: make python_copy_sources accept path
178                 S=${S}/subversion/bindings/swig/python python_copy_sources
179                 rm -r "${S}"/subversion/bindings/swig/python || die
180         fi
181
182         xdg_environment_reset
183 }
184
185 src_configure() {
186         local myconf=(
187                 --libdir="${EPREFIX%/}/usr/$(get_libdir)"
188                 $(use_with apache2 apache-libexecdir)
189                 $(use_with apache2 apxs "${APXS}")
190                 $(use_with berkdb berkeley-db "db.h:${EPREFIX%/}/usr/include/db${SVN_BDB_VERSION}::db-${SVN_BDB_VERSION}")
191                 $(use_with ctypes-python ctypesgen "${EPREFIX%/}/usr")
192                 $(use_enable dso runtime-module-search)
193                 $(use_with gnome-keyring)
194                 $(use_enable java javahl)
195                 $(use_with java jdk "${JAVA_HOME}")
196                 $(use_with kwallet)
197                 $(use_enable nls)
198                 $(use_with sasl)
199                 $(use_with http serf)
200                 --with-apr="${EPREFIX%/}/usr/bin/apr-1-config"
201                 --with-apr-util="${EPREFIX%/}/usr/bin/apu-1-config"
202                 --disable-experimental-libtool
203                 --without-jikes
204                 --disable-mod-activation
205                 --disable-static
206         )
207
208         if use python || use perl || use ruby; then
209                 myconf+=( --with-swig )
210         else
211                 myconf+=( --without-swig )
212         fi
213
214         if use java ; then
215                 myconf+=( --without-junit )
216         fi
217
218         case ${CHOST} in
219                 *-aix*)
220                         # avoid recording immediate path to sharedlibs into executables
221                         append-ldflags -Wl,-bnoipath
222                 ;;
223                 *-cygwin*)
224                         # no LD_PRELOAD support, no undefined symbols
225                         myconf+=( --disable-local-library-preloading LT_LDFLAGS=-no-undefined )
226                         ;;
227                 *-interix*)
228                         # loader crashes on the LD_PRELOADs...
229                         myconf+=( --disable-local-library-preloading )
230                 ;;
231                 *-solaris*)
232                         # need -lintl to link
233                         use nls && append-libs intl
234                         # this breaks installation, on x64 echo replacement is 32-bits
235                         myconf+=( --disable-local-library-preloading )
236                 ;;
237                 *-mint*)
238                         myconf+=( --enable-all-static --disable-local-library-preloading )
239                 ;;
240                 *)
241                         # inject LD_PRELOAD entries for easy in-tree development
242                         myconf+=( --enable-local-library-preloading )
243                 ;;
244         esac
245
246         #version 1.7.7 again tries to link against the older installed version and fails, when trying to
247         #compile for x86 on amd64, so workaround this issue again
248         #check newer versions, if this is still/again needed
249         myconf+=( --disable-disallowing-of-undefined-references )
250
251         # for build-time scripts
252         if use ctypes-python || use python || use test; then
253                 python_setup
254         fi
255
256         if use python && [[ ${CHOST} == *-darwin* ]] ; then
257                 export ac_cv_python_link="$(tc-getCC) "'$(PYTHON_CFLAGS) -bundle -undefined dynamic_lookup $(PYTHON_LIBS)'
258                 export ac_cv_python_libs='$(PYTHON_CFLAGS) -bundle -undefined dynamic_lookup $(PYTHON_LIBS)'
259                 export ac_cv_python_compile="$(tc-getCC)"
260         fi
261
262         # allow overriding Python include directory
263         ac_cv_path_RUBY=$(usex ruby "${EPREFIX%/}/usr/bin/ruby${RB_VER}" "none") \
264         ac_cv_path_RDOC=$(usex ruby "${EPREFIX%/}/usr/bin/rdoc${RB_VER}" "none") \
265         ac_cv_python_includes='-I$(PYTHON_INCLUDEDIR)' \
266         econf "${myconf[@]}"
267 }
268
269 src_compile() {
270         emake local-all
271
272         if use ctypes-python ; then
273                 # pre-generate .py files
274                 use ctypes-python && emake ctypes-python
275
276                 pushd subversion/bindings/ctypes-python >/dev/null || die
277                 distutils-r1_src_compile
278                 popd >/dev/null || die
279         fi
280
281         if use python ; then
282                 swig_py_compile() {
283                         local p=subversion/bindings/swig/python
284                         rm -f ${p} || die
285                         ln -s "${BUILD_DIR}" ${p} || die
286
287                         python_export PYTHON_INCLUDEDIR
288                         emake swig-py \
289                                 swig_pydir="$(python_get_sitedir)/libsvn" \
290                                 swig_pydir_extra="$(python_get_sitedir)/svn"
291                 }
292
293                 # this will give us proper BUILD_DIR for symlinking
294                 BUILD_DIR=python \
295                 python_foreach_impl swig_py_compile
296         fi
297
298         if use perl ; then
299                 emake swig-pl
300         fi
301
302         if use ruby ; then
303                 emake swig-rb
304         fi
305
306         if use java ; then
307                 emake -j1 JAVAC_FLAGS="$(java-pkg_javac-args) -encoding iso8859-1" javahl
308         fi
309
310         if use extras ; then
311                 emake tools
312         fi
313
314         if use doc ; then
315                 doxygen doc/doxygen.conf || die "Building of Subversion HTML documentation failed"
316
317                 if use java; then
318                         emake doc-javahl
319                 fi
320         fi
321 }
322
323 src_test() {
324         if has_version ~${CATEGORY}/${P} ; then
325                 default
326
327                 if use ctypes-python ; then
328                         python_test() {
329                                 "${PYTHON}" subversion/bindings/ctypes-python/test/run_all.py \
330                                         || die "ctypes-python tests fail with ${EPYTHON}"
331                         }
332
333                         distutils-r1_src_test
334                 fi
335
336                 if use python ; then
337                         swig_py_test() {
338                                 pushd "${BUILD_DIR}" >/dev/null || die
339                                 "${PYTHON}" tests/run_all.py || die "swig-py tests fail with ${EPYTHON}"
340                                 popd >/dev/null || die
341                         }
342
343                         BUILD_DIR=subversion/bindings/swig/python \
344                         python_foreach_impl swig_py_test
345                 fi
346         else
347                 ewarn "The test suite shows errors when there is an older version of"
348                 ewarn "${CATEGORY}/${PN} installed. Please install =${CATEGORY}/${P}*"
349                 ewarn "before running the test suite."
350                 ewarn "Test suite skipped."
351         fi
352 }
353
354 src_install() {
355         emake -j1 DESTDIR="${D}" local-install
356
357         if use ctypes-python ; then
358                 pushd subversion/bindings/ctypes-python >/dev/null || die
359                 distutils-r1_src_install
360                 popd >/dev/null || die
361         fi
362
363         if use python ; then
364                 swig_py_install() {
365                         local p=subversion/bindings/swig/python
366                         rm -f ${p} || die
367                         ln -s "${BUILD_DIR}" ${p} || die
368
369                         emake \
370                                 DESTDIR="${D}" \
371                                 swig_pydir="$(python_get_sitedir)/libsvn" \
372                                 swig_pydir_extra="$(python_get_sitedir)/svn" \
373                                 install-swig-py
374                 }
375
376                 BUILD_DIR=python \
377                 python_foreach_impl swig_py_install
378         fi
379
380         if use perl ; then
381                 emake DESTDIR="${D}" INSTALLDIRS="vendor" install-swig-pl
382                 perl_delete_localpod
383                 find "${ED}" "(" -name .packlist -o -name "*.bs" ")" -delete
384         fi
385
386         if use ruby ; then
387                 emake DESTDIR="${D}" install-swig-rb
388         fi
389
390         if use java ; then
391                 emake DESTDIR="${D}" install-javahl
392                 java-pkg_regso "${ED%/}"/usr/$(get_libdir)/libsvnjavahl*$(get_libname)
393                 java-pkg_dojar "${ED%/}"/usr/$(get_libdir)/svn-javahl/svn-javahl.jar
394                 rm -fr "${ED%/}"/usr/$(get_libdir)/svn-javahl/*.jar
395         fi
396
397         # Install Apache module configuration.
398         if use apache2 ; then
399                 keepdir "${APACHE_MODULES_CONFDIR}"
400                 insinto "${APACHE_MODULES_CONFDIR}"
401                 doins "${FILESDIR}/47_mod_dav_svn.conf"
402         fi
403
404         # Install Bash Completion, bug 43179.
405         newbashcomp tools/client-side/bash_completion svn
406         bashcomp_alias svn svn{admin,dumpfilter,look,sync,version}
407         rm -f tools/client-side/bash_completion
408
409         # Install hot backup script, bug 54304.
410         newbin tools/backup/hot-backup.py svn-hot-backup
411         rm -fr tools/backup
412
413         # Install svnserve init-script and xinet.d snippet, bug 43245.
414         newinitd "${FILESDIR}"/svnserve.initd3 svnserve
415         newconfd "${FILESDIR}"/svnserve.confd svnserve
416         insinto /etc/xinetd.d
417         newins "${FILESDIR}"/svnserve.xinetd svnserve
418
419         #adjust default user and group with disabled apache2 USE flag, bug 381385
420         use apache2 || sed -e "s\USER:-apache\USER:-svn\g" \
421                         -e "s\GROUP:-apache\GROUP:-svnusers\g" \
422                         -i "${ED%/}"/etc/init.d/svnserve || die
423         use apache2 || sed -e "0,/apache/s//svn/" \
424                         -e "s:apache:svnusers:" \
425                         -i "${ED%/}"/etc/xinetd.d/svnserve || die
426
427         # Install documentation.
428         dodoc CHANGES COMMITTERS README
429         dodoc tools/xslt/svnindex.{css,xsl}
430         rm -fr tools/xslt
431
432         # Install extra files.
433         if use extras ; then
434                 cat <<- EOF > 80subversion-extras
435                         PATH="${EPREFIX}/usr/$(get_libdir)/subversion/bin"
436                         ROOTPATH="${EPREFIX}/usr/$(get_libdir)/subversion/bin"
437                 EOF
438                 doenvd 80subversion-extras
439
440                 emake DESTDIR="${D}" toolsdir="/usr/$(get_libdir)/subversion/bin" install-tools
441
442                 find tools "(" -name "*.bat" -o -name "*.in" -o -name ".libs" ")" -print0 | xargs -0 rm -fr
443                 rm -fr tools/client-side/svnmucc
444                 rm -fr tools/server-side/{svn-populate-node-origins-index,svnauthz-validate}*
445                 rm -fr tools/{buildbot,dev,diff,po}
446
447                 insinto /usr/share/${PN}
448                 find tools -name '*.py' -exec sed -i -e '1s:python:&2:' {} + || die
449                 doins -r tools
450         fi
451
452         if use doc ; then
453                 docinto html
454                 dodoc -r doc/doxygen/html/*
455
456                 if use java ; then
457                         java-pkg_dojavadoc doc/javadoc
458                 fi
459         fi
460
461         prune_libtool_files --all
462
463         cd "${ED%/}"/usr/share/locale
464         for i in * ; do
465                 [[ ${i} == *$LINGUAS* ]] || { rm -r ${i} || die ; }
466         done
467 }
468
469 pkg_preinst() {
470         # Compare versions of Berkeley DB, bug 122877.
471         if use berkdb && [[ -f "${EROOT%/}/usr/bin/svn" ]] ; then
472                 OLD_BDB_VERSION="$(scanelf -nq "${EROOT%/}/usr/$(get_libdir)/libsvn_subr-1$(get_libname 0)" | grep -Eo "libdb-[[:digit:]]+\.[[:digit:]]+" | sed -e "s/libdb-\(.*\)/\1/")"
473                 NEW_BDB_VERSION="$(scanelf -nq "${ED%/}/usr/$(get_libdir)/libsvn_subr-1$(get_libname 0)" | grep -Eo "libdb-[[:digit:]]+\.[[:digit:]]+" | sed -e "s/libdb-\(.*\)/\1/")"
474                 if [[ "${OLD_BDB_VERSION}" != "${NEW_BDB_VERSION}" ]] ; then
475                         CHANGED_BDB_VERSION="1"
476                 fi
477         fi
478 }
479
480 pkg_postinst() {
481         if [[ -n "${CHANGED_BDB_VERSION}" ]] ; then
482                 ewarn "You upgraded from an older version of Berkeley DB and may experience"
483                 ewarn "problems with your repository. Run the following commands as root to fix it:"
484                 ewarn "    db4_recover -h ${SVN_REPOS_LOC}/repos"
485                 ewarn "    chown -Rf apache:apache ${SVN_REPOS_LOC}/repos"
486         fi
487
488         ewarn "If you run subversion as a daemon, you will need to restart it to avoid module mismatches."
489 }
490
491 pkg_postrm() {
492         :
493 }
494
495 pkg_config() {
496         # Remember: Don't use ${EROOT}${SVN_REPOS_LOC} since ${SVN_REPOS_LOC}
497         # already has EPREFIX in it
498         einfo "Initializing the database in ${SVN_REPOS_LOC}..."
499         if [[ -e "${SVN_REPOS_LOC}/repos" ]] ; then
500                 echo "A Subversion repository already exists and I will not overwrite it."
501                 echo "Delete \"${SVN_REPOS_LOC}/repos\" first if you're sure you want to have a clean version."
502         else
503                 mkdir -p "${SVN_REPOS_LOC}/conf"
504
505                 einfo "Populating repository directory..."
506                 # Create initial repository.
507                 "${EROOT}usr/bin/svnadmin" create "${SVN_REPOS_LOC}/repos"
508
509                 einfo "Setting repository permissions..."
510                 SVNSERVE_USER="$(. "${EROOT}etc/conf.d/svnserve"; echo "${SVNSERVE_USER}")"
511                 SVNSERVE_GROUP="$(. "${EROOT}etc/conf.d/svnserve"; echo "${SVNSERVE_GROUP}")"
512                 if use apache2 ; then
513                         [[ -z "${SVNSERVE_USER}" ]] && SVNSERVE_USER="apache"
514                         [[ -z "${SVNSERVE_GROUP}" ]] && SVNSERVE_GROUP="apache"
515                 else
516                         [[ -z "${SVNSERVE_USER}" ]] && SVNSERVE_USER="svn"
517                         [[ -z "${SVNSERVE_GROUP}" ]] && SVNSERVE_GROUP="svnusers"
518                 fi
519                 chmod -Rf go-rwx "${SVN_REPOS_LOC}/conf"
520                 chmod -Rf o-rwx "${SVN_REPOS_LOC}/repos"
521                 echo "Please create \"${SVNSERVE_GROUP}\" group if it does not exist yet."
522                 echo "Afterwards please create \"${SVNSERVE_USER}\" user with homedir \"${SVN_REPOS_LOC}\""
523                 echo "and as part of the \"${SVNSERVE_GROUP}\" group if it does not exist yet."
524                 echo "Finally, execute \"chown -Rf ${SVNSERVE_USER}:${SVNSERVE_GROUP} ${SVN_REPOS_LOC}/repos\""
525                 echo "to finish the configuration."
526         fi
527 }