# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=rsync
pkgver=3.2.3
pkgrel=1
pkgdesc="A file transfer program to keep remote files in sync"
arch=('i686' 'x86_64')
url="https://rsync.samba.org"
groups=('net-utils')
license=('GPL3')
depends=('perl' 'libiconv' 'liblz4' 'libopenssl' 'libxxhash' 'libzstd')
makedepends=('libiconv-devel' 'liblz4-devel' 'libxxhash-devel' 'libzstd-devel' 'openssl-devel')
conflicts=('rsync2')
replaces=('rsync2')
source=("https://download.samba.org/pub/rsync/src/${pkgname}-${pkgver}.tar.gz"
        rsync-3.2.2-msysize.patch)
sha256sums=('becc3c504ceea499f4167a260040ccf4d9f2ef9499ad5683c179a697146ce50e'
            '9476f1315136a773682947addedd436e85412423d6599d62faa4d4fe11058735')

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  patch -p1 -i ${srcdir}/rsync-3.2.2-msysize.patch
  autoreconf -fiv
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  ./configure \
      --build=${CHOST} \
      --prefix=/usr
  
  make reconfigure
  make man all
}

check() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make test
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" install
  install -Dm755 support/rrsync "${pkgdir}/usr/lib/rsync/rrsync"

  install -Dm644 ${srcdir}/${pkgname}-${pkgver}/COPYING ${pkgdir}/usr/share/licenses/${pkgname}/COPYING
}
