Doing some more testing I found another out that non-existing libraries
have to be removed from LD_PRELOAD.
So here's a new patch.
- Martin
On Wed, 15 Dec 2010, Martin Furter wrote:
Here is version 2 of the patch.
On Tue, 14 Dec 2010, Philip Martin wrote:
Martin Furter <m...@rola.ch> writes:
The generated script then has to be included into the tarball. I
believe to remember that there's a script which creates the
tarball. Can anyone give me a pointer where I can find it?
tools/dist/dist.sh
The tarball is created after autogen.sh has been run; autogen.sh runs
gen-make.py.
No changes seem to be needed there since it's run in the sandbox.
- Martin
[[[
Generate build/transform_libtool_scripts.sh from gen-make.py using
information read from build.conf.
* build/generator/gen_make.py
(write_transform_libtool_scripts,_get_all_lib_deps):
New functions which generate transform_libtool_scripts.sh.
(write): Call write_transform_libtool_scripts.
* build/transform_libtool_scripts.sh
Delete.
]]]
Index: build/transform_libtool_scripts.sh
===================================================================
--- build/transform_libtool_scripts.sh (revision 1049476)
+++ build/transform_libtool_scripts.sh (working copy)
@@ -1,123 +0,0 @@
-#!/bin/sh
-#
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-#
-
-# Dependencies of libraries
-# TODO: generate from build.conf
-subr="subr"
-auth_gnome_keyring="auth_gnome_keyring $subr"
-auth_kwallet="auth_kwallet $subr"
-delta="delta $subr"
-diff="diff $subr"
-fs_util="fs_util $subr"
-fs_base="fs_base $delta $fs_util $subr"
-fs_fs="fs_fs $delta $fs_util $subr"
-fs="fs $fs_base $fs_fs $fs_util $subr"
-repos="repos $delta $fs $fs_util $subr"
-ra_local="ra_local $delta $fs $fs_util $repos $subr"
-ra_neon="ra_neon $delta $subr"
-ra_serf="ra_serf $delta $subr"
-ra_svn="ra_svn $delta $subr"
-ra="ra $delta $ra_local $ra_neon $ra_serf $ra_svn $subr"
-wc="wc $delta $diff $subr"
-client="client $delta $diff $ra $subr $wc"
-
-# Delete duplicates in dependencies of libraries
-ls subversion | grep libsvn_ | while read library_dir; do
- library=`basename $library_dir | sed s/libsvn_//`
- library_dependencies="$(echo -n $(for x in $(eval echo "\$$library"); do
echo $x; done | sort -u))"
- eval "$library=\$library_dependencies"
-done
-
-# Dependencies of executables
-svn="$auth_gnome_keyring $auth_kwallet $client $delta $diff $ra $subr $wc"
-svnadmin="$delta $fs $repos $subr"
-svndumpfilter="$delta $fs $repos $subr"
-svnlook="$delta $diff $fs $repos $subr"
-svnserve="$delta $fs $ra_svn $repos $subr"
-svnsync="$auth_gnome_keyring $auth_kwallet $delta $ra $subr"
-svnversion="$subr $wc"
-entries_dump="$subr $wc"
-atomic_ra_revprop_change="$subr $ra"
-
-# Variable 'executables' containing names of variables corresponding to
executables
-executables="svn svnadmin svndumpfilter svnlook svnserve svnsync svnversion
entries_dump atomic_ra_revprop_change"
-
-for executable in $executables; do
- # Set variables containing paths of executables
- eval "${executable}_path=subversion/$executable/$executable"
- if [ "$executable" = entries_dump ]; then
- eval "${executable}_path=subversion/tests/cmdline/entries-dump"
- fi
- if [ "$executable" = atomic_ra_revprop_change ]; then
- eval "${executable}_path=subversion/tests/cmdline/atomic-ra-revprop-change"
- fi
- # Delete duplicates in dependencies of executables
- executable_dependencies="$(echo -n $(for x in $(eval echo "\$$executable");
do echo $x; done | sort -u))"
- eval "$executable=\$executable_dependencies"
-done
-
-test_paths="$(find subversion/tests -mindepth 2 -maxdepth 2 -name '*-test' !
-path '*/.libs/*' | sort)"
-for test in $test_paths; do
- test_path="$test"
- # Dependencies of tests are based on names of directories containing tests
- test_library="$(echo $test | sed -e
's:^subversion/tests/libsvn_\([^/]*\)/.*:\1:')"
- test_dependencies="$(eval echo "\$$test_library")"
- # Set variables corresponding to tests and containing dependencies of tests
- test="$(echo $test | sed -e 's:^subversion/tests/libsvn_[^/]*/\(.*\):\1:' -e
's/-/_/g')"
- eval "$test=\$test_dependencies"
- # Set variables containing paths of tests
- eval "${test}_path=\$test_path"
- # Set variable 'tests' containing names of variables corresponding to tests
- tests="$tests $test"
-done
-
-# auth-test dynamically loads libsvn_auth_gnome_keyring and
libsvn_auth_kwallet libraries
-auth_test="auth_gnome_keyring auth_kwallet $auth_test"
-
-# Usage: sed_append LINE_NUMBER TEXT FILE
-sed_append()
-{
- sed -e "$1a\\
-$2" "$3" > "$3.new"
- mv -f "$3.new" "$3"
-}
-
-current_directory="$(pwd)"
-for libtool_script in $executables $tests; do
- eval "libtool_script_path=\$${libtool_script}_path"
- libtool_script_libraries=""
- if [ -f "$libtool_script_path" ]; then
- if { grep LD_LIBRARY_PATH "$libtool_script_path" && ! grep LD_PRELOAD
"$libtool_script_path"; } > /dev/null; then
- echo "Transforming $libtool_script_path"
- libtool_script_dependencies="$(eval echo "\$$libtool_script")"
- for libtool_script_dependency in $libtool_script_dependencies; do
-
libtool_script_library="$current_directory/subversion/libsvn_$libtool_script_dependency/.libs/libsvn_$libtool_script_dependency-1.so"
- [ -f "$libtool_script_library" ] &&
libtool_script_libraries="$libtool_script_libraries $libtool_script_library"
- done
- libtool_script_libraries="${libtool_script_libraries# *}"
- # Append definitions of LD_PRELOAD to libtool scripts
- sed_append 4 "LD_PRELOAD=\"$libtool_script_libraries\""
"$libtool_script_path"
- sed_append 5 "export LD_PRELOAD" "$libtool_script_path"
- chmod +x "$libtool_script_path"
- fi
- fi
-done
Index: build/generator/gen_make.py
===================================================================
--- build/generator/gen_make.py (revision 1049476)
+++ build/generator/gen_make.py (working copy)
@@ -23,6 +23,7 @@
#
import os
+import stat
import sys
try:
# Python >=3.0
@@ -453,6 +454,8 @@
self.write_standalone()
+ self.write_transform_libtool_scripts(install_sources)
+
def write_standalone(self):
"""Write autogen-standalone.mk"""
@@ -468,6 +471,84 @@
standalone.write(open("build-outputs.mk","r").read())
standalone.close()
+ def write_transform_libtool_scripts(self, install_sources):
+ """Write build/transform_libtool_scripts.sh"""
+ script = 'build/transform_libtool_scripts.sh'
+ fd = open(script, 'w')
+ fd.write('''#!/bin/sh
+# DO NOT EDIT -- AUTOMATICALLY GENERATED
+
+transform()
+{
+ SCRIPT="$1"
+ LIBS="$2"
+ if [ -f $SCRIPT ]; then
+ if grep LD_PRELOAD "$SCRIPT" > /dev/null; then
+ :
+ elif grep LD_LIBRARY_PATH "$SCRIPT" > /dev/null; then
+ echo "Transforming $SCRIPT"
+ EXISTINGLIBS=""
+ for LIB in $LIBS; do
+ if [ -f $LIB ]; then
+ if [ -z "$EXISTINGLIBS" ]; then
+ EXISTINGLIBS="$LIB"
+ else
+ EXISTINGLIBS="$EXISTINGLIBS $LIB"
+ fi
+ fi
+ done
+ cat "$SCRIPT" |
+ (
+ read LINE
+ echo "$LINE"
+ echo "LD_PRELOAD=\\"$EXISTINGLIBS\\""
+ echo "export LD_PRELOAD"
+ cat
+ ) < "$SCRIPT" > "$SCRIPT.new"
+ mv -f "$SCRIPT.new" "$SCRIPT"
+ chmod +x "$SCRIPT"
+ fi
+ fi
+}
+
+DIR=`pwd`
+
+''')
+ libdep_cache = {}
+ paths = {}
+ for target_ob in install_sources:
+ if not isinstance(target_ob, gen_base.TargetExe):
+ continue
+ name = target_ob.name
+ libs = self._get_all_lib_deps(target_ob.name, libdep_cache, paths)
+ path = paths[name]
+ for i in range(0, len(libs)):
+ lib = libs[i]
+ libpath = paths[libs[i]]
+ libs[i] = '$DIR/%s/.libs/%s-%s.so' % (libpath, lib, self.version)
+ fd.write('transform %s/%s "%s"\n' % (path, name, " ".join(libs)))
+ fd.close()
+ mode = stat.S_IRWXU|stat.S_IRGRP|stat.S_IXGRP|stat.S_IROTH|stat.S_IXOTH
+ os.chmod(script, mode)
+
+ def _get_all_lib_deps(self, target_name, libdep_cache, paths):
+ if not target_name in libdep_cache:
+ libs = {}
+ path = None
+ if target_name in self.sections:
+ section = self.sections[target_name]
+ opt_libs = self.sections[target_name].options.get('libs')
+ paths[target_name] = section.options.get('path')
+ if opt_libs:
+ for lib_name in opt_libs.split():
+ if lib_name.startswith('libsvn_'):
+ libs[lib_name] = True
+ for lib in self._get_all_lib_deps(lib_name, libdep_cache, paths):
+ libs[lib] = True
+ libdep_cache[target_name] = libs.keys()[:]
+ libdep_cache[target_name].sort()
+ return libdep_cache[target_name]
+
class UnknownDependency(Exception):
"We don't know how to deal with the dependent to link it in."
pass