# Maintainer: Bin Meng <bmeng.cn@gmail.com>

pkgname=u-boot-tools
pkgver=2021.07
pkgrel=1
pkgdesc="U-Boot Tools"
arch=('i686' 'x86_64')
url="https://github.com/u-boot/u-boot"
license=('GPL2')
depends=('dtc' 'openssl')
makedepends=('openssl-devel')
source=(https://ftp.denx.de/pub/u-boot/u-boot-${pkgver}.tar.bz2{,.sig})
noextract=("u-boot-${pkgver}.tar.bz2")
sha256sums=('312b7eeae44581d1362c3a3f02c28d806647756c82ba8c72241c7cdbe68ba77e'
            'SKIP')
validpgpkeys=('1A3C7F70E08FAB1707809BBF147C39FF9634B72C')

prepare() {
  # workaround an issue of bsdtar for extracting symbolic links in the tarball
  bsdtar -xzf ${srcdir}/u-boot-${pkgver}.tar.bz2 -C $srcdir || true
  bsdtar -xzf ${srcdir}/u-boot-${pkgver}.tar.bz2 -C $srcdir || true
}

build() {
  cd ${srcdir}/u-boot-${pkgver}
  make tools-only_defconfig tools-only NO_SDL=1
}

package() {
  mkdir -p ${pkgdir}/usr/bin
  cd ${srcdir}/u-boot-${pkgver}
  cp -f tools/dumpimage.exe ${pkgdir}/usr/bin/
  cp -f tools/fdtgrep.exe ${pkgdir}/usr/bin/
  cp -f tools/fit_info.exe ${pkgdir}/usr/bin/
  cp -f tools/fit_check_sign.exe ${pkgdir}/usr/bin/
  cp -f tools/mkimage.exe ${pkgdir}/usr/bin/
}
