Search code examples
macosshellpackagemaker

Package Maker check error from the Shell Script


I need to create a Package for my Mac Application, and i am using PackageMaker

I need to check the JVM Version and if its lesser then 10.6 then i shall abort installtion and ask user to install JVM first,
for that i am using following shell script

REQUIRED_VERSION=106
#Converting the value in numeric value for comparison in later part of the script REQUIRED_VERSION=`echo $REQUIRED_VERSION | sed -e 's;\.;0;g'`
#Redirecting complete output of java -version to tmp.ver file
java -version >tmp.ver 2>&1
#Getting current version from the tmp.ver file
VERSION=`cat tmp.ver | grep "java version" | awk '{ print substr($3, 2, length($3)-2); }'`
rm tmp.ver
#Coverting into numeric value
VERSION=`echo $VERSION | awk '{ print substr($1, 1, 3); }' | sed -e 's;\.;0;g'`
echo $VERSION
if [ $VERSION ]
    then
        if [ $VERSION -gt $REQUIRED_VERSION ] || [ $VERSION -eq $REQUIRED_VERSION ]
           then
                 echo "requirement matched"
                 exit 1;
           else
                 echo "lower version"
                 exit 0;
        fi
    else
         echo "not able to find java version"
         exit 0;
fi

and in package maker i have put a check to pass , but in all cases its hitting hte fail condition, i.e. written type is not correct, can anyone help me out, with "What shall be the correct return value form shell script" that package maker can understand its script pass or fail.


Solution

  • exit 0 is what you return from the InstallationCheck script to indicate success.

    Anything else indicates an error.

    Reverse your 0's and 1's in your script and you should be good to go.

    And this answer should be okay for the older version of PackageMaker you're using. More recent versions of PackageMaker may support InstallationCheck scripts, but the current Apple documentation for PackageMaker doesn't mention this at all and instead focuses on a "Product Package Requirements Pane" (look at Figure 2-8 in the documentation).