#this template is devious, to handle the way debian has butchered the layout.

#120321 ubuntu precise pangolin: screen out 'seamonkey-addons'...
SMLIBDIR="`find usr/lib -maxdepth 1 -type d -name seamonkey\* | grep -v 'addons' | head -n 1`"

if [ "$SMLIBDIR" != "" ];then
 BASESMLIB="`basename $SMLIBDIR`"
 
 if [ "$BASESMLIB" != "seamonkey" ];then
  ln -s $BASESMLIB usr/lib/seamonkey
  SMPARENT="`pwd | rev | cut -f 1 -d '/' | rev`"
  mkdir -p ../${SMPARENT}_DEV/usr/include
  ln -s $BASESMLIB ../${SMPARENT}_DEV/usr/include/seamonkey
 fi

 if [ -d usr/lib/${BASESMLIB} ];then
  rm -rf usr/lib/${BASESMLIB}/chrome/icons
  mv -f usr/share/seamonkey/chrome/icons usr/lib/${BASESMLIB}/chrome/
  rm -rf usr/lib/${BASESMLIB}/extensions/*
  rm -rf usr/share/seamonkey
 fi
 
 #test if sm 1.x or 2.x
 if [ -f usr/lib/seamonkey/platform.ini ];then
  #sm2 get rid of the sm1 config...
  rm -rf root/.mozilla/default
  rm -f root/.mozilla/appreg
  SMMILESTONE="`cat usr/lib/seamonkey/platform.ini | grep '^Milestone' | cut -f 2 -d '='`"
  SMPREFSJS="`find root/.mozilla/seamonkey -maxdepth 2 -type f -name prefs.js`"
  #this makes the puppy home page display at first run of sm...
  smPATTERN="s% "rv:.*"% "rv:${SMMILESTONE}"%"
  sed -e "$smPATTERN" $SMPREFSJS > /tmp/seamonkey-temp-prefsjs
  cp -f /tmp/seamonkey-temp-prefsjs $SMPREFSJS
 else
  #old sm 1.x
  rm -rf root/.mozilla/extensions
  rm -rf root/.mozilla/seamonkey
  #TODO need to update milestone entry in prefs.js so that the puppy home page displays on first run.
 fi
 
 
fi

#***NOTICE template needs to be updated for Ubuntu/debian SM2***
#ubuntu... sm1...
if [ -e usr/share/seamonkey/chrome/installed-chrome.txt ];then
 #have removed 'modern' and 'sroaming'...
 grep -v 'modern' usr/share/seamonkey/chrome/installed-chrome.txt >/tmp/installed-chrome.txt
 grep -v 'sroaming' /tmp/installed-chrome.txt >usr/share/seamonkey/chrome/installed-chrome.txt
fi
