#!/bin/sh

PKG_NAME="ExifTool"
APP_NAME="exiftool"
PKG_PATH="/var/packages/$PKG_NAME/target"
LOG="/var/packages/$PKG_NAME/target/log"

DO_CHECK_OTHER_VERSION ()
{
type exiftool >/dev/null 2>&1 || { echo >&2 "I require exiftool but it's not installed.  Aborting."; }

if which exiftool > /dev/null
	then
		DISTRIBUTOR_LINE=$(grep 'distributor=' "$PKG_PATH/INFO")
		DISTRIBUTOR="${DISTRIBUTOR_LINE:13}"
		DISTRIBUTOR="${DISTRIBUTOR%?}"
		if [ "$DISTRIBUTOR" != "Sylvain Grosset" ]
			then 
				echo "ExifTool already installed. Please uninstall before using this package" > $SYNOPKG_TEMP_LOGFILE
				exit 1
				
		fi
		
fi
}

DO_LINK()
{
ln -s "$PKG_PATH/lib/" "/usr/bin/"
ln -s "$PKG_PATH/$APP_NAME" "/usr/bin/$APP_NAME" 
echo "Command exiftool is now functional in terminal" > $SYNOPKG_TEMP_LOGFILE
}


DO_REMOVE()
{
	# remove old version
	if [ -e /bin/$APP_NAME ]
		then 
		rm -f /bin/$APP_NAME
	fi
	if [ -e /bin/lib/$PKG_NAME.pm ]
		then 
		rm -r /bin/lib
	fi
	
	#remove version > 9.75-13
	if [[ -h "/usr/bin/$APP_NAME" ]]
		then
			rm -f /usr/bin/$APP_NAME
	fi
	
	if [[ -h "/usr/bin/lib" ]]
		then
			rm -r /usr/bin/lib
	fi
}
