#!/bin/sh

set -e

# if we're upgrading from a version using the old format
if( (test "$1" = "upgrade") && (dpkg --compare-versions "$2" lt "1.4") ); then
  #convert to the new format, saving the old just to be completely save
  for FILE in `ls /etc/desktop-profiles/*.listing`; do
    mv $FILE $FILE.oldformat;
    cat $FILE.oldformat | sed -e 's/\(.*;\)\(.*;.*;.*;\)\(.*;\)\(.*\)/\1\3\2\4/g' > $FILE
  done;  
fi;  

# if we're upgrading from a version that didn't have the path2listing script
# ensure we don't loose the old defaults
if( (test "$1" = "upgrade") && (dpkg --compare-versions "$2" lt "1.4.6") ); then
  cat /etc/desktop-profiles/desktop-profiles.listing | grep ';GCONF;' > /etc/desktop-profiles/desktop-profiles_path2listing.listing 
fi;

#DEBHELPER#
