Spacer http://macenterprise.org MacResource.org - Mac OS X enterprise deployment project Spacer
Site Map Contact Us Top Background
 
Search
 
 
Creating Snapshot Packages with packagemaker E-mail
Written by Patrick McNeal   
Wednesday, 29 March 2006
In XCode 2.2, Apple quietly introduced a new snapshot option to packagemaker that can create a package by tracking changes to a specific directory.  The man page for packagemaker has been updated, but the current version, XCode 2.2.1, contains a couple of mistakes and no examples. This article hopes to fill in the missing pieces. PackageMaker

Overview

Creating a package with snapshots is broken into three steps:
  1. Snapshot the current state of a directory
  2. Add, install or modify files in the directory
  3. Create package containing the modifications
Step One: Create Snapshot

/Developer/Tools/PackageMaker --snapshot root-path \
destination-path

This command will cause PackageMaker to create a destination-path.snapshot directory that contains an Info.plist and a bill of materials describing the current state of root-path.  To simplify step three, I've found it's easier to enter an absolute path for root-path, though it may not be necessary in all cases.

Step Two: Make Modifications

At this point you can install your software.  Since we are only watching one directory, PackageMaker will not capture any modifications made to other parts of the file system.

Step Three: Create Package

/Developer/Tools/PackageMaker -build -snapshot destination-path.snapshot \
-i PATH-TO-Info.plist -b /tmp -p destination-path

Contrary to what the current man page says, -p and -i are required.  destination-path.snapshot specifies the location of the snapshot from step one.  You have to add ".snapshot" to destination-path as PackageMaker automatically appended it.  Info-file specifies an Info.plist to use when creating the package.  destination-path is the name of the package to create, including ".pkg," where the final package will be located.

Examples

Backup your system before making any modifications.  These examples have worked for me, but I make no guarantees about how they will work for you.

To use the examples, create a simple Info.plist in your working directory. The plist format is very important, as the snapshot function will fail if not created correctly. Here is an example:




	CFBundleGetInfoString
	foo
	CFBundleIdentifier
	com.macenterprise.foo
	CFBundleShortVersionString
	0.1
	IFMajorVersion
	0
	IFMinorVersion
	0
	IFPkgFlagAllowBackRev
	
	IFPkgFlagAuthorizationAction
	AdminAuthorization
	IFPkgFlagBackgroundAlignment
	topleft
	IFPkgFlagBackgroundScaling
	none
	IFPkgFlagDefaultLocation
	/
	IFPkgFlagFollowLinks
	
	IFPkgFlagInstallFat
	
	IFPkgFlagInstalledSize
	0
	IFPkgFlagIsRequired
	
	IFPkgFlagOverwritePermissions
	
	IFPkgFlagRelocatable
	
	IFPkgFlagRestartAction
	NoRestart
	IFPkgFlagRootVolumeOnly
	
	IFPkgFlagUpdateInstalledLanguages
	
	IFPkgFormatVersion
	0.10000000149011612


Simple Example

In this example, we'll create a simple package that installs one file. In testing, an empty directory will not work, as the snapshot command will produce a corrupt pacakge.

Create the directory we'll be watching:

mkdir foo touch foo/test

Make snapshot of the directory:

/Developer/Tools/PackageMaker --snapshot `pwd`/foo \
/tmp/foo

Install file:

touch foo/bar

Create package:

/Developer/Tools/PackageMaker -build -snapshot /tmp/foo.snapshot \
-i Info.plist -p /tmp/foo.pkg

Test Package:

open /tmp/foo.pkg

Complex Example

In this example, we'll create a package for Firefox.

Make snapshot of /Applications:

/Developer/Tools/PackageMaker --snapshot /Applications
/tmp/Applications

Using lsbom, we can see what was snapshot:

lsbom /tmp/Applications.snapshot/Contents/snapshot.bom

Download Firefox, and drag the application into /Applications

Create package:

/Developer/Tools/PackageMaker -build -snapshot /tmp/Application.snapshot \
-i Info.plist -p /tmp/FireFox.pkg

Test Package:

open /tmp/Firefox.pkg

Note: One of the problems is that extraneous files can be captured with the snapshot utility. The most notable type of file is .DS_Store files. Add the -ds switch to filter out these types of files. Next, the Installer will not have a descriptive name, instead being called "My Great App". This problem can be remedied by including a Description.plist file, and using the -d option. Here is an example:




        IFPkgDescriptionDescription
        
        IFPkgDescriptionTitle
        Foo


For more information on customizing your package through Info.plist and other settings, see Apple's documentation.
Last Updated ( Friday, 14 July 2006 )
 
< Prev   Next >