From 8c5a64cd92e73b1bb73f91eb698e76f8e6df0b7f Mon Sep 17 00:00:00 2001
From: Nico Schottelius <nico@kr.ethz.ch>
Date: Tue, 22 Feb 2011 11:47:43 +0100
Subject: [PATCH 1/2] support manifest args in cdist-manifest-run

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
---
 bin/cdist-manifest-run | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bin/cdist-manifest-run b/bin/cdist-manifest-run
index 38cf9f1b..5d617444 100755
--- a/bin/cdist-manifest-run
+++ b/bin/cdist-manifest-run
@@ -23,7 +23,7 @@
 #
 
 . cdist-config
-[ $# -eq 3 ] || __cdist_usage "<target host> <manifest> <outdir>"
+[ $# -ge 3 ] || __cdist_usage "<target host> <manifest> <outdir> [manifest arguments]"
 set -u
 
 export __cdist_target_host="$1"; shift
@@ -43,4 +43,4 @@ fi
 
 mkdir -p "${__cdist_output_dir}" || __cdist_exit_err "Cannot create output dir ${__cdist_output_dir}"
 
-__cdist_exec_fail_on_error "${__cdist_manifest}"
+__cdist_exec_fail_on_error "${__cdist_manifest}" "$@"

From 2e0cdf73d98a80476d1559aa35e1abfcb327be57 Mon Sep 17 00:00:00 2001
From: Nico Schottelius <nico@kr.ethz.ch>
Date: Tue, 22 Feb 2011 11:54:50 +0100
Subject: [PATCH 2/2] add cd to cdist-manifest-run-all

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
---
 bin/cdist-manifest-run-all | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/bin/cdist-manifest-run-all b/bin/cdist-manifest-run-all
index 35b54e4d..0fbc1791 100755
--- a/bin/cdist-manifest-run-all
+++ b/bin/cdist-manifest-run-all
@@ -50,7 +50,10 @@ while [ "$__cdist_new_objects_created" = "y"  ]; do
 
    # Check every object, if we need to run it
    while read __cdist_object; do
+      # Full path to current object
       __cdist_cur_object_dir="$__cdist_object_base_dir/$__cdist_object"
+      # Only the id
+      __cdist_object_id="${__cdist_object#*/}"
 
       if [ ! -f "${__cdist_cur_object_dir}/$__cdist_name_object_finished" ]; then
          echo "Working on object ${__cdist_object} ..."
@@ -61,7 +64,14 @@ while [ "$__cdist_new_objects_created" = "y"  ]; do
 
          if [ -x "${__cdist_manifest}" ]; then
             echo "Executing manifest ${__cdist_manifest} ..."
-            cdist-manifest-run "$__cdist_target_host" "${__cdist_manifest}" "${__cdist_new_objects_dir}"
+
+            # Safely change directory, convienent for type-writers
+            (
+               cd "$__cdist_cur_object_dir"
+               cdist-manifest-run "$__cdist_target_host" "$__cdist_manifest"     \
+                                  "$__cdist_new_objects_dir" "$__cdist_object_id"
+            )
+
             __cdist_object_list "${__cdist_new_objects_dir}" > "$__cdist_new_objects_list"
 
             # Verify no conflicting objects have been created