On Fri, Mar 24, 2006 at 11:06:04AM +0200, Gabriel George POPA wrote: > Frank Denis wrote:
> I installed Hyper Estraier but now, because it is in chroot, it cannot > find the libraries it depends on. I had this problem quite a few times > with different programs. I did not have the time to solve it (with other > programs too). What do I do: ldconfig? This is the standard method? > ldconfig with what params? Or maybe it's better to set the LD_LIBRARY_PATH? I use something like the following for copying stuff into chroot. Note: this works for me, but might not do in certain corner cases. Glue aside, use ldd to figure out which libraries are needed and copy those. This was just a quick hack. Being a shell script, it is also quite inefficient - mostly due to the fact it starts lots of programs. I might one day create a Perl implementation, which would be much faster. Any comments are welcome, as always. One noteworthy thing is that it attemps to synchronize directories - notably, it will delete anything from the destination directory not found in the source directory. One other noteworthy thing is that it Does not clear old libraries. ## BEGIN ## #!/bin/sh # Syntax: # cpchroot file1 [file2 [file3 ...]] # # Copies all files, which should be given as a fully qualified path, into the # corresponding directory relative to the current directory. # # As a special case, when the file being copied is a dynamically linked # executable, also copy any libraries it depends on. # # Any directories required are created. # # When a directory is given as an argument, cpchroot is applied to all files in # the directory, and the directory is then searched for any files that are not # in the original umask 022 LIBS="" ERROR=0 TMP1=`mktemp` || exit 1 TMP2=`mktemp` || exit 1 smartcp() { RELATIVE_BASE=`dirname "$1" | sed -e 's/^\///'` if ! [ -e "$RELATIVE_BASE" ]; then install -d "$RELATIVE_BASE" || ERROR=1; fi if [ ! -e ".$1" -o \( -f "$1" -o -h "$1" \) -a ".$1" -ot "$1" ]; then echo "cp $1 `pwd`$1"; cp "$1" ".$1" || ERROR=1; fi } exit_and_clean() { rm $TMP1 $TMP2 exit $1 } if [ $# -eq 0 ]; then echo "$0 cannot be called with zero arguments" >&2; echo "Syntax: $0 file1 [file2 [file3 ...]]" >&2; exit_and_clean 127 fi echo "Don't run just any script off the internet!" >&2; if [ `id -u` -eq 0 ]; then echo "AND ESPECIALLY NOT AS ROOT!" >&2; fi exit 127 for i in "$@"; do if ! [ -e "$i" ]; then echo "File $i not found" >&2; exit_and_clean 2; fi if ! echo $i | grep '^\/' >/dev/null; then echo "File $i not given as absolute path" >&2; exit_and_clean 2; fi done # Okay, our input is sane. Now let's get to it. for i in "$@"; do if [ -d "$i" ]; then # Recursively descend into the directory find "$i" ! -type d -print0 | xargs -0 $0; # Remove any fluff find "$i" | sed -e 's/^/./' | sort > $TMP1 find ".$i" | sort > $TMP2 if ! cmp $TMP1 $TMP2 >/dev/null; then for i in `diff -u $TMP1 $TMP2 | sed -ne '1,2d' -e 's/^+//p'`; do echo "rm -rf $i" | sed -e "s/\.\//`pwd`/"; rm -rf $i; done fi else if file "$i" 2>/dev/null | \ grep 'ELF.*executable.*dynamically linked' >/dev/null; then LIBS="$LIBS `ldd \"$i\" | sed -e '1,3d' -e 's/.* //' 2>/dev/null`"; fi smartcp "$i" fi done if [ "x$LIBS" != "x" ]; then LIBS=`echo $LIBS | sort | uniq` for i in $LIBS; do smartcp "$i" done fi exit_and_clean $ERROR ## EOF ## As to the legalese: this script is hereby placed into the public domain, so feel free to do as you please with it. I'd strongly suggest not altering certain features when publishing it on the internet, though. Joachim