#!/bin/sh

# ASSUMES THE i686 FOLDER INITIALLY HAS *NO* NVIDIA RPMS

# 1. Build the entire NVIDIA package.
rpmbuild -bb --target "$(uname -m)" --define "kernel $(uname -r)" ~/src/rpm/SPECS/nvidia-glx.spec

# 2. We aren't debugging this thing.
rm ~/src/rpm/RPMS/i686/nvidia-glx-debuginfo-*.rpm

# 3. Update the local yum repo.
mv ~/src/rpm/RPMS/i686/nvidia-glx*.rpm ~/local/repo
mv ~/src/rpm/RPMS/i686/kernel-module-nvidia*.rpm ~/local/repo
createrepo ~/local/repo

# 4. Install the new Nvidia package with yum.
sudo yum -y update "nvidia-glx*"
# Unnecessary, will be grabbed by previous update.
#sudo yum -y update "kernel-module-nvidia-$(uname -r)*"
