[csw-devel] SF.net SVN: opencsw:[535] gar-wrapper

skayser at users.sourceforge.net skayser at users.sourceforge.net
Mon Sep 19 23:04:38 CEST 2011


Revision: 535
          http://opencsw.svn.sourceforge.net/opencsw/?rev=535&view=rev
Author:   skayser
Date:     2011-09-19 21:04:37 +0000 (Mon, 19 Sep 2011)
Log Message:
-----------
mgar: fail gracefully on unexpected svn/git errors in pkg and build system dir

Modified Paths:
--------------
    gar-wrapper/CHANGES
    gar-wrapper/mgar

Modified: gar-wrapper/CHANGES
===================================================================
--- gar-wrapper/CHANGES	2011-09-19 20:00:47 UTC (rev 534)
+++ gar-wrapper/CHANGES	2011-09-19 21:04:37 UTC (rev 535)
@@ -1,9 +1,11 @@
 Changes since 0.92 (r380):
 * NEW command "show-var" to show runtime value of recipe vars (Maciej Blizinski)
-* NEW command "grep-buildsys" to facilitate greping the build system
+* NEW command "grep-buildsys" to facilitate grepping the build system
+* NEW command alias "-V" for "version"
 * CHANGE added package version to "version" command output
 * CHANGE "newpkg" command now runs relative to the build tree (not $PWD)
 * CHANGE tweaked error message when running a pkg command in a non-pkg dir
+* FIX fail gracefully in case of VCS issues with pkg or build system dirs
 
 Changes since 0.91 (r360):
 * NEW command "newpkg <pkg> <version>" to create package recipe skeletons

Modified: gar-wrapper/mgar
===================================================================
--- gar-wrapper/mgar	2011-09-19 20:00:47 UTC (rev 534)
+++ gar-wrapper/mgar	2011-09-19 21:04:37 UTC (rev 535)
@@ -154,6 +154,35 @@
   exit 2
 }
 
+function die_vcsdir_invalid {
+  local __dir=`get_absolute_dirname "$1"`
+  local __errmsg=`echo "$2" | gsed 's,^,  ,'`
+  echo "Checking VCS status failed: ${__dir}"
+  echo "${__errmsg}"
+  exit 2
+}
+
+# Makes mgar fail gracefully in case of unexpected svn/git hickups like
+# the ones introduced with the backwards-incompatible svn 1.7pre3 release.
+# svn: E155036: Working copy [...] too old (format 10, created by Subversion 1.6
+function assert_vcsdir_valid {
+  local __dir="$1"
+  local __vcstype=""
+  local __out=""
+
+  # Temporarily disable the global set -e to handle exit codes != 0
+  set +e
+  [ -d "${__dir}/.svn" ] && __vcstype="svn"
+  [ -d "${__dir}/.git" ] && __vcstype="git"
+  case ${__vcstype} in
+    svn) __out=`svn status "${__dir}" 2>&1`;;
+    git) __out=`git status "${__dir}" 2>&1`;;
+    *) __out="Directory neither contains .svn or .git"; /bin/false;;
+  esac
+  [ $? -eq 0 ] || die_vcsdir_invalid "${__dir}" "${__out}"
+  set -e
+}
+
 function in_pkg_dir {
   [ -f Makefile ] || return 1
   grep "^include gar/category.mk" Makefile >/dev/null 2>&1 || return 1
@@ -545,6 +574,7 @@
 # actually in a pkg directory and that the pkg relevant GAR branch can be found
 if is_per_pkg_command $1; then
   assert_in_pkg_dir
+  assert_vcsdir_valid .
   assert_no_conflicting_gar_dir_present
   BUILDSYS_OVERRIDE="`read_config_value OVERRIDE_BUILDSYS`"
   BUILDSYS_PKG="`get_pkg_buildsysdir`"
@@ -592,7 +622,8 @@
                      -name .git -prune -o -name "${2:-*}" -print;;
     grep-buildsys) shift; ack "$1" "$BUILDSYS";;
   list-categories) ls "$BUILDSYS/categories/";;
-    show-buildsys) __rev=`get_rev "$BUILDSYS"`
+    show-buildsys) assert_vcsdir_valid "$BUILDSYS"
+                   __rev=`get_rev "$BUILDSYS"`
                    __branch=`get_repourl "$BUILDSYS" | sed -e "s,$GAR_REPO,,"`
                    echo -e "$BUILDSYS\t(Revision: $__rev, Branch: $__branch)"
                    ;;

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list