Create a MacOS X App Bundle Using MacPorts

From Octave
Revision as of 05:42, 22 June 2012 by Bpabbott (talk | contribs)
Jump to navigation Jump to search

Install MacPorts

MacPorts, formerly called DarwinPorts, is a package management system that simplifies the installation of software on the MacOS X and Darwin operating systems. It is a free/open source software project to simplify installation of other free/open source software. Similar in aim and function to Fink and the BSDs' ports collections, DarwinPorts was started in 2002 as part of the OpenDarwin project, with the involvement of a number of Apple Inc. employees including Landon Fuller, Kevin Van Vechten, and Jordan Hubbard.

An itemized overview of a MacPorts install is below.

  • Install XCode: This is done via the MacOS X App Store.
  • Follow MacPorts' installation instructions.
  • MacPorts has good support for Octave. A list of what MacPorts has available for Octave is here. To install the most recent version of Octave, type sudo port install octave-devel at the Terminal's command line. Octave has many dependencies which will be downloaded and installed prior to Octave. The entire installation process can take a few hours.

Install an Octave Port

For the purpose of creating an App bundle using MacPorts, an Octave port must be installed. A standard MacPorts port or a local port may be used. For a local portfile it is first required that a local portfile repository be created and the local portfile placed there.

Installing an Octave port is done as;

  • sudo port install <portname>

Where <portname> is the name of the port. For example, the name of the port for Octave 3.6.x is octave36.

All of Octave's dependencies will also be Installed. MacPorts' Octave port includes the non-GPL Metis. To avoid license violations do not bundle Metis with Octave and then distribute to others.

Once an Octave port is installed the command below may be used to determine / verify the port's version and variants.

  • port installed <portname>

Create the MacOS X App Bundle

Produce a DMG of the Octave port and its dependencies

MacPorts provides a feature for producing binary packages with standalone binary installers that are precompiled; they do not require MacPorts on the target system. Binary files created with MacPorts may be either .pkg (Mac OS X Installer Packages), or RPM (RPM Package Manager) format. MacPorts may also process a .pkg package into a Mac OS X .dmg disk image file. The port command shown below will create a DMG type binary installer for the Octave port and all its dependencies.

  • sudo port mdmg <portname>

If more than one version of Octave is installed, or if more than one variant of Octave has been installed, the version and variant should be included.

  • sudo port mdmg <portname> @<version>+variant1+variant2

The DMG will be placed in a port's work directory. If a local portfile is used, a symbolic link to the work directory will be placed in the directory containing the portfile.

Use the DMG to produce the App bundle

  • Download the App Boilerplate from Savannah's task tracker.
    1. To be placed on Savannah soon.
    2. An itemized list of the Boilerplate's contents is below.
      • Boilerplate
        • Contents
          • Info.plist
          • MacOS
            • Octave
          • Resources
            • appIcon.icns
            • AppSettings.plist
            • bin
              • octave
            • script
  • Create a copy of the DMG's contents
    1. Save the original MacPorts installation.
      • sudo mv /opt /opt-save
    2. Install the DMG. This will create a new /opt directory.
    3. Move the new /opt to the directory containing the App Boilerplate.
    4. Restore the MacPorts installation
      • sudo mv /opt-save /opt
  • Create the App bundle using the shell script below. This script produces an App bundle named
#!/bin/sh -e
if [ -n "${FULLAPP}" ]; then
  mkdir ${FULLAPP}
  mkdir ${FULLAPP}/Contents
  mkdir ${FULLAPP}/Contents/MacOS
  cp -af ${MACPORTS_PREFIX} ${FULLAPP}/Contents/Resources
  ## Remove symbolic link to octave-$VERSION. This will be replaced by
  ## a shell script that is part of the Boilerplate
  rm ${FULLAPP}/Contents/Resources/bin/octave

cp -pRf Boilerplate/. ${FULLAPP}/.
chmod 731 ${FULLAPP}

Problems and Restrictions of the App Bundle

  • Spaces in path to the App bundle
  • Conflicts with other Aquaterm Installations
  • No Universal Builds
  • Limited MacOS Compatibility
  • Icon needs improvement