Commit f4e51f77 authored by Jérome Perrin's avatar Jérome Perrin Committed by Rafael Monnerat

wrapper script: workaround kernel limitation in shebang line length

/reviewed-on !54
parent e7de55e2
......@@ -134,13 +134,14 @@ class GenericBaseRecipe(object):
Creates a very simple (one command) shell script for process replacement.
Creates a shell script for process replacement.
Takes care of quoting.
Takes care of #! line limitation when the wrapped command is a script.
if pidfile parameter is specified, then it will make the wrapper a singleton,
accepting to run only if no other instance is running.
lines = [ '#!/bin/sh' ]
lines = [ '#!/bin/bash' ]
for comment in comments:
lines.append('# %s' % comment)
......@@ -164,7 +165,20 @@ class GenericBaseRecipe(object):
echo $$ > $pidfile""" % (pidfile, command)))
lines.append('exec %s' % shlex.quote(command))
# Inspired by
# If the wrapped command uses a shebang, execute the referenced
# executable passing the script path as first argument.
# This is to workaround the limitation of 127 characters in #!
if [[ -f $COMMAND && x$(head -c2 "$COMMAND") = x"#!" ]]; then
SHEBANG=$(head -1 "$COMMAND")
exec $COMMAND """ % shlex.quote(command)))
for param in parameters:
if len(lines[-1]) < 40:
......@@ -54,8 +54,15 @@ class Recipe(GenericBaseRecipe):
if environment is not None:
environment = dict((k.strip(), v.strip()) for k, v in [
line.split('=') for line in environment.splitlines() if line.strip() ])
return [self.createPythonScript(
# We create a python script and a wrapper around the python
# script because the python script might have a too long #! line
python_script = self.createPythonScript(
(command_line, wait_files, environment,),
(command_line, wait_files, environment,), )
return [python_script, self.createWrapper(
parameters_extra=parameters_extra) ]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment