From 8f2e7d535921670b5f0b1378c5d3b5d521a6a521 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20de=20Saint=20Martin?= <cedric.dsm@tiolive.com>
Date: Mon, 11 Jul 2011 11:49:33 +0200
Subject: [PATCH] Set PATH in slaprunner wrapper

---
 slapos/recipe/slaprunner/__init__.py | 6 ++++--
 slapos/recipe/slaprunner/execute.py  | 4 +++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/slapos/recipe/slaprunner/__init__.py b/slapos/recipe/slaprunner/__init__.py
index 1849232b1..e05ec3f13 100644
--- a/slapos/recipe/slaprunner/__init__.py
+++ b/slapos/recipe/slaprunner/__init__.py
@@ -68,9 +68,11 @@ class Recipe(BaseSlapRecipe):
         self.substituteTemplate(pkg_resources.resource_filename(__name__,
           'template/slapos.cfg.in'), configuration))
     self.path_list.append(config_file)
+    
+    execute_arguments = dict(path = os.environ['PATH'],
+        args = [self.options['slaprunner'].strip(), config_file])
     self.path_list.extend(zc.buildout.easy_install.scripts([('slaprunner',
       'slapos.recipe.slaprunner.execute', 'execute')], self.ws, sys.executable,
-      self.wrapper_directory, arguments=[self.options['slaprunner'].strip(),
-        config_file]))
+      self.wrapper_directory, arguments=execute_arguments))
     self.setConnectionDict(dict(url='http://[%s]:%s' % (ipv6, runner_port)))
     return self.path_list
diff --git a/slapos/recipe/slaprunner/execute.py b/slapos/recipe/slaprunner/execute.py
index 09395c071..deff58a83 100644
--- a/slapos/recipe/slaprunner/execute.py
+++ b/slapos/recipe/slaprunner/execute.py
@@ -3,4 +3,6 @@ import os
 
 def execute(args):
   """Portable execution with process replacement"""
-  os.execv(args[0], args)
+  if args.get("path", None):
+    os.environ['PATH'] = args["path"]
+  os.execv(args["launch_args"][0], args["launch_args"])
-- 
2.30.9