#!/usr/bin/bash
# JOBoRun		: Jwm OpenBox Obarun RUNit
# Maintainer	: Joe Bo Run <joborun@disroot.org>
# PkgSource		: url="https://gittea.disroot.org/joborun-pkg/jobextra/$pkgname"
# Website		: https://pozol.eu
#-----------------------------------------| DESCRIPTION |---------------------------------------

pkgname=subversion
pkgver=1.14.2
pkgrel=07
pkgdesc="A Modern Concurrent Version Control System"
arch=('x86_64')
url="https://subversion.apache.org/"
depends=('glibc' 'file' 'libutf8proc' 'serf' 'sqlite' 
		'apr' 'apr-util' 'zlib' 'lz4' 'expat' 'libsasl')
makedepends=('apache' 'python' 'python-py3c' 'perl' 'swig' 
		'java-environment>=8' 'libgnome-keyring' 'kwallet'
		 'kdelibs4support' 'ruby')

optdepends=('libgnome-keyring: for GNOME Keyring for auth credentials'
            'kwallet: for KWallet for auth credentials'
            'bash-completion: for svn bash completion'
            'python: for some hook scripts'
            'java-environment: for Java support'
            'ruby: for some hook scripts')
checkdepends=('ruby-test-unit')
provides=('svn')
backup=('etc/xinetd.d/svn' 'etc/conf.d/svnserve')
options=('!makeflags' '!emptydirs')
source=(https://www.apache.org/dist/subversion/subversion-${pkgver}.tar.bz2{,.asc}
        svn
        svnserve.conf
        svnserve.tmpfiles
        subversion.rpath.fix.patch
        ruby-frozen-nil.patch)

