JSON Adapter/Release Builds

Building JSON-enabled Adapters

How to produce binaries for a release (and release testing).

Building for release is more involved than building for your own machine, as the resulting binaries must be compatible with a large number of distributions, versions and hardware. The range of supported configurations is mainly dictated by the combinations which pEp integrators still support.

Preparing the build environment

macOS Build

The macOS Build makes use of a dedicated instance of MacPorts, installed to the prefix /opt/MacPorts/10.9. But before starting, the legacy SDK needs to be installed to the system.

Obtain and install a copy of the Apple OS X SDK 10.9

The following copy has been obtained by the procedure documented below.

Apple OS X SDK 10.9 (GPG signature)

Extracting Apple OS X SDK 10.9 from original Xcode

We retrieved the Mac OS X 10.9 SDK by resetting a physical Apple MacBook Pro to factory settings, installing macOS 10.11 and then Xcode from the App Store.

Install MacPorts

Make sure to install the alternate sw_vers script to /opt/MacPorts/shims/sw_vers and make it executable.

Then obtain MacPorts source (tested with MacPorts 2.6.2) and unpack to /opt/MacPorts/src/MacPorts-2.6.2.

#!/bin/sh
# sw_vers shim script
if [ x$1 == x-productVersion ] ; then
	echo "$MACOSX_DEPLOYMENT_TARGET"
	exit
elif [ -n "$1" ] ; then
	/usr/bin/sw_vers "$@"
	exit
fi
MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-10.9.1}
/usr/bin/sw_vers | while read KEY VAL ; do
	case $KEY in
		"ProductVersion:") /bin/echo "ProductVersion:"$'\t'"$MACOSX_DEPLOYMENT_TARGET" ;;
		*) /bin/echo "$KEY"$'\t'"$VAL" ;;
	esac
done
export PATH=/opt/MacPorts/shims:/usr/bin:/bin:/usr/sbin:/sbin
export MACOSX_DEPLOYMENT_TARGET=10.9

MP_PREFIX=/opt/MacPorts/$MACOSX_DEPLOYMENT_TARGET
MP_HOME=${MP_PREFIX}/home/build

mkdir -p "$MP_PREFIX" "$MP_HOME"

cd /opt/MacPorts/src/MacPorts-2.6.1
HOME="$MP_HOME" ./configure \
    --with-no-root-privileges --with-universal-archs="x86_64" \
    --prefix="$MP_PREFIX" --with-applications-dir="$MP_PREFIX/Applications"
HOME="$MP_HOME" make

Double check that MacPorts has been built for the wanted API “version”:

otool -l src/macports1.0/MacPorts.dylib | grep -E "(cmd LC_BUILD_VERSION|cmd LC_VERSION_MIN_MACOSX)" -A6
      cmd LC_VERSION_MIN_MACOSX
  cmdsize 16
  version 10.9
      sdk 10.14
Load command 9
      cmd LC_SOURCE_VERSION
  cmdsize 16

If all is well:

HOME="$MP_HOME" make install

Then edit /opt/MacPorts/$MACOSX_DEPLOYMENT_TARGET/etc/macports/macports.conf and update or add the following settings (or use the scripted version below to edit it automatically):

universal_archs           x86_64
startupitem_install       no
startupitem_autostart     no
macosx_deployment_target  10.9
macosx_sdk_version        10.9
# Automatically update etc/macports/macports.conf:
echo "# macosx_deployment_target  10.9" >>"$MP_PREFIX"/etc/macports/macports.conf
echo "# macosx_sdk_version  10.9" >>"$MP_PREFIX"/etc/macports/macports.conf
for KV in universal_archs=x86_64 startupitem_install=no startupitem_autostart=no \
        buildfromsource=always \
        extra_env=MACOSX_DEPLOYMENT_TARGET \
        macosx_deployment_target=$MACOSX_DEPLOYMENT_TARGET \
        macosx_sdk_version=$MACOSX_DEPLOYMENT_TARGET ; do
    /usr/bin/sed -i.bak "s/^[#\\t ]*${KV%=*}[\\t ].*$/${KV%=*} ${KV#*=}/" \
        "$MP_PREFIX"/etc/macports/macports.conf
done
cd $MP_PREFIX
bin/port selfupdate
bin/port upgrade outdated

Notes:

bin/port install gnupg2 -openldap -pinentry_mac

Historic notes

Previous releases were built with “VirtualBrew”, a patched version of Homebrew. The upstream project is refactoring their code too frequently for keeping up. Since MacPorts now introduced an (undocumented) option to pass the required SDK selection to the build environment, switching to MacPorts was an easy decision.

Linux Build

TODO

Windows Build

TODO