OS X Lion Macports

OS X Lion Macports, Can I upgrade from Snow Leopard?

With the new release of Apple Mac OS X Lion, there are a lot of changes on the kernel and backends. Therefore I don’t think it’s possible to do port upgrade on Macports in order to upgrade your existing or installed ports in OS X Snow Leopard.

OS X Lion Macports

I have tried several times to upgrade ports previously installed in Snow Leopard, unfortunately no luck to getting it works in OS X Lion Macports, some library couldn’t load and some library cannot be found. Failed miserably with tons of error messages.

I have decided to re-install, or rather clean install Macports on my newly installed Mac OS X Lion.

OS X Lion Macports with XCode 4.1

Before installing OS X Lion Macports, you need to download and install latest Xcode 4.1 which designs for Mac OS X Lion. Xcode 4.1 can be downloaded at App Store, the file size is around 2.96GB, it might take some time for user who has slow internet access.

The existing Xcode on your Snow Leopard will not support latest version of Macports.

OS X Lion Macports

OS X Lion Macports, Before Clean Install

Before proceed with OS X Lion Macports clean install, I suggest you do a few things as I listed below.

1. Dump current installed packages database. Run “port installed > installed.ports.log” to keep a list of packages currently install on your Macports. Which later you will need to re-install all the packages. Below is the sample of my current installed packages.


  apache2 @2.2.19_0+preforkmpm (active)
  apr @1.4.5_1 (active)
  apr-util @1.3.12_0 (active)
  atk @1.32.0_0 (active)
  autoconf @2.68_2 (active)
  autoconf213 @2.13_1 (active)
  automake @1.11.1_0 (active)
  axel @2.4_0 (active)
  bison @2.5_0 (active)
  bzip2 @1.0.6_0 (active)
  c-ares @1.7.4_0 (active)
  cacti @0.8.7g_1 (active)
  cairo @1.10.2_3 (active)
  ctags @5.8_0 (active)
  curl @7.21.7_0+ssl (active)
  curl-ca-bundle @7.21.7_0 (active)
  cyrus-sasl2 @2.1.23_3+kerberos (active)
  db46 @4.6.21_6 (active)
  dbus @1.4.12_0 (active)
  dia @0.97.1_2 (active)
  docbook-xml @5.0_0 (active)

2. Dump or backup your database data such as PostgreSQL and MySQL.

3. Backup your old directory, which is “/opt/local”, rename it to “/opt/local-snowleopard”, this is to keep all your data in order to migrate over to newly installed Macports later on.

OS X Lion Macports Clean Install

Macports team has not release latest Macports package/installer for OS X Lion (as when I written this post). If the official download is not available for OS X Lion, you need to install it from latest subversion built.

Create a new directory to check out latest subversion built for OS X Lion Macports


# mkdir /opt/lion-macports 
# cd /opt/lion-macports
# svn co http://svn.macports.org/repository/macports/trunk

This will download the latest build of subversion, next we will proceed with OS X Lion Macports installation


# cd /opt/lion-macports/trunk/base
# ./configure --enable-readline
# make
# sudo make install
# make distclean 

After installation, make sure OS X Lion Macports binary is exported into your environment path, existing user should not have this problem, for new user, edit your environment path as show below; Search for export path line


#sudo vi ~/.bash_profile
export PATH=/opt/local/bin:/opt/local/sbin:$PATH

Add /opt/local/bin and /opt/local/sbin into export PATH.

After environment path has been configured, get the latest update port tree and your are done


# sudo port -d selfupdate 

OS X Lion Macports. Install package

You are basically you done Macports installation on Mac OS X Lion. Refer to your dump file I mentioned earlier “installed.ports.log”, re-install all the packages or the packages you need in newly installed OS X Lion Macports

I know it’s a little PITA (Pain In the Ass), but so far this is the only solution which can fix my problem by migrating into OS X Lion Macports.

OS X Lion Macports. Re-install MySQL

This is an example how I reinstall and load MySQL database which previously installed on Snow Leopard Macports into OS X Lion Macports.

1. Firstly, clean install MySQL5.1 database


# sudo port -v install mysql5-server 

You might see error with plist conflict



Error: Target org.macports.activate returned: Image error: /Library/LaunchDaemons/org.macports.mysql5.plist already exists and does not belong to a registered port.  Unable to activate port mysql5-server. Use 'port -f activate mysql5-server' to force the activation.
Warning: the following items did not execute (for mysql5-server): org.macports.activate
Log for mysql5-server is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_databases_mysql5-server/mysql5-server/main.log
Error: Status 1 encountered during processing.
To report a bug, see 

To fix it, force plist replacement.


# sudo port -f activate mysql5-server
--->  Computing dependencies for mysql5-server
--->  Activating mysql5-server @5.1.57_0
Warning: File /Library/LaunchDaemons/org.macports.mysql5.plist already exists.  Moving to: /Library/LaunchDaemons/org.macports.mysql5.plist.mp_1311315120.
--->  Cleaning mysql5-server

2. Move database into data directory, it required root privileges


# sudo su 
# cp -RPa /opt/local-snowleopard/var/db/mysql5 /opt/local/var/db/

3. Start MySQL Server


# sudo /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper start

Please also share how you migrate existing Macports into OS X Lion Macports.