aboutsummaryrefslogtreecommitdiffstats
path: root/emulators
diff options
context:
space:
mode:
authordbn <dbn@FreeBSD.org>2013-03-26 04:08:45 +0800
committerdbn <dbn@FreeBSD.org>2013-03-26 04:08:45 +0800
commit2ea2027db6fe09365c58b8cb73bc3e872b679e71 (patch)
tree0269e887f60668adbdc372f896aca965e4fa3e4b /emulators
parentf994db038caf3cb2b50a3dcc7903d2afa601e518 (diff)
downloadfreebsd-ports-gnome-2ea2027db6fe09365c58b8cb73bc3e872b679e71.tar.gz
freebsd-ports-gnome-2ea2027db6fe09365c58b8cb73bc3e872b679e71.tar.zst
freebsd-ports-gnome-2ea2027db6fe09365c58b8cb73bc3e872b679e71.zip
Add emulators/i386-wine-devel, slave to emulators/wine-devel.
This port adds shims to enable wine to run cleanly on an amd64 system. This is done by doing a "static link" of the package: including all libraries required by the port. It is possible to use this package under i386, although it is intended for an amd64 system. Feedback welcome for improvement of the port. Approved by: bdrewery (mentor)
Diffstat (limited to 'emulators')
-rw-r--r--emulators/Makefile1
-rw-r--r--emulators/i386-wine-devel/Makefile75
-rw-r--r--emulators/i386-wine-devel/files/binbounce32
-rw-r--r--emulators/i386-wine-devel/files/nvidia.sh178
-rw-r--r--emulators/i386-wine-devel/files/pkg-install41
5 files changed, 327 insertions, 0 deletions
diff --git a/emulators/Makefile b/emulators/Makefile
index 1a83c5e5bc3c..970d3dcb9ef3 100644
--- a/emulators/Makefile
+++ b/emulators/Makefile
@@ -58,6 +58,7 @@
SUBDIR += hfsutils
SUBDIR += higan
SUBDIR += hugo
+ SUBDIR += i386-wine-devel
SUBDIR += ia64sim
SUBDIR += ines
SUBDIR += its
diff --git a/emulators/i386-wine-devel/Makefile b/emulators/i386-wine-devel/Makefile
new file mode 100644
index 000000000000..7c5e7fed333c
--- /dev/null
+++ b/emulators/i386-wine-devel/Makefile
@@ -0,0 +1,75 @@
+# Created by: David Naylor <dbn@FreeBSD.org>
+# $FreeBSD$
+
+PKGNAMEPREFIX= i386-
+
+# Use the wine port to do most of the heavy lifting
+MASTERDIR= ${.CURDIR}/../wine-devel
+PKGINSTALL= ${.CURDIR}/files/pkg-install
+PKGDEINSTALL= ${PKGINSTALL}
+
+ACTUAL-PACKAGE-DEPENDS= ${DO_NADA}
+WINELIBDIR= ${PREFIX}/lib32
+CONFIGURE_ARGS+= --bindir=${PREFIX}/bin32 --libdir=${WINELIBDIR}
+CONFLICTS= wine-[0-9]*
+PLIST_REINPLACE+= winelib
+PLIST_REINPLACE_WINELIB= s!lib/!lib32/!g
+WINE_SLAVE_BUILD= yes
+USE_LDCONFIG32= ${WINELIBDIR} ${WINELIBDIR}/wine
+
+# Hook into post-install and do some adapting to make i386 binaries work nicely
+# under FreeBSD/amd64 (include add dependant i386 libs)
+post-install-script:
+ # Install bounce script to access the 32bit executables
+ ${INSTALL_SCRIPT} ${.CURDIR}/files/binbounce ${PREFIX}/bin/wine
+ for i in `grep ^bin ${TMPPLIST} | xargs -n1 basename` ; do \
+ [ "$${i}" = "wine" ] || ${LN} -f ${PREFIX}/bin/wine ${PREFIX}/bin/$${i} ; \
+ echo bin32/$${i} >> ${TMPPLIST} ; \
+ done
+ if [ -n "${WITH_PKGNG}" ]; then \
+ echo '@dirrmtry bin32' >> ${TMPPLIST}; \
+ else \
+ echo '@unexec rmdir %D/bin32 2>/dev/null || true' >> ${TMPPLIST}; \
+ fi
+ # Find all libraries that are linked too (via ldd(1))
+ grep -v '[@%]' ${TMPPLIST} | sed "s!^!${PREFIX}/!g" | \
+ xargs -n1 file -F' ' | grep ELF | cut -f1 -d' ' | \
+ env LD_LIBRARY_PATH=${PREFIX}/lib32:${LD_LIBRARY_PATH} xargs ldd -f '%p\n' \
+ | sort -u | grep -v '^\(/usr\)\?/lib' | grep -v "^${PREFIX}/lib32/libwine.so" \
+ | grep -v "^${PREFIX}/lib32/wine" > ${WRKDIR}/winelibs
+ for i in `cat ${WRKDIR}/winelibs` ; do \
+ ${INSTALL_DATA} $${i} ${PREFIX}/lib32/ ; \
+ echo lib32/`basename $${i}` >> ${TMPPLIST} ; \
+ done
+ # Find all soft dependancies (via strings(1))
+ grep -v '[@%]' ${TMPPLIST} | sed "s!^!${PREFIX}/!g" | \
+ xargs -n1 file -F' ' | grep ELF | cut -f1 -d' ' | xargs strings | \
+ grep '^lib.*\.so' | sort -u > ${WRKDIR}/winesoftlibs
+ for i in `cat ${WRKDIR}/winesoftlibs` ; do \
+ if [ -e ${LOCALBASE}/lib/$${i} ] && [ -z "`grep $${i} ${TMPPLIST}`" ] ; then \
+ ${INSTALL_DATA} ${LOCALBASE}/lib/$${i} ${PREFIX}/lib32/ ; \
+ echo lib32/$${i} >> ${TMPPLIST} ; \
+ fi ; \
+ done
+ if [ -n "${WITH_PKGNG}" ]; then \
+ echo '@dirrmtry lib32' >> ${TMPPLIST}; \
+ else \
+ echo '@unexec rmdir %D/lib32 2>/dev/null || true' >> ${TMPPLIST}; \
+ fi
+ # Install nvidia patching script
+ ${INSTALL_SCRIPT} ${.CURDIR}/files/nvidia.sh ${DATADIR}/patch-nvidia.sh
+ echo ${DATADIR:S|$(PREFIX)/||}/patch-nvidia.sh >> ${TMPPLIST}
+ @${ECHO}
+ ${SETENV} PKG_PREFIX=${PREFIX} ${SH} ${PKGINSTALL} ${PKGNAME} PRE-INSTALL
+ ${SETENV} PKG_PREFIX=${PREFIX} ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL
+ @${CAT} ${PKGMESSAGE}
+
+post-package-script:
+ if [ -n "${WITH_PKGNG}" ]; then \
+ ${XZ_CMD} -dc ${PKGFILE} | \
+ ${SED} -e "s/^\(arch: freebsd:.*:x86\):32/\1:64/" | \
+ ${XZ_CMD} > ${WRKDIR}/${PKGNAME}${PKG_SUFX}; \
+ ${MV} ${WRKDIR}/${PKGNAME}${PKG_SUFX} ${PKGFILE}; \
+ fi
+
+.include "${MASTERDIR}/Makefile"
diff --git a/emulators/i386-wine-devel/files/binbounce b/emulators/i386-wine-devel/files/binbounce
new file mode 100644
index 000000000000..030fb850076d
--- /dev/null
+++ b/emulators/i386-wine-devel/files/binbounce
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+TARGET="$0"
+_count=0
+while [ -L "$TARGET" ]
+do
+ _old="$TARGET"
+ TARGET="`readlink "$TARGET"`"
+ if [ ! -e "$TARGET" ]
+ then
+ TARGET="`dirname "$_old"`/$TARGET"
+ fi
+ _count=$(($_count + 1))
+ if [ $_count -gt 100 ]
+ then
+ echo "$0: to many symbolic links" > /dev/stderr
+ exit 1
+ fi
+done
+
+LOCALBASE=`dirname "$TARGET"`/..
+BINNAME=`basename "$TARGET"`
+
+if [ `uname -p` = i386 ]
+then
+ export LD_LIBRARY_PATH="$LOCALBASE/lib32":"$LOCALBASE/lib32/wine":"$LD_LIBRARY_PATH"
+else
+ export LD_32_LIBRARY_PATH="$LOCALBASE/lib32":"$LOCALBASE/lib32/wine":"$LD_32_LIBRARY_PATH":/usr/lib32
+fi
+export PATH="$LOCALBASE/bin32":"$PATH"
+
+exec "$LOCALBASE/bin32/$BINNAME" "$@"
diff --git a/emulators/i386-wine-devel/files/nvidia.sh b/emulators/i386-wine-devel/files/nvidia.sh
new file mode 100644
index 000000000000..1a74e9dfec0b
--- /dev/null
+++ b/emulators/i386-wine-devel/files/nvidia.sh
@@ -0,0 +1,178 @@
+#!/bin/sh
+# Copyright 2010, 2011, 2012 David Naylor <naylor.b.david@gmail.com>.
+# Copyright 2012 Jan Beich <jbeich@tormail.org>
+# 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
+# Version 1.5 - 2011/10/23
+# - add support for no-fetch mode
+# - backup the original openGL.so.1 library
+# Version 1.6 - 2012/06/06
+# - add support for pkgng
+# Version 1.7 - 2012/06/23
+# - make nVidia detection more robust
+# - allow mixed pkg/pkgng operation
+# Version 1.8 - 2012/07/02
+# - fix mixed pkg/pkgng operation
+# Version 1.9 - 2012/10/31
+# - fix permission of extracts files
+
+set -e
+
+PORTSDIR=${PORTSDIR:-/usr/ports}
+PREFIX=${PREFIX:-/usr/local}
+DISTDIR=${DISTDIR:-${PORTSDIR}/distfiles}
+
+if [ -d $DISTDIR ]
+then
+ cd $DISTDIR
+ NO_REMOVE_NVIDIA="yes"
+else
+ cd /tmp/
+fi
+
+terminate() {
+
+ echo "!!! $2 !!!"
+ echo "Terminating..."
+ exit $1
+
+}
+
+args=`getopt -n $*`
+if [ $? -ne 0 ]
+then
+ echo "Usage: $0 [-n]"
+ exit 7
+fi
+set -- $args
+while true
+do
+ case $1 in
+ -n)
+ NO_FETCH=yes
+ ;;
+ --)
+ shift
+ break
+ ;;
+ esac
+ shift
+done
+
+version() {
+ local ret pkg="$1"
+ if [ -f "/usr/local/sbin/pkg" ]
+ then
+ ret=`pkg query -g '%v' $pkg`
+ fi
+
+ if [ -z "$ret" ]
+ then
+ ret=`pkg_info -E $pkg'*' | cut -f 3 -d -`
+ fi
+ # installed manually or failed to register
+ if [ -z "$ret" ] && [ "$pkg" = "nvidia-driver" ]
+ then
+ ret=`sed -n "s/.*Version: //p" 2> /dev/null \
+ $PREFIX/share/doc/NVIDIA_GLX-1.0/README || true`
+ fi
+ echo "$ret"
+}
+
+[ `whoami` = root ] \
+ || terminate 254 "This script should be run as root"
+
+echo "===> Patching wine-fbsd64 to work with x11/nvidia-driver:"
+
+if [ -z "${WINE}" ]
+then
+ WINE=`version wine-fbsd64`
+fi
+[ -n "$WINE" ] \
+ || terminate 255 "Unable to detect wine-fbsd64, please install first"
+echo "=> Detected wine-fbsd64: ${WINE}"
+
+NV=`version nvidia-driver`
+[ -n "$NV" ] \
+ || 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
+ [ -n "$NO_FETCH" ] \
+ && terminate 8 "NVIDIA-FreeBSD-x86-${NV}.tar.gz unavailable"
+ echo "=> Downloading NVIDIA-FreeBSD-x86-${NV}.tar.gz from ftp://download.nvidia.com..."
+ fetch -apRr 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="--no-same-owner --no-same-permissions --strip-components 2 -C $PREFIX/lib32"
+for i in $EXTRACT_LIST
+do
+ EXTRACT_ARGS="$EXTRACT_ARGS --include NVIDIA-FreeBSD-x86-${NV}/obj/$i"
+done
+[ -f ${PREFIX}/lib32/libGL.so.1~ ] \
+ || cp ${PREFIX}/lib32/libGL.so.1 ${PREFIX}/lib32/libGL.so.1~
+umask 0333
+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}"
diff --git a/emulators/i386-wine-devel/files/pkg-install b/emulators/i386-wine-devel/files/pkg-install
new file mode 100644
index 000000000000..a2c737a3f11f
--- /dev/null
+++ b/emulators/i386-wine-devel/files/pkg-install
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+PKG_PREFIX=${PKG_PREFIX-/usr/local}
+export PREFIX=${PKG_PREFIX}
+export WINE=$1
+
+case "$2" in
+ PRE-INSTALL|DEINSTALL)
+ mv -f ${PKG_PREFIX}/lib32/libGL.so.1~ ${PKG_PREFIX}/lib32/libGL.so.1 > /dev/null 2>&1
+ rm -f ${PKG_PREFIX}/lib32/libGLcore.so.1 ${PKG_PREFIX}/lib32/libnvidia-glcore.so.1 ${PKG_PREFIX}/lib32/libnvidia-tls.so.1
+ ;;
+ POST-INSTALL)
+ sh ${PKG_PREFIX}/share/wine/patch-nvidia.sh -n > /dev/null 2>&1
+ case $? in
+ 0)
+ cat << _EOF
+$1 has been patched for use with nvidia graphics driver. If
+the version of the installed nvidia graphics driver changes execute (as root):
+_EOF
+ ;;
+ 1)
+ cat << _EOF
+This system does not appear to use a nvidia graphics driver. If this changes
+and then every time the driver's version changes execute (as root)
+_EOF
+ ;;
+ *)
+ cat << _EOF
+A NVIDIA GRAPHICS DRIVER HAS BEEN DETECTED ON THIS SYSTEM AND THE AUTOMATED
+PATCHING HAS FAILED, execute (as root)
+_EOF
+ ;;
+ esac
+ cat << _EOF
+ sh ${PKG_PREFIX}/share/wine/patch-nvidia.sh
+to get 2D/3D acceleration to work with the nvidia driver. Without this wine
+will crash when a program requires 2D/3D graphics acceleration.
+
+_EOF
+ ;;
+esac