#!/bin/sh # Copyright 2010 David Naylor . All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY David Naylor ``AS IS'' AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO # EVENT SHALL David Naylor OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, # OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # The views and conclusions contained in the software and documentation are # those of the authors and should not be interpreted as representing official # policies, either expressed or implied, of David Naylor. # Version 1.0 - 2010/05/28 # - initial release # Version 1.1 - 2010/10/04 # - add support for 256 driver series # - use passive connections for FTP # - allow resuming of downloads if they were interrupted # - add license and copyright notice # Version 1.2 - 2010/10/17 # - try to save the NVIDIA tarball under $PORTSDIR/distfiles # - obay $PREFIX # - extract files directly to destination (avoids using /tmp) # Version 1.3 - 2010/11/02 # - add support for future driver series # Version 1.4 - 2011/05/23 # - add support for legacy drivers set -e PORTSDIR=${PORTSDIR:-/usr/ports} PREFIX=${PREFIX:-/usr/local} if [ -d $PORTSDIR/distfiles ] then cd $PORTSDIR/distfiles NO_REMOVE_NVIDIA="yes" else cd /tmp/ fi terminate() { echo "!!! $2 !!!" echo "Terminating..." exit $1 } [ `whoami` = root ] \ || terminate 254 "This script should be run as root" echo "===> Patching wine-fbsd64 to work with x11/nvidia-driver:" WINE=`pkg_info -E wine-fbsd64'*' | cut -f 3 -d -` \ || terminate 255 "Unable to detect wine-fbsd64, please install first" echo "=> Detected wine-fbsd64: ${WINE}" NV=`pkg_info -E nvidia-driver-'*' | cut -f 3 -d -` \ || terminate 1 "Unable to detect nvidia-driver, please install first" echo "=> Detected nvidia-driver: ${NV}" NVIDIA=${NV} NV=`echo ${NV} | cut -f 1 -d _ | cut -f 1 -d ,` if [ ! -f NVIDIA-FreeBSD-x86-${NV}.tar.gz ] then echo "=> Downloading NVIDIA-FreeBSD-x86-${NV}.tar.gz from ftp://download.nvidia.com..." fetch -pRr ftp://download.nvidia.com/XFree86/FreeBSD-x86/${NV}/NVIDIA-FreeBSD-x86-${NV}.tar.gz \ || terminate 2 "Failed to download NVIDIA-FreeBSD-x86-${NV}.tar.gz" fi echo "=> Extracting NVIDIA-FreeBSD-x86-${NV}.tar.gz to $PREFIX/lib32..." EXTRACT_LIST="libGL.so.1" case $NV in 195*|173*|96*|71*) EXTRACT_LIST="$EXTRACT_LIST libGLcore.so.1 libnvidia-tls.so.1" ;; *) EXTRACT_LIST="$EXTRACT_LIST libnvidia-glcore.so.1 libnvidia-tls.so.1" ;; esac EXTRACT_ARGS="--strip-components 2 -C $PREFIX/lib32" for i in $EXTRACT_LIST do EXTRACT_ARGS="$EXTRACT_ARGS --include NVIDIA-FreeBSD-x86-${NV}/obj/$i" done tar $EXTRACT_ARGS -xvf NVIDIA-FreeBSD-x86-${NV}.tar.gz \ || terminate 3 "Failed to extract NVIDIA-FreeBSD-x86-${NV}.tar.gz" echo "=> Cleaning up..." [ -n "$NO_REMOVE_NVIDIA" ] || rm -vf NVIDIA-FreeBSD-x86-${NV}.tar.gz \ || terminate 6 "Failed to remove files" echo "===> wine-fbsd64-${WINE} successfully patched for nvidia-driver-${NVIDIA}"