diff options
Diffstat (limited to 'trunk/lib/common.sh')
-rw-r--r-- | trunk/lib/common.sh | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/trunk/lib/common.sh b/trunk/lib/common.sh index 22ac924..d1f16c6 100644 --- a/trunk/lib/common.sh +++ b/trunk/lib/common.sh @@ -949,6 +949,64 @@ function check_and_create_svn_repo { } +function repository_import { + + # import a folder into a subversion repository + # usage: repository_import <folder> <repository> + + local folder="$1" oldfolder + local repository="$2" repository_type repository_path + + if [ ! -d "$folder" ] || [ -z "$repository" ]; then + EXIT_CODE="1" + return $EXIT_CODE + fi + + if ! check_svn_repo $repository; then + echo "Invalid repository $repository, aborting." + EXIT_CODE="1" + return $EXIT_CODE + fi + + if ! echo $repository | grep -q ":"; then + repository="file://$repository" + fi + + mkdir -p $folder + + if [ -d "$folder/.svn" ]; then + echo "Packages folder $folder seens to be already under revision control, aborting." + EXIT_CODE="1" + return $EXIT_CODE + fi + + check_and_create_svn_repo $repository + if [ "$?" != "0" ]; then + EXIT_CODE="1" + return $EXIT_CODE + fi + + repository_path="`echo $repository | cut -d : -f 2`" + if [ -d "$repository_path" ]; then + chown_svn $repository_path && chgrp_svn $repository_path + fi + + echo "Importing files from $folder into $repository..." + su_svn import $folder $repository -m "initial import" + if [ "$?" == "0" ]; then + echo "Making $folder a working copy of $repository..." + oldfolder="$(mktemp -d $(echo $folder | sed -e 's/\/*$//g').XXXXXX)" + echo "Backing up old $folder at $oldfolder..." + mv $folder $oldfolder + chown_svn `dirname $folder` && chgrp_svn `dirname $folder` + su_svn checkout $repository $folder + else + EXIT_CODE="1" + return $EXIT_CODE + fi + +} + # ----------------------------------------------- # update jail functions # ----------------------------------------------- |