来自 Shell 脚本的 Package Maker 检查错误
我需要为我的 Mac 应用程序创建一个包,并且我正在使用 PackageMaker,
我需要检查 JVM 版本,如果它小于 10.6,那么我将中止安装并要求用户首先安装 JVM,
为此,我正在使用以下 shell 脚本
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
,并在软件包制造商中进行了检查以通过,但在所有情况下它都会遇到失败条件,即书面类型不正确,任何人都可以帮助我, “shell 脚本的正确返回值应该是多少”,软件包制造商可以了解其脚本的成功或失败。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
exit 0
是您从 InstallationCheck 脚本返回的内容,表示成功。其他任何内容都表明有错误。
将脚本中的
0
和1
颠倒过来,就可以开始了。对于您正在使用的旧版本的 PackageMaker,这个答案应该没问题。较新版本的 PackageMaker 可能支持 InstallationCheck 脚本,但 PackageMaker 的当前 Apple 文档 根本没有提及这一点,而是重点关注“产品包要求窗格”(请参阅文档中的图 2-8)。
exit 0
is what you return from the InstallationCheck script to indicate success.Anything else indicates an error.
Reverse your
0
's and1
'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).