Skip to content

Commit

Permalink
make: Use proper separators for LD_LIBRARY_PATH and use BEGINLIBPATH …
Browse files Browse the repository at this point in the history
…on OS/2.

Improper handling would blow up the environment with a too long string and
make DosExecPgm freak out when calling gcc and return ERROR_BAD_ENVIRONMENT.
See http://trac.netlabs.org/rpm/ticket/275 for more info.
  • Loading branch information
dmik committed Nov 2, 2017
1 parent 167e4f3 commit aa479ad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
10 changes: 3 additions & 7 deletions buildtools/wafsamba/samba_conftests.py
Expand Up @@ -4,7 +4,7 @@
import os, shutil, re
import Build, Configure, Utils, Options, Logs
from Configure import conf
from samba_utils import TO_LIST, ADD_LD_LIBRARY_PATH
from samba_utils import TO_LIST, ADD_LD_LIBRARY_PATH, SET_LD_LIBRARY_PATH


def add_option(self, *k, **kw):
Expand Down Expand Up @@ -329,11 +329,7 @@ def CHECK_LIBRARY_SUPPORT(conf, rpath=False, version_script=False, msg=None):
lastprog = o.link_task.outputs[0].abspath(env)

if not rpath:
if 'LD_LIBRARY_PATH' in os.environ:
old_ld_library_path = os.environ['LD_LIBRARY_PATH']
else:
old_ld_library_path = None
ADD_LD_LIBRARY_PATH(os.path.join(bdir, 'default/libdir'))
old_ld_library_path = ADD_LD_LIBRARY_PATH(os.path.join(bdir, 'default/libdir'))

# we need to run the program, try to get its result
args = conf.SAMBA_CROSS_ARGS(msg=msg)
Expand All @@ -347,7 +343,7 @@ def CHECK_LIBRARY_SUPPORT(conf, rpath=False, version_script=False, msg=None):
ret = (proc.returncode == 0)

if not rpath:
os.environ['LD_LIBRARY_PATH'] = old_ld_library_path or ''
SET_LD_LIBRARY_PATH(old_ld_library_path)

conf.check_message(msg, '', ret)
return ret
Expand Down
18 changes: 13 additions & 5 deletions buildtools/wafsamba/samba_utils.py
Expand Up @@ -36,15 +36,23 @@ def GET_TARGET_TYPE(ctx, target):


def ADD_LD_LIBRARY_PATH(path):
'''add something to LD_LIBRARY_PATH'''
if 'LD_LIBRARY_PATH' in os.environ:
oldpath = os.environ['LD_LIBRARY_PATH']
'''add something to LD_LIBRARY_PATH (BEGINLIBPATH on OS/2) and return its previous contents'''
var = 'BEGINLIBPATH' if os.name == 'os2' else 'LD_LIBRARY_PATH'
if var in os.environ:
oldpath = os.environ[var]
else:
oldpath = ''
newpath = oldpath.split(':')
newpath = [] if oldpath == '' else oldpath.split(os.pathsep)
if not path in newpath:
newpath.append(path)
os.environ['LD_LIBRARY_PATH'] = ':'.join(newpath)
os.environ[var] = os.pathsep.join(newpath)
return oldpath


def SET_LD_LIBRARY_PATH(path):
'''set LD_LIBRARY_PATH (BEGINLIBPATH on OS/2) to path'''
var = 'BEGINLIBPATH' if os.name == 'os2' else 'LD_LIBRARY_PATH'
os.environ[var] = path


def needs_private_lib(bld, target):
Expand Down

0 comments on commit aa479ad

Please sign in to comment.