#!/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=tor
pkgver=0.4.7.12
pkgrel=01
pkgdesc='An anonymizing overlay network. w/o zstd and systemd'
arch=(x86_64)
#url='https://www.torproject.org/dist'
url="https://dist.torproject.org"
conflicts=('tor-git') 
provides=('tor-git') 
#backup=(
#    'etc/tor/torrc')

depends=('openssl' 'libevent' 'bash' 'libseccomp' 'xz')
makedepends=('ca-certificates' 'asciidoc')
checkdepends=('python')
optdepends=('torsocks: allow transparent SOCKS proxying'
            'obfs4proxy: obfuscating pluggable transport proxy'
            'meek: obfuscating pluggable transport proxy')


source=("$url/$pkgname-$pkgver.tar.gz"{,.sha256sum{,.asc}}
	'tor.tmpfiles' 'tor.sysusers')
prepare() {
    cd "$pkgname-$pkgver"
}

build() {
  cd "$pkgname-$pkgver"
    ./configure --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --disable-zstd \
    --disable-zstd-advanced-apis \
    --disable-systemd \
    --disable-html-manual \
    --disable-ipv6 \
    --enable-lzma \
    --enable-xz \
    --disable-dependency-tracking \
    --disable-unittests \
    --enable-pic

  make
}

check() {
    cd "$pkgname-$pkgver"
    make check ||true
}

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

    make DESTDIR="$pkgdir" install

    install -Dm644 "$srcdir/tor.sysusers"  "$pkgdir/usr/lib/sysusers.d/tor.conf"
    install -Dm644 "$srcdir/tor.tmpfiles"  "$pkgdir/usr/lib/tmpfiles.d/tor.conf"

    # patch upstream configuration file
#    patch -Np1 < "$srcdir/torrc.patch"

    install -Dm 0644 src/config/torrc.sample "$pkgdir"/etc/tor/torrc
    chown -R 43:43 "${pkgdir}"/etc/tor/torrc
#    rm "$pkgdir"/etc/tor/torrc.sample

    install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

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

license=('BSD') 

validpgpkeys=(2133BC600AB133E1D826D173FE43009C4607B1FB  # Nick Mathewson
              F65CE37F04BA5B360AE6EE17C218525819F78451  # Roger Dingledine
              1C1BC007A9F607AA8152C040BEA7B180B1491921) # Alexander Færøy <ahf@0x90.dk>

sha256sums=(3b5d969712c467851bd028f314343ef15a97ea457191e93ffa97310b05b9e395  # tor-0.4.7.12.tar.gz
	5f41319a07feb872c8687219a87f27e39d462f5c0cfba8269234cf48ff0ea5f2  # tor-0.4.7.12.tar.gz.sha256sum
	18b1980b6b4441b361494f27bc58857aa097dad7fb0d520968fed2c48303221e  # tor-0.4.7.12.tar.gz.sha256sum.asc
	06c00318d84ead3f939b267c7ae9e4cc1cd90c534d0b57ddd2595fee9065ee7f  # tor.tmpfiles
	231405d1fbbcc68168248f93edd19ae14b60f66bb4d1c8e46ead1d4cd8e0ae7c) #  tor.sysusers


