This is a how to package in RPM format, the Csync2 synchronization tool on CentOS 6.x.
Enjoy it!
Steps
- Append RPM Forge repository by creating the file /etc/yum.repos.d/rpmforge.repo with the following content:
- Install building dependencies:
- Create a temporal cache and define a downloader command:
- Download latest csync2 tarball with sources:
- Download an sqlite compatible version:
- Create a clean RPM build environment:
- Copy the sources tar balls to SOURCES and BUILD:
- Extract the csync2.spec archive from tar ball and modify it to user sqlite sources and include some missing files into the final RPM:
- Build and install the csync2 RPM packages:
$ sudo dd of=/etc/yum.repos.d/rpmforge.repo << EOT
[rpmforge]
name=CentOS-$releasever - Rpmforge
baseurl=http://apt.sw.be/redhat/el6/en/$basearch/rpmforge
gpgcheck=0
enabled=1
EOT
$ sudo yum -y groupinstall "Development Tools"
$ sudo yum -y install openssl-devel
$ sudo yum -y install librsync librsync-devel
$ sudo yum install gnutls openssl libtasn1 gnutls-devel
$ mkdir -p /tmp/cache
#/**
# * Downloads a file to the cache if doesn't exists
# *
# * @param $1 the file to download
# * @param $2 the url where the file is located
# */
$ get() {
[ -f /tmp/cache/$1 ] || wget -t inf -w 5 -c $2/$1 -O /tmp/cache/$1
}
$ lastver=1.34
$ cs=csync2-$lastver.tar.gz
$ get $cs http://oss.linbit.com/csync2/$cs
$ sqver=2.8.16
$ sq=sqlite-$sqver.tar.gz
get $sq http://pkgs.fedoraproject.org/repo/pkgs/sqlite/$sq/9c79b461ff30240a6f9d70dd67f8faea/$sq
$ rm -rf ~/rpmbuild ~/.rpmmacros
$ mkdir -p ~/rpmbuild/{BUILD,RPMS,S{OURCE,PEC,RPM}S}
$ cat > ~/.rpmmacros <<< "%_topdir $HOME/rpmbuild"
$ cd ~/rpmbuild
$ cp /tmp/cache/$cs SOURCES/
$ cp /tmp/cache/$sq BUILD/
$ cd SPECS
$ tar --strip-components=1 -x csync2-$lastver/csync2.spec -vzf ../SOURCES/$cs
$ sed -i \
-e 's/^%changelog/%files\n%defattr(-,root,root,-)\n\/usr\/sbin\/csync2-compare\n\/etc\/csync2.cfg\n\/etc\/xinetd.d\/csync2\n\/usr\/sbin\/csync2\n\/usr\/share\/man\/man1\/csync2.1.gz\n\n&/' \
-e 's/\(^%configure\)/\1 --with-libsqlite-source=..\/sqlite-2.8.16.tar.gz --disable-gnutls/' csync2.spec
$ cd ..
$ rpmbuild -bb SPECS/csync2.spec
$ sudo rpm -ivh RPMS/x86_64/csync2-$lastver-1.x86_64.rpm
Enjoy it!