How to get pg_archivecleanup on Amazon Linux 2014.03? I have an Amazon EC2 instance based on Amazon Linux AMI 2014.03. I installed PostresSQL from their repos:

yum install postgresql-libs postgresql postgresql-server postgresql-devel


I've read about Amazon's unexpected upgrade from 9.1 to 9.2, so I added this line to the end of /etc/yum.conf so hopefully I can control any upgrades:

exclude=postgresql*


So far so good. Now I'm setting up continuous archiving and I want to run pg_archivecleanup.  However I can't find the postgresql-contrib package on the Amazon distro, and it's not listed in the packages:

http://aws.amazon.com/amazon-linux-ami/2014.03-packages/

Is there someplace else to get that pre-compiled?  I tried the following to compile it myself:

sudo su -
cd /usr/local/src
wget http://ftp.postgresql.org/pub/source/v9.2.7/postgresql-9.2.7.tar.gz
tar -xzf postgresql-9.2.7.tar.gz
cd /usr/local/src/postgresql-9.2.7
./configure --without-readline # fails until you add --without-readline
cd /usr/local/src/postgresql-9.2.7/contrib/pg_archivecleanup
gmake
gmake install


but the gmake fails:

gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard pg_archivecleanup.o  -L../../src/port -Wl,--as-needed -Wl,-rpath,'/usr/local/pgsql/lib',--enable-new-dtags  -lpgport -lz -lcrypt -ldl -lm  -o pg_archivecleanup
/usr/bin/ld: cannot find -lpgport
collect2: error: ld returned 1 exit status
gmake: *** [pg_archivecleanup] Error 1


Trying to figure out the -lpgport issue led me to some very obscure bug reports here and here. Tracking bugs in Linux itself seems a little extreme just to compile one file. 

What is my best option?


Find another source for the contrib package - where?
Find a way to compile this module - how?
Ditch Amazon Linux and start from scratch with an Ubuntu AMI.
Forget pg_archivecleanup and write a script to delete old WAL files.


EDIT

I'm using Elastic Beanstalk with some pretty tight integration to the Amazon AMI. I'm sure it could be made to work with another AMI, but I expect there would be other gotchas.  What about this option, adapted from this post:

# Change to home directory to download the software
cd ~/
# Get the right postgresql package (Redhat 64 Bit)
wget http://yum.postgresql.org/9.2/redhat/rhel-6-x86_64/pgdg-redhat92-9.2-7.noarch.rpm
# Install the package
sudo rpm -ivh pgdg-redhat92-9.2-7.noarch.rpm
sudo yum install postgresql92-contrib


Does that give me the best of both worlds, an Amazon AMI with an official Postgres repo?  If necessary, I could completely re-install Postgres from that RHEL repo.
With the help of this AWS forum thread, I realized that this line in /etc/yum.conf

exclude=postgresql*


excludes not only updates but installs.  Once I commented that out (temporarily), I was able to use

sudo yum install postgresql-contrib


to install postgresql-contrib directly from the Amazon repo--no need for changing the repository or the operating system.