svn up to tgz

# Update svn and build
# – a bash from-to.delete to remove deleted files and directories
# – a from-to.tgz of the added/modified files
# only parameter is the base dir

OLD=`svnversion -n $1`
echo “Current version: ${OLD}”
svn update $1 > ${OLD}-up.log
NEW=`svnversion -n $1`
if [ $NEW -eq $OLD ]; then echo “NO CHANGE since ${OLD}”; rm ${OLD}-up.log; exit 0; fi

echo “New version: ${NEW}”
cp ${OLD}-up.log ${OLD}-${NEW}.log

# deleted files or dirs?
RM=$(sed -n ‘/^[D]\s\s*\(.*\)$/s//\1/p’ ${OLD}-${NEW}.log)
if [ -n “${RM}” ] ; then
echo ‘#!/bin/bash’ > ${OLD}-${NEW}.delete
echo “# deleted from ${OLD} to ${NEW}” >> ${OLD}-${NEW}.delete
for fil in ${RM}; do echo “rm -R ${fil}” >> ${OLD}-${NEW}.delete ; done
chmod a+x ${OLD}-${NEW}.delete
echo ${OLD}-${NEW}.delete

# added/changed files ?
for fil in  $(sed -n ‘/^[AU]\s\s*\(.*\)$/s//\1/p’ ${OLD}-${NEW}.log); do
if [ ! -d “$fil” ] ; then
TGZ=”${TGZ} ${fil}” ;
done    # fil
if [ -n “${TGZ}” ] ; then
tar czvf ${OLD}-${NEW}.tgz ${TGZ}
echo ${OLD}-${NEW}.tgz
exit 0

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply