Name: owl

%define snapshot_upstream_version	0
%define snapshot_date	20220129
%define snapshot_hash	8e4e840

Version: %{snapshot_upstream_version}^%{snapshot_date}git%{snapshot_hash}
Release: 1%{?dist}

Summary: Open implementation of the Apple AWDL ad hoc protocol
License: GPLv3+
URL: https://github.com/hdfssk/owl


Source0: %{url}/archive/%{snapshot_hash}.tar.gz?downloadas=/%{name}-%{snapshot_hash}.tar.gz

%define submod1_name	radiotap
%define submod1_version	94984dd
Source1: https://github.com/radiotap/radiotap-library/archive/%{submod1_version}.tar.gz?downloadas=/%{submod1_name}-%{submod1_version}.tar.gz
# https://github.com/radiotap/radiotap-library/archive/HEAD.tar.gz

%define submod2_name	googletest
%define submod2_version	1.14.0
Source2: https://github.com/google/${submod2_name}/archive/refs/tags/v%{submod2_version}.tar.gz?downloadas=/%{submod2_name}-%{submod2_version}.tar.gz
# https://github.com/google/googletest/archive/HEAD.tar.gz


Requires: libpcap libev libnl3
BuildRequires: cmake gcc-c++ libpcap-devel libev-devel libnl3-devel


%description
Open Wireless Link (OWL) is an open implementation of the Apple Wireless Direct Link (AWDL) ad hoc protocol for Linux and macOS written in C and part of the Open Wireless Link project.

OWL runs in user space and makes use of Linux’s Netlink API for Wi-Fi specific operations such as channel switching and to integrate itself in the Linux networking stack by providing a virtual network interface such that existing IPv6-capable programs can use AWDL without modification.

You can use OWL to in combination with OpenDrop to enable Apple AirDrop functionality on Linux-based systems such as a Raspberry Pi 3.


%prep
%define source_dir %{name}-%{snapshot_hash}
[ -d %{source_dir} ] && %{__rm} -rf %{source_dir}
mkdir -p %{source_dir} && \
tar -xvf %{SOURCE0} -C %{source_dir} --strip-components 1 && \
tar -xvf %{SOURCE1} -C %{source_dir}/%{submod1_name} --strip-components 1 && \
tar -xvf %{SOURCE2} -C %{source_dir}/%{submod2_name} --strip-components 1 && \
%autosetup -T -D -n %{name}-%{snapshot_hash}

%build
%global _hardened_build 1
%global debug_package %{nil}
%global _vpath_builddir build
%cmake -B %{_vpath_builddir} -D INSTALL_GTEST=OFF
%cmake_build

%install
%cmake_install

%check
%ctest

%files
%doc README.md
%license COPYING
%{_bindir}/*

%changelog
* Sun Sep 24 2023 Honore Doktorr <hdfssk@gmail.com> - 0^20220129git8e4e840-1
- Initial packaging