# Maintainer: Levente Polyak <levente[at]leventepolyak[dot]net>
# Contributor: s1gma <s1gma@mindslicer.com>

pkgname=ropgadget
_pkgname=ROPgadget
pkgver=5.7
pkgrel=1
pkgdesc='Search gadgets in binaries to facilitate ROP exploitation for several file formats and architectures'
url='http://www.shell-storm.org/project/ROPgadget'
arch=('any')
license=('GPL2')
depends=('python-capstone')
makedepends=('python-setuptools')
source=(${pkgname}-${pkgver}.tar.gz::https://github.com/JonathanSalwan/${_pkgname}/archive/v${pkgver}.tar.gz)
sha512sums=('ec7036395dd97327fbfc46df0f6d97aaf074be903caaae36757f5e02510b7bcf15c3b055caac4ee6b7c88c5c4efcebb80ec94b14d069c5743fd5b116e32acd85')

prepare() {
  cd ${_pkgname}-${pkgver}
  sed 's|python2|python|g' -i ropgadget/**/*.py ropgadget/*/*/*.py
}

build() {
  cd ${_pkgname}-${pkgver}
  python setup.py build
}

check() {
  cd ${_pkgname}-${pkgver}
  ./ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 --string "main"
}

package() {
  cd ${_pkgname}-${pkgver}
  python setup.py install -O1 --root="${pkgdir}" --prefix=/usr
  install -Dm 644 README.md -t "${pkgdir}/usr/share/doc/${pkgname}"
}

# vim:set ts=2 sw=2 et:
