openvpn/openvpn.spec

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

mercurial