rendered paste body#!/bin/bashIMP_PATH=$1OLD_PATH=`pwd`touch svnimport.log# strip trailing slash if it existsREPO1=`echo $IMP_PATH | sed -n -e 's/\(.*\)\/$/\1/p'`if [ "x$REPO1" = "x" ] ; then REPO1=$IMP_PATHfi# grab repo name from last dir/item in pathREPO_NAME=`echo $REPO1 | sed -n -e 's/.*\/\([^/]*\)$/\1/p'`# no echo, svncreate echos statusssh -l root boris "/root/svncreate $REPO_NAME"if [ "$?" -ne "0" ] ; then echo Repository creation failed. exit $?fiecho Creating temporary directory.TEMP_DIR=`mktemp -d`if [ "$?" -ne "0" ] ; then echo failed. exit $?fiecho Creating repository layout.mkdir $TEMP_DIR/trunkif [ "$?" -ne "0" ] ; then echo failed. exit $?fimkdir $TEMP_DIR/branchesif [ "$?" -ne "0" ] ; then echo failed. exit $?fimkdir $TEMP_DIR/tagsif [ "$?" -ne "0" ] ; then echo failed. exit $?fiecho Copying files to temporary repository trunk directory.cp -R $IMP_PATH/* $TEMP_DIR/trunkif [ "$?" -ne "0" ] ; then echo failed. exit $?fiecho Cleaning unneeded files.cd $TEMP_DIRif [ -e "cbuild.c" ] ; then ./cbuild.c cleanfifind "$TEMP_DIR" -iname ".svn" | xargs rm -frif [ -e "Makefile" ] || [ -e "makefile" ] || [ -e "MAKEFILE" ] ; then make clean 2>&1 >/dev/nullfifind "$TEMP_DIR" -iname "*~" -o -iname "*.o" -o -iname "*.a" -o -iname "*.so" -o -iregex "core\.\d+" -deletecd $OLD_PATHecho Importing new tree into repository.svn import -m "Initial import" $TEMP_DIR http://svn.tomasu.org/repos/$REPO_NAME > svnimport.logif [ "$?" -ne "0" ] ; then echo failed. exit $?fiecho Removing temporary directory.rm -fr $TEMP_DIRif [ "$?" -ne "0" ] ; then echo failed. exit $?fiecho Backing up original directory.cp -a $IMP_PATH $IMP_PATH.oldif [ "$?" -ne "0" ] ; then echo failed. exit $?firm -fr $IMP_PATHecho Setting up local svn files.mkdir ${IMP_PATH}.svncosvn co --non-interactive http://svn.tomasu.org/repos/$REPO_NAME/trunk ${IMP_PATH}.svnco >> svnimport.logif [ "$?" -ne "0" ] ; then echo failed. mv $IMP_PATH.old $IMP_PATH rm -fr $IMP_PATH.svnco exit $?fiecho Moving checked out directory to final location.mv ${IMP_PATH}.svnco ${IMP_PATH}if [ "$?" -ne "0" ] ; then echo failed. rm -fr ${IMP_PATH}.svnco rm -fr ${IMP_PATH} mv ${IMP_PATH}.old ${IMP_PATH} exit $?firm -fr $IMP_PATH.old