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
  5. rpm -ihv --nomd5 freeradius-2.2.3-6.fc19.src.rpm
  6. cd /usr/src/redhat/SPECS; wget
  7. cd /usr/src/redhat/SOURCES; wget
  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"
    #export CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing -fpic -fPIE -DPIE"
    #export LDFLAGS="-pie -Wl,-znow"
  9. rpmbuild --buildroot /tmp/rpmbuild -ba /usr/src/redhat/SPECS/freeradius-2.2.3-6.spec

  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!