Monday 27 January 2014

Building FreeRadius RPM for EL5

Hopefully this might be useful for some poor sucker who has to build a FreeRadius RPM for an antiquated OS.
I used this useful page as a starting point, so some of this is duplicated with a few important additions. My build is for version 2.2.3
  1. yum install rpm-build
  2. find /usr/src/redhat -type d | xargs chmod a+wx
  3. yum install autoconf automake gdbm-devel libtool libtool-ltdl-devel openssl-devel pam-devel zlib-devel net-snmp-devel net-snmp-utils readline-devel libpcap-devel openldap-devel perl-devel perl-ExtUtils-Embed python-devel mysql-devel postgresql-devel unixODBC-devel gcc make
  4. wget http://kojipkgs.fedoraproject.org/packages/freeradius/2.2.3/6.fc19/src/freeradius-2.2.3-6.fc19.src.rpm
  5. rpm -ihv --nomd5 freeradius-2.2.3-6.fc19.src.rpm
  6. cd /usr/src/redhat/SPECS; wget http://confluence.diamond.ac.uk/download/attachments/25140151/freeradius-2.2.3-6.spec
  7. cd /usr/src/redhat/SOURCES; wget https://raw.github.com/FreeRADIUS/freeradius-server/v2.x.x/redhat/freeradius-radiusd-init
  8. edit freeradius-2.2.3-6.spec to remove -fPIC stuff
    #%ifarch s390 s390x
    #export CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing -fPIC -fPIE -DPIE"
    #export LDFLAGS="-pie -Wl,-znow"
    #%else
    #export CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing -fpic -fPIE -DPIE"
    #export LDFLAGS="-pie -Wl,-znow"
    #%endif
    
  9. rpmbuild --buildroot /tmp/rpmbuild -ba /usr/src/redhat/SPECS/freeradius-2.2.3-6.spec

Notes:
  1. I found that the -fPIC CFLAGs made the libtool fail with a confusing message saying you need to add -fPIC.
  2. If you don't add --buildroot to the rpmbuild command you'll find it'll be blank and things will be put in all sorts of interesting locations. More worryingly it then deletes stuff and you end up losing things like /usr/include/* which is not good!

No comments: