# $Id: PKGBUILD 143897 2015-10-13 08:24:01Z fyan $
# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=rclone
pkgver=1.23
pkgrel=1
pkgdesc="Sync files to and from Google Drive, S3, Swift, Cloudfiles, Dropbox and Google Cloud Storage"
arch=('i686' 'x86_64')
url="http://rclone.org/"
license=('MIT')
depends=('gcc-go')
makedepends=('git' 'python2' 'pandoc')
source=("git+https://github.com/ncw/rclone.git#tag=v$pkgver")
md5sums=('SKIP')

prepare() {
  cd rclone

  sed -i "1s/python$/&2/" make_manual.py

  mkdir -p .gopath/src/github.com/ncw
  ln -sf "$PWD" .gopath/src/github.com/ncw/rclone
  export GOPATH="$PWD/.gopath"

  go get github.com/ncw/rclone
}

build() {
  cd rclone
  export GOPATH="$PWD/.gopath"

  go build
  make doc
}

check() {
  cd rclone
  make test || warning "Tests failed"
}

package() {
  cd rclone
  make DESTDIR="$pkgdir" install

  install -Dm644 COPYING "$pkgdir/usr/share/licenses/$pkgname/COPYING"

  install -Dm644 rclone.1 "$pkgdir/usr/share/man/man1/rclone.1"
  install -d "$pkgdir/usr/share/doc/$pkgname"
  install -t "$pkgdir/usr/share/doc/$pkgname" -m644 MANUAL.html MANUAL.txt
}
