#!/bin/bash
# Geschrieben von Sebastian Siebert, 2010
# http://www.sebastian-siebert.de/2009/12/27/opensuse-11-2-proprietaeren-grafik-treiber-ati-catalyst-9-12-als-rpm-installieren/

ATIDIR="ati-9.12"
PATCHFILE="ati-9.12-debug.patch"

if [ -d ${ATIDIR} ]; then
    echo "Entferne das Verzeichnis ${ATIDIR} ..."
    rm -rf ${ATIDIR}
fi

echo "Entpacke den Inhalt vom Installer ins Verzeichnis ${ATIDIR} ..."
sh ./ati-driver-installer-9-12-x86.x86_64.run --extract ${ATIDIR}

echo "Downloade die Patch-Datei ${PATCHFILE} ..."
wget http://www.sebastian-siebert.de/downloads/${PATCHFILE}

echo "Patche den PackageBuilder-Skript ..."
patch -p0 <${PATCHFILE}

echo "Ermittle die Architektur ..."
if [ "$(uname -m)" = "x86_64" ]; then
    PACKAGE="SuSE/SUSE112-AMD64"
else
    PACKAGE="SuSE/SUSE112-IA32"
fi

cd ${ATIDIR}
echo "Package: $PACKAGE"
./ati-installer.sh 8.681 --buildpkg $PACKAGE
cd ..
