来自 Shell 脚本的 Package Maker 检查错误

发布于 2025-01-08 17:33:33 字数 1158 浏览 3 评论 0原文

我需要为我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

安稳善良 2025-01-15 17:33:33

exit 0 是您从 InstallationCheck 脚本返回的内容,表示成功。

其他任何内容都表明有错误。

将脚本中的 01 颠倒过来,就可以开始了。

对于您正在使用的旧版本的 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 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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文