# Packager = Tuxcore <dev@tuxcore.org> 
pkgname=wpa_supplicant
pkgver=2.10
pkgrel=8
epoch=2
pkgdesc='A utility providing key negotiation for WPA wireless networks'
url='https://w1.fi/wpa_supplicant/'
arch=(x86_64)
license=(BSD-3-Clause)
depends=(
  glibc
  libdbus
  libnl
  openssl
  pcsclite
  readline
)
makedepends=(
  docbook-sgml
  docbook-utils
  git
  perl-sgmls
)
install=wpa_supplicant.install
source=(
  "git+https://w1.fi/hostap.git?signed#tag=hostap_${pkgver//./_}"
  wpa_supplicant_config

  # More permissive TLS fallback
  0001-Enable-TLSv1.0-by-default.patch

  # Unit improvements from Ubuntu
  0002-Tweak-D-Bus-systemd-service-activation-configuration.patch
  0003-Add-IgnoreOnIsolate-yes-to-keep-wpa-supplicant-runni.patch

  # https://lists.infradead.org/pipermail/hostap/2022-May/040511.html
  # https://bugs.archlinux.org/task/76474
  0004-Allow-legacy-renegotiation-to-fix-PEAP-issues-with-s.patch

  # https://lists.infradead.org/pipermail/hostap/2022-May/040571.html
  # https://bugs.archlinux.org/task/76474
  0005-OpenSSL-Drop-security-level-to-0-with-OpenSSL-3.0-wh.patch

  # https://salsa.debian.org/debian/wpa/-/commit/13e1d28e4f987a220c546df94df86bb9b2371874
  0006-Disable-Werror-for-eapol_test.patch

  # https://lists.infradead.org/pipermail/hostap/2022-January/040178.html
  0007-nl80211-add-extra-ies-only-if-allowed-by-driver.patch

  # https://lists.infradead.org/pipermail/hostap/2022-April/040352.html
  0008-AP-guard-FT-SAE-code-with-CONFIG_IEEE80211R_AP.patch

  # https://w1.fi/cgit/hostap/commit/?id=e9b4ad2364c68130c7618a88a171e29e0e15007e
  0009-OpenSSL-Apply-connection-flags-before-reading-certif.patch

  # https://bugs.archlinux.org/task/78770
  0010-Don-t-upgrade-SSL-security-level-to-1-when-setting-c.patch

  # More unit improvements from Debian
  0011-Add-reload-support-to-the-systemd-unit-files.patch

  # https://salsa.debian.org/debian/wpa/-/commit/5e9486d9de777c9145bcc8bf8048a08abf539cac
  0012-WNM-Choose-the-best-available-BSS-not-just-the-first.patch
  0013-wpa_supplicant-Fix-wpa_supplicant-configuration-pars.patch

  # https://salsa.debian.org/debian/wpa/-/commit/f0d078409df01fa466523c2ab015274c351a83c0
  0014-Abort-ongoing-scan.patch

  # https://salsa.debian.org/debian/wpa/-/commit/fdcff9f7b4c699f94e38e519e34220e528bee2f9
  0015-Override-ieee80211w-from-pmf-for-AP-mode-in-wpa_supp.patch
)
b2sums=('b2122646f481d64c4a2c00dea39610799948adc413b6b98c46eb36e3d4fb0cd9f62d4922f4cc0db900e031041a87c4f0f90f8ac84283ebaf9d7838108360fd86'
        '9785af24e59e3d48dc3ab055cc6b9e5bbf081e801fbbfa70d532c2ad8f7f4e59c2679385c75aa02f856ec387cd5182640ff91d892aed9846c738da57e05574d9'
        '3afb304a7f5f2f830b6101be7e6d74281257cd007a1586c3e713ace833ee7743c00163551f831d9e67632d9c488f461a8de9224945439a6dd0341a11a60eda53'
        '7175e7aab682370aef1b3358eaa839dcb009e12940aa2b9949c8c3254406341433e84af09d09ad670bf41f5201d979af02095c87a368b76465a952b1be9de049'
        '6472d571f18c3ee718315888b9c756c4579a4b411e8c6994002f9a79fb0a36fbebe8b3d419af0f9ea881dd1bc439d03dbe3c6d6661e670f16575197c31f0bd7a'
        '07c009184b7d701067e7b63db3434c678171016e1702eeb630c0bb5ee91d10f186c2aef4837d433a863b6a3439e25404d6b141189eb09c65ee9a1422dc84159d'
        'bc1ede03d9b38704d5c5dfea35216cda390d9f195d7b988c7a34722fcc8da3a7d31e4b3a75ae2e2829d0512fe01cbcb011bad3ec71caa20f2a7578c079906587'
        '5fd4394232efb46e115c7a739ccd3f1a485503d14e28ec9ced43a225b722740b8261254e21fa5c011958b0bccb473415a5487e84aae33ef8ec1f629a7065bf9b'
        'd8ff913f6f72226a93cf0d9999f0bd2abd992ef9562035e8e020d8af825966eaceab1314351d6da0ef70be350c5a63e9b76907f137828f0f3eb3a1cf2d179ae5'
        '72f3f64f18eacf974aca8aa8a2b4d89d1b360b5b15e6e1df4f96228feee7743fc64eb751e9e7dca51a9f7171d28c31cfae92b93b9a1a270a0273af98bccd064c'
        'a51947cc8ebd2cd4e76af11ca283ae0d011ba48ffcad30c58d1958c55d9a115cdb0d31c8fb46c56f5ed986ce9cb45e84decbb37c48f1e52f60debfa4a602450c'
        'd2403fb58f6b9bbace5f1ebf69a75ee0fa3b7cf0c82c1517f88ef78b88eeccda6f83ad62e67a7bef64ef8d58776486b0df16af24f7dbbf8c6de767ac07c6f10e'
        'cdb99d58957584ec762fc77a21f78dd4f6908842113515f174c122abca69d9adc8ed4d7a79aad52274951b029d5854030cd5caa7782c1951e2c8b86144a2a74c'
        '5e423fc9a6a6c0943dcc36b44703616abb8fb5a920902eef3704a819a2b83645849fd4605c893d8a29cfb44367be4e51845f15155fd2a009bf83def456ec7e6c'
        '6862e044523431deb49bb4ff2d61aeb1cdb615f2e900b3ffc2a17fd68ecbf7c98392390e6caf89fb51ae4733aae8c02064121b5ffc7c614302de065593df9181'
        '7e79b8912bec9c73143e51702829716cacbfd567ff8f3e8584e5d65e482f9909df360e0425f44f9f13e46e659fdc0493268461d185965dd6c5bb55ba656d5da0'
        'e118d52d7b2c64e1a42b9fb22c91b756881ceffe01a3444af0f906045017ccee047185e477297c2c38c175aaaa89b899f7e86ff0e3d4c95813a10cccdeba2f40')
  EC4AA0A991A5F2464582D52D2B6EF432EFC895FA # Jouni Malinen <j@w1.fi>
)

