简体   繁体   English

如何为我的二进制文件创建 a.pkg mac 安装程序?

[英]How can i create a .pkg mac installer for my binary?

I have a binary file, foo .我有一个二进制文件foo Built using vercel/pkg .使用vercel/pkg构建。

I would like to bundle this in an installer for mac;我想把它捆绑在 mac 的安装程序中; A .pkg installer file. .pkg安装程序文件。

It should install the binary in /usr/local/bin/foo .它应该在/usr/local/bin/foo中安装二进制文件。

Attempt:试图:

$ cd Desktop // <--- foo binary is here
$ pkgbuild --identifier com.foo.pkg --install-location ./usr/local/bin/ --root ./ foo.pkg

This creates a.pkg file: foo.pkg on my desktop.这会在我的桌面上创建一个 .pkg 文件: foo.pkg And when i run foo.pkg , it installs the foo binary in /usr/local/bin correctly, except that it also leaves foo.pkg in /usr/local/bin also.当我运行foo.pkg时,它会在/usr/local/bin中正确安装foo二进制文件,除了它还foo.pkg/usr/local/bin中。

How can make pkgbuild avoid leaving foo.pkg inside /usr/local/bin ?如何使pkgbuild避免将foo.pkg留在/usr/local/bin中?


UPDATE:更新:

Based on this thread , I think it will work if i set BundleIsRelocatable to false.基于这个线程,我认为如果我将BundleIsRelocatable设置为 false 它将起作用。 But I am not able to figure out how that is done.但我无法弄清楚这是如何完成的。

When you pass --root , it takes everything in that folder and bakes it into the package. You're running pkgbuild in the root that you're building - it seems very likely that you have a copy of foo.pkg on your desktop that was created by an earlier run of pkgbuild .当您通过--root时,它会获取该文件夹中的所有内容并将其烘焙到 package 中。您正在构建的根目录中运行pkgbuild - 您的桌面上很可能有foo.pkg的副本它是由先前运行的pkgbuild创建的。 When you run it again, the old foo.pkg is now built into the new package.当您再次运行它时,旧的foo.pkg现在已内置到新的 package 中。

Instead, point --root at a directory only containing the files you wish to package.相反,将--root指向包含您希望 package 的文件的目录。

Otherwise, use --analyze to generate a component list of your root directory.否则,使用--analyze生成根目录的组件列表。 Customize the resulting.plist as necessary (specifying the files you want to include and associated options), then feed it back into pkgbuild with --component-plist .根据需要自定义 resulting.plist(指定要包含的文件和关联的选项),然后使用--component-plist将其反馈回pkgbuild

You should read the man page if you haven't already.如果您还没有阅读手册页,则应该阅读。

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

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