app=hostapd
version=2.9
build=1sml
homepage="https://w1.fi/hostapd/"
download="https://w1.fi/releases/hostapd-2.9.tar.gz"
desc="User space daemon for wifi authentication"
requires="libnl openssl"

build() {
  mkandenterbuilddir
  rm -rf $app-$version

  tar xf $srcdir/$app-$version.tar.?z*
  cd $app-$version
  fixbuilddirpermissions

  applypatch $srcdir/01.patch
  applypatch $srcdir/02.patch
  applypatch $srcdir/03.patch
  applypatch $srcdir/CVE-2019-16275.patch

  cd hostapd
  cat $srcdir/hostapd.defconfig > .config

  make 

  install -Dm 644 hostapd.8 $pkg/share/man/man8/hostapd.8
  install -Dm 644 hostapd_cli.1 $pkg/share/man/man1/hostapd_cli.1
  install -Dm 755 hostapd $pkg/bin/hostapd
  install -Dm 755 hostapd_cli $pkg/bin/hostapd_cli
  install -Dm 600 hostapd.conf $pkg/etc/hostapd/hostapd.conf.new

  cp ../COPYING $pkgdocs/

  preprunitservice hostapd down

  mkfinalpkg
}

sha512sums="
003c5f10607d7383227e396096b6ee86cb9047b32ab7cd8ebea4aa8cef5d77d86028bc54486b59dca46cf5f6778d8657464ca8637a78289bc6d9be3d0a7cee34  hostapd-2.9.tar.lz
b76bbca282a74ef16c0303e5dbd2ccd33a62461595964d52c1481b0bfa4f41deacde56830b85409b288803b87ceb6f33cf0ccc69c5b17ec632c2d4784b872f3c  01.patch
00cc739e78c42353a555c0de2f29defecff372927040e14407a231d1ead7ff32a37c9fd46bea7cdf1c24e3ac891bc3d483800d44fc6d2c8a12d2ae886523b12c  02.patch
69243af20cdcfa837c51917a3723779f4825e11436fb83311355b4ffe8f7a4b7a5747a976f7bf923038c410c9e9055b13b866d9a396913ad08bdec3a70e9f6e0  03.patch
63710cfb0992f2c346a9807d8c97cbeaed032fa376a0e93a2e56f7742ce515e9c4dfadbdb1af03ba272281f639aab832f0178f67634c222a5d99e1d462aa9e38  CVE-2019-16275.patch
"
