Cannot upgrade postgresql 9.4 -> 9.5beta2 after postgis 2.1.6 -> 2.2.0 upgrade

I managed to solve my problem by following these steps:

  1. Download the source to 2.1.6 and apply the patch found here
  2. Postgis 2.1.6 will now compile with Postgresql 9.5beta2. Compile and install.
  3. pg_upgrade now works, having the old version of Postgis installed.

I don't think this is an ideal situation, but at least it runs now.