build: fixed the python path in installed python scripts
authorAndrew Tridgell <tridge@samba.org>
Sat, 27 Mar 2010 08:12:10 +0000 (19:12 +1100)
committerAndrew Tridgell <tridge@samba.org>
Tue, 6 Apr 2010 10:27:11 +0000 (20:27 +1000)
buildtools/wafsamba/wafsamba.py

index 2a79f702ef694d24070c0887ecae9f4e0b5cde9e..1d0b1ba3c19fdc068c88e053a5f4e173d4bc79f6 100644 (file)
@@ -641,14 +641,32 @@ def SAMBA_SCRIPT(bld, name, pattern, installdir, installname=None):
 Build.BuildContext.SAMBA_SCRIPT = SAMBA_SCRIPT
 
 
 Build.BuildContext.SAMBA_SCRIPT = SAMBA_SCRIPT
 
 
+def install_file(bld, destdir, file, chmod=0644, flat=False,
+                 python_fixup=False, destname=None):
+    '''install a file'''
+    destdir = bld.EXPAND_VARIABLES(destdir)
+    if not destname:
+        destname = file
+        if flat:
+            destname = os.path.basename(destname)
+    dest = os.path.join(destdir, destname)
+    if python_fixup:
+        # fixup the python path it will use to find Samba modules
+        inst_file = file + '.inst'
+        bld.SAMBA_GENERATOR('python_%s' % destname,
+                            rule="sed 's|\(sys.path.insert.*\)bin/python\(.*\)$|\\1${PYTHONDIR}\\2|g' < ${SRC} > ${TGT}",
+                            source=file,
+                            target=inst_file)
+        file = inst_file
+    bld.install_as(dest, file, chmod=chmod)
+
+
 def INSTALL_FILES(bld, destdir, files, chmod=0644, flat=False,
                   python_fixup=False, destname=None):
     '''install a set of files'''
 def INSTALL_FILES(bld, destdir, files, chmod=0644, flat=False,
                   python_fixup=False, destname=None):
     '''install a set of files'''
-    destdir = bld.EXPAND_VARIABLES(destdir)
-    if destname:
-        bld.install_as(os.path.join(destdir,destname), files, chmod=chmod)
-    else:
-        bld.install_files(destdir, files, chmod=chmod, relative_trick=not flat)
+    for f in TO_LIST(files):
+        install_file(bld, destdir, f, chmod=chmod, flat=flat,
+                     python_fixup=python_fixup, destname=destname)
 Build.BuildContext.INSTALL_FILES = INSTALL_FILES
 
 
 Build.BuildContext.INSTALL_FILES = INSTALL_FILES