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 runningpkgbuildin the root that you're building - it seems very likely that you have a copy offoo.pkgon your desktop that was created by an earlier run ofpkgbuild. When you run it again, the oldfoo.pkgis now built into the new package.Instead, point
--rootat a directory only containing the files you wish to package.Otherwise, use
--analyzeto 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 intopkgbuildwith--component-plist.You should read the man page if you haven't already.