
#t2 readline pkg is broken. symlinks broken...
RLREALLIBS="`find usr/lib -type f -name \*.so.\* | tr '\n' ' '`"
for ONEREALLIB in $RLREALLIBS
do
 BASEREALLIB="`basename $ONEREALLIB`"
 BASEREALNAME="`echo -n "$BASEREALLIB" | cut -f 1 -d '.'`"
 ln -snf $BASEREALLIB usr/lib/${BASEREALNAME}.so
 ln -snf $BASEREALLIB usr/lib/${BASEREALNAME}.so.5
 ln -snf $BASEREALLIB usr/lib/${BASEREALNAME}.so.6
done

if [ ! -e usr/lib/libreadline.so.5 ];then
 if [ ! -e lib/libreadline.so.5 ];then
  [ -e usr/lib/libreadline.so.6 ] && ln -s libreadline.so.6 usr/lib/libreadline.so.5
  [ -e lib/libreadline.so.6 ] && ln -s libreadline.so.6 lib/libreadline.so.5
 fi
fi

if [ ! -e usr/lib/libhistory.so.5 ];then
 if [ ! -e lib/libhistory.so.5 ];then
  [ -e usr/lib/libhistory.so.6 ] && ln -s libhistory.so.6 usr/lib/libhistory.so.5
  [ -e lib/libhistory.so.6 ] && ln -s libhistory.so.6 lib/libhistory.so.5
 fi
fi

#120315 NOTICE: below situation quite a lot of pkgs, so have put a big fix into 3builddistro...
##120315 Precise Pangolin Ubuntu has moved the libs (ditto for glibc)...
#if [ ! -e ./lib/libreadline.so.5 -a ! -e ./lib/libreadline.so.6 ];then
# #all the libs are in /lib/i386-linux-gnu/
# GLIBCLIBS="`find lib -mindepth 2 -name 'libreadline.so.*' | head -n 1`"
# if [ "$GLIBCLIBS" ];then
#  GLIBCPATH="`dirname $GLIBCLIBS`"
#  cp -a -f --remove-destination ${GLIBCPATH}/* ./lib/
#  sync
#  rm -rf $GLIBCPATH
#  #need this symlink, as when move libs in devx below, symlinked libs are wrong...
#  ln -s ./ $GLIBCPATH
#  #devx, move these to readline_DEV/lib also...
#  if [ -d ../readline_DEV/${GLIBCPATH} ];then
#   cp -a -f --remove-destination ../readline_DEV/${GLIBCPATH}/* ../readline_DEV/lib/
#   sync
#   rm -rf ../readline_DEV/$GLIBCPATH
#  fi
#  #something weird in 2createpackages, /lib/i386-linux-gnu get built at readline_DEV/usr/lib/i386-linux-gnu...
#  if [ -d ../readline_DEV/usr/${GLIBCPATH} ];then
#   mkdir -p ../readline_DEV/lib
#   cp -a -f --remove-destination ../readline_DEV/usr/${GLIBCPATH}/* ../readline_DEV/lib/
#   sync
#   rm -rf ../readline_DEV/usr/$GLIBCPATH
#  fi
# fi
#fi
