app=tor
version=0.4.1.6
build=1sml
homepage="https://www.torproject.org/"
download="https://archive.torproject.org/tor-package-archive/tor-0.4.1.6.tar.gz"
desc="The second-generation onion router"
requires="gcc-libs zlib libcap openssl libevent ca-certificates"

build() {
  mkandenterbuilddir
  rm -rf $app-$version

  tar xf $srcdir/$app-$version.tar.?z*
  cd $app-$version
  fixbuilddirpermissions

  ./configure \
    --prefix="" \
    --sysconfdir=/etc \
    --disable-tool-name-check \
    --enable-pic 

  make
  make install DESTDIR=$pkg

  cp LICENSE $pkgdocs/

  mkdir -p $pkg/etc/tor
  rm $pkg/etc/tor/torrc.sample
  cp $srcdir/torrc.sample $pkg/etc/tor/torrc

  mkdir -p $pkg/var/lib/tor
  chown -R tor:tor $pkg/var/lib/tor

  preprunitservice tor down
  
  mkfinalpkg
}

sha512sums="
58bf6c233e13fd7dd1cfdeee55aadd3641e727a1f35173b1c2dfb73412591122499c4f78c03f913fed2780f1f2ed3798ab5bc533b0fd98d3960e12d04d375dba  tor-0.4.1.6.tar.lz
"
