#!/bin/tcsh

# This script attempts to set up a private RPM database on the 
# the JLab CUE for the current OS/architecture. The database
# will be created (if it doesn't already exist) in a 
# subdirectory of /group/halld/Software/OS.


# Setup root of our private RPM database and place the
# standard arguments in  the HDRPM_ARGS environment variable
setenv BMS_OSNAME `/group/halld/Software/scripts/osrelease.pl`
setenv HDRPM /group/halld/Software/OS/$BMS_OSNAME
setenv HDRPM_ARGS "--dbpath $HDRPM/rpm --relocate /=$HDRPM"

# Create and initialize the root of our private RPM area.
# We use the same directory to hold both the files used by
# rpm itself and the files installed from the rpms that we 
# want to use.
if (! -d $HDRPM/rpm ) then
	# rpm database directory doesn't exist. Create it.
	echo Creating rpm database in $HDRPM ...
	mkdir -p $HDRPM/rpm
	rpm --initdb --dbpath $HDRPM/rpm
	echo Copying system-wide RPM database files ...
	cp /var/lib/rpm/* $HDRPM/rpm
else
	# rpm directory exists. Assume database is valid.
	echo attempting to use existing RPM database
endif

# Location of RPMs
setenv RPMDIR /group/12gev_phys/www/packages

rpm -ivh $RPMDIR/xerces-c-2.8.0-fc8.i386.rpm $HDRPM_ARGS
rpm -ivh $RPMDIR/root-5.14.00-fc8.i386.rpm $HDRPM_ARGS
rpm -ivh $RPMDIR/jana-0.4.7-fc8.i386.rpm $HDRPM_ARGS
