How to install PostgreSQL on Ubuntu 13.04?

You need to run something to resolve the postgresql-common conflict in short with the following (read only the bottom if you just want it to work and don't care why)

The long winded reason. Basically the 3rd party postgresql-common (build 141+) says it Breaks: logrotate (>= 3.8). The included ubuntu postgresql-common package (build 140) does not have this problem. postgresql-9.2 only requires a build of 135 or greater of postgresql-common. By running the following commands. This will specify a repository to get postgresql-common from, which in this case the ubuntu provided package of build 140 of postgresql-common while using the 3rd party apt repo to install Postgresql-9.2

Follow these instructions installing the precise sources repo:

Create /etc/apt/sources.list.d/pgdg.list. The distributions are called codename-pgdg. In the example, replace squeeze with the actual distribution you are using:

deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main

(You may determine the codename of your distribution by running lsb_release -c.) Import the repository key from http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc, update the package lists, and start installing packages:

wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -

Commands to run if you once you have the apt

sudo apt-get update
sudo apt-get install postgresql-common -t raring
sudo apt-get install postgresql-9.2

As your log describes the package is deprecated. But more specifically it has moved. From the PPA owner's page:

In about a year (during Ubuntu 12.04 LTS's life time, but after 12.10 is end-of-life) this PPA is going to be deprecated. Please consider moving to apt.postgresql.org soon.

I had issues upgrading to 13.04 with PostgreSQL 9.2 installed on my 12.10 (as described here). This resulted in me unistalling PostgreSQL 9.2 and upgrading. If you also have this issue, back-up your database or it will be lost when uninstalled.

After the upgrade, I uncommented the PostgreSQL repo in /etc/apt/sources.list.d/pgdg.list and ran:

sudo apt-get update

If you don't already have the PostgreSQL repo added, you should follow these instructions, with the exception that there is not a package for Raring (13.04) yet. Just use Precise.

For reference, my pgdg.list file looks like:

deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main 

And running the update, I can see it getting PostgreSQL 9.2 from the precise package (Whereas, other updates are raring):

Get:5 http://apt.postgresql.org precise-pgdg Release.gpg [836 B]
Get:7 http://apt.postgresql.org precise-pgdg Release [25.6 kB]
Get:10 http://apt.postgresql.org precise-pgdg/main amd64 Packages [27.6 kB]
Get:14 http://apt.postgresql.org precise-pgdg/main i386 Packages [27.6 kB]
Ign http://apt.postgresql.org precise-pgdg/main Translation-en_US
Ign http://apt.postgresql.org precise-pgdg/main Translation-en

Running psql --version to confirm this, the terminal outputs:

psql (PostgreSQL) 9.2.4

I tried to install postgresql-9.2 by following tutorial on postgresql wiki. Unfortunately there are no packages for raring distribution yet.
When I tried to install package for older distribution (precise) I got conflicts with other packages that I couldn't resolve.

The only solution I found is to install older version (postgresql-9.1) by:

sudo apt-get install postgresql