Create a MacOS X App Bundle Using MacPorts: Difference between revisions

From Octave
Jump to navigation Jump to search
(streamline and generally improve the content)
(include instructions for adding a local portfile)
Line 17: Line 17:
Installing an Octave port is done as;
Installing an Octave port is done as;


* {{Codeline|<nowiki>sudo port install <portname></nowiki>}}
<nowiki>sudo port install <portname></nowiki>


Where {{Codeline|<nowiki><portname></nowiki>}} is the name of the port. For example, the name of the port for Octave 3.6.x is {{Codeline|<nowiki>octave36</nowiki>}}.
Where {{Codeline|<nowiki><portname></nowiki>}} is the name of the port. For example, the name of the port for Octave is simply {{Codeline|<nowiki>octave</nowiki>}}.


All of Octave's dependencies will also be Installed. MacPorts' Octave port includes the non-GPL [http://glaros.dtc.umn.edu/gkhome/views/metis METIS]. To avoid license violations do not bundle Metis with Octave and then distribute to others. A second motivation to use a local portfile is that the portfiles for the 3.4.x and 3.6.x series did not include all dependencies for the {{Codeline|<nowiki>print</nowiki>}} feature.  The missing dependencies are [http://www.macports.org/ports.php?by=name&substr=epstool epstool], [http://www.macports.org/ports.php?by=name&substr=pstoedit pstoedit], and [http://www.macports.org/ports.php?by=name&substr=transfig transfig].
All of Octave's dependencies will also be Installed. MacPorts' Octave port includes the non-GPL [http://glaros.dtc.umn.edu/gkhome/views/metis METIS]. To avoid license violations do not bundle Metis with Octave and then distribute to others. A second motivation to use a local portfile is that the portfiles for the 3.4.x and 3.6.x series did not include all dependencies for the {{Codeline|<nowiki>print</nowiki>}} feature.  The missing dependencies are [http://www.macports.org/ports.php?by=name&substr=epstool epstool], [http://www.macports.org/ports.php?by=name&substr=pstoedit pstoedit], and [http://www.macports.org/ports.php?by=name&substr=transfig transfig].
The steps are adding a local portfile repository and placing an Octave portfile in it are itemized below. It is assumed that the portfile name is {{Codeline|<nowiki>octave-local</nowiki>}}, and that the portfile has been placed on the users Desktop.
* Create your local portfile repository
<nowiki>mkdir ~/ports</nowiki>
* Place the Octave portile in the local repository
<nowiki>mkdir ~/ports/math
mkdir ~/ports/math/octave-local
cp ~/Desktop/portfile ~/ports/math/octave-local</nowiki>
* Index your local repository
<nowiki>cd ~/portfile
portindex -f</nowiki>


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


* {{Codeline|<nowiki>port installed <portname></nowiki>}}
<nowiki>port installed <portname></nowiki>


=Create the MacOS X App Bundle=
=Create the MacOS X App Bundle=
Line 53: Line 64:
* Set the "Script Type" to "Shell"
* Set the "Script Type" to "Shell"
* Specify the "Script Path".
* Specify the "Script Path".
** Click on the "Select" button and select the [[MacOS_X_App_Launcher_Script|App shell script]] used to launch the Terminal app, {{Codeline|<nowiki>script</nowiki>}}.
** Click on the "Select" button and select the [[MacOS_X_App_Launcher_Script|App shell script]] used to launch the Terminal app.
* Set the "Output" to "None".
* Set the "Output" to "None".
* Specify App Name (Octave-3.7.0).
* Specify App Name (Octave-3.7.0).

Revision as of 15:45, 23 June 2012

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.

MacPorts has historically been rather good a maintaining their Octave portfiles. However, there are times when the maintainer fall behind. If the current version of the octave-devel port isn't current, it will be necessary to produce a local portfile.

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 is simply octave.

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. A second motivation to use a local portfile is that the portfiles for the 3.4.x and 3.6.x series did not include all dependencies for the print feature. The missing dependencies are epstool, pstoedit, and transfig.

The steps are adding a local portfile repository and placing an Octave portfile in it are itemized below. It is assumed that the portfile name is octave-local, and that the portfile has been placed on the users Desktop.

  • Create your local portfile repository
mkdir ~/ports
  • Place the Octave portile in the local repository
mkdir ~/ports/math
mkdir ~/ports/math/octave-local
cp ~/Desktop/portfile ~/ports/math/octave-local
  • Index your local repository
cd ~/portfile
portindex -f

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

There are effectively four tasks needed to produce the App bundle. First, Octave and all its build and run-time dependencies must be extracted from the MacPorts installation. Second a App bundle template for running a shell script is required. This may be done using the MacOS X developer tool, Platypus. Third, the shell script which the App bundle runs is needed. This script will be used to launch the MacOS X Terminal app. This script is referred to as the App's shell script. Finally, a script for setting up the shell environment for Octave and running Octave is required. This script is referred to as the Octave shell script.

Produce a DMG for Octave 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 the 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 Platypus to produce a template for the App bundle

To creating an application bundle for MacOS X the utility, Platypus, is used. Platypus is a developer tool for the Mac OS X operating system which is intended to create native Mac OS X applications from interpreted scripts such as shell scripts or Perl, Ruby and Python programs.

A shell script intended to launch a MacOS X Terminal and run Octave will be used as the basis for the MacOS X App bundle.

  • Run the Platypus application.
  • Import Octave's Icon.
  • Set the "Script Type" to "Shell"
  • Specify the "Script Path".
    • Click on the "Select" button and select the App shell script used to launch the Terminal app.
  • Set the "Output" to "None".
  • Specify App Name (Octave-3.7.0).
  • Click the "Create" button.
  • Save the App bundle template to the location of your choice.

Populate the App Bundle

  • Save the original MacPorts installation.
    • sudo mv /opt /opt-save
  • Install the MacPorts Octave DMG. This will create a new /opt directory containing Octave and all its build and run-time dependencies.
  • Place the Octave shell script in the same directory as the App bundle template created using Platypus.
  • Populare the App bundle by running the script below from the directory containing the Platypus App bundle template and the Octave shell script.
#! /bin/sh
VERSION=3.7.0
APP=Octave
FULLAPP="${APP}-${VERSION}.app"
MACPORTS_PREFIX="/opt/local/"
cp -pRf ${MACPORTS_PREFIX} ${FULLAPP}/Contents/Resources/.
rm ${FULLAPP}/Contents/Resources/bin/octave
cp octave ${FULLAPP}/Contents/Resources/bin/.
mkdir ${FULLAPP}/Contents/Resources/Applications
cp /Applications/MacPorts/AquaTerm.app ${FULLAPP}/Contents/Resources/Applications/.
  • Restore the original MacPorts installation.
sudo rm -r /opt
sudo mv /opt-save /opt

Problems and Restrictions of the App Bundle

  • The path to the App bundle must not contain spaces
  • Conflicts with other Aquaterm Installations
  • No Universal Builds
  • Limited MacOS Compatibility
  • Icon needs improvement