Re: [Samba] [PATCH] Force python for Samba on platforms with a too old installed python (eg RHEL 5.9)

2013-04-09 Thread Michael Adam
pushed

On 2013-04-08 at 18:59 +1000, Andrew Bartlett wrote:
> Phil,
> 
> I've tried following your mails, and your trials, but got totally lost.
> 
> So what I've done is write up a patch, which should address the one
> issue I've been able to distil out of this, which is that when Samba is
> built against something other than the default python, samba-tool
> segfaults.
> 
> This happens because if we build and link against one library, but you
> run samba-tool with a different python, internal things go boom. 
> 
> This patch works for me on my Centos 5 box. 
> 
> As to all your trials building different versions of python, I can't
> really offer a solution - I've not seen those myself, and you really
> seem to have quite a mix of things going wrong here.  I would suggest
> that if you do want to build a new AD DC, you should do so on a modern
> OS, where python just works.  
> 
> While I will certainly work (as this patch will help a lot with) to have
> install_with_python work for the AD DC, the intended purpose was simply
> to get enough of python going to run our build system for simpler file
> server installations, to allow a transition from the second (autoconf)
> build system.  (And in that it has been quite successful).
> 
> Please test these patches, hopefully they will resolve your issue.
> 
> Finally, if you get odd build errors (such as the symlink error you
> got), then 'git clean -x -f -d' will blow away everything not nailed
> down in the git checkout.  This tends to fix that kind of issue (such as
> happened when I moved our python code around in master and in v4-0-test
> for 4.0.5). 
> 
> Metze (or someone else on the team),
> 
> Please review or push to master. 
> 
> Thanks,
> 
> Andrew Bartlett


pgpDtShSDA2gE.pgp
Description: PGP signature
-- 
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/options/samba

Re: [Samba] [PATCH] Force python for Samba on platforms with a too old installed python (eg RHEL 5.9)

2013-04-08 Thread Phil Quesinberry
Hi Andrew,

Many, many thanks and sorry about that... I was somewhat lost while writing
the post myself, I was trying to distill all of the different things I had
tried down into useful information but I somehow missed the mark.

After I had posted the message, I manually did a configure of Samba's
private copy of Python and then did a make uninstall to let it do some
housecleaning.  After doing that, I was then able to compile Samba
successfully without passing any flags but I'm still getting a libgnutls
error when attempting to execute pdbedit and the same error as before with
samba-tool.

I pulled down and applied your patch against master but it didn't seem to
have any effect.  I did another build with the install_with_python script
but am still getting the same errors:

[root@Server1 samba4]# pdbedit
pdbedit: error while loading shared libraries: libgnutls.so.26: cannot open
shared object file: No such file or directory
[root@Server1 samba4]# samba-tool
Traceback (most recent call last):
  File "/usr/local/samba/bin/samba-tool", line 33, in 
from samba.netcmd.main import cmd_sambatool
  File "/usr/local/samba/lib/python2.6/site-packages/samba/__init__.py",
line 50, in 
from samba._ldb import Ldb as _Ldb
ImportError: libgnutls.so.26: cannot open shared object file: No such file
or directory
[root@Server1 samba4]# git status
# On branch master
# Changes not staged for commit:
#   (use "git add ..." to update what will be committed)
#   (use "git checkout -- ..." to discard changes in working
directory)
#
#   modified:   buildtools/wafsamba/samba_python.py
#   modified:   buildtools/wafsamba/wafsamba.py
#   modified:   wscript
#
# Untracked files:
#   (use "git add ..." to include in what will be committed)
#
#   buildtools/wafsamba/wscript.orig
#   buildtools/wafsamba/wscript.rej
#   wscript.orig
#   wscript.rej
no changes added to commit (use "git add" and/or "git commit -a")

- Phil




--
View this message in context: 
http://samba.2283325.n4.nabble.com/Re-Python-UCS2-vs-UCS4-issue-on-latest-git-ImportError-undefined-symbol-PyUnicodeUCS2-Decode-NOT-SOL-tp4646314p4646438.html
Sent from the Samba - General mailing list archive at Nabble.com.
-- 
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/options/samba


[Samba] [PATCH] Force python for Samba on platforms with a too old installed python (eg RHEL 5.9)

2013-04-08 Thread Andrew Bartlett
Phil,

I've tried following your mails, and your trials, but got totally lost.

So what I've done is write up a patch, which should address the one
issue I've been able to distil out of this, which is that when Samba is
built against something other than the default python, samba-tool
segfaults.

This happens because if we build and link against one library, but you
run samba-tool with a different python, internal things go boom. 

This patch works for me on my Centos 5 box. 

As to all your trials building different versions of python, I can't
really offer a solution - I've not seen those myself, and you really
seem to have quite a mix of things going wrong here.  I would suggest
that if you do want to build a new AD DC, you should do so on a modern
OS, where python just works.  

While I will certainly work (as this patch will help a lot with) to have
install_with_python work for the AD DC, the intended purpose was simply
to get enough of python going to run our build system for simpler file
server installations, to allow a transition from the second (autoconf)
build system.  (And in that it has been quite successful).

Please test these patches, hopefully they will resolve your issue.

Finally, if you get odd build errors (such as the symlink error you
got), then 'git clean -x -f -d' will blow away everything not nailed
down in the git checkout.  This tends to fix that kind of issue (such as
happened when I moved our python code around in master and in v4-0-test
for 4.0.5). 

Metze (or someone else on the team),

Please review or push to master. 

Thanks,

Andrew Bartlett

-- 
Andrew Bartletthttp://samba.org/~abartlet/
Authentication Developer, Samba Team   http://samba.org

>From 7cbada3356a797f72dc6af3f170183c8e2159e1c Mon Sep 17 00:00:00 2001
From: Andrew Bartlett 
Date: Mon, 8 Apr 2013 15:57:45 +1000
Subject: [PATCH 1/3] 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
---
 buildtools/wafsamba/samba_python.py | 10 ++
 buildtools/wafsamba/wafsamba.py | 15 ++-
 wscript |  5 +
 3 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/buildtools/wafsamba/samba_python.py b/buildtools/wafsamba/samba_python.py
index b2172f7..847b431 100644
--- a/buildtools/wafsamba/samba_python.py
+++ b/buildtools/wafsamba/samba_python.py
@@ -5,6 +5,16 @@ from samba_utils import *
 from samba_autoconf import *
 
 from Configure import conf
+
+@conf
+def SAMBA_CHECK_PYTHON(conf, mandatory=True):
+# enable tool to build python extensions
+conf.find_program('python', var='PYTHON', mandatory=mandatory)
+conf.check_tool('python')
+path_python = conf.find_program('python')
+conf.env.PYTHON_SPECIFIED = (conf.env.PYTHON != path_python)
+conf.check_python_version((2,4,2))
+
 @conf
 def SAMBA_CHECK_PYTHON_HEADERS(conf, mandatory=True):
 if conf.env["python_headers_checked"] == []:
diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py
index f7156ec..3559cc1 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)
diff --git a/wscript b/wscript
index