Continuing previous article about Building xtables-addons1-1.24 RPM Package, Now added feature which allow us to build the package with options
for example:
$ rpmbuild -ta xtables-addons-1.24.tar.bz2 --with ACCOUNT --with ipset --with geoip
With this command, only ACCOUNT,ipset,geoip modules would be built, other xtables-addons modules are not built(discarded)
Availble options:
--with ACCOUNT --with CHAOS --with DELUDE --with DHCPMAC --with ECHO --with IPMARK --with LOGMARK --with RAWNAT --with STEAL --with SYSRQ --with TARPIT --with TEE --with condition --with fuzzy --with geoip --with iface --with ipp2p --with ipset --with ipv4options --with length2 --with lscan --with pknock --with psd --with quota2
Here’s xtables-addons.spec file
%define _build_ACCOUNT %{?_with_ACCOUNT:1}%{!?_with_ACCOUNT:0} %define _build_CHAOS %{?_with_CHAOS:1}%{!?_with_CHAOS:0} %define _build_DELUDE %{?_with_DELUDE:1}%{!?_with_DELUDE:0} %define _build_DHCPMAC %{?_with_DHCPMAC:1}%{!?_with_DHCPMAC:0} %define _build_ECHO %{?_with_ECHO:1}%{!?_with_ECHO:0} %define _build_IPMARK %{?_with_IPMARK:1}%{!?_with_IPMARK:0} %define _build_LOGMARK %{?_with_LOGMARK:1}%{!?_with_LOGMARK:0} %define _build_RAWNAT %{?_with_RAWNAT:1}%{!?_with_RAWNAT:0} %define _build_STEAL %{?_with_STEAL:1}%{!?_with_STEAL:0} %define _build_SYSRQ %{?_with_SYSRQ:1}%{!?_with_SYSRQ:0} %define _build_TARPIT %{?_with_TARPIT:1}%{!?_with_TARPIT:0} %define _build_TEE %{?_with_TEE:1}%{!?_with_TEE:0} %define _build_condition %{?_with_condition:1}%{!?_with_condition:0} %define _build_fuzzy %{?_with_fuzzy:1}%{!?_with_fuzzy:0} %define _build_geoip %{?_with_geoip:1}%{!?_with_geoip:0} %define _build_iface %{?_with_iface:1}%{!?_with_iface:0} %define _build_ipp2p %{?_with_ipp2p:1}%{!?_with_ipp2p:0} %define _build_ipset %{?_with_ipset:1}%{!?_with_ipset:0} %define _build_ipv4options %{?_with_ipv4options:1}%{!?_with_ipv4options:0} %define _build_length2 %{?_with_length2:1}%{!?_with_length2:0} %define _build_lscan %{?_with_lscan:1}%{!?_with_lscan:0} %define _build_pknock %{?_with_pknock:1}%{!?_with_pknock:0} %define _build_psd %{?_with_psd:1}%{!?_with_psd:0} %define _build_quota2 %{?_with_quota2:1}%{!?_with_quota2:0} Name: xtables-addons Version: 1.24 Release: 1%{?dist} Group: Productivity/Networking/Security Summary: IP Packet Filter Administration Extensions License: GPL URL: http://xtables-addons.sf.net/ Source: %name-%version.tar.bz2 BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: kernel-headers BuildRequires: iptables-devel >= 1.4.3 BuildRequires: pkgconfig >= 0.23 Provides: ipset = 4.2 %define _kernver %(uname -r) %define _kerneldir %(echo /lib/modules/%{_kernver}) %define _mconfig_path %{_builddir}/%{name}-%{version}/mconfig %define _makefilepath %{_builddir}/%{name}-%{version}/Makefile %define _extensionsmakefilepath %{_builddir}/%{name}-%{version}/extensions/Makefile %description Xtables is used to set up, maintain, and inspect the tables of IP packet filter rules in the Linux kernel. Xtables-addons is the successor to patch-o-matic(-ng). Likewise, it contains extensions that were not, or are not yet, accepted in the main kernel/iptables packages. %prep %setup -q if [ ! -e configure ]; then ./autogen.sh; fi; %build %configure --with-kbuild=%{_kerneldir}/build \ --with-xtlibdir="/%{_lib}/xtables"; # don't do depmod -a yet, so remove depmod -a from Makefile %{__perl} -pi -e 's/depmod\ -a/#depmod -a/g' %{_makefilepath} # suppress warning when make modules_install %{__perl} -pi -e 's/modules_install;/modules_install 2>&1 | grep -v "WARNING:";/g' %{_extensionsmakefilepath} # --with ACCOUNT %if %{_build_ACCOUNT} %{__perl} -pi -e 's/build_ACCOUNT=.+/build_ACCOUNT=m/' %{_mconfig_path} %else %{__perl} -pi -e 's/build_ACCOUNT=m/build_ACCOUNT=/' %{_mconfig_path} %endif # --with CHAOS %if %{_build_CHAOS} %{__perl} -pi -e 's/build_CHAOS=.+/build_CHAOS=m/' %{_mconfig_path} %else %{__perl} -pi -e 's/build_CHAOS=m/build_CHAOS=/' %{_mconfig_path} %endif # --with DELUDE %if %{_build_DELUDE} %{__perl} -pi -e 's/build_DELUDE=.+/build_DELUDE=m/' %{_mconfig_path} %else %{__perl} -pi -e 's/build_DELUDE=m/build_DELUDE=/' %{_mconfig_path} %endif # --with DHCPMAC %if %{_build_DHCPMAC} %{__perl} -pi -e 's/build_DHCPMAC=.+/build_DHCPMAC=m/' %{_mconfig_path} %else %{__perl} -pi -e 's/build_DHCPMAC=m/build_DHCPMAC=/' %{_mconfig_path} %endif # --with ECHO %if %{_build_ECHO} %{__perl} -pi -e 's/build_ECHO=.+/build_ECHO=m/' %{_mconfig_path} %else %{__perl} -pi -e 's/build_ECHO=m/build_ECHO=/' %{_mconfig_path} %endif # --with IPMARK %if %{_build_IPMARK} %{__perl} -pi -e 's/build_IPMARK=.+/build_IPMARK=m/' %{_mconfig_path} %else %{__perl} -pi -e 's/build_IPMARK=m/build_IPMARK=/' %{_mconfig_path} %endif # --with LOGMARK %if %{_build_LOGMARK} %{__perl} -pi -e 's/build_LOGMARK=.+/build_LOGMARK=m/' %{_mconfig_path} %else %{__perl} -pi -e 's/build_LOGMARK=m/build_LOGMARK=/' %{_mconfig_path} %endif # --with RAWNAT %if %{_build_RAWNAT} %{__perl} -pi -e 's/build_RAWNAT=.+/build_RAWNAT=m/' %{_mconfig_path} %else %{__perl} -pi -e 's/build_RAWNAT=m/build_RAWNAT=/' %{_mconfig_path} %endif # --with STEAL %if %{_build_STEAL} %{__perl} -pi -e 's/build_STEAL=.+/build_STEAL=m/' %{_mconfig_path} %else %{__perl} -pi -e 's/build_STEAL=m/build_STEAL=/' %{_mconfig_path} %endif # --with SYSRQ %if %{_build_SYSRQ} %{__perl} -pi -e 's/build_SYSRQ=.+/build_SYSRQ=m/' %{_mconfig_path} %else %{__perl} -pi -e 's/build_SYSRQ=m/build_SYSRQ=/' %{_mconfig_path} %endif # --with TARPIT %if %{_build_TARPIT} %{__perl} -pi -e 's/build_TARPIT=.+/build_TARPIT=m/' %{_mconfig_path} %else %{__perl} -pi -e 's/build_TARPIT=m/build_TARPIT=/' %{_mconfig_path} %endif # --with TEE %if %{_build_TEE} %{__perl} -pi -e 's/build_TEE=.+/build_TEE=m/' %{_mconfig_path} %else %{__perl} -pi -e 's/build_TEE=m/build_TEE=/' %{_mconfig_path} %endif # --with condition %if %{_build_condition} %{__perl} -pi -e 's/build_condition=.+/build_condition=m/' %{_mconfig_path} %else %{__perl} -pi -e 's/build_condition=m/build_condition=/' %{_mconfig_path} %endif # --with fuzzy %if %{_build_fuzzy} %{__perl} -pi -e 's/build_fuzzy=.+/build_fuzzy=m/' %{_mconfig_path} %else %{__perl} -pi -e 's/build_fuzzy=m/build_fuzzy=/' %{_mconfig_path} %endif # --with geoip %if %{_build_geoip} %{__perl} -pi -e 's/build_geoip=.+/build_geoip=m/' %{_mconfig_path} %else %{__perl} -pi -e 's/build_geoip=m/build_geoip=/' %{_mconfig_path} %endif # --with iface %if %{_build_iface} %{__perl} -pi -e 's/build_iface=.+/build_iface=m/' %{_mconfig_path} %else %{__perl} -pi -e 's/build_iface=m/build_iface=/' %{_mconfig_path} %endif # --with ipp2p %if %{_build_ipp2p} %{__perl} -pi -e 's/build_ipp2p=.+/build_ipp2p=m/' %{_mconfig_path} %else %{__perl} -pi -e 's/build_ipp2p=m/build_ipp2p=/' %{_mconfig_path} %endif # --with ipset %if %{_build_ipset} %{__perl} -pi -e 's/build_ipset=.+/build_ipset=m/' %{_mconfig_path} %else %{__perl} -pi -e 's/build_ipset=m/build_ipset=/' %{_mconfig_path} %endif # --with ipv4options %if %{_build_ipv4options} %{__perl} -pi -e 's/build_ipv4options=.+/build_ipv4options=m/' %{_mconfig_path} %else %{__perl} -pi -e 's/build_ipv4options=m/build_ipv4options=/' %{_mconfig_path} %endif # --with length2 %if %{_build_length2} %{__perl} -pi -e 's/build_length2=.+/build_length2=m/' %{_mconfig_path} %else %{__perl} -pi -e 's/build_length2=m/build_length2=/' %{_mconfig_path} %endif # --with lscan %if %{_build_lscan} %{__perl} -pi -e 's/build_lscan=.+/build_lscan=m/' %{_mconfig_path} %else %{__perl} -pi -e 's/build_lscan=m/build_lscan=/' %{_mconfig_path} %endif # --with pknock %if %{_build_pknock} %{__perl} -pi -e 's/build_pknock=.+/build_pknock=m/' %{_mconfig_path} %else %{__perl} -pi -e 's/build_pknock=m/build_pknock=/' %{_mconfig_path} %endif # --with psd %if %{_build_psd} %{__perl} -pi -e 's/build_psd=.+/build_psd=m/' %{_mconfig_path} %else %{__perl} -pi -e 's/build_psd=m/build_psd=/' %{_mconfig_path} %endif # --with quota2 %if %{_build_quota2} %{__perl} -pi -e 's/build_quota2=.+/build_quota2=m/' %{_mconfig_path} %else %{__perl} -pi -e 's/build_quota2=m/build_quota2=/' %{_mconfig_path} %endif #make %{?_smp_mflags}; %{__make} %install b="%{buildroot}"; rm -Rf "$b"; mkdir "$b"; %{__make} install DESTDIR="$b"; # There is no -devel package. So no need for these files. find "$b%{_prefix}" -iname "*.la" -delete; %if %{_build_ACCOUNT} find "$b%{_libdir}" -maxdepth 1 -type l -iname "*.so" -delete; %endif %clean rm -Rf "%{buildroot}"; %post /sbin/depmod -a %postun /sbin/depmod -a %files %defattr(-,root,root) %{_mandir}/*/* %if %{_build_ACCOUNT} || %{_build_ipset} %attr(755,root,root) %{_sbindir}/* %endif %if %{_build_ACCOUNT} %attr(755,root,root) %{_libdir}/*.so.* %endif %attr(755,root,root) /%{_lib}/xtables/* %attr(644,root,root) %{_kerneldir}/* %changelog * Thu Apr 1 2010 - Hari Hendaryanto <hari.h@csmcom.com> - new upstream release 1.24
As usual, test first before applying on production server