prepare() {
  cd hostap

  local src
  for src in "${source[@]}"; do
    [[ $src = *.patch ]] || continue
    echo "Applying patch $src..."
    patch -Np1 < "../$src"
  done

  cp ../wpa_supplicant_config $pkgname/.config
}

_make() {
  local make_options=(
    BINDIR=/usr/bin
    LIBDIR=/usr/lib
    "$@"
  )

  make "${make_options[@]}"
}

build() {
  cd hostap/$pkgname

  _make
  _make eapol_test
  _make -C doc/docbook man
}

package() {
  cd hostap/$pkgname

  _make DESTDIR="$pkgdir" install

  install -Dm755 eapol_test "$pkgdir/usr/bin/eapol_test"

  install -dm755 "$pkgdir/etc/wpa_supplicant"
  install -Dm644 wpa_supplicant.conf -t "$pkgdir/usr/share/doc/wpa_supplicant"

  install -Dm644 dbus/fi.w1.wpa_supplicant1.service \
    -t "$pkgdir/usr/share/dbus-1/system-services"

  install -Dm644 dbus/dbus-wpa_supplicant.conf \
    "$pkgdir/usr/share/dbus-1/system.d/wpa_supplicant.conf"

  install -Dm644 doc/docbook/*.5 -t "$pkgdir/usr/share/man/man5"
  install -Dm644 doc/docbook/*.8 -t "$pkgdir/usr/share/man/man8"
  rm "$pkgdir"/usr/share/man/man8/wpa_{priv,gui}.8

  install -Dm644 systemd/*.service -t "$pkgdir/usr/lib/systemd/system"

  install -Dm644 ../README "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

# vim:set sw=2 sts=-1 et:
