]> gitweb.fluxo.info Git - simplepkg.git/commitdiff
attemting to fix 64
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Thu, 15 Jan 2009 15:23:23 +0000 (15:23 +0000)
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Thu, 15 Jan 2009 15:23:23 +0000 (15:23 +0000)
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@743 04377dda-e619-0410-9926-eae83683ac58

trunk/lib/common.sh
trunk/src/mkbuild

index 9589568a3daa671737bb28a09d712a77fd05f1d3..5d125b784e2595e86f467b84ec23242965313764 100644 (file)
@@ -664,10 +664,56 @@ function sync_repo {
 
 function svn_add {
 
-  if [ -e "$1" ] && [ -d "`dirname $1`/.svn" ] && ! svn_check $1; then
-    su_svn add $1
+  local file="$1" folder folders dir_list cwd
+  local subfolder subfolders
+
+  if [ -e "$file" ] && ! svn_check $file; then
+
+    folder="`absolute_folder $file`"
+    cwd="`pwd`"
+
+    if [ -d "$folder/.svn" ]; then
+      cd $folder
+      su_svn add `basename $file`
+    else
+
+      # reverse folder order
+      dir_list="`echo $folder | tr '/' ' '`"
+      for i in $dir_list; do
+        folders="$i $folders"
+      done
+
+      cd $folder
+
+      for i in $folders; do
+        cd ..
+        if [ -d ".svn" ]; then
+          # add the parent folder
+          su_svn add --depth=empty $i
+
+          # add all subfolders
+          cd $i
+          subfolders="$(echo $folder | sed -e "s/^$(regexp_slash $(pwd))//")"
+          for subfolder in `echo $subfolders | tr '/' ' '`; do
+            if ! svn_check $subfolder; then
+              su_svn add --depth=empty $subfolder
+              cd $subfolder
+            fi
+          done
+
+          # add the file
+          cd $folder
+          su_svn add `basename $file`
+
+          break
+        fi
+      done
+
+    fi
   fi
 
+  cd $cwd
+
 }
 
 function svn_del {
@@ -741,6 +787,43 @@ function svn_mkdir {
 
 }
 
+function is_inside_svn_repo {
+
+  # check if a file is inside a svn repository
+  # usage: is_inside_svn_repo <file>
+
+  local file="$1" folder folders dir_list cwd
+
+  if [ -e "$file" ]; then
+    folder="`absolute_folder $file`"
+  fi
+
+  if [ -d "$folder/.svn" ]; then
+    return true
+  fi
+
+  # reverse folder order
+  dir_list="`echo $folder | tr '/' ' '`"
+  for i in $dir_list; do
+    folders="$i $folders"
+  done
+
+  cwd="`pwd`"
+  cd $folder
+
+  for i in $folders; do
+    cd ..
+    if [ -d ".svn" ]; then
+      cd $cwd
+      return true
+    fi
+  done
+
+  cd $cwd
+  return false
+
+}
+
 function su_svn {
 
   # execute svn using a different user
@@ -1532,6 +1615,22 @@ function file_extension {
 
 }
 
+function absolute_folder {
+
+  # get the absolute folder from a file
+  # usage: absolute_folder <file>
+
+  local file="$1" cwd
+
+  if [ -e "$file" ]; then
+    cwd="`pwd`"
+    cd `dirname $file`
+    pwd
+    cd $cwd
+  fi
+
+}
+
 function check_installed {
 
   # checks if a package is installed 
index d705929440ed12045c089af731ace857d1523574..fdee5eda2905f4f2317e251cd83da67cd6f372f3 100755 (executable)
@@ -643,25 +643,22 @@ function submit_mkbuild {
 
   local candidate oldplace
 
-  # check mkbuild directory
+  # Check mkbuild directory
   [ ! -d $MKBUILDS_DIR ] && build_repo $MKBUILDS_DIR $MKBUILDS_SVN
 
   # Get mkbuild path in parameter file
   MKBUILD_PATH=$SLACKBUILD_PATH
 
-  # change to mkbuilds directory
+  # Change to mkbuilds directory
   cd $MKBUILDS_DIR/
 
-  # Add mkbuild scripts
-  # check path
+  # Check path
   [ ! -e $MKBUILD_PATH ] && svn_mkdir $MKBUILD_PATH
 
-  # add mkbuild
-  svn_copy $WORK/`basename $MKBUILD_NAME` $MKBUILD_PATH
-
-  for i in `ls $WORK | grep -E -v '(SlackBuild|old|slack-required|.mkbuild$|.tmp$)\*{0,1}$'`; do
+  # Add relevant files
+  for i in `ls $WORK | grep -E -v '(SlackBuild|old|slack-required|.tmp$)\*{0,1}$'`; do
     if [ "`basename $i`" != "$DIST_SRC_NAME" ]; then
-      if ! is_the_same $(dirname $MKBUILD_PATH) $WORK; then
+      if ! is_the_same $MKBUILD_PATH $WORK; then
         svn_copy $WORK/$i $MKBUILD_PATH
       else
         svn_add $WORK/$i
@@ -669,7 +666,7 @@ function submit_mkbuild {
     fi
   done
 
-  # remove stuff in old places
+  # Remove stuff in old places
   for candidate in $(find . -name $(basename $MKBUILD_NAME)); do
     oldplace="`dirname $candidate | sed -e 's/^\.\///'`"
     if [ "$oldplace" != "$MKBUILD_PATH" ]; then
@@ -685,8 +682,8 @@ function submit_mkbuild {
 
 function submit_cleanup {
 
-  # remove files that should not be stored at the mkbuilds repository
-  if ! is_the_same $(dirname $MKBUILD_PATH) $WORK; then
+  # Remove files that should not be stored at the mkbuilds repository
+  if is_the_same $MKBUILD_PATH $WORK; then
     (
       cd $WORK
       rm -f *.old *.tmp *.SlackBuild slack-required $DIST_SRC_NAME