File toke-checkout.sh of Package erlang-toke
#!/bin/bash
date=`date +"%Y%m%d"`
version="0"
name="toke" # folder base name (without version)
spec="erlang-toke" # spec file base name (without extension)
url="http://hg.opensource.lshift.net/toke/"
deletefolder=0 # set to 1 to delete the folder the repository is checked out to
#####
folder="./${name}"
tarfile="${folder}-${version}.hg${date}.tar.bz2"
if [ ! -d ${folder} ]; then
echo "checkout ${url} -> ${folder} ..."
hg clone ${url} ${folder}
result=$?
else
echo "pull ${url} -> ${folder} ..."
cd ${folder}
hg pull
result=$?
cd -
fi
if [ ${result} -eq 0 ]; then
echo "making ${tarfile} ..."
tar -cjf ${tarfile} ${folder} --exclude-vcs
result=$?
fi
if [ ${result} -eq 0 ]; then
echo "changing .spec file ..."
sed -i -e "s/%define hg_version .*/%define hg_version ${date}/g" -e "s/%define pkg_version .*/%define pkg_version ${version}/g" ./${spec}.spec
result=$?
fi
if [ ${result} -eq 0 -a ${deletefolder} -eq 1 ]; then
echo "removing ${folder} ..."
rm -rf ${folder}
fi