How do I install the earthdistance (and requirement cube) modules for Postgresql?

I need to install earthdistance, an extension for Postgresql. The page for it says:

The earthdistance module provides two different approaches to calculating great circle distances on the surface of the Earth. The one described first depends on the cube package (which must be installed before earthdistance can be installed). The second one is based on the built-in point datatype, using longitude and latitude for the coordinates.

This seems to be true..

dealermade=# CREATE EXTENSION earthdistance FROM unpackaged;
ERROR:  required extension "cube" is not installed

However, I can't install cube either

dealermade=# CREATE EXTENSION cube FROM unpackaged;
ERROR:  type "cube" does not exist

Seems awkward the cube extension requires the cube type it provides. I'm using PostgreSQL 9.1.1. I'm doing this on Ubuntu, and I have companion package postgresql-contrib-9.1 installed. That said, there is no cube.sql on my system.

If I try to install earthdistance.sql directly I get this

$ psql -d db -f /usr/share/postgresql/9.1/extension/earthdistance--1.0.sql
CREATE FUNCTION
psql:/usr/share/postgresql/9.1/extension/earthdistance--1.0.sql:31: ERROR:  type "cube" does not exist
CREATE FUNCTION
CREATE FUNCTION
psql:/usr/share/postgresql/9.1/extension/earthdistance--1.0.sql:49: ERROR:  type "earth" does not exist
psql:/usr/share/postgresql/9.1/extension/earthdistance--1.0.sql:55: ERROR:  type earth does not exist
psql:/usr/share/postgresql/9.1/extension/earthdistance--1.0.sql:61: ERROR:  type earth does not exist
psql:/usr/share/postgresql/9.1/extension/earthdistance--1.0.sql:67: ERROR:  type earth does not exist
psql:/usr/share/postgresql/9.1/extension/earthdistance--1.0.sql:73: ERROR:  type earth does not exist
psql:/usr/share/postgresql/9.1/extension/earthdistance--1.0.sql:79: ERROR:  could not access file "MODULE_PATHNAME": No such file or directory
psql:/usr/share/postgresql/9.1/extension/earthdistance--1.0.sql:88: ERROR:  function geo_distance(point, point) does not exist

FROM unpackaged is only for when it's already installed as a contrib module (i.e. from upgrading from 9.0) and you need to turn it into an extension. Therefore, just:

CREATE EXTENSION cube;
CREATE EXTENSION earthdistance;