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

Jump to navigation Jump to search
Remove categories to avoid likeliness of getting here.
(→‎Create an Installer DMG: begin section describing the use of dmgCreator to produce a MacOSX DMG based installer)
(Remove categories to avoid likeliness of getting here.)
 
(43 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Warning|This page is outdated (October 2019).  For more recent information, see [[Octave for macOS]].}}
== Caveats ==
Since the initial success with producing a bundle, two things have changed on the Macports end.
* gcc-4.7 must be used, as some dependencies are no longer supported by gcc-4.5. To look for ports using a <code>gcc45</code> variant, type <code>port rdeps gcc45</code> at the terminal's command line.
* The <code>sudo port mdmg octave-devel @3.6.4+atlas+docs+fltk+gcc47</code> command fails when bundling the <code>xorg-libx11</code> port.  Review the output of the command <code>port rdeps octave-devel @3.6.4+atlas+fltk+gcc47-x11+no_x11-metis</code> to identify the ports whose variants must be modified to avoid <code>gcc45</code> and <code>xorg-libx11</code>.  There is one dependency (<code>Transfig</code>) for which <code>x11</code> is not optional.  To resolve this, the <code>octave-devel</code> Portfile must be modified and the <code>Transfig</code> run-time dependency removed. This means that Xfig output is not available using Octave's <code>print()</code> function/command.
* While editing the Portfile for <code>octave-devel</code>, the references to <code>metis</code> should also be removed to avoid a GPL violation.
* Once the dependencies are resolved, the DMG may be created by <code>sudo port mdmg octave-devel @3.6.4+atlas+fltk+gcc47-x11+no_x11-metis</code>.
==Install MacPorts==
==Install MacPorts==


Line 9: Line 19:
* 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. For the remainder of this page, it is assume a local portfile is being used and that the port name is {{Codeline|<nowiki>octave-local</nowiki>}}.
MacPorts has historically been rather good a maintaining their Octave portfiles. However, there are times when the maintainers 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. For the remainder of this page, it is assume a local portfile is being used and that the port name is {{Codeline|<nowiki>octave-local</nowiki>}}.


