# Maintainer: David P. <megver83@parabola.nu>

pkgbase=android-sdk-meta
pkgname=(android-sdk android-sdk-build-tools android-sdk-platform-tools)
_debver=25.0.0
pkgver=$_debver
_debrel=12
pkgrel=1
arch=(any)
url="https://developer.android.com/studio/releases/sdk-tools.html"
license=('APACHE')
source=("http://ftp.debian.org/debian/pool/main/a/${pkgbase}/${pkgbase}_${_debver}+${_debrel}.tar.xz")
sha512sums=('fa1a9f2a33f03e031e2a2bde6fd74508c4e35c63fb959c1432c08f2d4683362fbde28126c951006bb18d620894273bbf0fef22ec3134fdec145fed9d0aa92794')

package_android-sdk(){
  pkgdesc="Software development kit for Android platform"
  depends=(proguard android-sdk-build-tools android-sdk-platform-tools)

  cd "${pkgbase}"

  local bins="e2fsck
              fsck.ext4
              mkfs.ext4
              resize2fs
              tune2fs"

  mkdir -p $pkgdir/usr/lib/android-sdk/{tools/proguard/{bin,lib},tools/bin,platform-tools,build-tools,licenses}
  for f in $bins; do
    ln -s /usr/bin/$f $pkgdir/usr/lib/$pkgname/tools/bin/$f
  done
  ln -s /usr/bin/proguard $pkgdir/usr/lib/$pkgname/tools/proguard/bin/proguard
  ln -s /usr/bin/proguardgui $pkgdir/usr/lib/$pkgname/tools/proguard/bin/proguardgui
  ln -s /usr/share/proguard/proguard.jar $pkgdir/usr/lib/$pkgname/tools/proguard/lib/proguard.jar
  ln -s /usr/share/proguard/proguardgui.jar $pkgdir/usr/lib/$pkgname/tools/proguard/lib/proguardgui.jar
  ln -s /usr/share/proguard/retrace.jar $pkgdir/usr/lib/$pkgname/tools/proguard/lib/retrace.jar

  cp -r tools $pkgdir/usr/lib/$pkgname
  cp licenses/apache-2.0 $pkgdir/usr/lib/$pkgname/licenses/apache-2.0

  mkdir -p $pkgdir/usr/share/licenses/$pkgname
  cp debian/copyright $pkgdir/usr/share/licenses/$pkgname/COPYRIGHT
}

package_android-sdk-build-tools(){
  pkgdesc="Tools for building Android applications"

  cd "${pkgbase}"
  mkdir -p $pkgdir/usr/lib/android-sdk/build-tools
  cp -r build-tools $pkgdir/usr/lib/android-sdk/build-tools/24.0.0

  mkdir -p $pkgdir/usr/share/licenses/$pkgname
  cp debian/copyright $pkgdir/usr/share/licenses/$pkgname/COPYRIGHT
}

package_android-sdk-platform-tools(){
  pkgdesc="Tools for interacting with an Android platform"
  depends=(sqlite3 android-tools android-sdk-platform-tools android-udev)

  cd "${pkgbase}"
  mkdir -p $pkgdir/usr/lib/android-sdk
  cp -r platform-tools $pkgdir/usr/lib/android-sdk
  ln -s /usr/bin/sqlite3 $pkgdir/usr/lib/android-sdk/platform-tools/sqlite3

  mkdir -p $pkgdir/usr/share/licenses/$pkgname
  cp debian/copyright $pkgdir/usr/share/licenses/$pkgname/COPYRIGHT
}
