# $Id: PKGBUILD 131078 2015-04-09 19:35:54Z anatolik $
# Maintainer: Anatol Pomozov
# Contributor: 謝致邦 <Yeking@Red54.com>
# Contributor: Alucryd <alucryd at gmail dot com>

pkgname=android-tools
pkgver=5.1.0_r3
pkgrel=1
pkgdesc='Android platform tools'
arch=(i686 x86_64)
url='http://tools.android.com/'
license=(Apache MIT)
depends=(openssl pcre)
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'
          '65fe33b2cb41c7125470b5c606cd2ca38193f6ad'
          '0bf0bdcabb78af81583c932cce198f918d9e4463'
          '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
}
