pkgname=rsync
pkgver=3.4.1
pkgdesc='A fast and versatile file copying tool for remote and local files'
arch=('x86_64')
homepage='https://rsync.samba.org/'
license=('GPL-3.0-or-later')
sources=("${pkgname}-${pkgver}.tar.gz"
  "rsyncd.conf"
)
urls=("https://www.samba.org/ftp/rsync/src/${sources[0]}"
  "rsyncd.conf"
)
md5sums=("04ce67866db04fd7a1cde0b78168406e"
  "d3681265192bc3b5c65115d140cfa71e"
)

src_prepare() {
  tar -xf ${distdir}/${sources[0]} --strip-components=1
}

src_build() {
  ./configure --prefix=/usr    \
              --disable-debug  \
              --without-included-zlib \
              --with-included-popt=no &&
  make
}

src_check() {
  sed -i '/typedef/d' wildtest.c &&
  make check
}

src_install() {
  make DESTDIR="${pkgdir}" install
  for i in support/*; do
    install -Dm0644 "$i" "$pkgdir/usr/share/doc/rsync/$i"
  done
  install -Dm0644 "tech_report.tex" "$pkgdir/usr/share/doc/rsync/tech_report.tex"
  install -Dm0644 ${filedir}/rsyncd.conf "$pkgdir/etc/rsyncd.conf"
  install -Dm0644 packaging/systemd/rsync.service "$pkgdir/usr/lib/systemd/system/rsyncd.service"
  install -Dm0644 packaging/systemd/rsync.socket "$pkgdir/usr/lib/systemd/system/rsyncd.socket"
  install -Dm0644 packaging/systemd/rsync@.service "$pkgdir/usr/lib/systemd/system/rsyncd@.service"
}
