autoconf mergedr. Fixez #60

This commit is contained in:
Kolan Sh 2012-03-24 14:14:12 +04:00
commit 8b00d187a4
21 changed files with 193 additions and 105 deletions

37
Makefile Normal file
View File

@ -0,0 +1,37 @@
SHELL = /bin/sh
PREFIX = /usr
all:
install:
install -d ${DESTDIR}/etc/X11
install --mode=644 etc/X11/* ${DESTDIR}/etc/X11
install -d ${DESTDIR}/etc/init.d
install etc/init.d/* ${DESTDIR}/etc/init.d
install -d ${DESTDIR}/${PREFIX}/bin
install bin/* ${DESTDIR}/${PREFIX}/bin
install -d ${DESTDIR}/${PREFIX}/sbin
install sbin/* ${DESTDIR}/${PREFIX}/sbin
install -d ${DESTDIR}/${PREFIX}/lib64
install lib64/*.so ${DESTDIR}/${PREFIX}/lib64
install -d ${DESTDIR}/${PREFIX}/lib64/snail
ln -sf /usr/lib64/opengl/nvidia/extensions ${DESTDIR}/${PREFIX}/lib64/snail
install -d ${DESTDIR}/${PREFIX}/lib64/snail/modules
ln -sf /usr/lib64/xorg/modules/drivers ${DESTDIR}/${PREFIX}/lib64/snail/modules
ln -sf /usr/lib64/xorg/modules/extensions ${DESTDIR}/${PREFIX}/lib64/snail/modules
ln -sf /usr/lib64/xorg/modules/libfb.so ${DESTDIR}/${PREFIX}/lib64/snail/modules
ln -sf /usr/lib64/xorg/modules/libwfb.so ${DESTDIR}/${PREFIX}/lib64/snail/modules
uninstall:
rm -f ${DESTDIR}/etc/X11/xorg.conf.*.snail
rm -f ${DESTDIR}/etc/init.d/snail-*
rm -f ${DESTDIR}/${PREFIX}/lib64/libdlfaker.so
rm -f ${DESTDIR}/${PREFIX}/lib64/libgefaker.so
rm -f ${DESTDIR}/${PREFIX}/lib64/librrfaker.so
rm -rf ${DESTDIR}/${PREFIX}/lib64/snail
rm -f ${DESTDIR}/${PREFIX}/bin/nvrun
rm -f ${DESTDIR}/${PREFIX}/bin/snail.vglrun
rm -f ${DESTDIR}/${PREFIX}/sbin/snail.nv_pwr_off
rm -f ${DESTDIR}/${PREFIX}/sbin/snail.nv_pwr_on
rm -f ${DESTDIR}/${PREFIX}/sbin/snail-watcher.sh
rm -f ${DESTDIR}/${PREFIX}/sbin/snail.configure

View File

@ -1,9 +1,8 @@
#!/sbin/runscript
DAEMON="/usr/local/sbin/snail.watcher.sh"
DAEMON="snail-watcher.sh"
DAEMON_ARGS=""
PIDFILE=/var/run/snail.pid
#PATH=/usr/local/sbin:/usr/local/bin:$PATH
PATH=$PATH:/usr/local/bin
depend() {

View File

@ -1,7 +1,7 @@
#!/sbin/runscript
DAEMON=/usr/bin/X
DAEMON_ARGS="-ac -config /etc/X11/xorg.conf.nvidia -sharevts -modulepath /usr/local/lib/snail -nolisten tcp -noreset :1 vt9"
DAEMON_ARGS="-ac -config /etc/X11/xorg.conf.nvidia -sharevts -modulepath /usr/lib/snail -nolisten tcp -noreset :1 vt9"
PIDFILE=/tmp/.X1-lock
depend() {
@ -9,7 +9,7 @@ depend() {
}
start() {
ebegin "Starting bumblebee nVidia Optimus"
ebegin "Starting Snail nVidia Optimus"
snail.nv_pwr_on || eend -1
! ps -p `cat $PIDFILE 2>&1` > /dev/null 2>&1 || eend -1
export LD_LIBRARY_PATH=/usr/lib/opengl/nvidia/lib:/usr/lib/opengl/nvidia/lib
@ -26,7 +26,7 @@ start() {
}
stop() {
ebegin "Stopping bumblebee nVidia Optimus"
ebegin "Stopping Snail nVidia Optimus"
kill `cat $PIDFILE 2>&1` > /dev/null 2>&1
snail.nv_pwr_off || eend -1
eend $result

118
sbin/snail.configure Executable file
View File

@ -0,0 +1,118 @@
#!/bin/bash
echo "Test for nVidia driver"
lsmod | grep '^nvidia ' &>/dev/null
[ 0 -ne $? ] && snail.nv_pwr_on && modprobe nvidia ; snail.nv_pwr_off
if [ 0 -eq $? ]; then
echo "nVidia driver is OK! ;-)"
modprobe -r nvidia
else
echo "You must install standart nVidia driver first!"
exit -1
fi
echo "Test for acpi_call module..."
lsmod | grep '^acpi_call ' &>/dev/null
if [ 0 -eq $? ]; then
echo "acpi_call is OK! ;-)"
else
modprobe acpi_call && lsmod | grep '^acpi_call ' &>/dev/null
if [ 0 -eq $? ]; then
modprobe -rf acpi_call
echo "Please configure acpi_call module for autoloading on system start and try again!"
exit -1
else
echo "acpi_call kernel module not found, please install it!"
exit -1
fi
fi
echo "Test for dmidecode utility..."
dmidecode &>/dev/null
if [ 0 -eq $? ]; then
echo "dmidecode utility is OK! ;-)"
else
echo "Please install dmidecode and run the script as root again."
fi
echo "Detecting your distribution..."
DISTRIB_ID=
DISTRIB_DESCRIPTION=
DISTRIB_RELEASE=
DISTRIB_CODENAME=
if [ -f /etc/gentoo-release ]; then
DISTRIB_ID=gentoo
DISTRIB_DESCRIPTION=`cat /etc/gentoo-release`
DISTRIB_RELEASE=${DISTRIB_DESCRIPTION##* }
DISTRIB_CODENAME=gentoo
elif [ -f /etc/debian-version ]; then
DISTRIB_ID=debian
DISTRIB_CODENAME=`cut -d'/' /etc/debian-version -f1`
elif [ -f /etc/slax-version ]; then
DISTRIB_ID=slax
DISTRIB_DESCRIPTION=`cat /etc/slax-version`
elif [ -f /etc/arch-release ]; then
DISTRIB_ID=arch
DISTRIB_DESCRIPTION=`cat /etc/arch-release`
elif [ -f /etc/slackware-version ]; then
DISTRIB_ID=slackware
DISTRIB_DESCRIPTION=`cat /etc/slackware-version`
elif [ `which lsb_release` ]; then
DISTRIB_ID=`lsb_release | grep '^Distributor' | sed 's~[^:]*:~~' | tr 'A-Z' 'a-z'`
DISTRIB_DESCRIPTION=`lsb_release | grep '^Description' | sed 's~[^:]*:~~'`
DISTRIB_RELEASE=`lsb_release | grep '^Release' | sed 's~[^:]*:~~'`
DISTRIB_CODENAME=`lsb_release | grep '^Codename' | sed 's~[^:]*:~~'`
elif [ -f /etc/os-release ]; then
DISTRIB_ID=`grep '^ID=' /etc/os-release | cut -d'=' -f2`
DISTRIB_DESCRIPTION=`grep '^PRETTY_NAME=' /etc/os-release | cut -d'=' -f2`
DISTRIB_RELEASE=`grep '^VERSION_ID=' /etc/os-release | cut -d'=' -f2`
DISTRIB_CODENAME=`grep '^NAME=' /etc/os-release | cut -d'=' -f2`
else
DISTRIB_DESCRIPTION=`cat /etc/*release* | head -n1`
DISTRIB_ID=`echo ${DISTRIB_DESCRIPTION%% *} | tr 'A-Z' 'a-z'`
DISTRIB_RELEASE=`echo ${DISTRIB_DESCRIPTION%% *} | sed 's~[^0-9]\+\([0-9\.]\+\).*~\1~'`
DISTRIB_CODENAME=$DISTRIB_ID
fi
[ "" == "$DISTRIB_ID" ] && echo 'GNU/Linux distribution not recognized, sorry! Please post a bug!' && exit -1
echo 'Detected distribution:'
echo "DISTRIB_ID=$DISTRIB_ID"
echo "DISTRIB_DESCRIPTION=$DISTRIB_DESCRIPTION"
echo "DISTRIB_RELEASE=$DISTRIB_RELEASE"
echo "DISTRIB_CODENAME=$DISTRIB_CODENAME"
echo "Configuring OpenGL libraries and nVidia GLX extensions"
if [ "gentoo" == "$DISTRIB_ID" ]; then
eselect opengl set xorg-x11
for arch in 32bit 64bit; do
for chip in i915 i965 r300 r600 sw; do
eselect mesa set $arch $chip classic &>/dev/null;
done;
done
echo "Adding snail-watcher to default"
eselect rc delete snail-xserver boot default
eselect rc delete snail-watcher boot
eselect rc add snail-watcher default
eselect rc stop snail-xserver
eselect rc restart snail-watcher
elif [ "fedora" == "$DISTRIB_ID" ]; then
echo ""
else
echo "No rules for Your distribution. Please make a bug report."
exit -1
fi
echo "Creating backups of original xorg.conf.* files and replacing with snail's versions..."
[[ -f /etc/X11/xorg.conf && ! -f /etc/X11/xorg.conf.snail-bkp ]] && mv /etc/X11/xorg.conf /etc/X11/xorg.conf.snail-bkp
[[ -f /etc/X11/xorg.conf.intel && ! -f /etc/X11/xorg.conf.intel.snail-bkp ]] && mv /etc/X11/xorg.conf.intel /etc/X11/xorg.conf.intel.snail-bkp
[[ -f /etc/X11/xorg.conf.nvidia && ! -f /etc/X11/xorg.conf.nvidia.snail-bkp ]] && mv /etc/X11/xorg.conf.nvidia /etc/X11/xorg.conf.nvidia.snail-bkp
cp -f /etc/X11/xorg.conf.intel.snail /etc/X11/xorg.conf.intel
cp -f /etc/X11/xorg.conf.nvidia.snail /etc/X11/xorg.conf.nvidia
ln -sf xorg.conf.intel /etc/X11/xorg.conf
echo "Recognizing BusID of both chips and set it in xorg.conf.* files..."
BusIDIntel="PCI:`lspci | grep VGA | grep Intel | cut -d" " -f1 | sed 's~\.~\:~g ; s~0\([0-9]\)~\1~g'`"
BusIDNvidia="PCI:`lspci | grep VGA | grep nVidia | cut -d" " -f1 | sed 's~\.~\:~g ; s~0\([0-9]\)~\1~g'`"
sed -i "s~BusIDIntel~$BusIDIntel~" /etc/X11/xorg.conf.intel
sed -i "s~BusIDNvidia~$BusIDNvidia~" /etc/X11/xorg.conf.nvidia
echo "`basename -- $0` is complete! ;-)"

View File

@ -1,45 +0,0 @@
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI=4
inherit eutils
DESCRIPTION="Snail - nVidia Optimus support in a simple way"
SRC_URI="ftp://backbone.myftp.org/projects/snail/snail-0.0.1.tar.gz"
HOMEPAGE="http://backbone.myftp.org/projects/snail"
KEYWORDS="-* ~x86 ~amd64"
SLOT="0"
LICENSE="GPL-3"
IUSE=""
DEPEND="x11-drivers/nvidia-drivers"
RDEPEND="${DEPEND}"
src_prepare() {
echo "src_prepare=`pwd`" >>/tmp/snail.log
}
src_configure() {
echo "src_configure=`pwd`" >>/tmp/snail.log
}
src_compile() {
echo "src_compile=`pwd`" >>/tmp/snail.log
}
src_install() {
echo "src_install=`pwd`" >>/tmp/snail.log
}
pkg_postinst() {
echo "src_postinst=`pwd`" >>/tmp/snail.log
}

34
snail-1.0.0.ebuild Normal file
View File

@ -0,0 +1,34 @@
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI=4
inherit eutils
DESCRIPTION="Snail - nVidia Optimus support"
SRC_URI="ftp://backbone.ws/projects/snail/snail-1.0.0.tar.bz2"
HOMEPAGE="https://chili.backbone.ws/projects/snail"
KEYWORDS="-* ~x86 ~amd64"
SLOT="0"
LICENSE="GPL-3"
IUSE=""
DEPEND="x11-drivers/nvidia-drivers"
RDEPEND="${DEPEND}"
src_install() {
echo "src_install=`pwd`" >>/tmp/snail.log
emake install DESTDIR="${D}" || die
}
pkg_postinst() {
snail.configure
}

View File

@ -1,21 +0,0 @@
#!/bin/sh
PREFIX=/usr/local
# Tell the system to use xorg-x11 OpenGL libraries and nVidia GLX extensions
eselect opengl set xorg-x11
for arch in 32bit 64bit; do for chip in i915 i965 r300 r600 sw; do eselect mesa set $arch $chip classic &>/dev/null; done; done
# Create backups of original xorg.conf.* files and replacing with snail's versions
[[ -f /etc/X11/xorg.conf && ! -f /etc/X11/xorg.conf.snail-bkp ]] && mv /etc/X11/xorg.conf /etc/X11/xorg.conf.snail-bkp
[[ -f /etc/X11/xorg.conf.intel && ! -f /etc/X11/xorg.conf.intel.snail-bkp ]] && mv /etc/X11/xorg.conf.intel /etc/X11/xorg.conf.intel.snail-bkp
[[ -f /etc/X11/xorg.conf.nvidia && ! -f /etc/X11/xorg.conf.nvidia.snail-bkp ]] && mv /etc/X11/xorg.conf.nvidia /etc/X11/xorg.conf.nvidia.snail-bkp
cp -f /etc/X11/xorg.conf.intel.snail /etc/X11/xorg.conf.intel
cp -f /etc/X11/xorg.conf.nvidia.snail /etc/X11/xorg.conf.nvidia
ln -sf xorg.conf.intel /etc/X11/xorg.conf
# Recognize BusID of both chips and set it in xorg.conf.* files
BusIDIntel="PCI:`lspci | grep VGA | grep Intel | cut -d" " -f1 | sed 's~\.~\:~g ; s~0\([0-9]\)~\1~g'`"
BusIDNvidia="PCI:`lspci | grep VGA | grep nVidia | cut -d" " -f1 | sed 's~\.~\:~g ; s~0\([0-9]\)~\1~g'`"
sed -i "s~BusIDIntel~$BusIDIntel~" /etc/X11/xorg.conf.intel
sed -i "s~BusIDNvidia~$BusIDNvidia~" /etc/X11/xorg.conf.nvidia

View File

@ -1,34 +0,0 @@
#!/bin/sh
# Tell the system to use both xorg-x11 OpenGL and GLX libraries
eselect opengl set xorg-x11
# Restore xorg.conf.* files from backups
[ -f /etc/X11/xorg.conf.snail-bkp ] && rm -f /etc/X11/xorg.conf && mv /etc/X11/xorg.conf.snail-bkp /etc/X11/xorg.conf
[ -f /etc/X11/xorg.conf.intel.snail-bkp ] && rm -f /etc/X11/xorg.conf.intel && mv /etc/X11/xorg.conf.intel.snail-bkp /etc/X11/xorg.conf.intel
[ -f /etc/X11/xorg.conf.nvidia.snail-bkp ] && rm -f /etc/X11/xorg.conf.nvidia && mv /etc/X11/xorg.conf.nvidia.snail-bkp /etc/X11/xorg.conf.nvidia
# Remove backup files
for f in "" .intel .nvidia ; do
rm -f /etc/X11/xorg.conf${f}.snail-bkp
done
# Remove all Snail files
rm -f /etc/X11/xorg.conf.intel.snail
rm -f /etc/X11/xorg.conf.nvidia
rm -f /etc/init.d/snail-watcher
rm -f /etc/init.d/snail-xserver
rm -f /usr/local/bin/nvrun
rm -f /usr/local/bin/snail.vglrun
rm -f /usr/local/lib64/libdlfaker.so
rm -f /usr/local/lib64/libgefaker.so
rm -f /usr/local/lib64/librrfaker.so
rm -f /usr/local/lib64/snail/extensions
rm -f /usr/local/lib64/snail/modules/drivers
rm -f /usr/local/lib64/snail/modules/extensions
rm -f /usr/local/lib64/snail/modules/libfb.so
rm -f /usr/local/lib64/snail/modules/libwfb.so
rmdir /usr/local/lib64/snail/modules 2>/dev/null
rm -f /usr/local/sbin/snail.nv_pwr_off
rm -f /usr/local/sbin/snail.nv_pwr_on
rm -f /usr/local/sbin/snail.watcher