Line 0
Link Here
|
|
|
1 |
#!/bin/sh |
2 |
# Copyright 2010, 2011, 2012 David Naylor <naylor.b.david@gmail.com>. |
3 |
# All rights reserved. |
4 |
# |
5 |
# Redistribution and use in source and binary forms, with or without |
6 |
# modification, are permitted provided that the following conditions are met: |
7 |
# |
8 |
# 1. Redistributions of source code must retain the above copyright notice, |
9 |
# this list of conditions and the following disclaimer. |
10 |
# |
11 |
# 2. Redistributions in binary form must reproduce the above copyright notice, |
12 |
# this list of conditions and the following disclaimer in the documentation |
13 |
# and/or other materials provided with the distribution. |
14 |
# |
15 |
# THIS SOFTWARE IS PROVIDED BY David Naylor ``AS IS'' AND ANY EXPRESS OR IMPLIED |
16 |
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
17 |
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
18 |
# EVENT SHALL David Naylor OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
19 |
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
20 |
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, |
21 |
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
22 |
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
23 |
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
24 |
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 |
# |
26 |
# The views and conclusions contained in the software and documentation are |
27 |
# those of the authors and should not be interpreted as representing official |
28 |
# policies, either expressed or implied, of David Naylor. |
29 |
|
30 |
# Version 1.0 - 2010/05/28 |
31 |
# - initial release |
32 |
# Version 1.1 - 2010/10/04 |
33 |
# - add support for 256 driver series |
34 |
# - use passive connections for FTP |
35 |
# - allow resuming of downloads if they were interrupted |
36 |
# - add license and copyright notice |
37 |
# Version 1.2 - 2010/10/17 |
38 |
# - try to save the NVIDIA tarball under $PORTSDIR/distfiles |
39 |
# - obay $PREFIX |
40 |
# - extract files directly to destination (avoids using /tmp) |
41 |
# Version 1.3 - 2010/11/02 |
42 |
# - add support for future driver series |
43 |
# Version 1.4 - 2011/05/23 |
44 |
# - add support for legacy drivers |
45 |
# Version 1.5 - 2011/10/23 |
46 |
# - add support for no-fetch mode |
47 |
# - backup the original openGL.so.1 library |
48 |
|
49 |
set -e |
50 |
|
51 |
PORTSDIR=${PORTSDIR:-/usr/ports} |
52 |
PREFIX=${PREFIX:-/usr/local} |
53 |
DISTDIR=${DISTDIR:-${PORTSDIR}/distfiles} |
54 |
|
55 |
if [ -d $DISTDIR ] |
56 |
then |
57 |
cd $DISTDIR |
58 |
NO_REMOVE_NVIDIA="yes" |
59 |
else |
60 |
cd /tmp/ |
61 |
fi |
62 |
|
63 |
terminate() { |
64 |
|
65 |
echo "!!! $2 !!!" |
66 |
echo "Terminating..." |
67 |
exit $1 |
68 |
|
69 |
} |
70 |
|
71 |
args=`getopt -n $*` |
72 |
if [ $? -ne 0 ] |
73 |
then |
74 |
echo "Usage: $0 [-n]" |
75 |
exit 7 |
76 |
fi |
77 |
set -- $args |
78 |
while true |
79 |
do |
80 |
case $1 in |
81 |
-n) |
82 |
NO_FETCH=yes |
83 |
;; |
84 |
--) |
85 |
shift |
86 |
break |
87 |
;; |
88 |
esac |
89 |
shift |
90 |
done |
91 |
|
92 |
[ `whoami` = root ] \ |
93 |
|| terminate 254 "This script should be run as root" |
94 |
|
95 |
echo "===> Patching wine-fbsd64 to work with x11/nvidia-driver:" |
96 |
|
97 |
if [ -z "${WINE}" ] |
98 |
then |
99 |
WINE=`pkg_info -E wine-fbsd64'*' | cut -f 3 -d -` |
100 |
fi |
101 |
[ -n "$WINE" ] \ |
102 |
|| terminate 255 "Unable to detect wine-fbsd64, please install first" |
103 |
echo "=> Detected wine-fbsd64: ${WINE}" |
104 |
|
105 |
NV=`pkg_info -E nvidia-driver-'*' | cut -f 3 -d -` |
106 |
[ -n "$NV" ] \ |
107 |
|| terminate 1 "Unable to detect nvidia-driver, please install first" |
108 |
echo "=> Detected nvidia-driver: ${NV}" |
109 |
|
110 |
NVIDIA=${NV} |
111 |
NV=`echo ${NV} | cut -f 1 -d _ | cut -f 1 -d ,` |
112 |
|
113 |
if [ ! -f NVIDIA-FreeBSD-x86-${NV}.tar.gz ] |
114 |
then |
115 |
[ -n "$NO_FETCH" ] \ |
116 |
&& terminate 8 "NVIDIA-FreeBSD-x86-${NV}.tar.gz unavailable" |
117 |
echo "=> Downloading NVIDIA-FreeBSD-x86-${NV}.tar.gz from ftp://download.nvidia.com..." |
118 |
fetch -pRr ftp://download.nvidia.com/XFree86/FreeBSD-x86/${NV}/NVIDIA-FreeBSD-x86-${NV}.tar.gz \ |
119 |
|| terminate 2 "Failed to download NVIDIA-FreeBSD-x86-${NV}.tar.gz" |
120 |
fi |
121 |
|
122 |
echo "=> Extracting NVIDIA-FreeBSD-x86-${NV}.tar.gz to $PREFIX/lib32..." |
123 |
EXTRACT_LIST="libGL.so.1" |
124 |
case $NV in |
125 |
195*|173*|96*|71*) |
126 |
EXTRACT_LIST="$EXTRACT_LIST libGLcore.so.1 libnvidia-tls.so.1" |
127 |
;; |
128 |
*) |
129 |
EXTRACT_LIST="$EXTRACT_LIST libnvidia-glcore.so.1 libnvidia-tls.so.1" |
130 |
;; |
131 |
esac |
132 |
|
133 |
EXTRACT_ARGS="--strip-components 2 -C $PREFIX/lib32" |
134 |
for i in $EXTRACT_LIST |
135 |
do |
136 |
EXTRACT_ARGS="$EXTRACT_ARGS --include NVIDIA-FreeBSD-x86-${NV}/obj/$i" |
137 |
done |
138 |
[ -f ${PREFIX}/lib32/libGL.so.1~ ] \ |
139 |
|| cp ${PREFIX}/lib32/libGL.so.1 ${PREFIX}/lib32/libGL.so.1~ |
140 |
tar $EXTRACT_ARGS -xvf NVIDIA-FreeBSD-x86-${NV}.tar.gz \ |
141 |
|| terminate 3 "Failed to extract NVIDIA-FreeBSD-x86-${NV}.tar.gz" |
142 |
|
143 |
echo "=> Cleaning up..." |
144 |
[ -n "$NO_REMOVE_NVIDIA" ] || rm -vf NVIDIA-FreeBSD-x86-${NV}.tar.gz \ |
145 |
|| terminate 6 "Failed to remove files" |
146 |
|
147 |
echo "===> wine-fbsd64-${WINE} successfully patched for nvidia-driver-${NVIDIA}" |