Thursday, May 7, 2009

How to install OpenVPN 2.1 on Centos/RHEL 5 using rpm

Download and compile pkcs11-helper

Download from http://www.opensc-project.org/


wget http://www.opensc-project.org/files/pkcs11-helper/pkcs11-helper-1.07.tar.bz2

Compile:
rpmbuild -tb pkcs11-helper-1.07.tar.bz2

Install:

rpm -ivh /usr/src/redhat/RPMS/i386/pkcs11-helper-1.07-2rh.i386.rpm /usr/src/redhat/RPMS/i386/pkcs11-helper-devel-1.07-2rh.i386.rpm

OpenVPN 2.1

Download: http://openvpn.net/index.php/downloads.html

Compile: You need to untar the source, copy the openvpn.spec to /usr/src/redhat/SPECS Then copy the original file to /usr/src/redhat/SOURCES Edit the openvpn.spec and delete the management string from it, then compile

rpmbuild -bb openvpn.spec

Install:
rpm -ivh /usr/src/redhat/RPMS/i386/openvpn-2.1_rc15-1.i386.rpm

Install lzo from rpmforge:
yum –enablerepo=rpmforge -y install lzo-devel

More info on using rpmforge on Centos/RHEL here:
http://dag.wieers.com/rpm/FAQ.php#B1

Thats it

6 comments:

  1. Thanks for the help, I needed it. For those who were as confused about "Edit the openvpn.spec and delete the management string from it", look for the lines:

    # Install extra %doc stuff
    %doc contrib/ easy-rsa/ management/ sample-*/ plugin/README.*

    and remove the string "management/ ", leaving the rest intact.

    I also needed an absolute path to build the rpm that was just modified:

    rpmbuild -bb /usr/src/redhat/SPEC/openvpn.spec


    Finally, the last instruction's double-dash turned into an endash.

    ReplyDelete
  2. Making it clearer (I'm using CentOS 5.3):

    cd ~/
    mkdir openvpn
    cd openvpn

    wget http://www.openvpn.net/release/openvpn-2.1_rc19.tar.gz
    wget ftp://ftp.muug.mb.ca/mirror/fedora/epel/5/x86_64/pkcs11-helper-devel-1.07-2.el5.1.i386.rpm
    wget ftp://ftp.muug.mb.ca/mirror/fedora/epel/5/x86_64/pkcs11-helper-1.07-2.el5.1.i386.rpm

    yum install openssl-devel lzo lzo-devel rpm-build autoconf automake imake pkgconfig gcc
    rpm -ivh pkcs11-helper-*.rpm

    cp openvpn-2.1_rc19.tar.gz /usr/src/redhat/SOURCES/
    tar -zxf openvpn-2.1_rc19.tar.gz
    cp openvpn-2.1_rc19/openvpn.spec /usr/src/redhat/SPECS/
    vi /usr/src/redhat/SPECS/openvpn.spec
    # Remove the string: /management

    rpmbuild -bb /usr/src/redhat/SPECS/openvpn.spec

    rpm -ivh /usr/src/redhat/RPMS/i386/openvpn-2.1_rc19-1.i386.rpm

    # Optional: Remove support packages
    yum remove elfutils lzo-devel openssl-devel e2fsprogs-devel keyutils-libs-devel krb5-devel libselinux-devel libsepol-devel zlib-devel rpm-build elfutils-libs pam-devel pkcs11-helper-devel autoconf automake imake pkgconfig gcc cpp glibc-devel glibc-headers kernel-headers libgomp
    # Remove temp files
    rm -rf /usr/src/redhat/SOURCES/openvpn-2.1_rc19.tar.gz
    rm -rf /usr/src/redhat/SPECS/openvpn.spec
    rm -rf /usr/src/redhat/BUILD/openvpn-2.1_rc19/

    cd ~/
    mv /usr/src/redhat/RPMS/i386/openvpn-2.1_rc19-1.i386.rpm ./
    rm -rf openvpn/

    Cheers,
    Fabrício Silva

    ReplyDelete
  3. Fabrício,

    Man this is the *real thing*, you made a poorly made tutorial into a really usefull one, I hadn't been able to build openvpn 2.1.1, because of those pkcs* thingy, I had to comment out the line with pkcs11-helper-* and then it built, also trying to build bzipped, pkcs11-helper archive gives me this error:

    rpmbuild -tb pkcs11-helper-1.07.tar.bz2
    error: Package already exists: %package devel

    In the meantime those pkcs11 things are just for auth with smart cards and who in the world will probably do thjat?.

    Thanks anyway.

    ReplyDelete
  4. rpmbuild -tb openvpn-2.1.1.tar.gz --define 'without_lzo 1' --define 'with_pkcs11 0'

    ReplyDelete
  5. The pkcs11 rpmbuild fix is very comical. Replace the tabs in the spec file with spaces.

    sed 's/\t/ /g' < pkcs11-helper.spec > pkcs11-helper.good.spec

    Then try rpmbuild again and reference the "pkcs11-helper.good.spec" file.

    ReplyDelete
  6. I followed the command from Svein_Hansen and it created the rpm without any issues. I did want lzo so I run the following command instead:

    rpmbuild -tb openvpn-2.1.3.tar.gz --define 'with_pkcs11 0'

    This build the rpm without the dependency on the pkcs11 so I was able to install openvpn 2.1.3.

    ReplyDelete