简体   繁体   English

OSX .pkg安装程序有时不会安装.app文件

[英]OSX .pkg installer sometimes does not install .app file

My Java application has a launcher which is a .app and a helper app which is bundled with it. 我的Java应用程序有一个启动器,它是一个.app和一个与它捆绑在一起的帮助应用程序。

I am trying to make .pkg installer with a background image using the following commands: 我正在尝试使用以下命令使用背景图像制作.pkg安装程序:

pkgbuild --root "./Temp"  --identifier "com.company.id" --install-location "/Applications" --sign "signature" "temp.pkg"
productbuild  --package-path "temp.pkg" --distribution "./Distribution.xml" --package-path "./Temp" --resources "./Resources" --sign "installer signature"  "$FINAL_PKG"

When I look in the directory at ./Temp both of the .app folders are there and when I deconstruct the .pkg with: 当我查看./Temp目录时,两个.app文件夹都存在,当我解构.pkg时:

pkgutil --expand "temp.pkg" "temp"

I see the .app folders but sometimes one of the .app folders do not show up when it is installed from the pkg. 我看到.app文件夹,但有时从pkg安装时,其中一个.app文件夹不显示。 They always seem to show up the first time it is installed, but on machines where the application is installed and deleted many times (like on test and development machines) one of the .app folders will eventually not show up. 它们似乎总是在第一次安装时出现,但是在多次安装和删除应用程序的机器上(如在测试和开发机器上),其中一个.app文件夹最终不会显示。 I am wondering what could be going on here? 我想知道这里会发生什么?

Initially we had the helper app inside a separate directory as the main app and in this case, the helper app would sometimes not get installed but the main app always would be. 最初我们将帮助应用程序作为主应用程序放在一个单独的目录中,在这种情况下,帮助应用程序有时不会安装,但主应用程序总是会安装。 Next, we tried putting the helper app inside of the main app and then this worked the first time but the next time I tried to to install from the installer the main app wasn't there! 接下来,我们尝试将帮助应用程序放在主应用程序中,然后这是第一次工作,但下次我尝试从安装程序安装主应用程序不在那里!

I have had roughly the same problem. 我遇到了大致相同的问题。 It appears that the OS X installer uses information about already installed packages and application bundles in order to decide where and if to install new packages. OS X安装程序似乎使用有关已安装的软件包和应用程序软件包的信息来决定安装新软件包的位置和安装方式。 As a result, sometimes my installer did not install any files whatsoever, and sometimes it just overwrote the .app bundle in my build tree. 因此,有时我的安装程序没有安装任何文件,有时它只是覆盖了我的构建树中的.app包。 Not necessarily the one used to build the installer, but any .app bundle that OS X had found. 不一定是用于构建安装程序的那个,而是OS X找到的任何.app包。 In order to get the installer to install the files properly I had to do two things: 为了让安装程序正确安装文件,我必须做两件事:

  1. Tell OS X to forget about the installed package 告诉OS X忘记已安装的软件包

    sudo pkgutil --forget <package id> Not sure if this is needed for you nor in my case, but it is probably a good idea anyway. sudo pkgutil --forget <package id>不确定这对你和我的情况是否需要,但无论如何它可能是一个好主意。

  2. Delete all existing .app bundles for the app. 删除应用程序的所有现有.app包。 If I didn't do this, the existing app bundle was overwritten on install instead of the app being placed in /Applications. 如果我没有这样做,则在安装时覆盖现有的应用程序包,而不是将应用程序放在/ Applications中。 Maybe there is a way to prevent this while building the installer package, but I haven't found it. 也许在构建安装程序包时有一种方法可以防止这种情况,但我还没有找到它。

If you can you should probably try to make your application self contained so that users can install it by just drag and dropping it into /Applications. 如果可以,您可能应该尝试使应用程序自包含,以便用户只需将其拖放到/ Applications中即可安装它。 Of course, this only works if you don't need to install anything outside of your .app bundle. 当然,这只适用于您不需要在.app包之外安装任何内容的情况。

If you don't want to (or can't expect other users to) hunt down and delete all existing copies of the app as described by villintehaspam, or just really need the app not to be relocated, you can provide a Component Property List file with BundleIsRelocatable set to false. 如果您不希望(或者不能指望其他用户)按照villintehaspam的描述追捕并删除应用程序的所有现有副本,或者只是真的需要不重新定位应用程序,则可以提供组件属性列表BundleIsRelocatable设置为false的文件。

An easy way to create a valid version of the plist file is with pkgbuild --analyze ; 创建plist文件的有效版本的简单方法是使用pkgbuild --analyze ; then you can edit the one property and use the file. 然后你可以编辑一个属性并使用该文件。 Eg: 例如:

pkgbuild --root myapp.root --analyze myapp.plist
/usr/libexec/PlistBuddy -c 'set :Dict:BundleIsRelocatable false' myapp.plist
pkgbuild --root myapp.root --component-plist myapp.plist [...other options...] myapp.pkg

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM