# $Id: PKGBUILD 124399 2014-12-23 18:04:00Z anatolik $
# Maintainer: Anatol Pomozov
# Contributor: 謝致邦 <Yeking@Red54.com>
# Contributor: Alucryd <alucryd at gmail dot com>

pkgname=android-tools
pkgver=5.0.2_r1
pkgrel=1
pkgdesc='Android platform tools'
arch=(i686 x86_64)
url='http://tools.android.com/'
license=(Apache MIT)
depends=(openssl)
makedepends=(git)
source=(git+https://android.googlesource.com/platform/system/core#tag=android-$pkgver
        git+https://android.googlesource.com/platform/system/extras#tag=android-$pkgver
        git+https://android.googlesource.com/platform/external/libselinux#tag=android-$pkgver
        git+https://android.googlesource.com/platform/external/f2fs-tools#tag=android-$pkgver
        adbMakefile
        fastbootMakefile
        bash_completion) # Bash completion file was taken from https://github.com/mbrubeck/android-completion
sha1sums=('SKIP'
          'SKIP'
          'SKIP'
          'SKIP'
          'ed3e9f6fc43ea9adb177ff1f81532a583b51e348'
          'a61991623b3a6c21129156f36d81076e5ac1a32d'
          'd99991b208c7c2d8d0053e9937653cca22d09b6d')


prepare() {
  # another way to fix the compilation error is to add #include <stddef.h>
  sed -e 's/f2fs_sparse_file = NULL/f2fs_sparse_file = 0/g' -i extras/f2fs_utils/f2fs_utils.c 
}

build() {
  make -C core/adb -f "$srcdir"/adbMakefile
  make -C core/fastboot -f "$srcdir"/fastbootMakefile
}

package(){
  install -Dm 755 core/adb/adb "$pkgdir"/usr/bin/adb
  install -Dm 755 core/fastboot/fastboot "$pkgdir"/usr/bin/fastboot

  install -Dm 644 bash_completion "$pkgdir"/etc/bash_completion.d/$pkgname
}
