tun/tun.spec

Fri, 07 Sep 2012 19:08:07 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 07 Sep 2012 19:08:07 +0200
changeset 667
9dacbd1d1aa2
parent 525
bf1e61b0917c
permissions
-rw-r--r--

Correct build configuration in Solaris subdir, correct english grammar,
remove irrelevant strip notice, introduce custom CFLAG logic, facilitate
use of Solaris Studio compiler with needed build configuration
adjustments, conditionally build 64 bit position independent code,
and accommodate tun(7) in newer Solaris releases by renaming driver
and module from conflicting 'tun' to 'vtun'. These changes include
some nonstandard 'I give up' logic causing out of tree builds by
manipulating the PATH, for example.

michael@75 1 ##
michael@75 2 ## tun.spec -- OpenPKG RPM Specification
michael@525 3 ## Copyright (c) 2012 Michael Schloh von Bennewitz <michael@schloh.com>
michael@75 4 ##
michael@75 5 ## Permission to use, copy, modify, and distribute this software for
michael@75 6 ## any purpose with or without fee is hereby granted, provided that
michael@75 7 ## the above copyright notice and this permission notice appear in all
michael@75 8 ## copies.
michael@75 9 ##
michael@75 10 ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
michael@75 11 ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
michael@75 12 ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
michael@75 13 ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
michael@75 14 ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
michael@75 15 ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
michael@75 16 ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
michael@75 17 ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
michael@75 18 ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
michael@75 19 ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
michael@75 20 ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
michael@75 21 ## SUCH DAMAGE.
michael@75 22 ##
michael@75 23
michael@75 24 # package information
michael@75 25 Name: tun
michael@75 26 Summary: Universal TUN/TAP Device Driver
michael@75 27 URL: http://vtun.sourceforge.net/tun/
michael@75 28 Vendor: Maxim Krasnyansky
michael@75 29 Packager: Michael Schloh von Bennewitz
michael@387 30 Distribution: Europalab Networks Production
michael@75 31 Class: EVAL
michael@75 32 Group: Driver
michael@75 33 License: GPL
michael@75 34 Version: 1.1
michael@525 35 Release: 20120800
michael@75 36
michael@75 37 # list of sources
michael@75 38 Source0: http://vtun.sourceforge.net/tun/tun-%{version}.tar.gz
michael@75 39 Patch0: tun.patch
michael@75 40
michael@75 41 # build information
michael@525 42 BuildPreReq: OpenPKG, openpkg >= 20100101, make
michael@525 43 PreReq: OpenPKG, openpkg >= 20100101
michael@75 44
michael@75 45 %description
michael@75 46 Tun provides packet reception and transmission for user space
michael@667 47 programs. It can be viewed as a simple point to point device, which
michael@75 48 instead of receiving packets from a physical media, receives them
michael@75 49 from user space program and instead of sending packets via physical
michael@75 50 media writes them to the user space program.
michael@75 51
michael@75 52 %track
michael@75 53 prog tun = {
michael@75 54 version = %{version}
michael@75 55 url = http://vtun.sourceforge.net/tun/
michael@75 56 regex = tun-(__VER__)\.tar\.gz
michael@75 57 }
michael@75 58
michael@75 59 %prep
michael@75 60 %setup -q -n tun-%{version}
michael@75 61 %patch -p0
michael@667 62 %{l_shtool} subst \
michael@667 63 -e 's;^\(CC *= *\).*;\1@CC@;' \
michael@667 64 -e 's;^\(CFLAGS *= *\).*;\1@CFLAGS@ $(DEFS) -D_KERNEL -I.;' \
michael@667 65 solaris/Makefile.in
michael@667 66 case "%{l_platform -t}" in
michael@667 67 *-sunos5.1[01] )
michael@667 68 %{l_shtool} subst \
michael@667 69 -e 's;"tun";"vtun";g' \
michael@667 70 solaris/tun.c
michael@667 71 %{l_shtool} subst \
michael@667 72 -e 's;tun;vtun;g' \
michael@667 73 solaris/tun.conf
michael@667 74 ;;
michael@667 75 esac
michael@525 76 case "%{l_platform -t}" in
michael@525 77 *-sunos5.11 )
michael@525 78 %{l_shtool} subst \
michael@525 79 -e 's;ddi_power\([ \t]*/\* devo_power \*/\);NULL\1;' \
michael@525 80 -e 's;\(else if( (cmd == DDI_SUSPEND)\) || (cmd == DDI_PM_SUSPEND) );\1);' \
michael@525 81 solaris/tun.c
michael@525 82 ;;
michael@525 83 esac
michael@667 84 case "%{l_platform -t}" in
michael@667 85 *64-* )
michael@667 86 %{l_shtool} subst \
michael@667 87 %if "%{l_cc}" == "/opt/solarisstudio12.3/bin/cc"
michael@667 88 -e 's;\(\$(LD)\) *\(.*-o tun\);\1 -64 \2;' \
michael@667 89 -e 's;^\(CFLAGS *=.*\);\1 -fast -xO4 -m64 -Kpic;' \
michael@667 90 %else
michael@667 91 -e 's;^\(CFLAGS *=.*\);\1 -O2 -m64 -fPIC;' \
michael@667 92 %endif
michael@667 93 solaris/Makefile.in
michael@667 94 ;;
michael@667 95 esac
michael@75 96
michael@75 97 %build
michael@667 98 %if "%{l_cc}" == "/opt/solarisstudio12.3/bin/cc"
michael@667 99 PATH="/bin:/sbin:/usr/bin:/usr/sbin:/opt/solarisstudio12.3/bin"
michael@667 100 %endif
michael@75 101 CC="%{l_cc}" \
michael@667 102 CFLAGS="%{l_cflags}" \
michael@75 103 ./configure \
michael@75 104 --prefix=%{l_prefix}
michael@75 105 locplat=`grep 'OS_DIR *=' Makefile | sed -e 's;OS_DIR[^=][^=]*= *\([^ ][^ ]*\);\1;'`
michael@75 106 ( cd $locplat
michael@75 107 %{l_make} %{l_mflags -O}
michael@75 108 ) || exit $?
michael@75 109
michael@75 110 %install
michael@75 111 %{l_shtool} mkdir -f -p -m 755 \
michael@75 112 $RPM_BUILD_ROOT%{l_prefix}/lib/tun
michael@75 113 locplat=`grep 'OS_DIR *=' Makefile | sed -e 's;OS_DIR[^=][^=]*= *\([^ ][^ ]*\);\1;'`
michael@75 114 ( cd $locplat
michael@667 115 case "%{l_platform -t}" in
michael@667 116 *-sunos5.1[01] )
michael@667 117 %{l_shtool} install -c -m 755 \
michael@667 118 tun $RPM_BUILD_ROOT%{l_prefix}/lib/tun/vtun
michael@667 119 %{l_shtool} install -c -m 644 \
michael@667 120 tun.conf $RPM_BUILD_ROOT%{l_prefix}/lib/tun/vtun.conf
michael@667 121 %{l_shtool} install -c -m 644 \
michael@667 122 if_tun.h $RPM_BUILD_ROOT%{l_prefix}/lib/tun/
michael@667 123 ;;
michael@667 124 * )
michael@667 125 %{l_shtool} install -c -m 755 \
michael@667 126 tun $RPM_BUILD_ROOT%{l_prefix}/lib/tun
michael@667 127 %{l_shtool} install -c -m 644 \
michael@667 128 tun.conf if_tun.h $RPM_BUILD_ROOT%{l_prefix}/lib/tun
michael@667 129 ;;
michael@667 130 esac
michael@75 131 ) || exit $?
michael@75 132 %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}
michael@75 133
michael@75 134 %files -f files
michael@75 135
michael@75 136 %clean
michael@75 137
michael@75 138 %post
michael@75 139 if [ $1 -eq 1 -o $1 -eq 2 ]; then
michael@75 140 # announce special nature of this package
michael@75 141 ( echo "Attention: The special nature of the package contents require privileged"
michael@75 142 echo "interation, and must be carefully copied and nonportably installed to"
michael@75 143 echo "system areas outside of the OpenPKG instance."
michael@75 144 echo ""
michael@75 145 echo "This package therefore does not conform to basic OpenPKG principles, and"
michael@75 146 echo "should be removed immediately after its short term utility is exhausted."
michael@75 147 echo ""
michael@75 148 echo "To complete the installation on a SVR4 style operating system:"
michael@75 149 echo ""
michael@75 150 echo " $ su -"
michael@75 151 echo " # find %{l_prefix}/lib/tun/ -print"
michael@667 152 echo " # shtool install -c -m 644 -o root -g sys (v)tun.conf /usr/kernel/drv/"
michael@667 153 echo " # (optional) shtool install -c -m 644 -o root -g bin if_tun.h /usr/include/net/"
michael@667 154 echo " # file (v)tun # if the driver 32-bit or 64-bit is very important"
michael@667 155 echo " # (either) shtool install -c -m 755 -o root -g sys (v)tun /usr/kernel/drv/"
michael@667 156 echo " # (or) shtool install -c -m 755 -o root -g sys (v)tun /usr/kernel/drv/amd64/"
michael@667 157 echo " # (or) shtool install -c -m 755 -o root -g sys (v)tun /usr/kernel/drv/sparcv9/"
michael@667 158 echo " # modinfo | grep tun"
michael@667 159 echo " # /usr/sbin/rem_drv -C (v)tun"
michael@667 160 echo " # /usr/sbin/add_drv (v)tun"
michael@667 161 echo " # modinfo | grep tun"
michael@75 162 ) | %{l_rpmtool} msg -b -t notice
michael@75 163 fi
michael@75 164 exit 0
michael@75 165
michael@75 166 %postun
michael@75 167 [ $1 -eq 0 ] || exit 0
michael@75 168 # announce special nature of this package on uninstall
michael@75 169 ( echo "Attention: The special nature of the package contents require privileged"
michael@75 170 echo "interation, and must be carefully deleted and nonportably uninstalled"
michael@75 171 echo "from system areas outside of the OpenPKG instance."
michael@75 172 echo ""
michael@75 173 echo " $ su -"
michael@667 174 echo " # ls -ld /usr/kernel/drv/*/*tun* /usr/kernel/drv/*tun* /usr/include/net/*tun*"
michael@667 175 echo " # modinfo | grep tun"
michael@667 176 echo " # /usr/sbin/rem_drv -C (v)tun"
michael@667 177 echo " # modinfo | grep tun"
michael@75 178 echo " # ls -ld /usr/kernel/drv/*tun*"
michael@667 179 echo " # ls -ld /usr/kernel/drv/*/*tun*"
michael@75 180 echo " # ls -ld /usr/include/net/*tun*"
michael@667 181 echo " # rm -f /usr/kernel/drv/[archpath]/(v)tun"
michael@667 182 echo " # rm -f /usr/kernel/drv/(v)tun.conf"
michael@75 183 echo " # rm -f /usr/include/net/if_tun.h"
michael@75 184 ) | %{l_rpmtool} msg -b -t notice
michael@75 185 exit 0
michael@75 186

mercurial