Apr 012010
 

This tutorial was tested on fedora 12 system, it might be worked on onthers redhat base system, I’ve modified rpm spec file as generic as possible. it was shamelessly stolen 😀 from Jan Engelhardt xtables rpm source file.i slightly modified it a bit

Download xtables-addons 1.24 source

$ wget http://downloads.sourceforge.net/project/xtables-addons/Xtables-addons/1.24/xtables-addons-1.24.tar.bz2?use_mirror=nchc

prepare your .rpmmacros environment, rpmbuild directories, if not exist yet

$ mkdir rpmbuild
$ mkdir -p rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS,tmp}

Create .rpmmacros file

$ vi  .rpmmacros
%_topdir                %(echo $HOME)/rpmbuild
%_tmppath               %(echo $HOME)/rpmbuild/tmp

[p>Extract xtables-addons-1.24.tar.bz2, cd to xtables-addons-1.24 directory

$ tar xjf xtables-addons-1.24.tar.bz2
$ cd xtables-addons-1.24

Create xtables-addons.spec file

$ vi xtables-addons.spec
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})

%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' Makefile

#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;
find "$b/%_libdir" -maxdepth 1 -type l -iname "*.so" -delete;

%clean
rm -Rf "%buildroot";

%post
/sbin/depmod -a

%postun
/sbin/depmod -a

%files
%defattr(-,root,root)
%{_mandir}/*/*
%attr(755,root,root) %{_sbindir}/*
%attr(755,root,root) %{_libdir}/*.so.*
%attr(755,root,root) /%{_lib}/xtables/*
%attr(644,root,root) %{_kerneldir}/*

%changelog
* Thu Apr 1 2010 - your-email@domain.tld
- new upstream release 1.24

Save it

Now, bzip it back as xtables-addons-1.24.tar.bz2 tarball

$ cd ..
$ tar cjf xtables-addons-1.24.tar.bz2 xtables-addons-1.24

Build xtables-addons-1.24.tar.bz2

$ rpmbuild -ta xtables-addons-1.24.tar.bz2

If there’s nothing gone wrong you’ll have 3 rpm files, here’s what i got on my system, your path should be different than mine

Wrote: /home/user/rpmbuild/SRPMS/xtables-addons-1.24-1.fc12.src.rpm
Wrote: /home/user/rpmbuild/RPMS/i686/xtables-addons-1.24-1.fc12.i686.rpm
Wrote: /home/user/rpmbuild/RPMS/i686/xtables-addons-debuginfo-1.24-1.fc12.i686.rpm

Install/upgrade

$ sudo rpm -Uvh /home/user/rpmbuild/RPMS/i686/xtables-addons-1.24-1.fc12.i686.rpm

Note: you’ve better test it on development machine first before applying on production one

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.