View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

2006Spring: MusExMachina: Cases: Team Productivity Practices: Squeak Loader

We developed a utility to minimize the startup time cost before development began at each meeting


Summary:

We did most of our development under Linux. In Linux, we had to compile the Squeak VM to be able to develop in squeak. We designated one of the team members to be the package maintainer for our set of compiled squeak binaries, and we would load the binary onto our local machines through a shell script.


copyandrun.sh

#/bin/bash
#
# Copy and Run script
# By Jacob Bolton  -  j(dot)m(dot)bolton(at)gmail(dot)com
#
# This script is designed to copy a set of data to a location.
# The following variables (USERTEMP, DESTINATION, DIRSANDFILES,
# GZARCHIVES, CDDIR, CMD) are used by the script.  DESTINATION must
# be specified, but the others are optional and may be changed to meet
# needs.  The script will attempt to copy and extract the files 
# specified and then run the command specified.  This can be used to
# move an application off of networked storage and then run it 
# preventing unnecessary network load and also allowing for a standard
# application 'package' that can be used by different users.
#
# LIMITATIONS
# - Archives are ALWAYS fully extracted even if all files are already in-tact
# - ONLY .tar.gz archives are currently supported
# - Destination path can only be created if its immediate parent already exists
# - Source files, dirs and archives must exist on local filesystem
#
# VARIABLES ------
#
# USERTEMP - full path to what will be the user's folder in /tmp
USERTEMP="/tmp/$USER"
# DESTINATION - full path to the destination folder for the data
# This parameter is REQUIRED
DESTINATION="$USERTEMP/cs2340"
# : delimited list of full path and file names to be copied
DIRSANDFILES="/net/hu14/gte189u/Squeak-3.6-3/enterprise/*:/net/hu14/gte189u/Squeak3.7gt2/Squeak.everything-shout.*:/net/hu14/gte189u/Squeak3.7gt2/SqueakV3.sources"
# : delimited list of full names of .tar.gz archive to be extracted
GZARCHIVES=""
# Full path to switch to before executing specified CMD
CDDIR="$DESTINATION"
# Command to execute after copying is complete
CMD="./squeak Squeak.everything-shout.image"

#Do not change this, it gets the current path
CURRENTDIR="$(pwd)"

echo $DIRSANDFILES

#Make sure DESTINATION is specified
if [[ -n $DESTINATION ]]; then
echo Using DESTINATION=$DESTINATION;
else
echo ERROR: DESTINATION is required and not specified.;
exit 1;
fi

#Check for user's temp folder (i.e. /tmp/$USER)
if [[ -e $USERTEMP ]]; then
echo Found existing $USERTEMP;
else
echo Creating $USERTEMP;
mkdir $USERTEMP;
fi

#Check for the destination folder
if [[ -e $DESTINATION ]]; then
echo Found existing $DESTINATION;
else
echo Creating $DESTINATION;
mkdir $DESTINATION;
fi

#Try to copy listed files to destination
if [[ -n $DIRSANDFILES ]]; then
echo DIRSANDFILES specified, copying files.;
p=$DIRSANDFILES;
until [[ $p = $d ]]; do 
set -f;
d=${p%%:*}; 
p=${p#*:};
echo Copying $d;
set +f;
cp -uR $d $DESTINATION;
if [[ $? -ne 0 ]]; then
echo Error copying $d, verify DIRSANDFILES is correct and files exist.;
exit 1;
fi
done;
else
echo DIRSANDFILES not specified, doing nothing.;
fi

#Try to extract archives in the destination
if [[ -n $GZARCHIVES ]]; then
echo GZARCHIVES specified, expanding files.;
cd $DESTINATION;
p=$GZARCHIVES;
until [[ $p = $d ]]; do 
set -f;
d=${p%%:*}; 
p=${p#*:}; 
echo Extracting $d;
set +f;
tar -xzf $d; 
if [[ $? -ne 0 ]]; then
echo Error extracting $d, verify GZARCHIVES is correct and files exist.;
exit 1;
fi
done;
cd $CURRENTDIR;
else
echo GZARCHIVES not specified, doing nothing.;
fi

#Try to switch to the CDDIR directory
if [[ -n $CDDIR ]]; then
if [[ -e $CDDIR ]]; then
echo Changing to $CDDIR;
cd $CDDIR;
else
echo $CDDIR does not exist, check script params.;
fi
else
echo CDDIR not specified, doing nothing.;
fi

#Try to execute CMD
if [[ -n $CMD ]]; then
echo Executing $CMD;
$CMD;
else
echo CMD not specified, doing nothing.;
fi


copyandrun.sh

Link to this Page