File dnsmasq.spec of Package dnsmasq
%define realname dnsmasq
%define realver  2.90
%define srcext   tar.xz
# turn off the generation of debuginfo rpm  (RH9) ??
%global debug_package %{nil}
# Common info
Name:          %{realname}
Version:       %{realver}
Release:       %{?extraver:0.}1%{?dist}
License:       GPL-2.0 or GPL-3.0
Group:         Productivity/Networking/DNS/Servers
URL:           http://www.thekelleys.org.uk/dnsmasq/doc.html
Summary:       A lightweight DHCP and caching DNS server
# Install-time parameters
Provides:      dns_daemon
# Build-time parameters
BuildRequires: pkg-config gettext
BuildRequires: pkgconfig(dbus-1)
BuildRequires: pkgconfig(libidn2)
BuildRequires: pkgconfig(libnetfilter_conntrack)
BuildRequires: pkgconfig(nettle) pkgconfig(hogweed)
BuildRequires: pkgconfig(libnftables)
BuildRequires: systemd-rpm-macros
Source0:       http://www.thekelleys.org.uk/dnsmasq/%{realname}-%{realver}%{?extraver}.%{srcext}
Source11:      dnsmasq.service
%description
Dnsmasq provides network infrastructure for small networks: DNS, DHCP, router
advertisement and network boot. It is designed to be lightweight and have
a small footprint, suitable for resource constrained routers and firewalls.
# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{realver}%{?extraver}
%{__sed} -ri \
 -e '/^#define CHGRP/ s|^(#define CHGRP ).+$|\1"nobody"|' \
 src/config.h
%build
_CFLAGS='%{optflags}-fpie -I%{_includedir} -DLEASEFILE=\"/var/lib/dnsmasq/leases\" -DRUNFILE=\"/run/dnsmasq.pid\" %{?gcc_lto}'
_LDFLAGS='-Wl,--as-needed -Wl,--strip-all -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro %{?gcc_lto}'
%{__make} %{?_smp_mflags} \
 CFLAGS="$_CFLAGS" \
 LDFLAGS="$_LDFLAGS" \
 \
 PREFIX=%{_prefix} \
 BINDIR=%{_sbindir} \
 MANDIR=%{_mandir} \
 LOCALEDIR=%{_datadir}/locale \
 \
 COPTS="-DHAVE_DBUS -DHAVE_LIBIDN2 -DHAVE_CONNTRACK -DHAVE_DNSSEC -DHAVE_NFTSET"
%install
_CFLAGS='%{optflags}-fpie -I%{_includedir} -DLEASEFILE="/var/lib/dnsmasq/leases" -DRUNFILE="/run/dnsmasq.pid" %{?gcc_lto}'
_LDFLAGS='-Wl,--as-needed -Wl,--strip-all -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro %{?gcc_lto}'
%{__make} install install-i18n DESTDIR=%{buildroot} \
 CFLAGS="$_CFLAGS" \
 LDFLAGS="$_LDFLAGS" \
 \
 PREFIX=%{_prefix} \
 BINDIR=%{_sbindir} \
 MANDIR=%{_mandir} \
 LOCALEDIR=%{_datadir}/locale \
 \
 COPTS="-DHAVE_DBUS -DHAVE_LIBIDN2 -DHAVE_CONNTRACK -DHAVE_DNSSEC -DHAVE_NFTSET"
%{__install} -d -m0755 %{buildroot}/etc/dnsmasq.d/
%{__install} -d -m0755 %{buildroot}/var/lib/dnsmasq/
%{__install} -D -m0644 trust-anchors.conf %{buildroot}%{_datadir}/dnsmasq/trust-anchors.conf
%{__install} -D -m0644 dbus/dnsmasq.conf %{buildroot}/etc/dbus-1/system.d/dnsmasq.conf
%{__sed} -r \
 -e 's|\%\%PREFIX\%\%|%{_prefix}|' \
 -e '/^#?conf-dir=.,\*\.conf/ s/^#//' \
 dnsmasq.conf.example > %{buildroot}/etc/dnsmasq.conf
%{__install} -D -m0644 %{S:11} %{buildroot}%{_unitdir}/dnsmasq.service
%find_lang %{name}
%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}
%files -f %{name}.lang
%defattr(-,root,root)
%license COPYING COPYING-v3
%doc CHANGELOG FAQ doc.html setup.html
%{_sbindir}/*
%config(noreplace) /etc/dnsmasq.conf
%config(noreplace) /etc/dbus-1/system.d/dnsmasq.conf
%dir %{_datadir}/dnsmasq/
%{_datadir}/dnsmasq/trust-anchors.conf
%dir /etc/dnsmasq.d/
%dir %attr(0755,nobody,nobody) /var/lib/dnsmasq/
%doc %{_mandir}/es/man8/*
%doc %{_mandir}/fr/man8/*
%doc %{_mandir}/man8/*
%{_unitdir}/dnsmasq.service
%if "%{expand:%_vendor}" == "suse"
%pre
%{service_add_pre %{name}.service}
%post
%{fillup_only %{name}}
%{service_add_post %{name}.service}
%preun
%{service_del_preun %{name}.service}
%postun
%{service_del_postun %{name}.service}
%{insserv_cleanup}
%endif
%if "%{expand:%_vendor}" == "redhat"
%post
%{systemd_post %{name}.service}
%preun
%{systemd_preun %{name}.service}
%postun
%{systemd_postun %{name}.service}
%endif
%changelog