summaryrefslogtreecommitdiffstats
path: root/buildtools/wafsamba/wafsamba.py
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2013-04-08 15:57:45 +1000
committerMichael Adam <obnox@samba.org>2013-04-10 00:13:45 +0200
commit58e3c5323e343dcab1c528c6b6a44925b76cb297 (patch)
tree1cc31a5f950aee4759edc30890a75bc585d01fe9 /buildtools/wafsamba/wafsamba.py
parent69b3d1944501f65427fbd12e4ddd3b66e67deedd (diff)
downloadsamba-58e3c5323e343dcab1c528c6b6a44925b76cb297.tar.gz
samba-58e3c5323e343dcab1c528c6b6a44925b76cb297.tar.xz
samba-58e3c5323e343dcab1c528c6b6a44925b76cb297.zip
build: Replace #!/usr/bin/env python with passed in PYTHON=
This means that if we were forced to use a specific python for the build, we will put that binary into the top of samba-tool, so it continues to work after the install. Andrew Bartlett Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'buildtools/wafsamba/wafsamba.py')
-rw-r--r--buildtools/wafsamba/wafsamba.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py
index f7156ecf7f4..3559cc196fe 100644
--- a/buildtools/wafsamba/wafsamba.py
+++ b/buildtools/wafsamba/wafsamba.py
@@ -696,14 +696,25 @@ def copy_and_fix_python_path(task):
replacement="""sys.path.insert(0, "%s")
sys.path.insert(1, "%s")""" % (task.env["PYTHONARCHDIR"], task.env["PYTHONDIR"])
+ shebang = None
+
+ if task.env["PYTHON"][0] == "/":
+ replacement_shebang = "#!%s" % task.env["PYTHON"]
+ else:
+ replacement_shebang = "#!/usr/bin/env %s" % task.env["PYTHON"]
+
installed_location=task.outputs[0].bldpath(task.env)
source_file = open(task.inputs[0].srcpath(task.env))
installed_file = open(installed_location, 'w')
+ lineno = 0
for line in source_file:
newline = line
- if pattern in line:
+ if lineno == 0 and task.env["PYTHON_SPECIFIED"] == True and line[:2] == "#!":
+ newline = replacement_shebang
+ elif pattern in line:
newline = line.replace(pattern, replacement)
installed_file.write(newline)
+ lineno = lineno + 1
installed_file.close()
os.chmod(installed_location, 0755)
return 0
@@ -727,6 +738,8 @@ def install_file(bld, destdir, file, chmod=MODE_644, flat=False,
target=inst_file)
bld.add_manual_dependency(bld.path.find_or_declare(inst_file), bld.env["PYTHONARCHDIR"])
bld.add_manual_dependency(bld.path.find_or_declare(inst_file), bld.env["PYTHONDIR"])
+ bld.add_manual_dependency(bld.path.find_or_declare(inst_file), str(bld.env["PYTHON_SPECIFIED"]))
+ bld.add_manual_dependency(bld.path.find_or_declare(inst_file), bld.env["PYTHON"])
file = inst_file
if base_name:
file = os.path.join(base_name, file)