Nvidia SlackBuild


Nvidia SlackBuild

Uno script Bash per creare dei Pacchetti TGZ dai driver NViDIA con estensione .run, ed installabili tramite il classico pkgtool.


Readme

L'uso è quello classico di uno SlackBuild. Basta porre nella stessa directory lo script ed il file .run contenente i driver nvidia, reperibili presso http://www.nvidia.com/object/unix.html Rendere eseguibile lo script con chmod +x Nvidia.SlackBuild e lanciarlo. Alla fine si avrà pronto nella medesima directory un pacchetto SlackWare con estensione .tgz installabile tramite il classico pkgtool o installpkg.



#!/bin/sh
# Heavily based on the Slackware 11 SlackBuild
# http://www.nvidia.com/object/unix.html
# http://www.slacky.it
# A Bash Script used to  Build a TGZ SlackWare package, with display driver Nvidia
# By Andrea Sciucca Gohanz ( gohanz @ infinito.it)


CWD=`pwd`
if ["$TMP" = ""]; then
 TMP=/tmp
fi

PKG=$TMP/package-NVIDIA-Linux-x86
NAME=NVIDIA-Linux-x86
VERSION=1.0-8762
OPENGL=${VERSION/-/.}
ARCH=IA32
RELEASE_DATE='Agoust 24, 2006'
KERNEL=$(uname -r)



#Check for root privileges
if [ `id -u` != "0" ]; then clear
  echo "You must be Root to run Nvidia-Linux-x86.SlackBuild"
  exit 1
fi
#


# Check for Kernel Source in /usr/src and make a symlink linux to kernel
cd /usr/src
if [ ! -r linux-$KERNEL ]; then clear
  echo "You must install the Kernel Source in /usr/src!"
   exit 1
else rm linux
ln -s linux-$KERNEL linux
fi
cd $CWD
#

# Check for .config file in the kernel source tree
cd /usr/src/linux
if [ ! -r .config ]; then clear
  echo "No .config file in the source tree! Please copy your .config file in /usr/src/linux
  or you need to recompile the kernel with make menuconfig!"
   exit 1
fi
cd $CWD
#

########### Function Build Package ##############################


PKG_BUILD () {




cp -a  LICENSE pkg-history.txt \
$PKG/usr/doc/$NAME-$VERSION
cat << EOF > $PKG/install/slack-desc
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description.  Line
# up the first '|' above the ':' following the base package name, and the '|'
# on the right side marks the last column you can put a character in.  You must
# make exactly 11 lines for the formatting to be correct.  It's also
# customary to leave one space after the ':'.

              |-----handy-ruler----------------------------------------------------|
NvidiaLinuxX86: Nvidia Linux Display Driver $ARCH
NvidiaLinuxX86: 
NvidiaLinuxX86: 
NvidiaLinuxX86: 
NvidiaLinuxX86:                        Version: $VERSION
NvidiaLinuxX86:                  Operating System: Linux IA32
NvidiaLinuxX86:                   Release Date: $RELEASE_DATE 
NvidiaLinuxX86:                        KERNEL : $KERNEL
NvidiaLinuxX86: 
NvidiaLinuxX86:                          WWW.SLACKY.IT
NvidiaLinuxX86: Packager Gohanz.
EOF





cd $CWD
cp -a *.SlackBuild  $PKG/usr/doc/$NAME-$VERSION
chown -R root.root $PKG/usr/doc/$NAME-$VERSION

chown -R root.bin $PKG/usr/bin
strip --strip-unneeded $PKG/usr/bin/* 2> /dev/null


##########Correct Desktop entry for Nvida-Xsettings##########
( cd $PKG/usr/share/applications
sed -i "s|Exec=__UTILS_PATH__/nvidia-settings|Exec=/usr/bin/nvidia-settings|g" nvidia-settings.desktop
sed -i "s|Icon=__DOCS_PATH__/nvidia-settings.png|Icon=/usr/doc/$NAME-$VERSION/nvidia-settings.png|g" 
nvidia-settings.desktop
sed -i "s|Icon=__PIXMAP_PATH__/nvidia-settings.png|Icon=/usr/share/pixmaps/nvidia-settings.png|g" 
nvidia-settings.desktop
)
#############################################################


cd $PKG
requiredbuilder -v -y -s $CWD $PKG
makepkg -l y -c n -p $CWD/NvidiaLinuxX86-$VERSION'Kernel'$KERNEL-$ARCH.tgz

if [ "$1" = "--cleanup" ]; then
 rm -rf $TMP/$NAME-$VERSION
 rm -rf $PKG
fi
}


############################END############################################



##########################################
#                                        #
#         START NVIDIA SLACKBUILD        #
#                                        #
##########################################




if [ ! -d $TMP ]; then
 mkdir -p $TMP 
fi
if [ ! -d $PKG ]; then
 mkdir -p $PKG 
fi



cd $TMP
sh $CWD/$NAME-$VERSION-pkg1.run -x

echo "+----------------------------------------------------------------+"
echo "| Starting SlackBuild  $NAME-$VERSION-Kernel-$KERNEL |"
echo "+----------------------------------------------------------------+"

cd $NAME-$VERSION-pkg1

find . -perm 777 -exec chmod 755 {} \;
find . -perm 775 -exec chmod 755 {} \;
find . -perm 555 -exec chmod 755 {} \;
find . -perm 666 -exec chmod 644 {} \;
find . -perm 664 -exec chmod 644 {} \;
find . -perm 444 -exec chmod 644 {} \;

chown -R root.root .



# Build SimLik.

( cd usr/X11R6/lib

ln -s libXvMCNVIDIA.so.$OPENGL libXvMCNVIDIA_dynamic.so.1 )


( cd usr/X11R6/lib/modules/extensions

ln -s libglx.so.$OPENGL libglx.so )


( cd usr/lib

ln -s libGL.so.1 libGL.so
ln -s libGL.so.$OPENGL libGL.so.1
ln -s libGLcore.so.$OPENGL libGLcore.so.1
ln -s libnvidia-cfg.so.1  libnvidia-cfg.so
ln -s libnvidia-cfg.so.$OPENGL   libnvidia-cfg.so.1
ln -s libnvidia-tls.so.$OPENGL   libnvidia-tls.so.1 )

( cd usr/lib/tls

ln -s libnvidia-tls.so.$OPENGL   libnvidia-tls.so.1 )

# End SimLink Build

mkdir -p $PKG/usr

( cd usr \

cp -a -r * $PKG/usr )

mkdir -p $PKG/lib/modules/$KERNEL/kernel/drivers/video

( cd usr/src/nv

make module # Compiling Module for Both 2.4/2.6 Kernel.

if [ `echo $KERNEL | cut -c -3` == "2.6" ]; then clear
  echo "Nvidia Module build for the Kernel $KERNEL success!"
  cp nvidia.ko $PKG/lib/modules/$KERNEL/kernel/drivers/video 2>/dev/null
elif [ `echo $KERNEL | cut -c -3` == "2.4" ]; then clear
  echo "Nvidia Module build for the Kernel $KERNEL success!"
  cp nvidia.o $PKG/lib/modules/$KERNEL/kernel/drivers/video 2>/dev/null
else
  echo " The Kernel $KERNEL Version, is not correct!"
fi
)

mkdir -p $PKG/usr/doc/$NAME-$VERSION

( cd $PKG/usr/share/doc

cp -a -r * $PKG/usr/doc/$NAME-$VERSION

rm -r $PKG/usr/share/doc
)

( cd $PKG/usr/share/man

mkdir -p $PKG/usr/man

cp -a -r * $PKG/usr/man

rm -r $PKG/usr/share/man
rm -r $PKG/usr/src
 )








# Xorg.conf copy in package


echo "****************************************************"
echo "                                                    "
echo "                                                    " 
echo "I must copy your xorg.conf file  in the TGZ Package?"

OPTIONS="Yes No"
select opt in $OPTIONS; do
if [ "$opt" = "Yes" ]; then
( cd /etc/X11
mkdir -p  $PKG/etc/X11
cp -a xorg.conf $PKG/etc/X11 ) 
mkdir -p $PKG/install
cat << EOF >> $PKG/install/doinst.sh
modprobe nvidia
ldconfig
nvidia-xconfig
EOF
# Call  Pkg-Build

PKG_BUILD
exit
else echo "Wrong Choice! (1/2)"
fi
done