27 January 2017

Building curl (7.52.1) rpms on CentOS 6 and 7

Greetings,

Let's save you the trouble of trial and error figuring out how to make this thing work in a somewhat elegant manner, by having rpms and being able to up/down-grade at any time, and eventually ending up with something like this:

[root@centos6 build]# curl --version
curl 7.52.1 (x86_64-redhat-linux-gnu) libcurl/7.52.1 OpenSSL/1.0.1e zlib/1.2.3 libssh2/1.4.2
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz UnixSockets HTTPS-proxy 
[root@centos6 build]# rpm -q curl
curl-7.52.1-1.x86_64
[root@centos6 build]# rpm -q libcurl
libcurl-7.52.1-1.x86_64
[root@centos6 build]# 

First, prepare your environment and sync the clocks. You don't want to know the ammount of wierd errors happening because your clock isn't in sync.

For CentOS 6:
sudo yum -y update && yum -y groupinstall "Development Tools" 
sudo yum -y install groff krb5-devel libidn-devel libssh2-devel nss-devel openldap-devel openssh-clients openssh-server pkgconfig stunnel zlib-devel rpm-build ntpdate perl-Time-HiRes 
sudo ntpdate -v time.nist.gov  

For CentOS 7:

sudo yum -y update
sudo yum group mark-install "Development Tools"
sudo yum group update
sudo yum -y install groff krb5-devel libidn-devel libssh2-devel nss-devel openldap-devel openssh-clients openssh-server pkgconfig stunnel zlib-devel rpm-build ntpdate perl-Time-HiRes perl-Digest-MD5
sudo ntpdate -v time.nist.gov

Now setup the actual build:

sudo adduser build

Login as user "build"

sudo su - build -
mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros

Now you will need the source package for curl 7.52.1 and this spec file which is "borrowed" and modified from the official centos srpm.

Copy this paste to a file and call it curl.spec, save it in the homedir of user "build" : Curl 7.52.1 spec

Paste this to rpmbuild/SOURCES/curlbuild.h (create it as it does not yet exist) : curlbuild.h

Download the sources :

wget https://curl.haxx.se/download/curl-7.52.1.tar.lzma -O rpmbuild/SOURCES/curl-7.52.1.tar.lzma

Then build :

cd && rpmbuild -ba curl.spec

It should work and the final files are these:

ls rpmbuild/RPMS/x86_64/ -lah
total 1.2M
drwxr-xr-x. 2 build build 4.0K Jan 27 20:33 .
drwxrwxr-x. 3 build build 4.0K Jan 27 20:33 ..
-rw-rw-r--. 1 build build 261K Jan 27 20:33 curl-7.52.1-1.x86_64.rpm
-rw-rw-r--. 1 build build  24K Jan 27 20:33 curl-debuginfo-7.52.1-1.x86_64.rpm
-rw-rw-r--. 1 build build 200K Jan 27 20:33 libcurl-7.52.1-1.x86_64.rpm
-rw-rw-r--. 1 build build 654K Jan 27 20:33 libcurl-devel-7.52.1-1.x86_64.rpm

Now install them :

rpm -Uvh /home/build/rpmbuild/RPMS/x86_64/curl-7.52.1-1.x86_64.rpm /home/build/rpmbuild/RPMS/x86_64/libcurl-7.52.1-1.x86_64.rpm 

Preparing...                ########################################### [100%]
   1:libcurl                ########################################### [ 50%]
   2:curl                   ########################################### [100%]

And you have it :

curl 7.52.1 (x86_64-redhat-linux-gnu) libcurl/7.52.1 OpenSSL/1.0.1e zlib/1.2.3 libssh2/1.4.2
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz UnixSockets HTTPS-proxy

Yay :D Happy downloading !
Big thanks to whoever maintains hilite.me !