tun/tun.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 525
bf1e61b0917c
permissions
-rw-r--r--

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

     1 ##
     2 ##  tun.spec -- OpenPKG RPM Specification
     3 ##  Copyright (c) 2012 Michael Schloh von Bennewitz <michael@schloh.com>
     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 ##
    24 #   package information
    25 Name:         tun
    26 Summary:      Universal TUN/TAP Device Driver
    27 URL:          http://vtun.sourceforge.net/tun/
    28 Vendor:       Maxim Krasnyansky
    29 Packager:     Michael Schloh von Bennewitz
    30 Distribution: Europalab Networks Production
    31 Class:        EVAL
    32 Group:        Driver
    33 License:      GPL
    34 Version:      1.1
    35 Release:      20120800
    37 #   list of sources
    38 Source0:      http://vtun.sourceforge.net/tun/tun-%{version}.tar.gz
    39 Patch0:       tun.patch
    41 #   build information
    42 BuildPreReq:  OpenPKG, openpkg >= 20100101, make
    43 PreReq:       OpenPKG, openpkg >= 20100101
    45 %description
    46     Tun provides packet reception and transmission for user space       
    47     programs. It can be viewed as a simple point to point device, which 
    48     instead of receiving packets from a physical media, receives them   
    49     from user space program and instead of sending packets via physical 
    50     media writes them to the user space program.                        
    52 %track
    53     prog tun = {
    54         version   = %{version}
    55         url       = http://vtun.sourceforge.net/tun/
    56         regex     = tun-(__VER__)\.tar\.gz
    57     }
    59 %prep
    60     %setup -q -n tun-%{version}
    61     %patch -p0
    62     %{l_shtool} subst \
    63         -e 's;^\(CC *= *\).*;\1@CC@;' \
    64         -e 's;^\(CFLAGS *= *\).*;\1@CFLAGS@ $(DEFS) -D_KERNEL -I.;' \
    65         solaris/Makefile.in
    66     case "%{l_platform -t}" in
    67         *-sunos5.1[01] )
    68             %{l_shtool} subst \
    69                 -e 's;"tun";"vtun";g' \
    70                 solaris/tun.c
    71             %{l_shtool} subst \
    72                 -e 's;tun;vtun;g' \
    73                 solaris/tun.conf
    74             ;;
    75     esac
    76     case "%{l_platform -t}" in
    77         *-sunos5.11 )
    78             %{l_shtool} subst \
    79                 -e 's;ddi_power\([ \t]*/\* devo_power \*/\);NULL\1;' \
    80                 -e 's;\(else if( (cmd == DDI_SUSPEND)\) || (cmd == DDI_PM_SUSPEND) );\1);' \
    81                 solaris/tun.c
    82             ;;
    83     esac
    84     case "%{l_platform -t}" in
    85         *64-* )
    86             %{l_shtool} subst \
    87 %if "%{l_cc}" == "/opt/solarisstudio12.3/bin/cc"
    88                 -e 's;\(\$(LD)\)  *\(.*-o tun\);\1 -64 \2;' \
    89                 -e 's;^\(CFLAGS *=.*\);\1 -fast -xO4 -m64 -Kpic;' \
    90 %else
    91                 -e 's;^\(CFLAGS *=.*\);\1 -O2 -m64 -fPIC;' \
    92 %endif
    93                 solaris/Makefile.in
    94             ;;
    95     esac
    97 %build
    98 %if "%{l_cc}" == "/opt/solarisstudio12.3/bin/cc"
    99     PATH="/bin:/sbin:/usr/bin:/usr/sbin:/opt/solarisstudio12.3/bin"
   100 %endif
   101     CC="%{l_cc}" \
   102     CFLAGS="%{l_cflags}" \
   103     ./configure \
   104         --prefix=%{l_prefix}
   105     locplat=`grep 'OS_DIR *=' Makefile | sed -e 's;OS_DIR[^=][^=]*= *\([^ ][^ ]*\);\1;'`
   106     ( cd $locplat
   107       %{l_make} %{l_mflags -O}
   108     ) || exit $?
   110 %install
   111     %{l_shtool} mkdir -f -p -m 755 \
   112         $RPM_BUILD_ROOT%{l_prefix}/lib/tun
   113     locplat=`grep 'OS_DIR *=' Makefile | sed -e 's;OS_DIR[^=][^=]*= *\([^ ][^ ]*\);\1;'`
   114     ( cd $locplat
   115       case "%{l_platform -t}" in
   116           *-sunos5.1[01] )
   117               %{l_shtool} install -c -m 755 \
   118                   tun $RPM_BUILD_ROOT%{l_prefix}/lib/tun/vtun
   119               %{l_shtool} install -c -m 644 \
   120                   tun.conf $RPM_BUILD_ROOT%{l_prefix}/lib/tun/vtun.conf
   121               %{l_shtool} install -c -m 644 \
   122                   if_tun.h $RPM_BUILD_ROOT%{l_prefix}/lib/tun/
   123               ;;
   124           * )
   125               %{l_shtool} install -c -m 755 \
   126                   tun $RPM_BUILD_ROOT%{l_prefix}/lib/tun
   127               %{l_shtool} install -c -m 644 \
   128                   tun.conf if_tun.h $RPM_BUILD_ROOT%{l_prefix}/lib/tun
   129               ;;
   130       esac
   131     ) || exit $?
   132     %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}
   134 %files -f files
   136 %clean
   138 %post
   139     if [ $1 -eq 1 -o $1 -eq 2 ]; then
   140         #   announce special nature of this package
   141         ( echo "Attention: The special nature of the package contents require privileged"
   142           echo "interation, and must be carefully copied and nonportably installed to"
   143           echo "system areas outside of the OpenPKG instance."
   144           echo ""
   145           echo "This package therefore does not conform to basic OpenPKG principles, and"
   146           echo "should be removed immediately after its short term utility is exhausted."
   147           echo ""
   148           echo "To complete the installation on a SVR4 style operating system:"
   149           echo ""
   150           echo "  $ su -"
   151           echo "  # find %{l_prefix}/lib/tun/ -print"
   152           echo "  # shtool install -c -m 644 -o root -g sys (v)tun.conf /usr/kernel/drv/"
   153           echo "  # (optional) shtool install -c -m 644 -o root -g bin if_tun.h /usr/include/net/"
   154           echo "  # file (v)tun  # if the driver 32-bit or 64-bit is very important"
   155           echo "  # (either) shtool install -c -m 755 -o root -g sys (v)tun /usr/kernel/drv/"
   156           echo "  # (or) shtool install -c -m 755 -o root -g sys (v)tun /usr/kernel/drv/amd64/"
   157           echo "  # (or) shtool install -c -m 755 -o root -g sys (v)tun /usr/kernel/drv/sparcv9/"
   158           echo "  # modinfo | grep tun"
   159           echo "  # /usr/sbin/rem_drv -C (v)tun"
   160           echo "  # /usr/sbin/add_drv (v)tun"
   161           echo "  # modinfo | grep tun"
   162         ) | %{l_rpmtool} msg -b -t notice
   163     fi
   164     exit 0
   166 %postun
   167     [ $1 -eq 0 ] || exit 0
   168     #   announce special nature of this package on uninstall
   169     ( echo "Attention: The special nature of the package contents require privileged"
   170       echo "interation, and must be carefully deleted and nonportably uninstalled"
   171       echo "from system areas outside of the OpenPKG instance."
   172       echo ""
   173       echo "  $ su -"
   174       echo "  # ls -ld /usr/kernel/drv/*/*tun* /usr/kernel/drv/*tun* /usr/include/net/*tun*"
   175       echo "  # modinfo | grep tun"
   176       echo "  # /usr/sbin/rem_drv -C (v)tun"
   177       echo "  # modinfo | grep tun"
   178       echo "  # ls -ld /usr/kernel/drv/*tun*"
   179       echo "  # ls -ld /usr/kernel/drv/*/*tun*"
   180       echo "  # ls -ld /usr/include/net/*tun*"
   181       echo "  # rm -f /usr/kernel/drv/[archpath]/(v)tun"
   182       echo "  # rm -f /usr/kernel/drv/(v)tun.conf"
   183       echo "  # rm -f /usr/include/net/if_tun.h"
   184     ) | %{l_rpmtool} msg -b -t notice
   185     exit 0

mercurial