openvpn/openvpn.spec

Mon, 28 Jan 2013 17:37:18 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Mon, 28 Jan 2013 17:37:18 +0100
changeset 758
a2c6460cfb16
parent 666
0c12a9c824a0
permissions
-rw-r--r--

Correct socket error reporting improvement with IPv6 portable code,
after helpful recommendation by Saúl Ibarra Corretgé on OSips devlist.

michael@666 1 ##
michael@666 2 ## openvpn.spec -- OpenPKG RPM Package Specification
michael@666 3 ## Copyright (c) 2000-2011 OpenPKG Foundation e.V. <http://openpkg.net/>
michael@666 4 ##
michael@666 5 ## Permission to use, copy, modify, and distribute this software for
michael@666 6 ## any purpose with or without fee is hereby granted, provided that
michael@666 7 ## the above copyright notice and this permission notice appear in all
michael@666 8 ## copies.
michael@666 9 ##
michael@666 10 ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
michael@666 11 ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
michael@666 12 ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
michael@666 13 ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
michael@666 14 ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
michael@666 15 ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
michael@666 16 ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
michael@666 17 ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
michael@666 18 ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
michael@666 19 ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
michael@666 20 ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
michael@666 21 ## SUCH DAMAGE.
michael@666 22 ##
michael@666 23
michael@666 24 # package version
michael@666 25 %define V_dist 2.2.2
michael@666 26 %define V_opkg 2.2.2
michael@666 27
michael@666 28 # package information
michael@666 29 Name: openvpn
michael@666 30 Summary: Virtual Private Network Facility
michael@666 31 URL: http://openvpn.net/
michael@666 32 Vendor: James Yonan
michael@666 33 Packager: OpenPKG Foundation e.V.
michael@666 34 Distribution: OpenPKG Community
michael@666 35 Class: BASE
michael@666 36 Group: Network
michael@666 37 License: GPL
michael@666 38 Version: %{V_opkg}
michael@668 39 Release: 20120800
michael@666 40
michael@666 41 # package options
michael@666 42 %option with_fsl yes
michael@666 43
michael@666 44 # list of sources
michael@666 45 Source0: http://swupdate.openvpn.net/community/releases/openvpn-%{V_dist}.tar.gz
michael@666 46 Source1: rc.openvpn
michael@666 47 Source2: fsl.openvpn
michael@666 48 Source3: openvpn.conf
michael@666 49 Patch0: openvpn.patch
michael@666 50
michael@666 51 # build information
michael@666 52 BuildPreReq: OpenPKG, openpkg >= 20100101
michael@666 53 PreReq: OpenPKG, openpkg >= 20100101, perl
michael@666 54 BuildPreReq: openssl, lzo >= 1.08
michael@666 55 PreReq: openssl, lzo >= 1.08
michael@666 56 %if "%{with_fsl}" == "yes"
michael@666 57 BuildPreReq: fsl >= 1.3.0
michael@666 58 PreReq: fsl >= 1.3.0
michael@666 59 %endif
michael@666 60
michael@666 61 %description
michael@666 62 OpenVPN is a robust and highly configurable VPN (Virtual Private
michael@666 63 Network) daemon which can be used to securely link two or more
michael@666 64 private networks using an encrypted tunnel over the internet.
michael@666 65
michael@666 66 %track
michael@666 67 prog openvpn = {
michael@666 68 version = %{V_dist}
michael@666 69 url = http://openvpn.net/index.php/open-source/downloads.html
michael@666 70 regex = openvpn-(2\.[1234](?:\.\d+|_rc\d+))\.tar\.gz
michael@666 71 }
michael@666 72
michael@666 73 %prep
michael@666 74 %setup -q -n openvpn-%{V_dist}
michael@666 75 %patch -p0
michael@666 76
michael@666 77 %build
michael@666 78 # configure program
michael@666 79 CC="%{l_cc}" \
michael@666 80 CFLAGS="%{l_cflags -O}" \
michael@666 81 CPPFLAGS="%{l_cppflags lzo openssl}" \
michael@666 82 LDFLAGS="%{l_ldflags} %{l_fsl_ldflags}" \
michael@666 83 LIBS="%{l_fsl_libs}" \
michael@666 84 ./configure \
michael@666 85 --prefix=%{l_prefix} \
michael@666 86 --mandir=%{l_prefix}/man \
michael@666 87 --with-ssl-headers=%{l_prefix}/include/openssl \
michael@666 88 --with-ssl-lib=%{l_prefix}/lib \
michael@666 89 --with-lzo-headers=%{l_prefix}/include/lzo \
michael@666 90 --with-lzo-lib=%{l_prefix}/lib
michael@666 91
michael@666 92 # build program
michael@666 93 %{l_make} %{l_mflags -O}
michael@666 94
michael@666 95 %install
michael@666 96 # install program
michael@666 97 %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
michael@666 98
michael@666 99 # strip down installation files
michael@666 100 strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
michael@666 101 rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/doc >/dev/null 2>&1 || true
michael@666 102
michael@666 103 # install additional files
michael@666 104 %{l_shtool} install -c -m 755 %{l_value -s -a} \
michael@666 105 -e 's;/usr/bin/perl;%{l_prefix}/bin/perl;' \
michael@666 106 sample-scripts/verify-cn $RPM_BUILD_ROOT%{l_prefix}/sbin/openvpn-verify-cn
michael@666 107
michael@666 108 # install run-command script
michael@666 109 %{l_shtool} mkdir -f -p -m 755 \
michael@666 110 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
michael@666 111 %{l_shtool} install -c -m 755 %{l_value -s -a} \
michael@666 112 %{SOURCE rc.openvpn} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
michael@666 113
michael@666 114 # install default config file
michael@666 115 %{l_shtool} mkdir -f -p -m 755 \
michael@666 116 $RPM_BUILD_ROOT%{l_prefix}/etc/openvpn
michael@666 117 %{l_shtool} install -c -m 644 %{l_value -s -a} \
michael@666 118 %{SOURCE openvpn.conf} \
michael@666 119 $RPM_BUILD_ROOT%{l_prefix}/etc/openvpn/
michael@666 120
michael@666 121 # install OSSP fsl configuration
michael@666 122 %{l_shtool} mkdir -f -p -m 755 \
michael@666 123 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
michael@666 124 %{l_shtool} install -c -m 644 %{l_value -s -a} \
michael@666 125 %{SOURCE fsl.openvpn} \
michael@666 126 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
michael@666 127
michael@666 128 # create run-time directory
michael@666 129 %{l_shtool} mkdir -f -p -m 755 \
michael@666 130 $RPM_BUILD_ROOT%{l_prefix}/var/openvpn
michael@666 131
michael@666 132 # determine installation files
michael@666 133 %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
michael@666 134 %{l_files_std} \
michael@666 135 '%config %{l_prefix}/etc/fsl/fsl.openvpn' \
michael@666 136 '%config %{l_prefix}/etc/openvpn/openvpn.conf'
michael@666 137
michael@666 138 %files -f files
michael@666 139
michael@666 140 %clean
michael@666 141
michael@666 142 %post
michael@666 143 # on initial install, create a sample shared key
michael@666 144 if [ $1 -eq 1 ]; then
michael@666 145 if [ ! -f $RPM_INSTALL_PREFIX/etc/openvpn/openvpn.dh ]; then
michael@666 146 $RPM_INSTALL_PREFIX/bin/openssl dhparam \
michael@666 147 -out $RPM_INSTALL_PREFIX/etc/openvpn/openvpn.dh 1024
michael@666 148 fi
michael@666 149 if [ ! -f $RPM_INSTALL_PREFIX/etc/openvpn/openvpn.key ]; then
michael@666 150 $RPM_INSTALL_PREFIX/sbin/openvpn \
michael@666 151 --genkey --secret $RPM_INSTALL_PREFIX/etc/openvpn/openvpn.key
michael@666 152 fi
michael@666 153 fi
michael@666 154
michael@666 155 # after upgrade, restart service
michael@666 156 [ $1 -eq 2 ] || exit 0
michael@666 157 eval `%{l_rc} openvpn status 2>/dev/null`
michael@666 158 [ ".$openvpn_active" = .yes ] && %{l_rc} openvpn restart
michael@666 159 exit 0
michael@666 160
michael@666 161 %preun
michael@666 162 # before erase, stop service and remove log files
michael@666 163 [ $1 -eq 0 ] || exit 0
michael@666 164 %{l_rc} openvpn stop 2>/dev/null
michael@666 165 rm -f $RPM_INSTALL_PREFIX/var/openvpn/*.log* >/dev/null 2>&1 || true
michael@666 166 rm -f $RPM_INSTALL_PREFIX/var/openvpn/*.status >/dev/null 2>&1 || true
michael@666 167 exit 0
michael@666 168

mercurial