# $Id: PKGBUILD 133095 2015-05-09 15:25:24Z arodseth $
# Maintainer: Alexander Rødseth <rodseth@gmail.com>
# Contributor: Kaiting Chen <kaitocracy@gmail.com>
# Contributor: Gergely Imreh <imrehgATgmailDOTcom>
# Contributor: champus, madeye, ranguvar and ninja_pt

pkgname=hwinfo
pkgver=21.12_1
_fn="$pkgname-${pkgver/_/-}.1.src.rpm"
pkgrel=1
pkgdesc='Hardware detection tool from openSUSE'
arch=('x86_64' 'i686')
url='http://download.opensuse.org/source/factory/repo/oss/suse/src/'
license=('GPL2')
depends=('libx86emu' 'bash' 'perl')
makedepends=('sysfsutils' 'rpmextract' 'flex' 'git')
options=('!emptydirs')
source=("http://download.opensuse.org/source/factory/repo/oss/suse/src/$_fn"
        'custom_ioctl.patch')
sha256sums=('1f20612a1498007fdf73ad306520f90dadfa46a8b646a2e9c28e88d67710ea15'
            '6e83b50aa34f31db5fe6de938402e7c4dda6ffa9ffe1346c076e4779018fcf1d')

prepare() {
  #aria2c -M "$pkgname.meta4" -V -c --allow-overwrite=true --no-conf=true

  # Wish upstream could just provide a normal $pkgname-$pkgver.tar.gz...
  rpmextract.sh "$_fn"
  tar Jxf "${_fn%-*.*}.tar.xz"

  # Patching
  cd "${_fn%-*.*}"
  patch -p0 -i ../custom_ioctl.patch
}

build() {
  make -C "${_fn%-*.*}" -j1 \
    CFLAGS+="-fPIC -I$srcdir/${_fn%-*.*}/src/hd" \
    LIBDIR=/usr/lib
}

package() {
  make -C "${_fn%-*.*}" LIBDIR=/usr/lib DESTDIR="$pkgdir" install
  mv "$pkgdir/usr/sbin" "$pkgdir/usr/bin"
}

# getver: -u 4 https://tracker.debian.org/pkg/hwinfo #
# vim:set ts=2 sw=2 et:
