I want to throw error dialog (and fail the installation) if certain file exists on the system. Is it possible?
pkg = flat file pkg
It's possible to customize the installer in various ways to get whatever functionality is needed generally. Typically in your scenario either a Pre-Installation script could be used or a Package Installer Plugin. The options would normally be defined in the installer package's distribution.dist which essentially functions as the schema it will follow.
See productbuild in the man pages:
--scripts scripts-path
- The contents of scripts-path is added to the product archive for use by system.run() commands commands in the distribution. This is valid only for product archives targeted to the OS X Installer application.
--plugins plugins-path
- The contents of plugins-path is added to the product archive for use by the OS X Installer application's plugin mechanism. It will normally contain a InstallerSections.plist file, and one or more plugin bundles.
↳ About Distribution Definition Files & productbuild
Related
I am new to iOS/OS X. I have written kernel code, Qt app and Front End application for my application for OS X & tested it, works fine.
Problems facing :
I have to make a single distributable .dmg, which will install all three codes{kernel code, Qt app & Front end application } in separate directories with single double click.
How can i make this work ?
Methods Tried :
1) I made separate .dmg and added to a folder and again created another .dmg of folder .(But it require again to double click to install all three code parts)
2) I tried to generate .dmg with command line macdeployqt, Disk Utility, IDMG , DropDMG (It help in also adding licenses).
2a) DropDMG have the option of joining and then convert Image /Archiver its not working, After i joined the first file (file.001) ,it shows message "Use Convert ..to join ".dmgpart"files. when i try for convert Image /Archiver option, it doesn't detect files (.dmgpart)
Note : I am using DropDMG trail version and i renamed all three files as file.001 , file.002.dmgpart and file.003.dmgpart (as per user guild )
A .dmg is a disk image, not an installer; you need to create an Installer Package instead.
PRODUCTBUILD
productbuild -- Build a product archive for the OS X Installer or the Mac App Store
A product archive is a flat file with a .pkg extension. productbuild creates a deployable product archive, archive,
chive, which can be used with the OS X Installer.
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/productbuild.1.html#//apple_ref/doc/man/1/productbuild
PKGBUILD
pkgbuild -- Build an OS X Installer component package from on-disk
files
A component package contains payload to be installed by the OS X Installer. Although a component
package can be installed on its own, it is typically incorporated into a product archive, along with a
distribution and localized resources, using productbuild(1).
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/pkgbuild.1.html#//apple_ref/doc/man/1/pkgbuild
I need to build a installer for my application which has below components/tasks -
Main .app file
Helper .app file
Supporting folders
.plist file which needs to be copied to /Library/LaunchAgents
load the plist file using "launchctl load"
As we see from the above components,
1. files needs to be extracted to /Applications/ABC
2. Execute a perl command file as administrator
As step2 above involved admin activities, installer should prompt admin/local username and password. Based on this, we need to proceed with next steps.
Can someone please suggest -
1. Installer tool (Preferably FREE) for the above scenario
2. Installer should prompt login/pwd while executing command file
You can use pkgbuild and productbuild commands to build the installer. Check this very detailed answer here
The official documentation for these commands are here pkgbuild and productbuild
There is another pkg creating app available: iceberg
For one of my projects i used building script using packagemaker. Packagemaker allows specify all files i need install from root, so my root had following structure:
Applications
My Application.app
Library
Preferences
MyCompanyName
some.xml
another.xml
tmp
default.p12
usr
local
bin
sometool
I.e. it had following features:
Some configuration files preinstalled for all users, to global Preferences (some.xml, another.xml)
Some command line tool being used as by main app as user in /usr/local/bin
Program uses certificates and there is one default certificate which will be moved to right place in postflight
How to do same with productbuild? Possible?
The basic tool that does the packaging you want is pkgbuild, not productbuild. pkgbuild will let you specify a root directory that, upon installation, will be expanded to '/'. So, you can use that for all of what you discuss in your question (though an installer putting something in /tmp is a bit weird - I'd suggest baking the cert right into your postinstall script).
I have created a flat .pkg file with following options on 10.7 using PackageMaker 3.0.6:
/Applications/PackageMaker.app/Contents/MacOS/Package --root ./myroot \
--id com.myroot.pkg --title "My Root" --scripts ./scripts --target 10.5 \
--verbose --resources ./resources --root-volume-only --domain system \
--no-relocate --versio 1.0 --certificate "My Cert Name"
In the resources folder I have background.png, Welcome.rtf and License.rtf and in the scripts folder I have preflight, postflight and various support files for those scripts. The resulting .pkg appears to be fully functional except that the installer does not display my background, welcome or license.
How can I add a custom background, welcome and license to a flat package?
As far as I can tell, the Distribution file in the .pkg is missing references to the background, welcome and license files.
As a workaround I tried using xar. If I unpack the package with xar like so:
xar -xf ./myroot.pkg -C work
and add the 3 tags for those files, then pack it again with xar:
cd work && xar -cf ../myroot2.pkg *
I get a package that starts installation ok with my background etc., but when it comes time to install my .app I get these errors (from /var/log/install.log):
run preupgrade script for myroot
Could not create task for action: run preupgrade script for myroot2
Install failed: The Installer could not extract files from the package for myroot2. Contact the software manufacturer for assistance.
IFDInstallController 863170 state = 7
I have also tried Flat Package Editor: open myroot.pkg, drag out Distribution, edit it, drag it back, delete old Distribution, save. Same problem as with xar.
I would prefer to have a fully scriptable solution as opposed to using GUIs.
Edit: I have also tried to use pkgutil to expand, edit Distribution, and reflatten a flat package. This gets the icons and readme in the installer, but the installer is then unable to unpack the payload. Same if I reflatten with Flat Package Editor. I have also tried to create an expanded package without PackageMaker (which works, except on 10.8), but when I try to flatten that with pkgutil the result is a corrupted package again.
PackageMaker always was buggy has hell, and got deprecated with Mac OS X 10.6 Snow Leopard.
You should use pkgbuild together with productbuild.
This Mac Installers Blog has some useful posts about Packagemaker including details about the usage and solutions to common problems. Hope it will help.
Check out the Luggage - it's a Makefile helper file that lets you create OS X packages with sane Makefiles. Disclaimer: I am the original author for it, though there are a lot of other people's contributions in it now.
I have an Ant script which turns my Java application into a nice Mac Bundle using the JarBundler task. The problem is how do I now turn that into a .pkg file for distribution?
I'm looking at using the packagemaker command line tool (located in /Developer/usr/bin/packagemaker) but it has a number of drawbacks:
If I use the '--doc' option to point it to a .pmdoc file (built using the PackageMaker GUI) then I will have to manually change the .pmdoc contents whenever I add files to my project
If I use the '--root' option to build the package based on the app bundle then it seems I don't get many of the features of the GUI (such as including the licence text).
How do other people produce a .pkg file with their build script?
Thanks
I use the following to build a package from a pmdoc and the the DMG containing the package on OS X 10.6:
/Developer/usr/bin/packagemaker --verbose --doc [project].pmdoc --out [project].pkg
mkdir -p dmg
cp -pR [project].pkg dmg
hdiutil create dmg/[Project]-r$SVN_REVISION.dmg -volname "[Project]" -fs HFS+ -srcfolder dmg
I use scripts to automatically update parts of the PackageMaker file. I found it more convenient to keep the old format .pmproj files rather than to switch to the more recent bundle format.
You can use packagemaker's --resources options to add a resources folder to the package. If you're building an older-style package (10.3 and maybe 10.4 target), all you need to do is put files with appropriate names (e.g. (License,ReadMe,Welcome).(rtf|html) and Background.(jpg|gif|pdf|tif)) optionally organized into .lproj subfolders, and they'll included & used by the package. This doesn't seem to work with distribution packages (10.5-style flat packages and some 10.4 packages), as the resource file names have to be listed in the distribution file, and I'm not sure how to put them there with packagemaker.