# Maintainer: PktSurf <smlinux@pktsurf.in>
app=wpa-supplicant
sapp="${app/-/_}"
version=2.10
build=3sml
homepage="https://w1.fi/"
download="https://w1.fi/releases/wpa_supplicant-$version.tar.gz"
desc="WPA/WPA2/IEEE 802.1X Supplicant"
requires="readline openssl libnl dbus"

prepbuilddir() {
  mkandenterbuilddir
  rm -rf $sapp-$version

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

  applypatch $srcdir/eloop.patch
  applypatch $srcdir/unsafe-renegotiation-1.patch
  applypatch $srcdir/unsafe-renegotiation-2.patch
  applypatch $srcdir/allow-tlsv1.patch
  applypatch $srcdir/silence-scan-results,patch
}

build() {
  cd wpa_supplicant 
  cp $srcdir/config .config

  make LIBDIR=/lib BINDIR=/bin all eapol_test
  make install LIBDIR=/lib BINDIR=/bin DESTDIR=$pkg

  cp ../COPYING $pkgdocs/LICENSE

  install -Dm 644 dbus/fi.w1.wpa_supplicant1.service $pkg/share/dbus-1/system-services/fi.w1.wpa_supplicant1.service
  install -Dm 644 dbus/dbus-wpa_supplicant.conf $pkg/share/dbus-1/system.d/dbus-wpa_supplicant.conf

  mkdir -p $pkg/share/man/man{5,8}
  cp doc/docbook/wpa_supplicant.conf.5 $pkg/share/man/man5/
  cp doc/docbook/{wpa_cli.8,wpa_passphrase.8,wpa_supplicant.8} $pkg/share/man/man8/

  install -Dm 0600 $srcdir/wpa_supplicant.conf $pkg/etc/wpa_supplicant.conf.new
  install -m 0755 $srcdir/wpa_connect_action.sh $pkg/etc/wpa_connect_action.sh
  mkdir -p $pkg/var/run/wpa_supplicant

  preprunitservice -s wpa-supplicant -d

  mkfinalpkg
}

sha512sums="
021c2a48f45d39c1dc6557730be5debaee071bc0ff82a271638beee6e32314e353e49d39e2f0dc8dff6e094dcc7008cfe1c32d0c7a34a1a345a12a3f1c1e11a1  wpa_supplicant-2.10.tar.gz
9c20b646cf89fab8919927f6533fa24d5e0ec2e6ca10fb738c6e1c17ad451978ecc9f26c09d518d8936d63f86994c8658cbf757d1b65ebced0481635ad69d89b  allow-tlsv1.patch
2be055dd1f7da5a3d8e79c2f2c0220ddd31df309452da18f290144d2112d6dbde0fc633bb2ad02c386a39d7785323acaf5f70e5969995a1e8303a094eb5fe232  eloop.patch
9528735924faf876a7094de46760605e5e66e265187421a668be06dbf03d7b4db6b84cbad793fcd6bd614e3ba540f82f1f80660d75e8a6070eeb7e9abb54ed28  unsafe-renegotiation-1.patch
a92ba3ed3f41022a8af9396d2b703ee47f78aa05c1fddb42919a7fe6a6fad71e3515c63457e97e252ae0a32c6c34d67ea6efe0278df1e141cf36e650237e5295  unsafe-renegotiation-2.patch
"
