diff options
author | rhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58> | 2009-01-19 15:38:38 +0000 |
---|---|---|
committer | rhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58> | 2009-01-19 15:38:38 +0000 |
commit | afb0901283052b06d75f04694f942139f424f177 (patch) | |
tree | 317f8424ac9099848d7b6ae22229487b0f3f08e6 /trunk/lib | |
parent | 16db13c00959aa09586f54701a55f49ee92de190 (diff) | |
download | simplepkg-afb0901283052b06d75f04694f942139f424f177.tar.gz simplepkg-afb0901283052b06d75f04694f942139f424f177.tar.bz2 |
mkbuild: adding import routines
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@755 04377dda-e619-0410-9926-eae83683ac58
Diffstat (limited to 'trunk/lib')
-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 # ----------------------------------------------- |