#! /bin/sh VERSION=`cat version.txt` # Check whether this script is run as unprivileged user if [ "X$LOGNAME" = "Xroot" ] then echo 'ERROR: This script must not be run as root!' exit 1 fi # Check whether HOME environment variable is set if [ "X$HOME" = "X" ] then echo 'ERROR: Environment variable HOME not set!' exit 1 fi # Check whether the version number was obtained if [ "X$VERSION" = "X" ] then echo 'ERROR: Failed to find version number!' echo 'Make sure to call this script in the correct directory!' exit 1 fi # Create HOME/rpmbuild directory if not yet present if [ ! -d ${HOME}/rpmbuild ] then mkdir -p ${HOME}/rpmbuild chmod 755 ${HOME}/rpmbuild fi # Create subdirectories of HOME/rpmbuild if not yet present for i in BUILD BUILDROOT RPMS SOURCES SPECS SRPMS do if [ ! -d ${HOME}/rpmbuild/${i} ] then mkdir -p ${HOME}/rpmbuild/${i} chmod 755 ${HOME}/rpmbuild/${i} fi done # Copy source tarball to HOME/rpmbuild/SOURCES if [ -f ../dktools-${VERSION}.tar.gz ] then cp ../dktools-${VERSION}.tar.gz ${HOME}/rpmbuild/SOURCES else echo 'ERROR: File' ../dktools-${VERSION}.ta.gz 'not found!' exit 1 fi # Copy *.spec file to HOME/rpmbuild/SPECS if [ -f dktools-el6.spec ] then cp dktools-el6.spec ${HOME}/rpmbuild/SPECS/dktools-el6.spec chmod 644 ${HOME}/rpmbuild/SPECS/dktools-el6.spec else echo 'ERROR: File dktools-el6.spec not found!' exit 1 fi # Build RPM file cd ${HOME}/rpmbuild/SPECS rpmbuild -ba dktools-el6.spec 2>&1 | tee errors # Some final notes echo '' ls ${HOME}/rpmbuild/RPMS/*/dktools-*${VERSION}*.rpm echo '' echo 'If the previous command succeeded, you find your *.rpm files' echo "in a subdirectory of the the ${HOME}/rpmbuild/RPMS directory." echo 'If the rpmbuild command showed errors, make sure to run the' echo 'sl6-prepare.sh script as root before running this one.' echo ''