All pastes #759061 Raw Edit

Someone

public text v1 · immutable
·published 2007-11-02 20:09 UTC
rendered paste body
#! /bin/sh

# ### !!! WARNING !!! ###
# This script does not deal with multiple versions of the same library. One
# of the versions will get overwritten.
# $KDEDIR needs to be set!!
# $KDE_BUILD needs to be set!!!


# This function needs the full name of one library (.so) in the build directory
# as argument.
# It then looks in the KDE install directory ($KDEDIR/lib) for libraries with a
# similar name and replaces all occurences of those libraries with a symlink to
# the library in the build directory.
# "Similar name" in this context means the basename of the given library plus any
# suffixes, e.g. ".1.0.0".
ReplaceBuildLib() {
  FULLNAME=$1
  BASENAME=`basename $FULLNAME`
  REPLACEDIR=$KDEDIR/lib

  # Print some basic info
  echo " Symlinking $1"
  echo "  Basename: $BASENAME"
  echo "  Looking for installed library in $REPLACEDIR and subdirs..."

  # Find libraries to replace with symlinks
  echo "   Found the following installed libraries which maches name:"
  REPLACELIBS=`find $REPLACEDIR -name $BASENAME*`
  for i in $REPLACELIBS; do
    echo "    $i"
  done

  # Remove those libraries
  echo "   Removing those libraries"
  for i in $REPLACELIBS; do
    echo "    Removing $i"
    rm $i
  done

  # Now replace removed libraries with symlinks
  echo "   Symlinking those libraries"
  for i in $REPLACELIBS; do
    echo "    Symlinking $i to $FULLNAME"
    ln -s $FULLNAME $i
  done
}

echo "Making symlinks for libraries from $KDEDIR/lib to $KDE_BUILD/KDE/$1..."
echo "Searching for libraries..."

# Search for libraries from root-dir so we will get the full name
cd /
ALLLIBRARIES=`find $KDE_BUILD/KDE/$1 -name *.so`
cd -

# Now process each library found
for LIBRARY in $ALLLIBRARIES; do
  ReplaceBuildLib $LIBRARY
done