#! /bin/sh

# Do we need to run this with -f ? The clock might be wrong,
# but forcing it slows the install...
gtk-update-icon-cache -f /usr/share/icons/hicolor

oldversion="$2"
if [ -z "$oldversion" ]; then
  if [ -f /usr/bin/maemo-select-menu-location ]; then
    maemo-select-menu-location osm2go.desktop
  fi
fi

if [ "$OSSO_PRODUCT_RELEASE_NAME" != "" ]; then
  if [ "$OSSO_PRODUCT_RELEASE_NAME" == "Maemo 5" ]; then
    if [ -d /home/user ]; then
      echo "/home/user exists, using it"
      USER_HOME=/home/user
    else
      echo "/home/user does not exist, using $HOME"
      USER_HOME=$HOME
    fi

    echo -n "Maemo 5"
    MMC_PATH=$USER_HOME/MyDocs/osm2go/
  else
    echo -n "Maemo pre-5"
    MMC_PATH=/media/mmc2/osm2go/
  fi
  echo " memcard location: $MMC_PATH"

  if [ ! -d $MMC_PATH ]; then
    echo "$MMC_PATH doesn't exist yet. Installing demo project."
    mkdir $MMC_PATH
    mv /usr/share/osm2go/demo $MMC_PATH
  else
    echo "$MMC_PATH already exists, doing nothing."
  fi
else
  echo "Unable to determine OS version, not installing any demo!"
fi

exit 0
