Import package vendor original specs for necessary manipulations.

Fri, 07 Sep 2012 19:01:31 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 07 Sep 2012 19:01:31 +0200
changeset 666
0c12a9c824a0
parent 665
af9f2bac68b2
child 667
9dacbd1d1aa2

Import package vendor original specs for necessary manipulations.

openvpn/fsl.openvpn file | annotate | diff | comparison | revisions
openvpn/openvpn.conf file | annotate | diff | comparison | revisions
openvpn/openvpn.patch file | annotate | diff | comparison | revisions
openvpn/openvpn.spec file | annotate | diff | comparison | revisions
openvpn/rc.openvpn file | annotate | diff | comparison | revisions
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/openvpn/fsl.openvpn	Fri Sep 07 19:01:31 2012 +0200
     1.3 @@ -0,0 +1,16 @@
     1.4 +##
     1.5 +##  fsl.openvpn -- OSSP fsl configuration
     1.6 +##
     1.7 +
     1.8 +ident (openvpn)/.+ q{
     1.9 +    prefix(
    1.10 +        prefix="%b %d %H:%M:%S %N <%L> $1[%P]: "
    1.11 +    )
    1.12 +    -> {
    1.13 +        debug: file(
    1.14 +            path="@l_prefix@/var/openvpn/openvpn.log",
    1.15 +            perm=0644, jitter=1, monitor=3600
    1.16 +        )
    1.17 +    }
    1.18 +};
    1.19 +
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/openvpn/openvpn.conf	Fri Sep 07 19:01:31 2012 +0200
     2.3 @@ -0,0 +1,17 @@
     2.4 +##
     2.5 +##  openvpn.conf -- OpenVPN Server Configuration
     2.6 +##
     2.7 +
     2.8 +#   use a dynamic tun(4) device
     2.9 +dev tun
    2.10 +
    2.11 +#   the remote peer
    2.12 +remote 192.168.0.1
    2.13 +
    2.14 +#   10.0.0.1 is the local  VPN endpoint
    2.15 +#   10.0.0.2 is the remote VPN endpoint
    2.16 +ifconfig 10.0.0.1 10.0.0.2
    2.17 +
    2.18 +#   the pre-shared static key
    2.19 +secret openvpn.key
    2.20 +
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/openvpn/openvpn.patch	Fri Sep 07 19:01:31 2012 +0200
     3.3 @@ -0,0 +1,13 @@
     3.4 +Index: tun.c
     3.5 +--- tun.c.orig	2011-04-06 18:05:52.000000000 +0200
     3.6 ++++ tun.c	2011-04-30 10:22:38.000000000 +0200
     3.7 +@@ -1400,7 +1400,8 @@
     3.8 + #elif defined(TARGET_SOLARIS)
     3.9 + 
    3.10 + #ifndef TUNNEWPPA
    3.11 +-#error I need the symbol TUNNEWPPA from net/if_tun.h
    3.12 ++#warning I usually need the symbol TUNNEWPPA from net/if_tun.h -- using a shameless local copy taken from TUN 1.1
    3.13 ++#define TUNNEWPPA   (('T'<<16) | 0x0001)
    3.14 + #endif
    3.15 + 
    3.16 + void
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/openvpn/openvpn.spec	Fri Sep 07 19:01:31 2012 +0200
     4.3 @@ -0,0 +1,168 @@
     4.4 +##
     4.5 +##  openvpn.spec -- OpenPKG RPM Package Specification
     4.6 +##  Copyright (c) 2000-2011 OpenPKG Foundation e.V. <http://openpkg.net/>
     4.7 +##
     4.8 +##  Permission to use, copy, modify, and distribute this software for
     4.9 +##  any purpose with or without fee is hereby granted, provided that
    4.10 +##  the above copyright notice and this permission notice appear in all
    4.11 +##  copies.
    4.12 +##
    4.13 +##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    4.14 +##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    4.15 +##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    4.16 +##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
    4.17 +##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    4.18 +##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    4.19 +##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
    4.20 +##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    4.21 +##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    4.22 +##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
    4.23 +##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    4.24 +##  SUCH DAMAGE.
    4.25 +##
    4.26 +
    4.27 +#   package version
    4.28 +%define       V_dist 2.2.2
    4.29 +%define       V_opkg 2.2.2
    4.30 +
    4.31 +#   package information
    4.32 +Name:         openvpn
    4.33 +Summary:      Virtual Private Network Facility
    4.34 +URL:          http://openvpn.net/
    4.35 +Vendor:       James Yonan
    4.36 +Packager:     OpenPKG Foundation e.V.
    4.37 +Distribution: OpenPKG Community
    4.38 +Class:        BASE
    4.39 +Group:        Network
    4.40 +License:      GPL
    4.41 +Version:      %{V_opkg}
    4.42 +Release:      20111223
    4.43 +
    4.44 +#   package options
    4.45 +%option       with_fsl  yes
    4.46 +
    4.47 +#   list of sources
    4.48 +Source0:      http://swupdate.openvpn.net/community/releases/openvpn-%{V_dist}.tar.gz
    4.49 +Source1:      rc.openvpn
    4.50 +Source2:      fsl.openvpn
    4.51 +Source3:      openvpn.conf
    4.52 +Patch0:       openvpn.patch
    4.53 +
    4.54 +#   build information
    4.55 +BuildPreReq:  OpenPKG, openpkg >= 20100101
    4.56 +PreReq:       OpenPKG, openpkg >= 20100101, perl
    4.57 +BuildPreReq:  openssl, lzo >= 1.08
    4.58 +PreReq:       openssl, lzo >= 1.08
    4.59 +%if "%{with_fsl}" == "yes"
    4.60 +BuildPreReq:  fsl >= 1.3.0
    4.61 +PreReq:       fsl >= 1.3.0
    4.62 +%endif
    4.63 +
    4.64 +%description
    4.65 +    OpenVPN is a robust and highly configurable VPN (Virtual Private
    4.66 +    Network) daemon which can be used to securely link two or more
    4.67 +    private networks using an encrypted tunnel over the internet.
    4.68 +
    4.69 +%track
    4.70 +    prog openvpn = {
    4.71 +        version   = %{V_dist}
    4.72 +        url       = http://openvpn.net/index.php/open-source/downloads.html
    4.73 +        regex     = openvpn-(2\.[1234](?:\.\d+|_rc\d+))\.tar\.gz
    4.74 +    }
    4.75 +
    4.76 +%prep
    4.77 +    %setup -q -n openvpn-%{V_dist}
    4.78 +    %patch -p0
    4.79 +
    4.80 +%build
    4.81 +    #   configure program
    4.82 +    CC="%{l_cc}" \
    4.83 +    CFLAGS="%{l_cflags -O}" \
    4.84 +    CPPFLAGS="%{l_cppflags lzo openssl}" \
    4.85 +    LDFLAGS="%{l_ldflags} %{l_fsl_ldflags}" \
    4.86 +    LIBS="%{l_fsl_libs}" \
    4.87 +    ./configure \
    4.88 +        --prefix=%{l_prefix} \
    4.89 +        --mandir=%{l_prefix}/man \
    4.90 +        --with-ssl-headers=%{l_prefix}/include/openssl \
    4.91 +        --with-ssl-lib=%{l_prefix}/lib \
    4.92 +        --with-lzo-headers=%{l_prefix}/include/lzo \
    4.93 +        --with-lzo-lib=%{l_prefix}/lib
    4.94 +
    4.95 +    #   build program
    4.96 +    %{l_make} %{l_mflags -O}
    4.97 +
    4.98 +%install
    4.99 +    #   install program
   4.100 +    %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
   4.101 +
   4.102 +    #   strip down installation files
   4.103 +    strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
   4.104 +    rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/doc >/dev/null 2>&1 || true
   4.105 +
   4.106 +    #   install additional files
   4.107 +    %{l_shtool} install -c -m 755 %{l_value -s -a} \
   4.108 +        -e 's;/usr/bin/perl;%{l_prefix}/bin/perl;' \
   4.109 +        sample-scripts/verify-cn $RPM_BUILD_ROOT%{l_prefix}/sbin/openvpn-verify-cn
   4.110 +
   4.111 +    #   install run-command script
   4.112 +    %{l_shtool} mkdir -f -p -m 755 \
   4.113 +        $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
   4.114 +    %{l_shtool} install -c -m 755 %{l_value -s -a} \
   4.115 +        %{SOURCE rc.openvpn} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
   4.116 +
   4.117 +    #   install default config file
   4.118 +    %{l_shtool} mkdir -f -p -m 755 \
   4.119 +        $RPM_BUILD_ROOT%{l_prefix}/etc/openvpn
   4.120 +    %{l_shtool} install -c -m 644 %{l_value -s -a} \
   4.121 +        %{SOURCE openvpn.conf} \
   4.122 +        $RPM_BUILD_ROOT%{l_prefix}/etc/openvpn/
   4.123 +
   4.124 +    #   install OSSP fsl configuration
   4.125 +    %{l_shtool} mkdir -f -p -m 755 \
   4.126 +        $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
   4.127 +    %{l_shtool} install -c -m 644 %{l_value -s -a} \
   4.128 +        %{SOURCE fsl.openvpn} \
   4.129 +        $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
   4.130 +
   4.131 +    #   create run-time directory
   4.132 +    %{l_shtool} mkdir -f -p -m 755 \
   4.133 +        $RPM_BUILD_ROOT%{l_prefix}/var/openvpn
   4.134 +
   4.135 +    #   determine installation files
   4.136 +    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
   4.137 +        %{l_files_std} \
   4.138 +        '%config %{l_prefix}/etc/fsl/fsl.openvpn' \
   4.139 +        '%config %{l_prefix}/etc/openvpn/openvpn.conf'
   4.140 +
   4.141 +%files -f files
   4.142 +
   4.143 +%clean
   4.144 +
   4.145 +%post
   4.146 +    #   on initial install, create a sample shared key
   4.147 +    if [ $1 -eq 1 ]; then
   4.148 +        if [ ! -f $RPM_INSTALL_PREFIX/etc/openvpn/openvpn.dh ]; then
   4.149 +            $RPM_INSTALL_PREFIX/bin/openssl dhparam \
   4.150 +                -out $RPM_INSTALL_PREFIX/etc/openvpn/openvpn.dh 1024
   4.151 +        fi
   4.152 +        if [ ! -f $RPM_INSTALL_PREFIX/etc/openvpn/openvpn.key ]; then
   4.153 +            $RPM_INSTALL_PREFIX/sbin/openvpn \
   4.154 +                --genkey --secret $RPM_INSTALL_PREFIX/etc/openvpn/openvpn.key
   4.155 +        fi
   4.156 +    fi
   4.157 +
   4.158 +    #   after upgrade, restart service
   4.159 +    [ $1 -eq 2 ] || exit 0
   4.160 +    eval `%{l_rc} openvpn status 2>/dev/null`
   4.161 +    [ ".$openvpn_active" = .yes ] && %{l_rc} openvpn restart
   4.162 +    exit 0
   4.163 +
   4.164 +%preun
   4.165 +    #   before erase, stop service and remove log files
   4.166 +    [ $1 -eq 0 ] || exit 0
   4.167 +    %{l_rc} openvpn stop 2>/dev/null
   4.168 +    rm -f $RPM_INSTALL_PREFIX/var/openvpn/*.log*   >/dev/null 2>&1 || true
   4.169 +    rm -f $RPM_INSTALL_PREFIX/var/openvpn/*.status >/dev/null 2>&1 || true
   4.170 +    exit 0
   4.171 +
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/openvpn/rc.openvpn	Fri Sep 07 19:01:31 2012 +0200
     5.3 @@ -0,0 +1,110 @@
     5.4 +#!@l_prefix@/bin/openpkg rc
     5.5 +##
     5.6 +##  rc.openvpn -- Run-Commands
     5.7 +##
     5.8 +
     5.9 +%config
    5.10 +    openvpn_enable="$openpkg_rc_def"
    5.11 +    openvpn_log_prolog="true"
    5.12 +    openvpn_log_epilog="true"
    5.13 +    openvpn_log_numfiles="10"
    5.14 +    openvpn_log_minsize="1M"
    5.15 +    openvpn_log_complevel="9"
    5.16 +
    5.17 +%common
    5.18 +    openvpn_etcdir="@l_prefix@/etc/openvpn"
    5.19 +    openvpn_vardir="@l_prefix@/var/openvpn"
    5.20 +    openvpn_signal () {
    5.21 +        [ -f $openvpn_vardir/$1.pid ] && kill -$2 `cat $openvpn_vardir/$1.pid`
    5.22 +    }
    5.23 +
    5.24 +%status -u @l_susr@ -o
    5.25 +    openvpn_usable="unknown"
    5.26 +    openvpn_active="yes"
    5.27 +    if rcService openvpn enable yes; then
    5.28 +        for cfgfile in $openvpn_etcdir/*.conf; do
    5.29 +            [ ".`grep '^disable' $cfgfile`" != . ] && continue
    5.30 +            name=`echo "$cfgfile" | sed -e 's;^.*/\([^/]*\)\.conf;\1;'`
    5.31 +            openvpn_signal $name 0
    5.32 +            if [ $? -ne 0 ]; then
    5.33 +                openvpn_active="no"
    5.34 +                break
    5.35 +            fi
    5.36 +        done
    5.37 +    fi
    5.38 +    echo "openvpn_enable=\"$openvpn_enable\""
    5.39 +    echo "openvpn_usable=\"$openvpn_usable\""
    5.40 +    echo "openvpn_active=\"$openvpn_active\""
    5.41 +
    5.42 +%start -p 200 -u @l_susr@
    5.43 +    rcService openvpn enable yes || exit 0
    5.44 +    rcService openvpn active yes && exit 0
    5.45 +    if [ -f $openvpn_etcdir/openvpn.sh ]; then
    5.46 +        sh $openvpn_etcdir/openvpn.sh start || exit $?
    5.47 +    fi
    5.48 +    for cfgfile in $openvpn_etcdir/*.conf; do
    5.49 +        [ ".`grep '^disable' $cfgfile`" != . ] && continue
    5.50 +        name=`echo "$cfgfile" | sed -e 's;^.*/\([^/]*\)\.conf;\1;'`
    5.51 +        if [ -f $openvpn_etcdir/$name.sh -a ".$name" != .openvpn ]; then
    5.52 +            sh $openvpn_etcdir/$name.sh start || exit $?
    5.53 +        fi
    5.54 +        @l_prefix@/sbin/openvpn \
    5.55 +            --daemon "$name" \
    5.56 +            --log-append $openvpn_vardir/$name.log \
    5.57 +            --writepid $openvpn_vardir/$name.pid \
    5.58 +            --status $openvpn_vardir/$name.status 60 \
    5.59 +            --config $cfgfile \
    5.60 +            --cd $openvpn_etcdir || exit $?
    5.61 +    done
    5.62 +
    5.63 +%stop -p 800 -u @l_susr@
    5.64 +    rcService openvpn enable yes || exit 0
    5.65 +    rcService openvpn active no && exit 0
    5.66 +    for cfgfile in $openvpn_etcdir/*.conf; do
    5.67 +        [ ".`grep '^disable' $cfgfile`" != . ] && continue
    5.68 +        name=`echo "$cfgfile" | sed -e 's;^.*/\([^/]*\)\.conf;\1;'`
    5.69 +        openvpn_signal $name TERM
    5.70 +    done
    5.71 +    sleep 1
    5.72 +    for cfgfile in $openvpn_etcdir/*.conf; do
    5.73 +        [ ".`grep '^disable' $cfgfile`" != . ] && continue
    5.74 +        name=`echo "$cfgfile" | sed -e 's;^.*/\([^/]*\)\.conf;\1;'`
    5.75 +        if [ -f $openvpn_etcdir/$name.sh -a ".$name" != .openvpn ]; then
    5.76 +            sh $openvpn_etcdir/$name.sh stop || true
    5.77 +        fi
    5.78 +    done
    5.79 +    if [ -f $openvpn_etcdir/openvpn.sh ]; then
    5.80 +        sh $openvpn_etcdir/openvpn.sh stop || true
    5.81 +    fi
    5.82 +    rm -f $openvpn_vardir/*.pid 2>/dev/null || true
    5.83 +
    5.84 +%restart -u @l_susr@
    5.85 +    rcService openvpn enable yes || exit 0
    5.86 +    rcService openvpn active no && exit 0
    5.87 +    rc openvpn stop start
    5.88 +
    5.89 +%reload -u @l_susr@
    5.90 +    rcService openvpn enable yes || exit 0
    5.91 +    rcService openvpn active no && exit 0
    5.92 +    for cfgfile in $openvpn_etcdir/*.conf; do
    5.93 +        [ ".`grep '^disable' $cfgfile`" != . ] && continue
    5.94 +        name=`echo "$cfgfile" | sed -e 's;^.*/\([^/]*\)\.conf;\1;'`
    5.95 +        openvpn_signal $name USR1
    5.96 +        if [ -f $openvpn_etcdir/$name.sh ]; then
    5.97 +            sh $openvpn_etcdir/$name.sh reload || true
    5.98 +        fi
    5.99 +    done
   5.100 +
   5.101 +%daily -u @l_susr@
   5.102 +    rcService openvpn enable yes || exit 0
   5.103 +    for cfgfile in $openvpn_etcdir/*.conf; do
   5.104 +        [ ".`grep '^disable' $cfgfile`" != . ] && continue
   5.105 +        name=`echo "$cfgfile" | sed -e 's;^.*/\([^/]*\)\.conf;\1;'`
   5.106 +        shtool rotate -f \
   5.107 +            -n ${openvpn_log_numfiles} -s ${openvpn_log_minsize} -d \
   5.108 +            -z ${openvpn_log_complevel} -o @l_rusr@ -g @l_rgrp@ -m 644 \
   5.109 +            -P "${openvpn_log_prolog}" \
   5.110 +            -E "${openvpn_log_epilog}; rc openvpn reload" \
   5.111 +            $openvpn_vardir/$name.log
   5.112 +    done
   5.113 +

mercurial