Difference between revisions of "Create a MacOS X App Bundle Using MacPorts"

From Octave
Jump to navigation Jump to search
(Switch to using Platypus to create the app bundle's template)
(streamline and generally improve the content)
Line 8: Line 8:
 
* Follow [http://www.macports.org/install.php MacPorts' installation instructions].
 
* Follow [http://www.macports.org/install.php MacPorts' installation instructions].
 
* MacPorts has good support for Octave. A list of what MacPorts has available for Octave is [http://www.macports.org/ports.php?by=name&substr=octave here]. To install the most recent version of Octave, type {{Codeline|<nowiki>sudo port install octave-devel</nowiki>}} 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 good support for Octave. A list of what MacPorts has available for Octave is [http://www.macports.org/ports.php?by=name&substr=octave here]. To install the most recent version of Octave, type {{Codeline|<nowiki>sudo port install octave-devel</nowiki>}} 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 [http://www.macports.org/ports.php?by=name&substr=octave-devel octave-devel] port isn't current, it will be necessary to produce a local portfile.
  
 
==Install an Octave Port==
 
==Install an Octave Port==
Line 19: Line 21:
 
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 3.6.x is {{Codeline|<nowiki>octave36</nowiki>}}.
  
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.
+
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].
  
 
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.
Line 27: Line 29:
 
=Create the MacOS X App Bundle=
 
=Create the MacOS X App Bundle=
  
==Produce a DMG of the Octave port and its dependencies==
+
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 [http://en.wikipedia.org/wiki/Terminal_(OS_X) 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 [http://guide.macports.org/index.html#using.binaries.binary-packages 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.
 
MacPorts provides a feature for [http://guide.macports.org/index.html#using.binaries.binary-packages 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.
Line 38: Line 42:
  
 
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.
 
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.
 
==Down load the Boilerplate from Savannah==
 
 
* Resources/Applications/AquaTerm.app
 
* Resources/bin/octave
 
* Resources/script
 
  
 
==Use Platypus to produce a template for the App bundle==
 
==Use Platypus to produce a template for the App bundle==
Line 49: Line 47:
 
To creating an application bundle for MacOS X the utility, [http://sveinbjorn.org/platypus 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.
 
To creating an application bundle for MacOS X the utility, [http://sveinbjorn.org/platypus 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 setup and run Octave will be used as the basis for the MacOS X App bundle.
+
A shell script intended to launch a [http://en.wikipedia.org/wiki/Terminal_(OS_X) MacOS X Terminal] and run Octave will be used as the basis for the MacOS X App bundle.
 
 
# Run Platypus
 
# Import Octave's Icon
 
# Set the "Script Type" to "Shell"
 
# Specify Script Path
 
#* Click on the "Select" button and select the shell script used to launch the Terminal app, {{Codeline|<nowiki>script</nowiki>}}
 
# Set "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.
 
 
 
==Copy the contents of the MacPorts DMG to the App bundle Template==
 
 
 
# Save the original MacPorts installation.
 
#* {{Codeline|<nowiki>sudo mv /opt /opt-save</nowiki>}}
 
# Install the DMG.  This will create a new {{Codeline|<nowiki>/opt</nowiki>}} directory.
 
# Move the the {{Codeline|<nowiki>/opt</nowiki>}} directory to the same location where {{Codeline|<nowiki>Boilerplate</nowiki>}} directory was placed.
 
# Restore the MacPorts installation
 
#* {{Codeline|<nowiki>sudo rm -r /opt</nowiki>}}
 
#* {{Codeline|<nowiki>sudo mv /opt-save /opt</nowiki>}}
 
  
==Populate the 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 [[MacOS_X_App_Launcher_Script|App shell script]] used to launch the Terminal app, {{Codeline|<nowiki>script</nowiki>}}.
 +
* 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.
  
Use the script below to copy the contents of the Boilerplate and opt/local into the App bundle.  This script assumes the App bundle is named {{Codeline|<nowiki>Octave-3.7.0.app</nowiki>}}.
+
==Populate the App Bundle==
  
 +
* Save the original MacPorts installation.
 +
** {{Codeline|<nowiki>sudo mv /opt /opt-save</nowiki>}}
 +
* Install the MacPorts Octave DMG. This will create a new {{Codeline|<nowiki>/opt</nowiki>}} directory containing Octave and all its build and run-time dependencies.
 +
* Place the [[MacOS_X_App_Octave_Shell_Script| 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 [[MacOS_X_App_Octave_Shell_Script| Octave shell script]].
 
  <nowiki>#! /bin/sh
 
  <nowiki>#! /bin/sh
 
VERSION=3.7.0
 
VERSION=3.7.0
 
APP=Octave
 
APP=Octave
 
FULLAPP="${APP}-${VERSION}.app"
 
FULLAPP="${APP}-${VERSION}.app"
MACPORTS_PREFIX="./opt/local/"
+
MACPORTS_PREFIX="/opt/local/"
 
cp -pRf ${MACPORTS_PREFIX} ${FULLAPP}/Contents/Resources/.
 
cp -pRf ${MACPORTS_PREFIX} ${FULLAPP}/Contents/Resources/.
 
rm ${FULLAPP}/Contents/Resources/bin/octave
 
rm ${FULLAPP}/Contents/Resources/bin/octave
cp -pRf Boilerplate/bin/ ${FULLAPP}/Contents/Resources/bin/.
+
cp octave ${FULLAPP}/Contents/Resources/bin/.
cp -pRf Boilerplate/Applications ${FULLAPP}/Contents/Resources/.</nowiki>  
+
mkdir ${FULLAPP}/Contents/Resources/Applications
 +
cp /Applications/MacPorts/AquaTerm.app ${FULLAPP}/Contents/Resources/Applications/.</nowiki>
 +
* Restore the original MacPorts installation.
 +
<nowiki>sudo rm -r /opt
 +
sudo mv /opt-save /opt</nowiki>
  
 
=Problems and Restrictions of the App Bundle=
 
=Problems and Restrictions of the App Bundle=

Revision as of 08:23, 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 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. 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.

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, script.
  • 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