===Install an Octave Port===
===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 [http://guide.macports.org/chunked/development.local-repositories.html local portfile repository be created] and the local portfile placed there.
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. In order to eliminate the Metis dependency, a local portfile may be used, and edited to remove metis. 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 <code>print</code> 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].  A third motivation for a local portfile is to provide additional flexibility in resolving problems with creating an Octave DMG using the <code>port mdmg ...</code> command.  For macports 2.1.3, having the <code>xorg-libx11</code> as a dependency for Octave has been found to cause the <code>port mdmg octave-local ...</code> command to fail. The <code>xorg-libx11</code> dependency may be avoided by specifying <code>-x11+no_x11-docs</code> as variants and by dropping the dependence to <code>transfig</code> (which has <code>xpm</code> as a dependency and <code>xpm</code> depends upon several <code>xorg-*</code> ports.


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]. A [[Prototype MacPorts PortFile|prototype portfile]] which does not depend upon METIS and does depend upon epstool, pstoedit, and transfig has been prepared.
A [[Prototype MacPorts PortFile|prototype portfile]] has been prepared, which does not depend upon METIS and does depend upon <code>epstool</code>, and <code>pstoedit</code> (there is no <code>transfig</code> dependency since it generates an <code>xorg-libx11</code> dependency). After [http://guide.macports.org/chunked/development.local-repositories.html creating a local portfile repository] an Octave portfile may be added to the local repository using the commands below.
 
After [http://guide.macports.org/chunked/development.local-repositories.html creating a local portfile repository] an Octave portfile may be added to the local repository using the commands below.
  <nowiki>mkdir -p ~/ports/math/octave-local
  <nowiki>mkdir -p ~/ports/math/octave-local
cp ~/Desktop/portfile ~/ports/math/octave-local</nowiki>
cp ~/Desktop/portfile ~/ports/math/octave-local</nowiki>
This assumes the Octave portfile had been placed on the users Desktop, and that the local portfile repository is located in the users home folder and named {{Codeline|<nowiki>ports</nowiki>}}. After adding the portfile, the local repository must be indexed for MacPorts to recognize it.
This assumes the Octave portfile had been placed on the user's Desktop, and that the local portfile repository is located in the users home folder and named <code>ports</code>. After adding the portfile, the local repository must be indexed for MacPorts to recognize it.
  <nowiki>cd ~/ports
  <nowiki>cd ~/ports
portindex -f</nowiki>
portindex -f</nowiki>
Once indexed the local Octave port may be installed.
Once indexed the local Octave port may be installed.
  <nowiki>sudo port install octave-local +atlas+gcc45</nowiki>
  <nowiki>sudo port install octave-local @3.6.4+atlas+fltk+gcc47</nowiki>


The use of the {{Codeline|+atlas}} variant is encouraged as bugs exist for Apple's {{Codeline|accelerate}} framework in both MacOS 10.6 and 10.7.  Octave's developers have included a fix for MacOS 10.6, but the fix does not work for MacOS 10.7.  There is some commentary on this in various developers discussion forums.  For example, see [https://github.com/mxcl/homebrew/issues/6649 this Homebrew thread (Octave 3.4 fails on lion)], [https://stat.ethz.ch/pipermail/r-sig-mac/2011-September/008564.html this R-Sig-Mac thread (R 2.13.1-patched, vecLib problem on Lion)], and [http://list.coin-or.org/pipermail/ipopt/2011-October/002610.html the COIN-OR thread (Ipopt - problems on OS X 10.7 Lion)].  Use of Apple's {{Codeline|accelerate}} framework should also be avoided for {{Codeline|arpack}} and {{Codeline|qrupdate}}.  To install the recommended variants, use the {{Codeline|port}} commands below.
The use of the <code>+atlas</code> variant is encouraged as bugs exist for Apple's accelerate framework in both MacOS 10.6 and 10.7.  Octave's developers have included a fix for MacOS 10.6, but the fix does not work for MacOS 10.7.  There is some commentary on this in various developers discussion forums.  For example, see [https://github.com/mxcl/homebrew/issues/6649 this Homebrew thread (Octave 3.4 fails on lion)], [https://stat.ethz.ch/pipermail/r-sig-mac/2011-September/008564.html this R-Sig-Mac thread (R 2.13.1-patched, vecLib problem on Lion)], and [http://list.coin-or.org/pipermail/ipopt/2011-October/002610.html the COIN-OR thread (Ipopt - problems on OS X 10.7 Lion)].  Use of Apple's accelerate framework should also be avoided for <code>arpack</code> and <code>qrupdate</code>.  To install the recommended variants, use the <code>port</code> commands below.


  <nowiki>port install arpack +atlas+gcc45
  <nowiki>port install arpack +atlas+gcc47
port install qrupdate +atlas+gcc45</nowiki>
port install qrupdate +atlas+gcc47</nowiki>


As a precaution against unexpected problems and a bloated App bundle, using consistent variants for Octave and its dependents is suggested.  For example, when using {{Codeline|+atlas}} make sure none of the dependents are using {{Codeline|+accelarate}}. Also, make sure no dependents are using the {{Codeline|+universal}} variant.  Using the {{Codeline|+gcc45}} variant is also recommended as all of Octave's dependents have a {{Codeline|+gcc45}} variant.  At the very least, following these suggestions will reduce the size of the bundle.  The name of Octave's dependent ports may be determined by the command below.
As a precaution against unexpected problems and a bloated App bundle, using consistent variants for Octave and its dependents is suggested.  For example, when using <code>+atlas</code> make sure none of the dependents are using <code>+accelarate</code>. Also, make sure no dependents are using the <code>+universal</code> variant.  Using the <code>+gcc47</code> variant is also recommended as all of Octave's dependents have a <code>+gcc47</code> variant.  At the very least, following these suggestions will reduce the size of the bundle.  The name of Octave's dependent ports may be determined by the command below.


  <nowiki>port deps octave-local</nowiki>
  <nowiki>port rdeps octave-local</nowiki>


The installed variants for each port may be determined by the command below.  Be sure to replace "<portname>" with the name of the port.
The installed variants for each port may be determined by the command below.  Be sure to replace "<portname>" with the name of the port.
Line 39: Line 47:
  <nowiki>port installed <portname></nowiki>
  <nowiki>port installed <portname></nowiki>


Once an Octave port is installed the command below may be used to determine / verify the version and variants of {{Codeline|<nowiki>octave-local</nowiki>}} which are installed.
Once an Octave port is installed the command below may be used to determine / verify the version and variants of <code>octave-local</code> which are installed.


  <nowiki>port installed octave-local</nowiki>
  <nowiki>port installed octave-local</nowiki>
===Install Dependencies with Specific Variants===
There may be problems bundling some dependencies.  For example, bundling the <code>xorg-libx11</code> port may fail.  To alleviate this problem (or similar ones), the problematic port can be avoided as a dependency.  The command used to produce the octave-local DMG, <code>port mdmg octave-local +variant1+variant2+etc</code>, applies the listed variants to each of the dependencies.  Therefore, it is necessary to provide a proper aggregate list of dependencies.  For Octave 3.6.4, the list below were sufficient.
<pre>sudo port mdmg octave-devel @3.6.4+atlas+fltk+gcc47-x11+no_x11-metis+llvm32+ssl+qt</pre>
<span style="color: green;"> If run from a fresh macports installation (i.e. no ports have yet been installed), then this command should complete with no errors.</span>  If ports have already been installed, then errors during the execution of this command are likely and may be resolved by modifying the variant(s) of installed packages, and/or modifying the list of variants used to produce the <code>octave-local</code> DMG.  <span style="color: red;">One of Octave's dependencies, <code>transfig</code>, requires port <code>xpm</code>, which requires many xorg ports that may cause the <code>port mdmg ...</code> command to fail.  To alleviate this problem, the <code>transfig</code> port can be eliminated as a run-time dependency for Octave </span> (can the <code>transfig</code> portfile be modified to eliminate the <code>xpm</code> dependency?).


==Create the MacOS X App Bundle==
==Create the MacOS X App Bundle==
Line 51: Line 67:
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.


  <nowiki>sudo port mdmg octave-local</nowiki>
  <nowiki>sudo port mdmg octave-devel @3.6.4+atlas+fltk+gcc47-x11+no_x11-metis+llvm32+ssl+qt</nowiki>
 
In the event errors such as the one below are encountered, the ports implicated (<code> gtk2 </code> in this case) must be clean prior to creating the dmg.
 
<nowiki>
Error: Requested variants "+quartz" do not match original selection "".
Please use the same variants again, perform 'port clean gtk2' or specify the force option (-f).
Error: org.macports.mpkg for port octave-local returned: Processing of port gtk2 failed</nowiki>
 
Be sure to clean each of the problematic ports prior to each attempt to create the dmg.


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.
<nowiki>sudo port clean gtk2</nowiki>


<nowiki>sudo port mdmg octave-local @<version>+variant1+variant2</nowiki>
The ports <code>cctools</code> and <code>curl</code> consistently need to be cleaned prior to the <code>port mdmg octave-local ...</code> command.  The reason for this is not understood (yet), but one hint is seen during the compilation of the DMG.


The DMG will be placed in the port's {{Codeline|<nowiki>work</nowiki>}} directory.  If a local portfile is used, a symbolic link to the {{Codeline|<nowiki>work</nowiki>}} directory will be placed in the directory containing the portfile. In this instance the DMG can be found in {{Codeline|<nowiki>~/ports/math/octave-local/work</nowiki>}}.
<pre>Portfile changed since last build; discarding previous state.</pre>


The DMG produced using the [http://www.octave.org/wiki/index.php?title=Prototype_MacPorts_PortFile prototype portfile's] does not include everything needed for Octave.  Both {{Codeline|macros.texi}}, {{Codeline|octave.info}}, and the {{Codeline|octave.info-#}} files are missing.  Until the cause for these missing files is identified and resolved, they will have to be copied manually to the App bundle.
The DMG will be placed in the port's <code>work</code> directory.  If a local portfile is used, a symbolic link to the <code>work</code> directory will be placed in the directory containing the portfile.  In this instance the DMG can be found in <code>~/ports/math/octave-local/work</code>.
 
The DMG produced using the [http://www.octave.org/wiki/index.php?title=Prototype_MacPorts_PortFile prototype portfile's] does not include everything needed for Octave.  Both <code>macros.texi</code>, <code>octave.info</code>, and the <code>octave.info-#</code> files are missing.  Until the cause for these missing files is identified and resolved, they will have to be copied manually to the App bundle (one possibility is that the <code>+docs</code> variant is not used.  Including the <code>+docs</code> variant would bundle <code>texlive</code> port as well as <code>xorg-libx11</code> and several other <code>xorg-*</code> ports.


===Create an Application Template for Octave===
===Create an Application Template for Octave===
Line 269: Line 296:
List of what can be done to improve the MacOS X App bundle.
List of what can be done to improve the MacOS X App bundle.
* The {{Codeline|macros.texi}} file doesn't install properly.  It should be in {{Codeline|share/octave/3.7.0+/etc}}, but doesn't show up.
* The {{Codeline|macros.texi}} file doesn't install properly.  It should be in {{Codeline|share/octave/3.7.0+/etc}}, but doesn't show up.
* [[Enable "linestyle" functionality for Gnuplot's x11 terminal]]
* Test the ability to compile mex-files and oct-files.
* Test the ability to compile mex-files and oct-files.
** Necessary changes
** Necessary changes
Line 274: Line 302:
*** Same for octave_confgure-3.7.0+
*** Same for octave_confgure-3.7.0+
*** Over-ride the built-in octave_configure_info and use an m-file version that replaces the original MacPorts prefix with the OCTAVE_HOME environment variable set by the bundle.
*** Over-ride the built-in octave_configure_info and use an m-file version that replaces the original MacPorts prefix with the OCTAVE_HOME environment variable set by the bundle.
*** The bundled mkoctfile references the gcc4.4 libraries instead of the gcc4.5 libraries that are actually bundled.  This needs to be corrected.
*** The bundled mkoctfile references the gcc4.4 libraries instead of the gcc4.7 libraries that are actually bundled.  This needs to be corrected.
** With the above changes [http://www.gnu.org/software/octave/doc/interpreter/Getting-Started-with-Oct_002dFiles.html {{Codeline|mkoctfile helloworld.cc}}] fails with the error below.  This is likely due to the {{Codeline|Octave-3.7.0+.app/Contents/Resources/bin/octave}} script over-riding the build environment variables normally set by {{Codeline|mkoctfile}}.
** With the above changes [http://www.gnu.org/software/octave/doc/interpreter/Getting-Started-with-Oct_002dFiles.html {{Codeline|mkoctfile helloworld.cc}}] fails with the error below.  This is likely due to the {{Codeline|Octave-3.7.0+.app/Contents/Resources/bin/octave}} script over-riding the build environment variables normally set by {{Codeline|mkoctfile}}.
*** Rely on {{Codeline|mkoctfile}} to setup the oct-file build environment (i.e. don't set any of it up in the {{Codeline|.../Octave-3.7.0+.app/Contents/Resources/bin/octave}} script.
*** Rely on {{Codeline|mkoctfile}} to setup the oct-file build environment (i.e. don't set any of it up in the {{Codeline|.../Octave-3.7.0+.app/Contents/Resources/bin/octave}} script.
Line 283: Line 311:
collect2: ld returned 1 exit status
collect2: ld returned 1 exit status


"/Applications/Octave-3.7.0+.app/Contents/Resources/bin/g++-mp-4.5" \
"/Applications/Octave-3.7.0+.app/Contents/Resources/bin/g++-mp-4.7" \
-c -I"/Applications/Octave-3.7.0+.app/Contents/Resources/include/curl" \
-c -I"/Applications/Octave-3.7.0+.app/Contents/Resources/include/curl" \
-I"/Applications/Octave-3.7.0+.app/Contents/Resources/include/readline" -fPIC \
-I"/Applications/Octave-3.7.0+.app/Contents/Resources/include/readline" -fPIC \
Line 293: Line 321:
helloworld.cc -o helloworld.o
helloworld.cc -o helloworld.o


"/Applications/Octave-3.7.0+.app/Contents/Resources/bin/g++-mp-4.5" -bundle -bundle_loader \
"/Applications/Octave-3.7.0+.app/Contents/Resources/bin/g++-mp-4.7" -bundle -bundle_loader \
"/Applications/Octave-3.7.0+.app/Contents/Resources/bin/octave-3.7.0+" -o helloworld.oct helloworld.o \
"/Applications/Octave-3.7.0+.app/Contents/Resources/bin/octave-3.7.0+" -o helloworld.oct helloworld.o \
-L"/Applications/Octave-3.7.0+.app/Contents/Resources/lib/octave/3.7.0+" \
-L"/Applications/Octave-3.7.0+.app/Contents/Resources/lib/octave/3.7.0+" \
-L"/Applications/Octave-3.7.0+.app/Contents/Resources/lib" -loctinterp -loctave -lcruft \
-L"/Applications/Octave-3.7.0+.app/Contents/Resources/lib" -loctinterp -loctave -lcruft \
"/Applications/Octave-3.7.0+.app/Contents/Resources/lib/gcc45/libstdc++.6.dylib"</nowiki>
"/Applications/Octave-3.7.0+.app/Contents/Resources/lib/gcc47/libstdc++.6.dylib"</nowiki>
* Should the contents of the la-files, in {{Codeline|Octave-3.7.0+.app/Resources/lib}}, be changed to reflect to use the {{Codeline|@executable_path}} token.
* Should the contents of the la-files, in {{Codeline|Octave-3.7.0+.app/Resources/lib}}, be changed to reflect to use the {{Codeline|@executable_path}} token.
** These files are from libtool.  For limited development, such as building oct-files and mex-files, are they needed at all?
** These files are from libtool.  For limited development, such as building oct-files and mex-files, are they needed at all?
Line 303: Line 331:
** This will allow for a fully automatic build of an App bundle from a shell script.
** This will allow for a fully automatic build of an App bundle from a shell script.
* Also use an AppleScript to record the creation of a MacOS X Octave icon.
* Also use an AppleScript to record the creation of a MacOS X Octave icon.
[[Category:Mac]]
 
[[Category:Outdated pages]]

Navigation menu