
mkdir -p ../glibc_DEV/sbin
if [ -f sbin/ldconfig.real ];then
 mv -f sbin/ldconfig.real ../glibc_DEV/sbin/ldconfig
 rm -f sbin/ldconfig
else
 mv -f sbin/ldconfig ../glibc_DEV/sbin/
fi

#slackware 13.1...
rm -f ./etc/profile.d/*.csh* 2>/dev/null

#120315 NOTICE: below situation quite a lot of pkgs, so have put a big fix into 3builddistro...
##120315 Ubuntu Precise Pangolin, they have moved the goalposts again...
#if [ ! -e ./lib/libc.so.6 ];then
# #all the libs are in /lib/i386-linux-gnu/
# GLIBCLIBS="`find lib -mindepth 2 -name libc.so.6 | 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 glibc_DEV/lib also...
#  if [ -d ../glibc_DEV/${GLIBCPATH} ];then
#   mkdir -p ../glibc_DEV/lib
#   cp -a -f --remove-destination ../glibc_DEV/${GLIBCPATH}/* ../glibc_DEV/lib/
#   sync
#   rm -rf ../glibc_DEV/$GLIBCPATH
#  fi
#  #something weird in 2createpackages, /lib/i386-linux-gnu get built at glibc_DEV/usr/lib/i386-linux-gnu...
#  if [ -d ../glibc_DEV/usr/${GLIBCPATH} ];then
#   mkdir -p ../glibc_DEV/lib
#   cp -a -f --remove-destination ../glibc_DEV/usr/${GLIBCPATH}/* ../glibc_DEV/lib/
#   sync
#   rm -rf ../glibc_DEV/usr/$GLIBCPATH
#  fi
# fi
#fi

#120620 my cut-down cache breaks things...
##120526
##/usr/lib/gconv has a cutdown set of files, need to use correct cache file...
#mv -f usr/lib/gconv-cut/gconv-modules usr/lib/gconv/
#mv -f usr/lib/gconv-cut/gconv-modules.cache usr/lib/gconv/
#rm -rf usr/lib/gconv-cut

#120829 now have full /usr/share/timezone, delete some things... no, seems all needed!!!
#[ -d usr/share/zoneinfo/posix ] && rm -rf usr/share/zoneinfo/posix
#[ -d usr/share/zoneinfo/right ] && rm -rf usr/share/zoneinfo/right
#[ -d usr/share/zoneinfo/SystemV ] && rm -rf usr/share/zoneinfo/SystemV

#130307 arch has moved libs from /lib to /usr/lib, which breaks chroot. move them back to proper place...
if [ "$DISTRO_BINARY_COMPAT" = "arch" ];then #exported from 2createpackages.
 FNDCLIBS="$(find usr/lib -mindepth 1 -maxdepth 1 -name '*.so*')"
 if [ "$FNDCLIBS" != "" ];then
  for ONECLIB in $FNDCLIBS
  do
   [ "$ONECLIB" = "" ] && continue
   BASECLIB="$(basename $ONECLIB)"
   #it seems, traditionally, these stay in /usr/lib...
   [ "$BASECLIB" = "libc.so" ] && [ ! -h $ONECLIB ] && continue
   [ "$BASECLIB" = "libpthread.so" ] && [ ! -h $ONECLIB ] && continue
   cp -a -f --remove-destination $ONECLIB ./lib/
   rm -f $ONECLIB
  done
  #traditionally, there are some symlinks in /usr/lib, recreate...
  FNDSYMLINKS="$(find lib -mindepth 1 -maxdepth 1 -name '*.so.[0-9]')"
  if [ "$FNDSYMLINKS" != "" ];then
   for ONESYMLINK in $FNDSYMLINKS
   do
    [ "$ONESYMLINK" = "" ] && continue
    if [ -h $ONESYMLINK ];then
     #TARGETLINK="$(readlink $ONESYMLINK)"
     TARGETLINK="$(basename $ONESYMLINK)"
     BASESYM="$(basename $ONESYMLINK | rev | cut -f 2-9 -d '.' | rev)"
     [ -e usr/lib/$BASESYM ] && continue
     ln -s ../../lib/$TARGETLINK usr/lib/$BASESYM
    fi
   done
  fi
 fi
 #do the same for glibc_DEV...
 mkdir -p ../glibc_DEV/lib
 mkdir -p ../glibc_DEV/usr/lib
 FNDCLIBS="$(find ../glibc_DEV/usr/lib -mindepth 1 -maxdepth 1 -name '*.so*')"
 if [ "$FNDCLIBS" != "" ];then
  for ONECLIB in $FNDCLIBS
  do
   [ "$ONECLIB" = "" ] && continue
   BASECLIB="$(basename $ONECLIB)"
   #it seems, traditionally, these stay in /usr/lib...
   [ "$BASECLIB" = "libc.so" ] && [ ! -h $ONECLIB ] && continue
   [ "$BASECLIB" = "libpthread.so" ] && [ ! -h $ONECLIB ] && continue
   cp -a -f --remove-destination $ONECLIB ../glibc_DEV/lib/
   rm -f $ONECLIB
  done
  #traditionally, there are some symlinks in /usr/lib, recreate...
  FNDSYMLINKS="$(find ../glibc_DEV/lib -mindepth 1 -maxdepth 1 -name '*.so.[0-9]')"
  if [ "$FNDSYMLINKS" != "" ];then
   for ONESYMLINK in $FNDSYMLINKS
   do
    [ "$ONESYMLINK" = "" ] && continue
    if [ -h $ONESYMLINK ];then
     #TARGETLINK="$(readlink $ONESYMLINK)"
     TARGETLINK="$(basename $ONESYMLINK)"
     BASESYM="$(basename $ONESYMLINK | rev | cut -f 2-9 -d '.' | rev)"
     [ -e ../glibc_DEV/usr/lib/$BASESYM ] && continue
     ln -s ../../lib/$TARGETLINK ../glibc_DEV/usr/lib/$BASESYM
    fi
   done
  fi
 fi
fi


