# Maintainer (of the AUR version): Jonathon Fernyhough <jonathon_at_manjaro_org>
# Contributor: Martchus <martchus@gmx.net>

# Does not put files under /opt in contrast to the AUR version

pkgname='hopper'
pkgver='4.3.26'
pkgrel='1'
pkgdesc='Reverse engineering tool that lets you disassemble, decompile and debug your applications'
arch=('x86_64')
url='https://www.hopperapp.com/'
license=('Commercial')
depends=('hicolor-icon-theme' 'libbsd' 'python2' 'qt5-base' 'ncurses5-compat-libs')
source=("https://d2ap6ypl1xbe4k.cloudfront.net/Hopper-v4-${pkgver}-Linux.pkg.tar.xz"
        'LICENSE')
sha256sums=('4e1aa4169349013e696cc2c65f5ac37bf0eb3719fe15695363007e2e3fa64b88'
            '0155d243d79d1ba0f6ff914f8ddb07a277830826559b2dd7922be01c3190393d')

package() {
  # Copy package content
  mkdir -p ${pkgdir}/usr/bin
  cp    ${srcdir}/opt/hopper-v4/bin/Hopper ${pkgdir}/usr/bin/Hopper
  cp -r ${srcdir}/opt/hopper-v4/lib ${pkgdir}/usr
  cp -r ${srcdir}/usr/share ${pkgdir}/usr

  # Remove conflicting files
  rm ${pkgdir}/usr/lib/{libobjc.so,libform.so.5,libncurses.so.5,libtinfo.so.5}

  # Remove launcher from Accessories
  sed -i '10s|Utility;||' ${pkgdir}/usr/share/applications/hopper-v4.desktop
  # Adjust executable path
  sed -i 's/\/opt\/hopper-v4\/bin\/Hopper/bash -c "LD_PRELOAD=\/usr\/lib\/libobjc.so.4.6 \/usr\/bin\/Hopper"/g' ${pkgdir}/usr/share/applications/hopper-v4.desktop

  # Install license file
  # https://www.hopperapp.com/license_agreement.html @ 2017-08-14
  install -Dm644 LICENSE ${pkgdir}/usr/share/licenses/${pkgname}/LICENSE
}
