1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python2_7 )
7 USE_RUBY="ruby23 ruby22 ruby21"
10 GENTOO_DEPEND_ON_PERL="no"
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
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}"
21 LICENSE="Subversion GPL-2"
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"
28 >=dev-db/sqlite-3.7.12
30 >=dev-libs/apr-util-1.3:1
34 berkdb? ( >=sys-libs/db-4.0.14:= )
35 ctypes-python? ( ${PYTHON_DEPS} )
38 gnome-base/libgnome-keyring
41 http? ( >=net-libs/serf-1.3.4 )
46 kde-frameworks/kcoreaddons:5
47 kde-frameworks/ki18n:5
48 kde-frameworks/kwallet:5
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 )
69 kde-frameworks/kdelibs4support:5
72 nls? ( sys-devel/gettext )
73 test? ( ${PYTHON_DEPS} )"
76 ctypes-python? ( ${PYTHON_REQUIRED_USE} )
77 python? ( ${PYTHON_REQUIRED_USE} )
79 ${PYTHON_REQUIRED_USE}
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
98 local apu_bdb_version="$(${EPREFIX}/usr/bin/apu-1-config --includes \
99 | grep -Eoe '-I${EPREFIX}/usr/include/db[[:digit:]]\.[[:digit:]]' \
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"
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."
111 einfo "Using: Berkeley DB ${SVN_BDB_VERSION}"
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"
123 depend.apache_pkg_setup
125 java-pkg-opt-2_pkg_setup
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"
135 append-cppflags -DSVN_DEBUG -DAP_DEBUG
138 # http://mail-archives.apache.org/mod_mbox/subversion-dev/201306.mbox/%3C51C42014.3060700@wandisco.com%3E
139 [[ ${CHOST} == *-solaris2* ]] && append-cppflags -D__EXTENSIONS__
141 # Allow for custom repository locations.
142 SVN_REPOS_LOC="${SVN_REPOS_LOC:-${EPREFIX}/var/svn}"
147 for rbslot in $(sed 's@\([[:digit:]]\+\)\([[:digit:]]\)@\1.\2@g' <<< ${USE_RUBY//ruby}) ; do
148 if has_version dev-lang/ruby:${rbslot} ; then
153 [[ -z "${RB_VER}" ]] && die "No useable ruby version found"
160 fperms +x build/transform_libtool_scripts.sh
163 -e "s/\(BUILD_RULES=.*\) bdb-test\(.*\)/\1\2/g" \
164 -e "s/\(BUILD_RULES=.*\) test\(.*\)/\1\2/g" configure.ac
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!"
173 sed -e 's/\(libsvn_swig_py\)-\(1\.la\)/\1-$(EPYTHON)-\2/g' \
174 -i build-outputs.mk || die "sed failed"
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
182 xdg_environment_reset
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}")
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
204 --disable-mod-activation
208 if use python || use perl || use ruby; then
209 myconf+=( --with-swig )
211 myconf+=( --without-swig )
215 myconf+=( --without-junit )
220 # avoid recording immediate path to sharedlibs into executables
221 append-ldflags -Wl,-bnoipath
224 # no LD_PRELOAD support, no undefined symbols
225 myconf+=( --disable-local-library-preloading LT_LDFLAGS=-no-undefined )
228 # loader crashes on the LD_PRELOADs...
229 myconf+=( --disable-local-library-preloading )
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 )
238 myconf+=( --enable-all-static --disable-local-library-preloading )
241 # inject LD_PRELOAD entries for easy in-tree development
242 myconf+=( --enable-local-library-preloading )
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 )
251 # for build-time scripts
252 if use ctypes-python || use python || use test; then
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)"
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)' \
272 if use ctypes-python ; then
273 # pre-generate .py files
274 use ctypes-python && emake ctypes-python
276 pushd subversion/bindings/ctypes-python >/dev/null || die
277 distutils-r1_src_compile
278 popd >/dev/null || die
283 local p=subversion/bindings/swig/python
285 ln -s "${BUILD_DIR}" ${p} || die
287 python_export PYTHON_INCLUDEDIR
289 swig_pydir="$(python_get_sitedir)/libsvn" \
290 swig_pydir_extra="$(python_get_sitedir)/svn"
293 # this will give us proper BUILD_DIR for symlinking
295 python_foreach_impl swig_py_compile
307 emake -j1 JAVAC_FLAGS="$(java-pkg_javac-args) -encoding iso8859-1" javahl
315 doxygen doc/doxygen.conf || die "Building of Subversion HTML documentation failed"
324 if has_version ~${CATEGORY}/${P} ; then
327 if use ctypes-python ; then
329 "${PYTHON}" subversion/bindings/ctypes-python/test/run_all.py \
330 || die "ctypes-python tests fail with ${EPYTHON}"
333 distutils-r1_src_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
343 BUILD_DIR=subversion/bindings/swig/python \
344 python_foreach_impl swig_py_test
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."
355 emake -j1 DESTDIR="${D}" local-install
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
365 local p=subversion/bindings/swig/python
367 ln -s "${BUILD_DIR}" ${p} || die
371 swig_pydir="$(python_get_sitedir)/libsvn" \
372 swig_pydir_extra="$(python_get_sitedir)/svn" \
377 python_foreach_impl swig_py_install
381 emake DESTDIR="${D}" INSTALLDIRS="vendor" install-swig-pl
383 find "${ED}" "(" -name .packlist -o -name "*.bs" ")" -delete
387 emake DESTDIR="${D}" install-swig-rb
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
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"
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
409 # Install hot backup script, bug 54304.
410 newbin tools/backup/hot-backup.py svn-hot-backup
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
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
427 # Install documentation.
428 dodoc CHANGES COMMITTERS README
429 dodoc tools/xslt/svnindex.{css,xsl}
432 # Install extra files.
434 cat <<- EOF > 80subversion-extras
435 PATH="${EPREFIX}/usr/$(get_libdir)/subversion/bin"
436 ROOTPATH="${EPREFIX}/usr/$(get_libdir)/subversion/bin"
438 doenvd 80subversion-extras
440 emake DESTDIR="${D}" toolsdir="/usr/$(get_libdir)/subversion/bin" install-tools
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}
447 insinto /usr/share/${PN}
448 find tools -name '*.py' -exec sed -i -e '1s:python:&2:' {} + || die
454 dodoc -r doc/doxygen/html/*
457 java-pkg_dojavadoc doc/javadoc
461 prune_libtool_files --all
463 cd "${ED%/}"/usr/share/locale
465 [[ ${i} == *$LINGUAS* ]] || { rm -r ${i} || die ; }
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"
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"
488 ewarn "If you run subversion as a daemon, you will need to restart it to avoid module mismatches."
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."
503 mkdir -p "${SVN_REPOS_LOC}/conf"
505 einfo "Populating repository directory..."
506 # Create initial repository.
507 "${EROOT}usr/bin/svnadmin" create "${SVN_REPOS_LOC}/repos"
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"
516 [[ -z "${SVNSERVE_USER}" ]] && SVNSERVE_USER="svn"
517 [[ -z "${SVNSERVE_GROUP}" ]] && SVNSERVE_GROUP="svnusers"
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."