aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>2009-01-30 19:58:17 +0000
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>2009-01-30 19:58:17 +0000
commit0a74464a3dab5ae8ba3d8616cd2da1bd30b5f85d (patch)
tree627635ec2daaedadaa01f8a254586e6527f1ce5e
parent9f2db07cb54fd3b0dbee1c35e7529a1cd66b40d7 (diff)
downloadsimplepkg-0a74464a3dab5ae8ba3d8616cd2da1bd30b5f85d.tar.gz
simplepkg-0a74464a3dab5ae8ba3d8616cd2da1bd30b5f85d.tar.bz2
more wrapper svn functions
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@787 04377dda-e619-0410-9926-eae83683ac58
-rw-r--r--trunk/lib/common.sh60
-rw-r--r--trunk/src/createpkg20
-rwxr-xr-xtrunk/src/jail-commit2
-rwxr-xr-xtrunk/src/mkbuild8
-rwxr-xr-xtrunk/src/templatepkg38
5 files changed, 75 insertions, 53 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/
diff --git a/trunk/src/createpkg b/trunk/src/createpkg
index 08280a4..9563055 100644
--- a/trunk/src/createpkg
+++ b/trunk/src/createpkg
@@ -305,7 +305,7 @@ function repository_checkout {
function repository_update {
- if [ ! -z "$1" ] && [ -d "$1/.svn" ]; then
+ if [ ! -z "$1" ] && svn_folder $1; then
echo "Fetching changes from svn repository for $1..."
cwd="`pwd`"
chown_svn $1 && chgrp_svn $1
@@ -319,14 +319,14 @@ function repository_status {
local cwd
- if [ -d "$PACKAGES_DIR/.svn" ]; then
+ if svn_folder $PACKAGES_DIR; then
echo "Status of $PACKAGES_DIR."
cwd="`pwd`"
cd $PACKAGES_DIR && su_svn status
cd $cwd
fi
- if [ -d "$NOARCH_DIR/.svn" ]; then
+ if svn_folder $NOARCH_DIR; then
cwd="`pwd`"
echo "Status of $NOARCH_DIR."
cd $NOARCH_DIR && su_svn status
@@ -365,7 +365,7 @@ function create_repo_folder {
if [ ! -d "$folder" ]; then
echo "Creating packages folder $folder..."
basedir="`dirname $folder`"
- if [ -d "$basedir/.svn" ] && ! svn_check $folder; then
+ if svn_folder $basedir && ! svn_check $folder; then
(
cd $basedir
chown_svn $basedir && chgrp_svn $basedir
@@ -375,7 +375,7 @@ function create_repo_folder {
mkdir -p $folder/$SUBFOLDER
fi
elif [ ! -e $folder/$SUBFOLDER ]; then
- if [ -d "$folder/.svn" ] && ! svn_check $folder/$SUBFOLDER; then
+ if svn_folder $folder && ! svn_check $folder/$SUBFOLDER; then
(
cd $folder
chown_svn $folder && chgrp_svn $folder
@@ -413,7 +413,7 @@ function remove_old_package_data {
fi
# Using subversion
- if [ -d "$makepkg_repos/.svn" ]; then
+ if svn_folder $makepkg_repos; then
(
@@ -516,7 +516,7 @@ function sign_package {
function create_package {
# Synchronize repository
- [ $SYNC -eq $yes ] && sync_repo $SLACKBUILDS_DIR $SLACKBUILDS_SVN
+ [ $SYNC -eq $yes ] && sync_svn_repo $SLACKBUILDS_DIR $SLACKBUILDS_SVN
# Update keyring
update_keyring $SLACKBUILDS_DIR/GPG-KEY
@@ -719,7 +719,7 @@ function create_package {
mv $PACKAGES_DIR/$PKG_NAME.asc $NEW_REPOS/
fi
- if [ -d "$NEW_REPOS/.svn" ]; then
+ if svn_folder $NEW_REPOS; then
(
cd $NEW_REPOS
chown_svn $PACKAGES_DIR && chgrp_svn $PACKAGES_DIR
@@ -850,7 +850,7 @@ fi
BASENAME="`basename $0`[$CREATEPKG_CHILD]"
check_config
-check_repo $SLACKBUILDS_DIR $SLACKBUILDS_SVN
+check_svn_repo $SLACKBUILDS_DIR $SLACKBUILDS_SVN
INSTALL=$off
NO_DEPS=$off
@@ -901,7 +901,7 @@ case $1 in
build_queue $*
;;
'--sync')
- sync_repo $SLACKBUILDS_DIR $SLACKBUILDS_SVN
+ sync_svn_repo $SLACKBUILDS_DIR $SLACKBUILDS_SVN
exit $EXIT_CODE
;;
'--help'|'-h'|'')
diff --git a/trunk/src/jail-commit b/trunk/src/jail-commit
index d91a767..60e0a36 100755
--- a/trunk/src/jail-commit
+++ b/trunk/src/jail-commit
@@ -98,7 +98,7 @@ function template_svn_commit {
# issue a svn_commit from a template folder
# usage: template_svn_commit <template-folder>
- if templates_under_svn && [ -d "$1/.svn" ]; then
+ if templates_under_svn && svn_folder $1; then
cd $1
echo First checking out from the repository...
svn update
diff --git a/trunk/src/mkbuild b/trunk/src/mkbuild
index dd04dec..1ef3328 100755
--- a/trunk/src/mkbuild
+++ b/trunk/src/mkbuild
@@ -253,7 +253,7 @@ function set_parameters {
'--sync' )
# Synchronize mkbuilds repository
mkbuild_update_keyring
- sync_repo $MKBUILDS_DIR $MKBUILDS_SVN
+ sync_svn_repo $MKBUILDS_DIR $MKBUILDS_SVN
exit $?
;;
'-v'|'--version')
@@ -701,7 +701,7 @@ function submit_mkbuild {
local candidate oldplace
# Check mkbuild directory
- [ ! -d $MKBUILDS_DIR ] && build_repo $MKBUILDS_DIR $MKBUILDS_SVN
+ if [ ! -d $MKBUILDS_DIR ] && build_svn_repo $MKBUILDS_DIR $MKBUILDS_SVN
# Get mkbuild path in parameter file
MKBUILD_PATH=$SLACKBUILD_PATH
@@ -784,14 +784,14 @@ function repository_status {
local cwd
- if [ -d "$MKBUILDS_DIR/.svn" ]; then
+ if svn_folder $MKBUILDS_DIR; then
echo "Status of $MKBUILDS_DIR."
cwd="`pwd`"
cd $MKBUILDS_DIR && su_svn status
cd $cwd
fi
- if [ -d "$SLACKBUILDS_DIR/.svn" ]; then
+ if svn_folder $SLACKBUILDS_DIR; then
cwd="`pwd`"
echo "Status of $SLACKBUILDS_DIR."
cd $SLACKBUILDS_DIR && su_svn status
diff --git a/trunk/src/templatepkg b/trunk/src/templatepkg
index 0eee075..ba5946b 100755
--- a/trunk/src/templatepkg
+++ b/trunk/src/templatepkg
@@ -174,7 +174,7 @@ function import_export_templates {
if [ ! -z "$2" ]; then
- if [ ! -d "$templates_folder/.svn" ]; then
+ if ! svn_folder $templates_folder; then
cd $basedir
@@ -225,7 +225,7 @@ function template_create {
echo Creating template `basename $TEMPLATE_BASE`...
- if templates_under_svn && [ -d "`dirname $TEMPLATE_BASE`/.svn" ]; then
+ if templates_under_svn && svn_folder `dirname $TEMPLATE_BASE`; then
cd `dirname $TEMPLATE_BASE`
svn mkdir `dirname $TEMPLATE_BASE`
else
@@ -240,7 +240,7 @@ function template_create {
touch `template_perms`
touch `template_packages`
- if templates_under_svn && [ -d "`dirname $TEMPLATE_BASE`/.svn" ]; then
+ if templates_under_svn && svn_folder `dirname $TEMPLATE_BASE`; then
cd `dirname $TEMPLATE_BASE`
@@ -268,7 +268,7 @@ function template_create {
info_commit="yes"
fi
- elif templates_under_svn && [ -d "$TEMPLATE_FOLDER/.svn" ]; then
+ elif templates_under_svn && svn_folder "$TEMPLATE_FOLDER"; then
mkdir `template_files` `template_scripts`
cd $TEMPLATE_FOLDER
@@ -315,7 +315,7 @@ function template_create {
cat $orig_packages > `template_packages`
fi
- if templates_under_svn && [ -d "$orig_template/.svn" ]; then
+ if templates_under_svn && svn_folder $orig_template; then
cd `dirname $TEMPLATE_BASE`
@@ -410,7 +410,7 @@ function template_update {
done
- if ! svn_check `template_packages` && [ -d "`dirname $TEMPLATE_BASE`/.svn" ]; then
+ if ! svn_check `template_packages` && svn_folder `dirname $TEMPLATE_BASE`; then
cd `dirname $TEMPLATE_BASE`
svn add `basedir $(template_packages)`
fi
@@ -443,7 +443,7 @@ function template_add {
if [ ! -a "`template_files`/$candidate" ]; then
mkdir -p `template_files`/`dirname $candidate`
cp -a $jail/$candidate `template_files`/$candidate
- if templates_under_svn && [ -d "`template_files`/.svn" ]; then
+ if templates_under_svn && svn_folder `template_files`; then
cwd="`pwd`"
cd `template_files`
svn add ./$candidate
@@ -472,15 +472,15 @@ function template_add {
destination="`echo $(template_files)/$file | sed -e 's/\/$//'`"
- if templates_under_svn && [ -d "`template_files`/.svn" ]; then
+ if templates_under_svn && svn_folder `template_files`; then
candidate="./`dirname $file`"
- if [ ! -d "`template_files`/$candidate/.svn" ]; then
+ if ! svn_folder `template_files`/$candidate; then
mkdir -p `template_files`/$candidate
cd `template_files`/`dirname $candidate`
while true; do
- if [ -d ".svn" ]; then
+ if svn_folder $(pwd); then
svn add `basename $candidate`
break
else
@@ -550,12 +550,12 @@ function check_template_exist {
mkdir $component
fi
- if templates_under_svn && [ -d "`dirname $TEMPLATE_BASE`/.svn" ]; then
+ if templates_under_svn && svn_folder `dirname $TEMPLATE_BASE`; then
svn add $component
info_commit="yes"
fi
- elif templates_under_svn && [ -d "`dirname $TEMPLATE_BASE`/.svn" ] && \
+ elif templates_under_svn && svn_folder `dirname $TEMPLATE_BASE` && \
! svn_check $component; then
cd `dirname $TEMPLATE_BASE`
@@ -580,7 +580,7 @@ function template_delete {
if [ -e "`template_files`/$1" ]; then
# first try to remove the file from the template
- if templates_under_svn && [ -d "`template_files`/.svn" ]; then
+ if templates_under_svn && svn_folder `template_files`; then
cd `template_files`
svn del --force ./$1 || rm -rf ./$1
if [ -z "$SILENT" ]; then
@@ -604,7 +604,7 @@ function template_delete {
fi
elif [ -e "`template_scripts`/$1" ]; then
- if templates_under_svn && [ -d "`template_scripts`/.svn" ]; then
+ if templates_under_svn && svn_folder `template_scripts`; then
cd `template_scripts`
svn del --force ./$1 || rm -rf ./$1
if [ -z "$SILENT" ]; then
@@ -640,7 +640,7 @@ function template_remove {
exit 1
fi
- if templates_under_svn && [ -d "$basedir/.svn" ]; then
+ if templates_under_svn && svn_folder $basedir; then
cd $TEMPLATE_FOLDER
svn update
svn del --force $template
@@ -729,7 +729,7 @@ function template_post_install_edit {
vi `template_scripts`/$1
fi
if [ "$sha1sum" != "`sha1sum $(template_scripts)/$1`" ] && \
- [ -d "`dirname $TEMPLATE_BASE`/.svn" ] && [ -z "$SILENT" ]; then
+ svn_folder `dirname $TEMPLATE_BASE` && [ -z "$SILENT" ]; then
echo "Please run 'jail-commit --all' to send changes to the repository"
fi
else
@@ -743,7 +743,7 @@ function template_post_install_edit {
touch `template_scripts`/$1
chmod +x `template_scripts`/$1
- if [ -d "`template_scripts`/.svn" ]; then
+ if svn_folder `template_scripts`; then
cd `template_scripts`
svn add $1
if [ -z "$SILENT" ]; then
@@ -774,7 +774,7 @@ function template_edit {
vi `template_packages`
fi
if [ "$sha1sum" != "`sha1sum $(template_packages)`" ] && \
- [ -d "`dirname $TEMPLATE_BASE`/.svn" ] && [ -z "$SILENT" ]; then
+ svn_folder `dirname $TEMPLATE_BASE` && [ -z "$SILENT" ]; then
echo "Please run 'jail-commit --all' to send changes to the repository"
fi
elif [ -e "`template_packages`" ]; then
@@ -937,7 +937,7 @@ elif [ "$1" == "-d" ] || [ "$1" == "--delete" ]; then
elif [ "$1" == "-s" ] || [ "$1" == "--sync" ]; then
- if templates_under_svn && [ -d "$TEMPLATE_FOLDER/.svn" ]; then
+ if templates_under_svn && svn_folder $TEMPLATE_FOLDER; then
( cd $TEMPLATE_FOLDER && svn update )
true
fi