# $Id: PKGBUILD 130303 2015-03-30 15:03:52Z tredaelli $
# Maintainer: Timothy Redaelli <timothy.redaelli@gmail.com>
# Contributor: Andy Weidenbaum <archbaum@gmail.com>
# ThomasV PGP key: gpg --recv-key 6694D8DE7BE8EE5631BED9502BD5824B7F9470E6
# http://bitcoin-otc.com/viewgpg.php?nick=ThomasV

pkgname=electrum
pkgver=2.0.4
pkgrel=1
pkgdesc="Lightweight Bitcoin wallet"
arch=('any')
depends=('python2-ecdsa' 'python2-pbkdf2' 'python2-requests' 'python2-pyasn1' 'python2-pyasn1-modules' 'python2-qrcode'
         'python2-protobuf' 'python2-tlslite' 'python2-dnspython' 'python2-pyqt4' 'python2-sip' 'python2-slowaes')
makedepends=('gettext' 'python2-pycurl' 'python2-setuptools' 'desktop-file-utils')
optdepends=('python2-btchip: BTChip hardware wallet support'
            'python2-matplotlib: plot transaction history in graphical mode'
            'zbar: QR code reading support')
url="https://electrum.org"
license=('GPL3')
source=("https://download.electrum.org/${pkgname^}-${pkgver}.tar.gz"{,.asc}
	https://github.com/spesmilo/electrum/commit/3ae2fb2e90b0296066509d1934d1c24b6333260f.patch)
md5sums=('d2103ceae1389ada2235314a126b1fe4'
         'SKIP'
         '55821e2591267b8efca22368eb063977')
sha256sums=('b77f70efbe337387dd9654c660b96dc5608ff7a76fe8fdc573d747e17fce3b61'
            'SKIP'
            'ca706164c16f0e1558506b5f581bde620c2b25d7dc48ca6a31bceabecf863cbe')
validpgpkeys=('6694D8DE7BE8EE5631BED9502BD5824B7F9470E6')

provides=('electrum')
install=electrum.install

prepare() {
  cd ${pkgname^}-${pkgver}

  find . -type f -exec sed -i 's#/usr/bin/python#/usr/bin/python2#g' {} +
  find . -type f -exec sed -i 's#/usr/bin/env python#/usr/bin/env python2#g' {} +

  # Disable useless (on linux) pyusb dependency
  patch -uNp1 -i ../3ae2fb2e90b0296066509d1934d1c24b6333260f.patch
}

build() {
  cd ${pkgname^}-${pkgver}

  pyrcc4 icons.qrc -o gui/qt/icons_rc.py
  python2 setup.py build
}

package() {
  cd ${pkgname^}-${pkgver}

  python2 setup.py install --root="${pkgdir}" --optimize=1
}
