#note: DISTRO_BINARY_COMPAT and DISTRO_FILE_PREFIX are visible here, exported in 2createpackages.
#Ubuntu note:
#$ARCHDIR in 2createpackages will cause usr/lib/i386-linux-gnu/* files to
#be moved to usr/lib/ before script FIXUPHACK is executed.

#for various versions of abiword, we have usr/lib/abiword-2.6, usr/lib/abiword-2.8,
#or usr/lib/abiword-2.9 ...
ABIWORDSUBDIR="$(find usr/lib -mindepth 1 -maxdepth 1 -type d -name 'abiword-*' | head -n 1 | rev | cut -f 1 -d '/' | rev)"

#move non-english files to abiword_NLS...
if [ "$ABIWORDSUBDIR" ];then
 if [ -d usr/share/$ABIWORDSUBDIR ];then
  mkdir -p ../abiword_NLS/usr/share/${ABIWORDSUBDIR}
  
  cp -a -f usr/share/${ABIWORDSUBDIR}/system.profile* ../abiword_NLS/usr/share/${ABIWORDSUBDIR}/
  rm -f usr/share/${ABIWORDSUBDIR}/system.profile*
  mv -f ../abiword_NLS/usr/share/${ABIWORDSUBDIR}/system.profile usr/share/$ABIWORDSUBDIR/
  mv -f ../abiword_NLS/usr/share/${ABIWORDSUBDIR}/system.profile-en* usr/share/$ABIWORDSUBDIR/
  
  if [ -d usr/share/$ABIWORDSUBDIR/strings ];then
   mkdir -p ../abiword_NLS/usr/share/${ABIWORDSUBDIR}/strings
   cp -a -f usr/share/${ABIWORDSUBDIR}/strings/* ../abiword_NLS/usr/share/${ABIWORDSUBDIR}/strings/
   rm -f usr/share/${ABIWORDSUBDIR}/strings/*
   mv -f ../abiword_NLS/usr/share/${ABIWORDSUBDIR}/strings/en-* usr/share/${ABIWORDSUBDIR}/strings/
  fi
  
  if [ -d usr/share/$ABIWORDSUBDIR/templates ];then
   mkdir -p ../abiword_NLS/usr/share/${ABIWORDSUBDIR}/templates
   cp -a -f usr/share/${ABIWORDSUBDIR}/templates/* ../abiword_NLS/usr/share/${ABIWORDSUBDIR}/templates/
   rm -f usr/share/${ABIWORDSUBDIR}/templates/*
   mv -f ../abiword_NLS/usr/share/${ABIWORDSUBDIR}/templates/normal.awt usr/share/${ABIWORDSUBDIR}/templates/
   mv -f ../abiword_NLS/usr/share/${ABIWORDSUBDIR}/templates/normal.awt-en* usr/share/${ABIWORDSUBDIR}/templates/
   mv -f ../abiword_NLS/usr/share/${ABIWORDSUBDIR}/templates/*.awt usr/share/${ABIWORDSUBDIR}/templates/
  fi
  
 fi
fi
