Skip to content

Archive for

26
May

Compiling GPG 2.1 on OSX

I’ve had to compile the pre-release version of Gnupg a few times lately to test some changes.
While it’s not particularly difficult, it can be a bit persnickety to get right..
To that end, I thought I’d share the build script I’ve been using.


If it’s useful to anyone else, that’s awesome! At the very least, it’ll be easy for me to find it next time I want to play around again 😉

Please note – This isn’t necessarily the right way to do anything. I’m not a GPG dev. These changes worked for me.

Also note – As of 5/25/14, I needed to patch GPG to make it compile.
I’ve linked the patch as part of the steps below.
Hopefully there’s a better way that’s added to git-master soon 😉

#!/bin/bash
# GPG 2.1 Installation Notes.
# Run this in a temporary directory, such as ~/Documents/gpg-inst
# This will add gpg binaries inside a subdirectory - Ex:  ~/Documents/gpg-inst/gpg

# First, we'll want some prerequisites from Homebrew.
# If you don't have Homebrew installed, you can get it from brew.sh

brew update
brew install autoconf gettext pkg-config readline git wget


# Ideally, you won't have already installed libgpg-error, libgcrypt, libassuan, etc via homebrew.
# If you have, this technique should still work, since we're explicitly listing where to find them,
# but it's a bit more risky.

# The autodetected version of stdint doesn't work
export gl_cv_absolute_stdint_h=/usr/include/stdint.h
export LDFLAGS=-lresolv
export GETTEXT_PREFIX=/usr/local/opt/gettext/bin/


# Download the old version of automake.
# The current version of automake defaults to parallel tests, which won't work with gnupg.
# GnuPG maintainers have so-far declined patches to fix. 
# We can work around this by adding AM_INIT_AUTOMAKE=[serial_tests] to -every- lib...
# But it's easier to just install the old frickin version :/

wget http://ftp.gnu.org/gnu/automake/automake-1.11.6.tar.gz
tar -xzf automake-1.11.6.tar.gz
cd automake-1.11.6/
./configure
make
make install
AUTOMAKE_SUFFIX=1.11
cd ..


### Install the various prerequisite libraries that are part of gnupg.
## LibGPG-Error
git clone git://git.gnupg.org/libgpg-error.git
cd libgpg-error
./autogen.sh --force
./configure --enable-maintainer-mode --prefix=`pwd`/inst/
make
make install
cd ..

## Libgcrypt
git clone git://git.gnupg.org/libgcrypt.git
cd libgcrypt
# By default, this tries to run transfig for the docs.
# This isn't trivial to install for OSX, and I don't need these docs locally right now ;)
sed -i '' 's/doc //g' Makefile.am
./autogen.sh
./configure --enable-maintainer-mode --disable-asm --with-gpg-error-prefix=`pwd`/../libgpg-error/inst --prefix=`pwd`/inst/
make
make install
cd ..

## Libassuan
git clone git://git.gnupg.org/libassuan.git
cd libassuan
./autogen.sh
./configure --enable-maintainer-mode --with-gpg-error-prefix=`pwd`/../libgpg-error/inst --prefix=`pwd`/inst/
make
make install
cd ..

## Libksba
git clone git://git.gnupg.org/libksba.git
cd libksba/
./autogen.sh
./configure --enable-maintainer-mode --with-gpg-error-prefix=`pwd`/../libgpg-error/inst --prefix=`pwd`/inst/
make
make install
cd ..

## NPTH
git clone git://git.gnupg.org/npth.git
cd npth
./autogen.sh
automake --add-missing
./configure --enable-maintainer-mode --prefix=`pwd`/inst/
make
make install
cd ..


### Now, we can install GPG 2.1

git clone git://git.gnupg.org/gnupg.git
cd gnupg


# If GPG complains about "Undefined symbols for architecture x86_64:" you might need to apply a patch to the Makefile
# If so, you can use my hacked-together version until something better is released.
# wget https://gist.githubusercontent.com/e1ven/167af3ac8a196773fc46/raw/62f4deb4936a6a32634ac3ee12c9a06cb4c8eac7/makefile.patch
# git am --signoff < makefile.patch

./autogen.sh --force
./configure --sysconfdir=/etc --enable-maintainer-mode --enable-symcryptrun --enable-mailto --enable-gpgtar --with-readline=/usr/local/opt/readline --with-gpg-error-prefix=`pwd`/../libgpg-error/inst --with-libgcrypt-prefix=`pwd`/../libgcrypt/inst --with-libassuan-prefix=`pwd`/../libassuan/inst --with-ksba-prefix=`pwd`/../libksba/inst --with-npth-prefix=`pwd`/../npth/inst --enable-static=yes  --disable-endian-check --disable-dependency-tracking --disable-asm
make
make install
26
May

“This copy of the Install OS X Mavericks application can’t be verified”

I’ve been reinstalling OSX on a few old machines lately, and I’ve come across a rather odd message.

OSXInstallError
“This copy of the Install OS X Mavericks application can’t be verified”

After encountering this error, the OSX installer dutifully quits, leaving me scratching my head.
Since I was installing using a USB stick, at first I assumed the image or hardware were bad, and tried several variations on replacing drives and re-making the install image.

Eventually, I realized that the problem was particular to the destination system, rather than my USB stick.

One thing that can cause this error is if the time is off on the destination system.
Since the machines I was installing to had been sitting for quite some time, their batteries had depleted fully, and the clock had reset back to 2000.

Once I figured this out, and stopped wasting time on install media, this is pretty straightforward to fix.

On the Destination machine, once it’s booted into the install media – Go to the Utilities menu, and choose Terminal.

If you run the command

date

you can see the system time, and confirm it’s wildly incorrect.

To fix it, we just need to find the correct time/date from another system.
On another machine, fire up the Terminal, and run

TZ=US/Pacific date +%s

This will output the current unix timestamp in the PDT timezone. We want the PDT timezone, since that’s what OSX defaults to when the clock is reset.

Once we have this timestamp, we can enter it back into the Destination machine.
In the terminal, run

date -f %s TIMESTAMP

(Replacing TIMESTAMP with the timestamp from the last step, such as “date +f %s 1401065468”)

After this, close out of the terminal, and the install should proceed normally 😉