I have a binary file, foo
. Built using vercel/pkg.
I would like to bundle this in an installer for mac; A .pkg
installer file.
It should install the binary in /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. 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.
How can make pkgbuild
avoid leaving foo.pkg
inside /usr/local/bin
?
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
. When you run it again, the old foo.pkg
is now built into the new package.
Instead, point --root
at a directory only containing the files you wish to package.
Otherwise, use --analyze
to generate a component list of your root directory. 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
.
You should read the man page if you haven't already.