%global module_name batman-adv

Name:           %{module_name}-dkms
Version:        2023.2
Release:        2%{?dist}
Summary:        Implementation of the B.A.T.M.A.N. routing protocol

License:        GPLv2+
URL:            https://www.open-mesh.org/projects/batman-adv/wiki
Source0:        https://downloads.open-mesh.org/batman/stable/sources/batman-adv/batman-adv-%{version}.tar.gz
Source100:      %{name}.conf

# Patch carried downstream: https://lists.open-mesh.org/mailman3/hyperkitty/list/b.a.t.m.a.n@lists.open-mesh.org/message/FSEYAYHWVSGJXPHWG3DHSHR7QXUWBDGW/
Patch0:         0001-batman-adv-compat-Fix-build-on-RHEL.patch

BuildArch:      noarch

Requires:       batctl
Requires:       dkms
Requires:       make

%description
B.A.T.M.A.N. (better approach to mobile ad-hoc networking) is a new routing
protocol for multi-hop ad-hoc mesh networks. B.A.T.M.A.N.-advanced is the
implementation of this protocol on ISO/OSI Layer 2, allowing mesh networks to be
used as a virtual switch. With this approach, LANs and WANs can be easily
integrated, and more protocols (like DHCP, IPv6) are supported.


%prep
%autosetup -n %{module_name}-%{version} -p1


%build
# Nothing to build


%install
rm -rf $RPM_BUILD_ROOT
install -dm 0755 %{buildroot}/%{_usrsrc}
cp -a . %{buildroot}/%{_usrsrc}/%{module_name}-%{version}
sed -e "s/@MODULE_VERSION@/%{version}/" %{SOURCE100} > %{buildroot}/%{_usrsrc}/%{module_name}-%{version}/dkms.conf


%post
/usr/lib/dkms/common.postinst %{module_name} %{version} %{_datarootdir}/%{module_name}
exit $?


%preun
dkms remove -m %{module_name} -v %{version} --all --rpm_safe_upgrade
exit 0


%files
%license LICENSES/preferred/GPL-2.0
%doc CHANGELOG.rst Documentation MAINTAINERS
%{_usrsrc}/%{module_name}-%{version}


%changelog
* Thu Aug 31 2023 Felix Kaechele <felix@kaechele.ca> - 2023.2-2
- fix RHEL patch for 8-stream / 8.9

* Thu Aug 31 2023 Felix Kaechele <felix@kaechele.ca> - 2023.2-1
- update to 2023.2
- refresh RHEL patch

* Fri Oct 28 2022 Felix Kaechele <felix@kaechele.ca> - 2022.2-1
- update to 2022.2

* Sat May 07 2022 Felix Kaechele <felix@kaechele.ca> - 2022.1-1
- update to 2022.1

* Sun Apr 24 2022 Felix Kaechele <felix@kaechele.ca> - 2022.0-3
- add patch to fix build on newer kernels

* Sat Apr 16 2022 Felix Kaechele <felix@kaechele.ca> - 2022.0-2
- add fragmentation bug patch

* Sun Mar 20 2022 Felix Kaechele <felix@kaechele.ca> - 2022.0-1
- update to 2022.0

* Tue Sep 14 2021 Felix Kaechele <felix@kaechele.ca> - 2021.3-1
- update to 2021.3

* Sat Aug 21 2021 Felix Kaechele <felix@kaechele.ca> - 2021.2-1
- update to 2021.2

* Fri Aug 06 2021 Felix Kaechele <felix@kaechele.ca> - 2021.1-2
- update RHEL patch

* Thu May 20 2021 Felix Kaechele <felix@kaechele.ca> - 2021.1-1
- update to 2021.0

* Thu Jan 28 2021 Felix Kaechele <heffer@fedoraproject.org> - 2021.0-1
- update to 2021.0

* Tue Oct 27 2020 Felix Kaechele <heffer@fedoraproject.org> - 2020.4-1
- update to 2020.4

* Fri Sep 04 2020 Felix Kaechele <heffer@fedoraproject.org> - 2020.3-1
- update to 2020.3

* Tue Jul 07 2020 Felix Kaechele <heffer@fedoraproject.org> - 2020.2-1
- update to 2020.2

* Mon Jul 06 2020 Felix Kaechele <heffer@fedoraproject.org> - 2020.1-2
- update EL 8.1 patch

* Fri Apr 24 2020 Felix Kaechele <heffer@fedoraproject.org> - 2020.1-1
- update to 2020.1

* Thu Mar 05 2020 Felix Kaechele <heffer@fedoraproject.org> - 2020.0-1
- update to 2020.0

* Sat Jan 25 2020 Felix Kaechele <heffer@fedoraproject.org> - 2019.5-2
- fix build on EL >= 8.1

* Mon Dec 30 2019 Felix Kaechele <heffer@fedoraproject.org> - 2019.5-1
- initial package