Add some error checking
This commit is contained in:
parent
b542575d3b
commit
fbd405332e
1 changed files with 10 additions and 4 deletions
|
@ -16,6 +16,7 @@ _VERBOSITY=1
|
|||
if [[ "$#" -ne 4 ]]; then
|
||||
echo "Syntax: $0 repo release_tag release_dir destination"
|
||||
echo "Checkout tag <release_tag> from repo <repo> into path <release_dir>/<destination>."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "TODO: check for $TMPDIR"
|
||||
|
@ -46,13 +47,13 @@ canonize_tag () {
|
|||
# or return existing directory
|
||||
create_dir () {
|
||||
local dir=$1
|
||||
local rc
|
||||
local rc=""
|
||||
|
||||
if [[ -d $dir ]]; then
|
||||
rc=$dir
|
||||
else
|
||||
mkdir -p $dir
|
||||
chmod g=u $dir
|
||||
mkdir -p $dir && \
|
||||
chmod g=u $dir && \
|
||||
rc=$dir
|
||||
fi
|
||||
echo $rc
|
||||
|
@ -61,7 +62,7 @@ create_dir () {
|
|||
# create an empty new directory and prepare destination directory
|
||||
create_or_fail_dir () {
|
||||
local dir=$1
|
||||
local rc
|
||||
local rc=""
|
||||
|
||||
if [[ -d $dir ]]; then
|
||||
rc=""
|
||||
|
@ -75,18 +76,23 @@ checkout_git () {
|
|||
local repo=$1
|
||||
local tag=$2
|
||||
local dir=$3
|
||||
local err
|
||||
|
||||
pushd $dir
|
||||
git clone --depth=1 --single-branch --branch=$tag -c feature.manyFiles=true $repo .
|
||||
err=$?
|
||||
popd
|
||||
|
||||
return $err
|
||||
}
|
||||
|
||||
|
||||
repo=$(check_repo $arg_repo)
|
||||
release_tag=$(canonize_tag $arg_tag)
|
||||
destination_dir=$(create_or_fail_dir $arg_dir/$arg_destination)
|
||||
if [[ -z $destination_dir ]]; then
|
||||
log "Covardly refusing to overwrite existing directory $arg_dir/$arg_destination."
|
||||
exit 1
|
||||
else
|
||||
log "Checking out Spack from $repo at tag $release_tag into directory $destination_dir"
|
||||
checkout_git $repo $release_tag $destination_dir
|
||||
|
|
Loading…
Reference in a new issue