Frequently Asked Questions

« Previous
How do I change the Mac computer name, host name and NetBIOS-name?
Next «
How do I install the OCS Inventory agent for Linux?

59. How do I create binary packages with MacPorts?

Let us assume the package we want to build is ImageMagick and your username is myusername.

Make a source install of MacPorts into /opt/mports

Read more about Source install.

$ sudo mkdir -p /opt/mports $ cd /opt/mports $ sudo chown myusername . $ git clone https://github.com/macports/macports-base.git $ git checkout v2.4.2

Install a copy of MacPorts into /opt/ImageMagick

Read more about Install Multiple MacPorts Copies.

$ export PATH=/bin:/sbin:/usr/bin:/usr/sbin $ MP_PREFIX=/opt/ImageMagick $ cd /opt/mports/macports-base $ ./configure --prefix=$MP_PREFIX --with-applications-dir=$MP_PREFIX/Applications $ make $ sudo make install

Build ImageMagick binary port meta package

Read more about MacPorts Port Binaries.

$ sudo $MP_PREFIX/bin/port selfupdate ---> Updating MacPorts base sources using rsync MacPorts base version 2.4.2 installed, MacPorts base version 2.4.2 downloaded. ---> Updating the ports tree ---> MacPorts base is already the latest version The ports tree has been updated. To upgrade your installed ports, you should run port upgrade outdated $ sudo $MP_PREFIX/bin/port mdmg ImageMagick ---> Computing dependencies for ImageMagick The following dependencies will be installed: Xft2 autoconf autoconf-archive automake bison ... xpm xrender xz zlib Continue? [Y/n]: Y ---> Fetching distfiles for gperf ---> Attempting to fetch gperf-3.1.tar.gz from ftp://ftp.funet.fi/pub/gnu/prep/gperf ... ... $ ls -lah $(find $MP_PREFIX -name ImageMagick-6.9.9-26.dmg) -rw-r--r--@ 1 root admin 166M Mar 22 14:38 /opt/ImageMagick/var/macports/build/_opt_ImageMagick_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_graphics_ImageMagick/ImageMagick/work/ImageMagick-6.9.9-26.dmg $ _

The package is located as above. This package can be installed on other computers. All files will reside at /opt/ImageMagick.

How to install the package we just created

  1. In this case we created a DMG with a MPKG.
  2. Open the DMG. But on another computer...

    $ open /opt/ImageMagick/var/macports/build/_opt_ImageMagick_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_graphics_ImageMagick/ImageMagick/work/ImageMagick-6.9.9-26.dmg

  3. Open the MPKG.

  4. Install the package.

  5. Done!

Everything at once

This will build two self-contained meta packages for gimp and ImageMagick and place them in the home directory.

for APP in gimp ImageMagick ; do export PATH=/bin:/sbin:/usr/bin:/usr/sbin export MP_PREFIX=/opt/$APP export MP_INST=/opt/MacPorts-$APP export $PORT=$MP_PREFIX/bin/port sudo mkdir -p $MP_INST && pushd $MP_INST && sudo chown $(whoami) . && git clone https://github.com/macports/macports-base.git && pushd $MP_INST/macports-base && git checkout v2.4.2 && ./configure --prefix=$MP_PREFIX --with-applications-dir=$MP_PREFIX/Applications && make && sudo make install && sudo $PORT selfupdate && sudo $PORT -N mpkg $APP && popd && popd cp -av $(find $MP_PREFIX/var/macports/build/ | grep 'mpkg$') $HOME/. done

This entry macports was last modified 2018-06-04

This documentation is covered by GNU Free Documentation License.