prepare() {
   cd ${pkgname}-${pkgver}
   patch -Np0 -i ../subversion.rpath.fix.patch
   patch -p1 -i ../ruby-frozen-nil.patch
   rm subversion/bindings/swig/proxy/*.swg

   ./autogen.sh
}

build() {
   cd ${pkgname}-${pkgver}
   ./configure --prefix=/usr \
               --with-apxs \
               --enable-javahl \
               --with-jdk=/usr/lib/jvm/default \
               --with-gnome-keyring \
               --with-kwallet \
               --with-apache-libexecdir=/usr/lib/httpd/modules \
               --with-ruby-sitedir=/usr/lib/ruby/vendor_ruby \
               --disable-static

   make LT_LDFLAGS="-L$Fdestdir/usr/lib"
   local python_version=$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
   make swig_pydir=/usr/lib/python${python_version}/site-packages/libsvn \
     swig_pydir_extra=/usr/lib/python${python_version}/site-packages/svn swig-py swig-pl javahl swig-rb
}

check() {
   cd ${pkgname}-${pkgver}
   export LANG=C LC_ALL=C
   make check check-swig-pl check-swig-py check-swig-rb CLEANUP=yes # check-javahl
}

package() {
   cd ${pkgname}-${pkgver}

   export LD_LIBRARY_PATH="${pkgdir}"/usr/lib:${LD_LIBRARY_PATH}
   make DESTDIR="${pkgdir}" INSTALLDIRS=vendor \
     swig_pydir=/usr/lib/python3.10/site-packages/libsvn \
     swig_pydir_extra=/usr/lib/python3.10/site-packages/svn \
     install install-swig-py install-swig-pl install-javahl install-swig-rb

   install -dm755 "${pkgdir}"/usr/share/subversion
   cp -a tools/hook-scripts "${pkgdir}"/usr/share/subversion/
   rm "${pkgdir}"/usr/share/subversion/hook-scripts/*.in

   ## svnserve ...

   # xinetd
   install -D -m 644 "${srcdir}"/svn "${pkgdir}"/etc/xinetd.d/svn

   ## ... tmpfiles
   install -D -m 644 "${srcdir}"/svnserve.tmpfiles "${pkgdir}"/usr/lib/tmpfiles.d/svnserve.conf

   # ... common config
   install -D -m 644 "${srcdir}"/svnserve.conf "${pkgdir}"/etc/conf.d/svnserve

   install -Dm 644 tools/client-side/bash_completion \
     "${pkgdir}"/usr/share/bash-completion/completions/subversion
   for i in svn svnadmin svndumpfilter svnlook svnsync svnversion; do
      ln -sf subversion "${pkgdir}"/usr/share/bash-completion/completions/${i}
   done
}

#---- license gpg-key sha256sums ----

license=('APACHE')

validpgpkeys=('19BBCAEF7B19B280A0E2175E62D48FAD16A0DE01'
              '8BC4DAE0C5A4D65F404401074F7DBAA99A59B973'
              'BA3C15B1337CF0FB222BD41A1BCA6586A347943F'
              'E7B2A7F4EC28BE9FF8B38BA4B64FFF1209F9FA74'
              '3D1DC66D6D2E0B9039528138C4A6C625CCC8E1DF'
              'A844790FB5743606EE95920776D788E1ED1A599C'
              '7B8CA7F6451AD89C8ADC077B376A3CFD110B1C95'
              '056F8016D9B87B1BDE41746799EC741B57921ACC'
              '3F8E467CB3366E3013E1120D583F00ADF981C39F'
              '91BFBF4D6956BD5DF7B72D23DFE691AE331BA3DB'
              'EC25FCC105618D04ADB43429C4416167349A3BCB')
# Ben Reser / Stefan Sperling / Branko Čibej / Evgeny Kotkov / Bert Huijben / Philip Martin /
# Stefan Fuhrmann / Stefan Hett (CODE SIGNING KEY) /Nathan Hartman (CODE SIGNING KEY) / James McCoy /
# Mark Phippard

sha512sums=('20ada4688ca07d9fb8da4b7d53b5084568652a3b9418c65e688886bae950a16a3ff37710fcfc9c29ef14a89e75b2ceec4e9cf35d5876a7896ebc2b512cfb9ecc'
            'SKIP'
            '3df59e92aa0314ff6adce26e2e1162bf2872ca03ff1f78891081a60e67b521b6046b4a2f85f718dcd27f9d5709594658817a09548cdb74e3976d371dbe47e7db'
            'f7f2ceac2446cc94ac2be3404083cc54a0f1f4d04d5301f600dfafca38819669bcffdfa45f1b90b9f3cdb042469385a764f11dc1a827f10c23ddf73b7ac6c9da'
            '7775f4da5003970c9ebdc2f696ba090df194a77d9daed791875488c943f72ae496b5f9cc6f3ff9f3f4de9f352a3b518137babdea38947d1a2d5dd16aa1844036'
            '60d538160e738eb3b3e84a3881fe5a8d75c79053d3f31c4c29ef6ace6ccc5dd4367ed712766c911bae3436e9706e4dd144b270bb45161a6c1834a37e154d0440'
            'bb772e55acd9601121ad06b254c364e8d8cf772ca59b8df0cf4c5c5ecba110d4108d0363672f121f770550cdd052802474029e57643258f398aacd2b63ccb898')

sha256sums=(c9130e8d0b75728a66f0e7038fc77052e671830d785b5616aad53b4810d3cc28  # subversion-1.14.2.tar.bz2
	e24732e02dfac748a2c70b469f73342dd05efcc4bdb08b29f4b693088a7f5a9a  # subversion-1.14.2.tar.bz2.asc
	ad2a082421c0c8b42ef5638ca3bfb9bcacac8bcab9b31ca519a108b02cecd760  # svn
	217b2d2e15adf1df54b8fcf4b748c2afa8b766af37a36b2f29a580f49e7b4ba3  # svnserve.conf
	6ac5c1d0e149178fbf478e0e8273e6350e1de95a197f13c7aa61b108a8f3b123  # svnserve.tmpfiles
	138d8b1ff7adb4519c5790eb80c69b441abd9b5ad79d75a8fd7c226e6ba21deb  # subversion.rpath.fix.patch
	e6846ca6b5136a3d217244dbebdcc8d8b449aaf61d09541e4f0aa76bee6c3845) # ruby-frozen-nil.patch

