]> gitweb.fluxo.info Git - hydra.git/commitdiff
Adding module-verify action
authorSilvio Rhatto <rhatto@riseup.net>
Wed, 10 Aug 2011 16:12:49 +0000 (13:12 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Wed, 10 Aug 2011 16:12:49 +0000 (13:12 -0300)
lib/hydra/action
lib/hydra/misc
share/hydra/module-verify [new file with mode: 0755]

index b5d76a90a1099b3dcbcb8b291449c59a2b4d389c..868f301a8e932e24fa42733646832ec8d3d76e5e 100644 (file)
@@ -41,3 +41,10 @@ function hydra_get_command {
 function hydra_dispatch {
   hydra_exec $ACTION $*
 }
+
+# Evaluate a parameter from the config file
+function hydra_eval_parameter {
+  if [ -e "$CONFIG" ] && grep -qe "^$1=" $CONFIG; then
+    grep -e "^$1=" $CONFIG | tail -n 1 | cut -d = -f 2 | sed -e 's/"//g' -e "s/'//g" | sed -e 's/ *#.*$//'
+  fi
+}
index f0bf210e2f6b72cb6f85c4217a3e8f5dade01d2c..90dd4b85e18265268b4eee77c42a47fe6b53aff8 100644 (file)
@@ -6,6 +6,7 @@ function hydra_set_env {
   export ACTION="$1"
 
   if [ ! -z "$HYDRA" ]; then
+    export HYDRA_FOLDER="`hydra_eval_parameter $HYDRA`"
     export PREFERENCES="$HOME/.hydra/$HYDRA"
   fi
 }
diff --git a/share/hydra/module-verify b/share/hydra/module-verify
new file mode 100755 (executable)
index 0000000..81afbfe
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/bash
+#
+# Verify a puppet module
+#
+
+# Load
+source $APP_BASE/lib/hydra/functions || exit 1
+hydra_config_load
+
+MODULE="$1"
+
+if [ -z "$1" ]; then
+  exit
+elif [ -z "$HYDRA_FOLDER" ] || [ ! -e "$HYDRA_FOLDER/modules" ]; then
+  echo "Please make a symlink $HYDRA_FOLDER/modules pointing to your devel puppet modules."
+  exit 1
+fi
+
+cd $PUPPET
+HASH_SUBMODULE="`git submodule | grep "modules/$MODULE " | awk '{ print $1 }'`"
+
+cd $HYDRA_FOLDER/modules/$MODULE
+
+HASH_MODULE="`git log -1 | grep "^commit" | awk '{ print $2 }'`"
+
+if [ "$HASH_MODULE" != "$HASH_SUBMODULE" ]; then
+  echo "Module $MODULE: hash differ!!:"
+  echo "Module:    $HASH_MODULE"
+  echo "Submodule: $HASH_SUBMODULE"
+  exit 1
+fi
+
+echo "Latest commit hash match."