
#Ubuntu Jaunty
#i don't understand this. /usr/lib/cups/backend is empty...
if [ -d usr/lib/cups/backend-available ];then
 if [ -d usr/lib/cups/backend ];then
  cp -a -f usr/lib/cups/backend-available/* usr/lib/cups/backend/
 fi
fi

#need cups-config
if [ -f ../cups_DEV/usr/bin/cups-config ];then
 cp -f ../cups_DEV/usr/bin/cups-config usr/bin/
fi

#slackware 13.1, wants the html web interace files at usr/share/doc/cups-1.4.3...
DOCCUPS="`find usr/doc -maxdepth 1 -type d -name cups* | head -n 1`"
if [ "$DOCCUPS" ];then
 BASEDOCCUPS="`basename $DOCCUPS`"
 rm -rf usr/share/doc/cups
 ln -s ../../doc/${BASEDOCCUPS} usr/share/doc/cups
 ln -s ../../doc/${BASEDOCCUPS} usr/share/doc/${BASEDOCCUPS}
 #reduce it a bit...
 for ONECUPSDOC in `find ${DOCCUPS} -maxdepth 1 -type d | tr '\n' ' '`
 do
  BASEONECUPS="`basename $ONECUPSDOC`"
  [ "$BASEONECUPS" = "help" ] && continue
  [ "$BASEONECUPS" = "images" ] && continue
  rm -rf usr/doc/${BASEDOCCUPS}/$BASEONECUPS
 done
fi

#slackware 13.1, have doc>exe...
[ -d usr/man ] && rm -rf usr/man
[ -d usr/share/man ] && rm -rf usr/share/man
[ -d usr/share/cups/examples ] && rm -rf usr/share/cups/examples

#drake puppy 0.1, july 2011, rcrsn51 advises that /etc/cups/snmp.conf "needs to be world-readable in order to detect network printers"
[ -f etc/cups/snmp.conf ] && chmod 644 etc/cups/snmp.conf

#111101 'help' directory seems not needed by web interface, move to _DOC...
CUPSHELPDIR="`find usr -type d -name help | sed -e 's%usr%%' | tr '\n' ' '`"
for ONECHD in $CUPSHELPDIR
do
 if [ -f usr${ONECHD}/cgi.html ];then
  mkdir -p ../cups_DOC/usr${ONECHD}
  cp -a -f usr${ONECHD}/* ../cups_DOC/usr${ONECHD}/
  rm -f usr${ONECHD}/*
 fi
done
#NOTE: the above is a hack. The variable PKGS_SPECS_TABLE in file DISTRO_PKGS_SPECS-*, has an entry like:
#yes|cups|cups|exe,dev,doc>exe,nls
#notice doc>exe, this ensures that 2createpackages won't move 'doc' dir to cups_DOC.
#but, we do want part of docs to go to cups_DOC, hence the hack.
#note, different distros have 'help' in different places:
#T2: /usr/share/doc/cups/help
#Slackware: /usr/doc/cups/help
#Debian: /usr/share/cups/doc-root/help

#111103 in addition to the above, also need to handle yes|cups|cups|exe,dev,doc,nls (no doc>exe)...
CUPSWEBINTERFACE="`find usr -type f -name favicon.ico`" #in same dir as index.html
if [ ! "$CUPSWEBINTERFACE" ];then
 if [ -d ../cups_DOC ];then
  CUPSWEBCSS="`find ../cups_DOC/usr -type f -name favicon.ico | head -n 1 | sed -e 's%\.\./cups_DOC/%%'`"
  if [ "$CUPSWEBCSS" ];then
   CUPSWEBDIR="`dirname $CUPSWEBCSS`"
   mkdir -p $CUPSWEBDIR
   cp -a -f ../cups_DOC/${CUPSWEBDIR}/* ${CUPSWEBDIR}/
   rm -rf ${CUPSWEBDIR}/help
  fi
 fi
fi
