michael@666: ## michael@666: ## openvpn.spec -- OpenPKG RPM Package Specification michael@666: ## Copyright (c) 2000-2011 OpenPKG Foundation e.V. michael@666: ## michael@666: ## Permission to use, copy, modify, and distribute this software for michael@666: ## any purpose with or without fee is hereby granted, provided that michael@666: ## the above copyright notice and this permission notice appear in all michael@666: ## copies. michael@666: ## michael@666: ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED michael@666: ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF michael@666: ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. michael@666: ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR michael@666: ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, michael@666: ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT michael@666: ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF michael@666: ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND michael@666: ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, michael@666: ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT michael@666: ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF michael@666: ## SUCH DAMAGE. michael@666: ## michael@666: michael@666: # package version michael@666: %define V_dist 2.2.2 michael@666: %define V_opkg 2.2.2 michael@666: michael@666: # package information michael@666: Name: openvpn michael@666: Summary: Virtual Private Network Facility michael@666: URL: http://openvpn.net/ michael@666: Vendor: James Yonan michael@666: Packager: OpenPKG Foundation e.V. michael@666: Distribution: OpenPKG Community michael@666: Class: BASE michael@666: Group: Network michael@666: License: GPL michael@666: Version: %{V_opkg} michael@668: Release: 20120800 michael@666: michael@666: # package options michael@666: %option with_fsl yes michael@666: michael@666: # list of sources michael@666: Source0: http://swupdate.openvpn.net/community/releases/openvpn-%{V_dist}.tar.gz michael@666: Source1: rc.openvpn michael@666: Source2: fsl.openvpn michael@666: Source3: openvpn.conf michael@666: Patch0: openvpn.patch michael@666: michael@666: # build information michael@666: BuildPreReq: OpenPKG, openpkg >= 20100101 michael@666: PreReq: OpenPKG, openpkg >= 20100101, perl michael@666: BuildPreReq: openssl, lzo >= 1.08 michael@666: PreReq: openssl, lzo >= 1.08 michael@666: %if "%{with_fsl}" == "yes" michael@666: BuildPreReq: fsl >= 1.3.0 michael@666: PreReq: fsl >= 1.3.0 michael@666: %endif michael@666: michael@666: %description michael@666: OpenVPN is a robust and highly configurable VPN (Virtual Private michael@666: Network) daemon which can be used to securely link two or more michael@666: private networks using an encrypted tunnel over the internet. michael@666: michael@666: %track michael@666: prog openvpn = { michael@666: version = %{V_dist} michael@666: url = http://openvpn.net/index.php/open-source/downloads.html michael@666: regex = openvpn-(2\.[1234](?:\.\d+|_rc\d+))\.tar\.gz michael@666: } michael@666: michael@666: %prep michael@666: %setup -q -n openvpn-%{V_dist} michael@666: %patch -p0 michael@666: michael@666: %build michael@666: # configure program michael@666: CC="%{l_cc}" \ michael@666: CFLAGS="%{l_cflags -O}" \ michael@666: CPPFLAGS="%{l_cppflags lzo openssl}" \ michael@666: LDFLAGS="%{l_ldflags} %{l_fsl_ldflags}" \ michael@666: LIBS="%{l_fsl_libs}" \ michael@666: ./configure \ michael@666: --prefix=%{l_prefix} \ michael@666: --mandir=%{l_prefix}/man \ michael@666: --with-ssl-headers=%{l_prefix}/include/openssl \ michael@666: --with-ssl-lib=%{l_prefix}/lib \ michael@666: --with-lzo-headers=%{l_prefix}/include/lzo \ michael@666: --with-lzo-lib=%{l_prefix}/lib michael@666: michael@666: # build program michael@666: %{l_make} %{l_mflags -O} michael@666: michael@666: %install michael@666: # install program michael@666: %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT" michael@666: michael@666: # strip down installation files michael@666: strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true michael@666: rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/doc >/dev/null 2>&1 || true michael@666: michael@666: # install additional files michael@666: %{l_shtool} install -c -m 755 %{l_value -s -a} \ michael@666: -e 's;/usr/bin/perl;%{l_prefix}/bin/perl;' \ michael@666: sample-scripts/verify-cn $RPM_BUILD_ROOT%{l_prefix}/sbin/openvpn-verify-cn michael@666: michael@666: # install run-command script michael@666: %{l_shtool} mkdir -f -p -m 755 \ michael@666: $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d michael@666: %{l_shtool} install -c -m 755 %{l_value -s -a} \ michael@666: %{SOURCE rc.openvpn} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/ michael@666: michael@666: # install default config file michael@666: %{l_shtool} mkdir -f -p -m 755 \ michael@666: $RPM_BUILD_ROOT%{l_prefix}/etc/openvpn michael@666: %{l_shtool} install -c -m 644 %{l_value -s -a} \ michael@666: %{SOURCE openvpn.conf} \ michael@666: $RPM_BUILD_ROOT%{l_prefix}/etc/openvpn/ michael@666: michael@666: # install OSSP fsl configuration michael@666: %{l_shtool} mkdir -f -p -m 755 \ michael@666: $RPM_BUILD_ROOT%{l_prefix}/etc/fsl michael@666: %{l_shtool} install -c -m 644 %{l_value -s -a} \ michael@666: %{SOURCE fsl.openvpn} \ michael@666: $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/ michael@666: michael@666: # create run-time directory michael@666: %{l_shtool} mkdir -f -p -m 755 \ michael@666: $RPM_BUILD_ROOT%{l_prefix}/var/openvpn michael@666: michael@666: # determine installation files michael@666: %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \ michael@666: %{l_files_std} \ michael@666: '%config %{l_prefix}/etc/fsl/fsl.openvpn' \ michael@666: '%config %{l_prefix}/etc/openvpn/openvpn.conf' michael@666: michael@666: %files -f files michael@666: michael@666: %clean michael@666: michael@666: %post michael@666: # on initial install, create a sample shared key michael@666: if [ $1 -eq 1 ]; then michael@666: if [ ! -f $RPM_INSTALL_PREFIX/etc/openvpn/openvpn.dh ]; then michael@666: $RPM_INSTALL_PREFIX/bin/openssl dhparam \ michael@666: -out $RPM_INSTALL_PREFIX/etc/openvpn/openvpn.dh 1024 michael@666: fi michael@666: if [ ! -f $RPM_INSTALL_PREFIX/etc/openvpn/openvpn.key ]; then michael@666: $RPM_INSTALL_PREFIX/sbin/openvpn \ michael@666: --genkey --secret $RPM_INSTALL_PREFIX/etc/openvpn/openvpn.key michael@666: fi michael@666: fi michael@666: michael@666: # after upgrade, restart service michael@666: [ $1 -eq 2 ] || exit 0 michael@666: eval `%{l_rc} openvpn status 2>/dev/null` michael@666: [ ".$openvpn_active" = .yes ] && %{l_rc} openvpn restart michael@666: exit 0 michael@666: michael@666: %preun michael@666: # before erase, stop service and remove log files michael@666: [ $1 -eq 0 ] || exit 0 michael@666: %{l_rc} openvpn stop 2>/dev/null michael@666: rm -f $RPM_INSTALL_PREFIX/var/openvpn/*.log* >/dev/null 2>&1 || true michael@666: rm -f $RPM_INSTALL_PREFIX/var/openvpn/*.status >/dev/null 2>&1 || true michael@666: exit 0 michael@666: