Hello
I again fell over transform_libtool_scripts.sh on solaris.
Here's a version in python which reads all the needed information from
build.conf instead of searching the filesystem.
I ran "make check" but it stopped at authz_tests:
[[[
...
Running tests in authz_tests.py [36/87][SKIPPED] Python sqlite3 module required
Don't know what to do about authz_tests.py
]]]
It's right, I don't have the sqlite3 module, but that's not a reason to
stop testing. I'll investigate that later...
There were just two FAIL's in fs-pack-test, the other tests were running
successfully.
Please comment and/or approve for commit.
- Martin
[[[
Replace a disgusting shell script by nice python code.
transform_libtool_scripts.py is more portable and also reads build.conf.
* Makefile.in
(transform-libtool-scripts): Call the python script.
* build/transform_libtool_scripts.sh
Delete.
* build/transform_libtool_scripts.py
New file.
]]]
Index: Makefile.in
===================================================================
--- Makefile.in (revision 1049012)
+++ Makefile.in (working copy)
@@ -351,7 +351,7 @@
local-all: @BUILD_RULES@ @TRANSFORM_LIBTOOL_SCRIPTS@
transform-libtool-scripts: @BUILD_RULES@
- @$(top_srcdir)/build/transform_libtool_scripts.sh
+ @$(PYTHON) $(top_srcdir)/build/transform_libtool_scripts.py
locale-gnu-pot:
cd $(abs_srcdir) && XGETTEXT="$(XGETTEXT)" MSGMERGE="$(MSGMERGE)" \
Index: build/transform_libtool_scripts.sh
===================================================================
--- build/transform_libtool_scripts.sh (revision 1049012)
+++ 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/transform_libtool_scripts.py
===================================================================
--- build/transform_libtool_scripts.py (revision 0)
+++ build/transform_libtool_scripts.py (revision 0)
@@ -0,0 +1,138 @@
+#!/usr/bin/env python
+#
+#
+# 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.
+#
+#
+#
+# transform_libtool_scripts.py -- Add LD_PRELOAD lines to the generated
+# wrapper scripts to force loading of the compiled libs instead of
+# the installed ones.
+#
+
+import os
+import os.path
+import re
+import sys
+try:
+ # Python >=3.0
+ import configparser
+except ImportError:
+ # Python <3.0
+ import ConfigParser as configparser
+
+
+class TransformLibtoolScripts:
+
+ def __init__(self, force):
+ self._force = force
+ self._cfg_exe_types = ('exe',)
+ self._cfg_exe_inst_re = re.compile('^(bin|test)$')
+ self._cfg_lib_types = ('lib', 'fs-module', 'ra-module')
+ self._cfg_lib_inst_re = re.compile('^(.*-)?lib$')
+ self._exes = []
+ self._paths = {}
+ self._dependencies = {}
+
+ def transform(self):
+ self._read_build_conf()
+ for exe in self._exes:
+ self._transform_exe(exe)
+
+ def _read_build_conf(self):
+ config = configparser.ConfigParser()
+ config.read('build.conf')
+ for section in config.sections():
+ self._add_dependency(config, section)
+
+ def _add_dependency(self, config, name):
+ if not config.has_section(name):
+ return
+ if name in self._paths:
+ return
+ for option in ( 'type', 'install', 'path', 'libs' ):
+ if not config.has_option(name, option):
+ return
+ type = config.get(name, 'type')
+ install = config.get(name, 'install')
+ path = config.get(name, 'path')
+ libs = config.get(name, 'libs').split()
+ for lib in libs:
+ self._add_dependency(config, lib)
+ if type in self._cfg_exe_types and self._cfg_exe_inst_re.match(install):
+ file = os.path.join(path, name)
+ if os.path.exists(file):
+ self._exes.append(name)
+ elif type in self._cfg_lib_types and self._cfg_lib_inst_re.match(install):
+ if not name.startswith('libsvn_'):
+ return
+ dependencies = []
+ for lib in libs:
+ if lib in self._dependencies:
+ for dep in self._dependencies[lib]:
+ if not dep in dependencies:
+ dependencies.append(dep)
+ dependencies.append(name)
+ self._paths[name] = path
+ self._dependencies[name] = dependencies
+
+ def _transform_exe(self, name):
+ cwd = os.getcwd()
+ path = self._paths[name]
+ deps = self._dependencies[name]
+ file = os.path.join(path, name)
+ lines = []
+ has_ld_preload = False
+ fd = open(file, 'r')
+ for line in fd:
+ if self._force and line.find('LD_PRELOAD') >= 0:
+ continue
+ lines.append(line)
+ if line.startswith('LD_PRELOAD='):
+ has_ld_preload = True
+ break
+ fd.close()
+ if has_ld_preload:
+ return
+ print('Transforming %s' % file)
+ libs = []
+ for dep in deps:
+ if dep != name:
+ libpath = self._paths[dep]
+ libname = '%s-1.so' % dep
+ libs.append(os.path.join(cwd, self._paths[dep], '.libs', libname))
+ ld_preload = 'LD_PRELOAD="%s"\n' % (' '.join(libs))
+ # insert LD_PRELOAD right before executing the program
+ # other tools (like file, sed, ...) called from the script don't need it
+ for i in range(len(lines)-1, -1, -1):
+ line = lines[i].strip()
+ if line.startswith('exec ') and not line.startswith('exec /'):
+ lines[i:i] = [ ld_preload, 'export LD_PRELOAD\n' ]
+ fd = open(file, 'w')
+ fd.write(''.join(lines))
+ fd.close()
+
+
+if __name__ == '__main__':
+ argc = len(sys.argv)
+ if argc >= 3 or (argc == 2 and sys.argv[1] != '--force'):
+ sys.stderr.write('USAGE: transform_libtool_scripts.py [--force]\n')
+ sys.exit(1)
+ transformer = TransformLibtoolScripts(argc == 2)
+ transformer.transform()
+
Property changes on: build/transform_libtool_scripts.py
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:eol-style
+ native