File iwd.spec of Package iwd

%define realname iwd
%define realver  2.8
%define srcext   tar.xz

%bcond_without   systemd

%define so_ver   0

%define dbus_datadir %(for var in datadir sysconfdir; do dbus_datadir=`pkg-config --variable=$var dbus-1`; test -n "$dbus_datadir" && break; done; echo "$dbus_datadir")

# Common info
Name:          %{realname}
Version:       %{realver}
Release:       wiz%{?extraver:0.}1%{?dist}
License:       LGPL-2.1
Group:         Productivity/Networking/Other
URL:           https://git.kernel.org/pub/scm/network/wireless/iwd.git
Summary:       Wireless daemon for Linux

%if %{with systemd}
Requires:      systemd
BuildRequires: pkgconfig(systemd)
%endif

# Build-time parameters
BuildRequires: xz
BuildRequires: pkg-config
BuildRequires: pkgconfig(libedit) >= 3.1 readline-devel
BuildRequires: pkgconfig(dbus-1)
BuildRequires: pkgconfig(systemd)
BuildRequires: pkgconfig(ell) >= 0.58
BuildRequires: python3-docutils
BuildRoot:     %{_tmppath}/%{name}-root
Source:        https://mirrors.edge.kernel.org/pub/linux/network/wireless/%{realname}-%{realver}%{?extraver}.%{srcext}

%description
Wireless daemon for Linux.

# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{realver}%{?extraver}

# Build/compile software
%build
_CFLAGS='%{optflags} %{?gcc_lto}'
_LDFLAGS='-Wl,--as-needed -Wl,--strip-all -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -lrt -lreadline %{?gcc_lto}'
%configure \
 --enable-pie \
%if %{with systemd}
 --enable-systemd-service \
%else
 --disable-systemd-service \
%endif
 --enable-external-ell \
 --enable-wired \
 --enable-libedit \
 --with-dbus-datadir=%{dbus_datadir} \
 CFLAGS="$_CFLAGS" \
 CXXFLAGS="$_CFLAGS" \
 LDFLAGS="$_LDFLAGS"
%{__make} %{?_smp_mflags} V=1

# Install built software into private root
%install
%{__make} install DESTDIR=%{buildroot}
%{__mkdir} -p %{buildroot}%{_sysconfdir}/iwd
%{__mkdir} -p %{buildroot}%{_localstatedir}/lib/iwd

# Cleanup
%clean
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}

# Main package file list
%files
%defattr(-,root,root)
%license COPYING
%doc AUTHORS ChangeLog README TODO
%dir %{_sysconfdir}/iwd
%{_bindir}/iw*
%{_libexecdir}/iwd
%{_libexecdir}/ead
%{dbus_datadir}/dbus-1/system.d/iwd-dbus.conf
%{dbus_datadir}/dbus-1/system.d/ead-dbus.conf
%{_datadir}/dbus-1/system-services/net.connman.iwd.service
%{_datadir}/dbus-1/system-services/net.connman.ead.service
%dir %{_prefix}/lib/modules-load.d
%{_prefix}/lib/modules-load.d/pkcs8.conf
%if 0%{?_unitdir:1}
%{_unitdir}/iwd.service
%{_unitdir}/ead.service
%dir %{_systemd_util_dir}/network
%{_systemd_util_dir}/network/80-iwd.link
%endif
%dir %{_localstatedir}/lib/iwd
%doc %{_mandir}/man1/*
%doc %{_mandir}/man5/*
%doc %{_mandir}/man7/*
%doc %{_mandir}/man8/*

%if "%{expand:%_vendor}" == "suse"

%pre
%if 0%{?_unitdir:1}
%{service_add_pre iwd.service}
%{service_add_pre ead.service}
%endif

%post
%if 0%{?_unitdir:1}
%{service_add_post iwd.service}
%{service_add_post ead.service}
%else
%{fillup_and_insserv %{realname}}
%endif

%preun
%if 0%{?_unitdir:1}
%{service_del_preun iwd.service}
%{service_del_preun ead.service}
%else
%{stop_on_removal %{realname}}
%endif
rm -rf %{_localstatedir}/cache/%{realname}/*

%postun
%if 0%{?_unitdir:1}
%{service_del_postun iwd.service}
%{service_del_postun ead.service}
%else
%{restart_on_update %{realname}}
%{insserv_cleanup}
%endif

%endif

%changelog
openSUSE Build Service is sponsored by