#!/bin/sh

#
# Install a particular $ROOT as the most recent stable version
#
#  examples:
#    stable_root hourly 2006010912
#    stable_root nightly 2006010917
#

if [[ xx"$1" == xx"" || yy"$2" == yy"" ]]; then 
    echo "Usage: $0 build curdate\n"
    exit 1
else
    echo "Mark $1 build for date $2 as the latest stable \$ROOT"
fi

#
# Reset "stable" symlink to point to the new version
#
cd /home/ngbuild/export/$1
rm -f stable
ln -s root_$2.tgz stable

#
# Expand the archive into a mountable tree
#
cd ..
rm -rf stable.new stable.prev
mkdir stable.new
cd stable.new
tar xzf ../$1/stable
echo "Expanded ROOT from $1 build dated $2" > README
cd ..
mv stable stable.prev
mv stable.new stable
rm -rf stable.prev

#
# Now rsync the export tree to the public build share on filestore
#
# cd ..
# rsync -avz --password-file=./rsync.pw export/ ngbuild@filestore::build/NC
