From 16db13c00959aa09586f54701a55f49ee92de190 Mon Sep 17 00:00:00 2001 From: rhatto Date: Sat, 17 Jan 2009 19:47:59 +0000 Subject: templatepkg now can automatically creates the svn repository git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@754 04377dda-e619-0410-9926-eae83683ac58 --- trunk/lib/common.sh | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++ trunk/src/createpkg | 61 +++++++++--------------------------------- trunk/src/mkbuild | 39 +++------------------------ trunk/src/templatepkg | 2 ++ 4 files changed, 92 insertions(+), 83 deletions(-) diff --git a/trunk/lib/common.sh b/trunk/lib/common.sh index a7fa50c..22ac924 100644 --- a/trunk/lib/common.sh +++ b/trunk/lib/common.sh @@ -925,6 +925,30 @@ function check_svn_repo { } +function check_and_create_svn_repo { + + # check and create svn repository + # usage: check_and_create_svn_repo + + local repository repository_type repository_path + + repository_type="`echo $repository | cut -d : -f 1`" + repository_path="`echo $repository | cut -d : -f 2`" + + if [ "$repository_type" == "file" ] && [ ! -d "$repository_path" ]; then + echo "Creating subversion repository $repository..." + mkdir -p `dirname $repository_path` + svnadmin create $repository_path --fs-type fsfs + if [ "$?" != "0" ]; then + EXIT_CODE="1" + return $EXIT_CODE + else + return 0 + fi + fi + +} + # ----------------------------------------------- # update jail functions # ----------------------------------------------- @@ -1634,6 +1658,55 @@ function absolute_folder { } +function list_builds { + + # list all available builds + # usage: list_builds + + local folder="$1" file_type="$2" + local i j k + + if [ ! -d "$folder" ] || [ -z "$file_type" ]; then + return + fi + + cd $folder + echo "Sarava $file_type list" + # level 1 + for i in *; do + if [ -d $i ]; then + echo -e " $i: " + ( + cd $i + # level 2 + for j in *; do + if [ -d $j ]; then + eecho $commun " $j" + ( + cd $j + BUILD="`ls *.$file_type 2>/dev/null`" + if [ "$BUILD" != "" ]; then + # level 3 + for k in $BUILD; do + eecho $messag " $k" + done + else + BUILD="" + fi + for k in *; do + if [ -d $k ]; then + eecho $messag " $k.$file_type" + fi + done + ) + fi + done + ) + fi + done + +} + function check_installed { # checks if a package is installed diff --git a/trunk/src/createpkg b/trunk/src/createpkg index c2d3c32..a02c8c8 100644 --- a/trunk/src/createpkg +++ b/trunk/src/createpkg @@ -211,43 +211,12 @@ function info_builds { } -function list_builds { +function list_slackbuilds { - # List all available SlackBuilds - cd $SLACKBUILDS_DIR - echo "Sarava SlackBuilds list" - # level 1 - for i in *; do - if [ -d $i ]; then - echo -e " $i: " - ( - cd $i - # level 2 - for j in *; do - if [ -d $j ]; then - eecho $commun " $j" - ( - cd $j - BUILD="`ls *.SlackBuild 2>/dev/null`" - if [ "$BUILD" != "" ]; then - # level 3 - for k in $BUILD; do - eecho $messag " $k" - done - else - BUILD="" - fi - for k in *; do - if [ -d $k ]; then - eecho $messag " $k.SlackBuild" - fi - done - ) - fi - done - ) - fi - done + # list all available slackbuilds + # usage: list_slackbuilds + + list_builds $SLACKBUILDS_DIR SlackBuild } @@ -379,7 +348,6 @@ function repository_import { repository="file://$repository" fi - repository_type="`echo $repository | cut -d : -f 1`" repository_path="`echo $repository | cut -d : -f 2`" # eval again so it doesn't include repository style information @@ -392,17 +360,14 @@ function repository_import { return $EXIT_CODE fi - if [ "$repository_type" == "file" ] && [ ! -d "$repository_path" ]; then - echo "Creating subversion repository $repository..." - mkdir -p `dirname $repository_path` - svnadmin create $repository_path --fs-type fsfs - chown_svn $repository_path && chgrp_svn $repository_path - if [ "$?" != "0" ]; then - EXIT_CODE="1" - return $EXIT_CODE - fi + check_and_create_svn_repo $repository + if [ "$?" != "0" ]; then + EXIT_CODE="1" + return $EXIT_CODE fi + chown_svn $repository_path && chgrp_svn $repository_path + echo "Importing packages from $packages_dir into $repository..." su_svn import $packages_dir $repository -m "importing binary packages" if [ "$?" == "0" ]; then @@ -612,7 +577,7 @@ case $1 in ;; '--search'|'-s') if [ $# -ne 2 ]; then - list_builds + list_slackbuilds else LIST=`find_slackbuild $2` for i in $LIST; do @@ -651,7 +616,7 @@ case $1 in exit $EXIT_CODE ;; '--list'|'-l') - list_builds + list_slackbuilds exit $EXIT_CODE ;; '--update') diff --git a/trunk/src/mkbuild b/trunk/src/mkbuild index 63ab779..c348038 100755 --- a/trunk/src/mkbuild +++ b/trunk/src/mkbuild @@ -1372,41 +1372,10 @@ function search_mkbuild { function list_mkbuilds { - # List all available mkbuilds - cd $MKBUILDS_DIR - echo "Sarava mkbuilds list" - # level 1 - for i in *; do - if [ -d $i ]; then - echo -e " $i: " - ( - cd $i - # level 2 - for j in *; do - if [ -d $j ]; then - eecho $commun " $j" - ( - cd $j - BUILD="`ls *.mkbuild 2>/dev/null`" - if [ "$BUILD" != "" ]; then - # level 3 - for k in $BUILD; do - eecho $messag " $k" - done - else - BUILD="" - fi - for k in *; do - if [ -d $k ]; then - eecho $messag " $k.mkbuild" - fi - done - ) - fi - done - ) - fi - done + # list all available mkbuilds + # usage: list_mkbuilds + + list_builds $MKBUILDS_DIR mkbuild } diff --git a/trunk/src/templatepkg b/trunk/src/templatepkg index 8d98950..0eee075 100755 --- a/trunk/src/templatepkg +++ b/trunk/src/templatepkg @@ -153,6 +153,7 @@ function import_export_templates { # usage: template_export local templates templates_folder basedir repository mode preposition + local repository_type repository_path if [ "$?" != 0 ]; then usage @@ -179,6 +180,7 @@ function import_export_templates { if [ "$mode" == "export" ]; then preposition="to" + check_and_create_svn_repo $repository echo Exporting templates to $repository... svn import $templates/ $repository/ -m "initial import" if [ "$?" != "0" ]; then -- cgit v1.2.3