Building a Mac OS X Package for Amanda: Difference between revisions

From wiki.zmanda.com
Jump to navigation Jump to search
(→‎Compile: change username to 'amandabackup')
(Information gleaned from actually finishing this process)
Line 1: Line 1:
This document discusses creating a MacOS X package (a .pkg file in a .dmg disk image) from scratch.  This is the process that the Amanda team follows to create a new package.  Unfortunately, Apple's packaging applications are not scriptable -- these instructions must be followed manually.
This document discusses creating a MacOS X package (a .pkg file) from scratch.  This process can be automated, although discussion of how that' done is beyond the scope of this document.


= Prerequisites =
= Prerequisites =
You will need:
You will need Apple's XCode (download the latest version from Apple at http://developer.apple.com/tools/xcode/).  If you want to compile from subversion, rather than a distribution tarball, you'll need autotools (use [http://www.finkproject.org/ Fink] or [http://darwinports.opendarwin.org/ DarwinPorts], or install them manually)
* XCode (download the latest version from Apple at http://developer.apple.com/tools/xcode/)
* autotools (use [http://www.finkproject.org/ Fink] or [http://darwinports.opendarwin.org/ DarwinPorts], or install them manually)


= Overview =
= Overview =
The basic plan here is to compile Amanda and install it into a temporary location (<tt>/tmp/amroot</tt>).  The result is essentially an overlay containing the files that <tt>make install</tt> would create.  We then use Package Maker to bundle that overlay with some additional scripts and utilities into a package.
The basic plan here is to compile Amanda and install it into a temporary location (<tt>/tmp/amroot</tt>).  The result is essentially an overlay containing the files that <tt>make install</tt> would create.  We then use Package Maker to bundle that overlay with some additional scripts and utilities into a package.
NOTE: these instructions reference files which may not yet be a part of the distribution tarball.


= Compile =
= Compile =
Amanda should be compiled as described in [[Installing Amanda on Mac OS X]].  You will need to create the amandabackup user, although creating the remaining directories is not required.  
Amanda should be compiled as described in [[Installing Amanda on Mac OS X]].  You will need to create the amandabackup user, although creating the remaining directories is not required.  


The configuration is
The configuration is minimally
  ./configure --prefix=/usr/local --with-user=amandabackup --with-group=wheel
  ./configure --prefix=/usr/local --with-user=amandabackup --with-group=wheel --sysconfdir=/private/etc --localstatedir=/private/var --with-tmpdir=/private/tmp/amanda


Instead of <tt>sudo make install</tt>, however, run  
However, instead of <tt>sudo make install</tt>, run  
  DESTDIR=/tmp/amroot sudo make install
  DESTDIR=/tmp/amroot sudo make install


You should now have a full amanda install located under <tt>/tmp/amroot/</tt>.
You should now have a full amanda install located under <tt>/tmp/amroot/</tt>.
== Fat build ==
Amanda is quite easy to compile into "fat" binaries; simply add the following before your <tt>./configure</tt>:
<pre>
    CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386" \
    LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386" \
</pre>


= Build Package =
= Build Package =
Open the Package Maker project under <tt>contrib/macosx</tt>.  Edit the "Package Version" information, if necessary, and then select Project -> Build.  You will be prompted for the location at which to save the resulting package.
== Cleanup ==
First, you'll need to shift the amanda install around a little bit.  You only want it to install the stuff under /usr/local; letting the Apple installer make changes in <tt>/private/var</tt> or <tt>/private/etc</tt> is asking for troubleSo remove those directories from <tt>/tmp/amroot</tt>.
 
== Resources ==
You will probably want to run some scripts, for example, to create the 'amandabackup' user, as part of your package's installation. Create a <tt>Resources</tt> directory.  In this example, it's at <tt>/tmp/Resources</tt>, but you may not consider your resources "temporary" once you've spent a few hours honing your scripts.  Create scripts in this directory named e.g., <tt>InstallCheck</tt> or <tt>postinstall</tt>.  See some of the [[#Links|links]] and XCode's included documentation for pointers.
 
== Make Package Project ==
Create a new package with PackageMaker, with the following settings:
; Root : <tt>/tmp/amroot/usr/local/</tt>
; Default Location : <tt>/usr/local/</tt>
; Authentication : <tt>root</tt>
; Relocatable : unchecked
; Extras : <tt>/tmp/Resources</tt>
; Package Version : (as appropriate for the version you're packaging
Then build the package.
 
= Links =
*  http://s.sudre.free.fr/Stuff/PackageMaker_Howto.html
* Examples from [http://sf.net/projects/pgsqlformac| PostgreSQL Tools for MacOS X]:
**  http://pgsqlformac.svn.sourceforge.net/viewvc/pgsqlformac/trunk/BuildScripts/
**  http://pgsqlformac.svn.sourceforge.net/viewvc/pgsqlformac/trunk/Installers/PostgreSQL8/Resources/postflight?revision=HEAD&view=markup
**  http://pgsqlformac.svn.sourceforge.net/viewvc/pgsqlformac/trunk/Installers/PostgreSQL8/Resources/InstallationCheck.strings?revision=21&view=markup

Revision as of 22:44, 5 April 2007

This document discusses creating a MacOS X package (a .pkg file) from scratch. This process can be automated, although discussion of how that' done is beyond the scope of this document.

Prerequisites

You will need Apple's XCode (download the latest version from Apple at http://developer.apple.com/tools/xcode/). If you want to compile from subversion, rather than a distribution tarball, you'll need autotools (use Fink or DarwinPorts, or install them manually)

Overview

The basic plan here is to compile Amanda and install it into a temporary location (/tmp/amroot). The result is essentially an overlay containing the files that make install would create. We then use Package Maker to bundle that overlay with some additional scripts and utilities into a package.

Compile

Amanda should be compiled as described in Installing Amanda on Mac OS X. You will need to create the amandabackup user, although creating the remaining directories is not required.

The configuration is minimally

./configure --prefix=/usr/local --with-user=amandabackup --with-group=wheel --sysconfdir=/private/etc --localstatedir=/private/var --with-tmpdir=/private/tmp/amanda

However, instead of sudo make install, run

DESTDIR=/tmp/amroot sudo make install

You should now have a full amanda install located under /tmp/amroot/.

Fat build

Amanda is quite easy to compile into "fat" binaries; simply add the following before your ./configure:

    CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386" \
    LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386" \

Build Package

Cleanup

First, you'll need to shift the amanda install around a little bit. You only want it to install the stuff under /usr/local; letting the Apple installer make changes in /private/var or /private/etc is asking for trouble. So remove those directories from /tmp/amroot.

Resources

You will probably want to run some scripts, for example, to create the 'amandabackup' user, as part of your package's installation. Create a Resources directory. In this example, it's at /tmp/Resources, but you may not consider your resources "temporary" once you've spent a few hours honing your scripts. Create scripts in this directory named e.g., InstallCheck or postinstall. See some of the links and XCode's included documentation for pointers.

Make Package Project

Create a new package with PackageMaker, with the following settings:

Root
/tmp/amroot/usr/local/
Default Location
/usr/local/
Authentication
root
Relocatable
unchecked
Extras
/tmp/Resources
Package Version
(as appropriate for the version you're packaging

Then build the package.

Links