summaryrefslogtreecommitdiff
path: root/buildtools
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2014-07-17 16:54:54 +0200
committerKarolin Seeger <kseeger@samba.org>2014-11-17 21:21:13 +0100
commit50f3e565427ac2d31c9641aa02ff94103a2f07a3 (patch)
tree7680c9646dc444b92d3bfad694ae71eb8e60f5be /buildtools
parent016f1ef8dab09a9f3fde1f76cc556504f2f579f9 (diff)
downloadsamba-50f3e565427ac2d31c9641aa02ff94103a2f07a3.tar.gz
wafsamba: add perl_fixup parameter to INSTALL_FILES
This fixes the search path for modules when installing a perl "binary" by replacing a line 'use lib "$RealBin/lib";' which works for the build directory with the appropriate "use lib" line. This is a step in allowing to install perl modules under the prefix directory again. BUG: https://bugzilla.samba.org/show_bug.cgi?id=10472 Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> (cherry picked from commit f73a0c2af9748d57721211472cd6c50b990ee693)
Diffstat (limited to 'buildtools')
-rw-r--r--buildtools/wafsamba/wafsamba.py47
1 files changed, 43 insertions, 4 deletions
diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py
index 032327b2464..c8220c2e9cd 100644
--- a/buildtools/wafsamba/wafsamba.py
+++ b/buildtools/wafsamba/wafsamba.py
@@ -725,9 +725,38 @@ sys.path.insert(1, "%s")""" % (task.env["PYTHONARCHDIR"], task.env["PYTHONDIR"])
os.chmod(installed_location, 0755)
return 0
+def copy_and_fix_perl_path(task):
+ pattern='use lib "$RealBin/lib";'
+
+ replacement = ""
+ if not task.env["PERL_LIB_INSTALL_DIR"] in task.env["PERL_INC"]:
+ replacement = 'use lib "%s";' % task.env["PERL_LIB_INSTALL_DIR"]
+
+ if task.env["PERL"][0] == "/":
+ replacement_shebang = "#!%s\n" % task.env["PERL"]
+ else:
+ replacement_shebang = "#!/usr/bin/env %s\n" % task.env["PERL"]
+
+ 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 lineno == 0 and task.env["PERL_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
+
def install_file(bld, destdir, file, chmod=MODE_644, flat=False,
- python_fixup=False, destname=None, base_name=None):
+ python_fixup=False, perl_fixup=False,
+ destname=None, base_name=None):
'''install a file'''
destdir = bld.EXPAND_VARIABLES(destdir)
if not destname:
@@ -744,18 +773,28 @@ def install_file(bld, destdir, file, chmod=MODE_644, flat=False,
source=file,
target=inst_file)
file = inst_file
+ if perl_fixup:
+ # fix the path perl will use to find Samba modules
+ inst_file = file + '.inst'
+ bld.SAMBA_GENERATOR('perl_%s' % destname,
+ rule=copy_and_fix_perl_path,
+ dep_vars=["PERL","PERL_SPECIFIED","PERL_LIB_INSTALL_DIR"],
+ source=file,
+ target=inst_file)
+ file = inst_file
if base_name:
file = os.path.join(base_name, file)
bld.install_as(dest, file, chmod=chmod)
def INSTALL_FILES(bld, destdir, files, chmod=MODE_644, flat=False,
- python_fixup=False, destname=None, base_name=None):
+ python_fixup=False, perl_fixup=False,
+ destname=None, base_name=None):
'''install a set of files'''
for f in TO_LIST(files):
install_file(bld, destdir, f, chmod=chmod, flat=flat,
- python_fixup=python_fixup, destname=destname,
- base_name=base_name)
+ python_fixup=python_fixup, perl_fixup=perl_fixup,
+ destname=destname, base_name=base_name)
Build.BuildContext.INSTALL_FILES = INSTALL_FILES