aboutsummaryrefslogtreecommitdiff
path: root/trunk/lib/common.sh
diff options
context:
space:
mode:
Diffstat (limited to 'trunk/lib/common.sh')
-rw-r--r--trunk/lib/common.sh60
1 files changed, 41 insertions, 19 deletions
diff --git a/trunk/lib/common.sh b/trunk/lib/common.sh
index 555ecbc..4bdd6b5 100644
--- a/trunk/lib/common.sh
+++ b/trunk/lib/common.sh
@@ -572,6 +572,28 @@ function is_writable_folder {
# subversion functions
# -----------------------------------------------
+function svn_update {
+
+ # simple wrapper around svn update
+ # usage: svn_update
+
+ svn update
+
+}
+
+function svn_folder {
+
+ # simple svn folder checker
+ # usage: svn_folder <folder>
+
+ if [ -d "$1/.svn" ]; then
+ return
+ else
+ return 1
+ fi
+
+}
+
function templates_under_svn {
# check if svn usage is enabled
@@ -603,11 +625,11 @@ function svn_check {
return 1
- elif [ -d "$folder/$file/.svn" ]; then
+ elif svn_folder $folder/$file; then
return 0
- elif [ -d "$folder/.svn" ]; then
+ elif svn_folder $folder; then
(
cd $folder
@@ -625,7 +647,7 @@ function svn_check {
}
-function build_repo {
+function build_svn_repo {
# Checkout a new slackbuild working copy
# input: $1 - svn directory name
@@ -639,17 +661,17 @@ function build_repo {
}
-function check_repo {
+function check_svn_repo {
# Verify if repository exist
# input: $1 - svn directory name
# $2 - svn address
[ $# -ne 2 ] && exit 5
- [ ! -d "$1" ] && build_repo $1 $2
+ [ ! -d "$1" ] && build_svn_repo $1 $2
}
-function sync_repo {
+function sync_svn_repo {
# Synchronize repository
# input: $1 - svn directory name
@@ -663,10 +685,10 @@ function sync_repo {
mkdir -p $folder
cd $folder
- if [ -d ".svn" ]; then
+ if svn_folder $(pwd); then
su_svn update
else
- build_repo $folder $url
+ build_svn_repo $folder $url
fi
cd $pwd
@@ -682,7 +704,7 @@ function svn_add {
folder="`absolute_folder $file`"
cwd="`pwd`"
- if [ -d "$folder/.svn" ]; then
+ if svn_folder $folder; then
cd $folder
su_svn add `basename $file`
else
@@ -697,7 +719,7 @@ function svn_add {
for i in $folders; do
cd ..
- if [ -d ".svn" ]; then
+ if svn_folder $(pwd); then
# add the parent folder
su_svn add --depth=empty $i
@@ -734,7 +756,7 @@ function svn_del {
file="$1"
folder="`dirname $file`"
- if [ -e "$file" ] && [ -d "$folder/.svn" ] && svn_check $file; then
+ if [ -e "$file" ] && svn_folder $folder && svn_check $file; then
chown_svn $file && chgrp_svn $file
( cd $folder && su_svn del --force `basename $file` )
else
@@ -768,7 +790,7 @@ function svn_copy {
fi
# add file to the revision system
- if [ -d "`dirname $dest`/.svn" ]; then
+ if svn_folder `dirname $dest`; then
chown_svn $dest && chgrp_svn $dest
( cd `dirname $dest` && svn_add `basename $dest` )
fi
@@ -791,7 +813,7 @@ function svn_mkdir {
DIR=$DIR/$i
if [ ! -e ${DIR:1} ]; then
su_svn mkdir ${DIR:1}
- elif [ -d "${DIR:1}" ] && [ ! -d "${DIR:1}/.svn" ]; then
+ elif [ -d "${DIR:1}" ] && ! svn_folder ${DIR:1}; then
su_svn add ${DIR:1}
fi
done
@@ -809,7 +831,7 @@ function is_inside_svn_repo {
folder="`absolute_folder $file`"
fi
- if [ -d "$folder/.svn" ]; then
+ if svn_folder $folder; then
return true
fi
@@ -824,7 +846,7 @@ function is_inside_svn_repo {
for i in $folders; do
cd ..
- if [ -d ".svn" ]; then
+ if svn_folder $(pwd); then
cd $cwd
return true
fi
@@ -891,7 +913,7 @@ function commit_changes {
local repos="$1" tmpfile
shift
- if [ -d "$repos/.svn" ]; then
+ if svn_folder $repos; then
cwd="`pwd`"
chown_svn $repos && chgrp_svn $repos
cd $repos
@@ -986,7 +1008,7 @@ function repository_import {
mkdir -p $folder
- if [ -d "$folder/.svn" ]; then
+ if svn_folder $folder; then
echo "Packages folder $folder seens to be already under revision control, aborting."
EXIT_CODE="1"
return $EXIT_CODE
@@ -1037,7 +1059,7 @@ function update_template_files {
# update template files from svn
# usage: update_template_files
- if templates_under_svn && [ -d "`template_files`/.svn" ]; then
+ if templates_under_svn && svn_folder `template_files`; then
echo Checking out last template revision from svn...
cd `dirname $TEMPLATE_BASE`
svn update
@@ -1082,7 +1104,7 @@ function copy_template_files {
if [ -d "$1" ]; then
if [ -d "`template_files`" ]; then
echo "Copying template files to $1..."
- if templates_under_svn && [ -d "`template_files`/.svn" ]; then
+ if templates_under_svn && svn_folder `template_files`; then
rsync -av --exclude=.svn `template_files`/ $1/
else
rsync -av `template_files`/ $1/