Create curl precompiled binaries with Macports

Create curl precompiled binaries with Macports

Sat 10 January 2015

After the upgrade to osx109 some of the features I used with curl suddenly stopped working. My options was deprecated somehow, so how should a case like this be handled?

You roll your own version of course. Configured and compiled from scratch with the options you need.

Ensure that the build environment is ready

Step 1 - Xcode install

$ xcode-select --install

Step 2 - Xcode license agreement

$ sudo xcodebuild

Build the current version of a port

Step 1 - Install the build environment, that is Macport

Its very important that the build environment is in a unique path, that is NOT in /opt/local. If you use /opt/local your build will conflict with the standard installation of Macports on the machines you are installing your prebuilt version of CURL on.

$ cd ~/Downloads
$ curl -L http://downloads.sourceforge.net/project/macports/MacPorts/2.3.4/MacPorts-2.3.4.tar.gz -o ~/Downloads/MacPorts.tar.gz
$ tar xfv MacPorts.tar.gz
$ cd MacPorts-2.3.4
$ export PATH=/bin:/sbin:/usr/bin:/usr/sbin
$ export MP_PREFIX=/opt/uib/curl
$ ./configure --prefix=$MP_PREFIX --with-applications-dir=$MP_PREFIX/Applications
$ make
$ sudo make install
$ export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/opt/uib/curl/bin
$ sudo sed -ie 's/#startupitem_install[[:blank:]]yes/startupitem_install    no/g' $MP_PREFIX/etc/macports/macports.conf
    

ensure that you have the following in the config file

$ cat $MP_PREFIX/etc/macports/macports.conf | grep startupitem_install
startupitem_install no

Step 2 - Install auxiliary tools

Download "Auxiliary Tools for Xcode - Late July 2012" and install Packagemaker from the bundle.

Step 3 - Build the port

$ sudo port -v selfupdate
$ sudo port -d mpkg curl
    

You will now find the distributable .mpkg file in:

/opt/uib/curl/var/macports/build/_opt_curl_var_macports_sources_rsync.macports.org_release_tarballs_ports_net_curl/curl/work/curl-7.39.0.mpkg

Build an older version of a port

Step 1 - Locate and download the portfile for the version we want to install

Portfiles can be found at: https://trac.macports.org/browser/trunk/dports

curl is located in the net/curl folder, so enter it by clicking on it.

- Click on the revision log to see what commit we want to use as our portfile.
- Download the "Original format" of the files and save them somewhere on your disk. If there is a "files" folder, grab the files inside that too.
- If you dont want to keep the portfiles after you have installed the curl version, you can save them in your tmp folder, i.e /tmp/curl and /tmp/curl/files. Its important that the port process can access the files, so don't hide them in your homefolder where only you can access them.

Step 2 - Build your port

Export path to the correct version of port:

$ export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/opt/uib/curl/bin
    

Enter the folder where the portfile(s) are located:

$ cd /tmp/curl
    

Make the port:

$ sudo port -d mpkg -F Portfile
    

You will now fint the distributable .mpkg file in:

/opt/uib/curl/var/macports/build/_private_tmp_curl_7_30/curl/work/curl-7.30.0.mpkg

Tagged as : various