]> gitweb.fluxo.info Git - simplepkg.git/commitdiff
addind createpkg --checkout and enhancing mkbuild --search
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Sat, 17 Jan 2009 19:15:25 +0000 (19:15 +0000)
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Sat, 17 Jan 2009 19:15:25 +0000 (19:15 +0000)
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@753 04377dda-e619-0410-9926-eae83683ac58

trunk/src/createpkg
trunk/src/mkbuild

index 52116d971a11ee367115a438ea29a9d5f3db04d4..c2d3c3243e53e76fd7ab592d74303075c81be927 100644 (file)
@@ -59,6 +59,8 @@ ${red}DESCRIPTION${normal}
                 check binary packages' svn repository status
             ${red}--import${normal}
                 import packages into a svn repository
+            ${red}--checkout${normal}
+                checkout binary packages from a svn repository
             ${red}--update-keyring${normal}
                 update GPG-KEY from binary repositories
             ${red}-h${normal}, ${red}--help${normal}
@@ -294,19 +296,33 @@ function load_parameters {
 
 function repository_checkout {
 
-  local svn
+  # checkout a binary repository
+  # usage: repository_checkout [repository-adress]
+
+  local svn oldfolder
 
   if [ -d "$PACKAGES_DIR" ]; then
-    mv $PACKAGES_DIR $PACKAGES_DIR.old
+    oldfolder="$(mktemp -d $(echo $PACKAGES_DIR | sed -e 's/\/*$//g').XXXXXX)"
+    echo "Moving old $PACKAGES_DIR to $oldfolder..."
+    mv $PACKAGES_DIR $oldfolder
   fi
 
   if [ -z "$1" ]; then
     svn="$1"
   else
-    svn="$SLACKBUILDS_SVN"
+    svn="$PACKAGES_SVN"
   fi
 
-  svn checkout $svn $PACKAGES_DIR
+  if check_svn_repo $svn; then 
+    svn checkout $svn $PACKAGES_DIR
+    chown_svn $PACKAGES_DIR && chgrp_svn $PACKAGES_DIR
+    if [ "$svn" != "$PACKAGES_SVN" ]; then
+      echo "Using svn repository different from the one pointed at $CONF." 
+    fi
+  else
+    echo "Invalid repository $repository, aborting."
+    EXIT_CODE="1"
+  fi
 
 }
 
@@ -354,6 +370,7 @@ function repository_import {
   fi
 
   if ! check_svn_repo $repository; then
+    echo "Invalid repository $repository, aborting."
     EXIT_CODE="1"
     return $EXIT_CODE
   fi
@@ -379,6 +396,7 @@ function repository_import {
     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
@@ -386,11 +404,12 @@ function repository_import {
   fi
 
   echo "Importing packages from $packages_dir into $repository..."
-  svn import $packages_dir $repository -m "importing binary packages"
+  su_svn import $packages_dir $repository -m "importing binary packages"
   if [ "$?" == "0" ]; then
     echo "Making $packages_dir a working copy of $repository..."
     rm -rf $packages_dir
-    svn checkout $repository $packages_dir
+    chown_svn `dirname $packages_dir` && chgrp_svn `dirname $packages_dir`
+    su_svn checkout $repository $packages_dir
   else
     EXIT_CODE="1"
     return $EXIT_CODE
@@ -648,13 +667,18 @@ case $1 in
     fi
     exit $EXIT_CODE
   ;;
+  '--status')
+    repository_status
+    exit $EXIT_CODE
+  ;;
   '--import')
     shift
     repository_import $*
     exit $EXIT_CODE
   ;;
-  '--status')
-    repository_status
+  '--checkout')
+    shift
+    repository_checkout $*
     exit $EXIT_CODE
   ;;
   '--update-keyring')
index 3a3a9beddcc162d8091f28bb8af86f1c16317726..63ab779980367b02e603f9852d0049925722a593 100755 (executable)
@@ -1356,6 +1356,11 @@ function search_mkbuild {
   # find a given mkbuild
   # usage: search_mkbuild [-i]
 
+  if [ "$MKBUILD_NAME" == ".mkbuild" ]; then
+    list_mkbuilds
+    return
+  fi
+
   if [ "$1" == "-i" ]; then
     # case insensitive mode
     find $MKBUILDS_DIR -iname $MKBUILD_NAME
@@ -1365,6 +1370,46 @@ 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
+
+}
+
 function edit_mkbuild {
 
   # edit a mkbuild