postgresql won't install dependencies Please help me figure out why postgresql isn't playing nice with updating.  I can't find anything on SO or Google that remedies this problem.  This is a production server and a distribution reinstall is not really an option.  apt-get install -f and apt-get autoclean/check will tell you to use apt-get install -f.

root@vps1484:/home# apt-get install -f
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following package was automatically installed and is no longer required:
  libaio1
Use 'apt-get autoremove' to remove it.
The following extra packages will be installed:
  postgresql-9.1
Suggested packages:
  oidentd ident-server locales-all
The following packages will be upgraded:
  postgresql-9.1
1 upgraded, 0 newly installed, 0 to remove and 14 not upgraded.
1 not fully installed or removed.
Need to get 0 B/4317 kB of archives.
After this operation, 193 kB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 98727 files and directories currently installed.)
Preparing to replace postgresql-9.1 9.1.13-0ubuntu0.13.10 (using .../postgresql-9.1_9.1.15-0ubuntu0.12.04_amd64.deb) ...
 * Stopping PostgreSQL 9.1 database server                                                                                                    [ OK ] 
Unpacking replacement postgresql-9.1 ...
dpkg: error processing /var/cache/apt/archives/postgresql-9.1_9.1.15-0ubuntu0.12.04_amd64.deb (--unpack):
 trying to overwrite '/usr/share/postgresql/9.1/man/man1/pg_basebackup.1.gz', which is also in package postgresql-client-9.1 9.1.13-0ubuntu0.13.10
Errors were encountered while processing:
 /var/cache/apt/archives/postgresql-9.1_9.1.15-0ubuntu0.12.04_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@vps1484:/home# sudo rm /usr/share/postgresql/9.1/man/man1/*               
root@vps1484:/home# sudo rm /var/cache/apt/archives/*                      
rm: cannot remove '/var/cache/apt/archives/partial': Is a directory
root@vps1484:/home# sudo rmdir /var/cache/apt/archives  
rmdir: failed to remove '/var/cache/apt/archives': Directory not empty
root@vps1484:/home# apt-get install -f
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following package was automatically installed and is no longer required:
  libaio1
Use 'apt-get autoremove' to remove it.
The following extra packages will be installed:
  postgresql-9.1
Suggested packages:
  oidentd ident-server locales-all
The following packages will be upgraded:
  postgresql-9.1
1 upgraded, 0 newly installed, 0 to remove and 14 not upgraded.
1 not fully installed or removed.
Need to get 4317 kB of archives.
After this operation, 193 kB disk space will be freed.
Do you want to continue [Y/n]? y
Get:1 http://ca.archive.ubuntu.com/ubuntu/ precise-security/main postgresql-9.1 amd64 9.1.15-0ubuntu0.12.04 [4317 kB]
Fetched 4317 kB in 0s (5940 kB/s)       
(Reading database ... 98727 files and directories currently installed.)
Preparing to replace postgresql-9.1 9.1.13-0ubuntu0.13.10 (using .../postgresql-9.1_9.1.15-0ubuntu0.12.04_amd64.deb) ...
 * Stopping PostgreSQL 9.1 database server                                                                                                    [ OK ] 
Unpacking replacement postgresql-9.1 ...
dpkg: error processing /var/cache/apt/archives/postgresql-9.1_9.1.15-0ubuntu0.12.04_amd64.deb (--unpack):
 trying to overwrite '/usr/share/postgresql/9.1/man/man1/pg_basebackup.1.gz', which is also in package postgresql-client-9.1 9.1.13-0ubuntu0.13.10
Errors were encountered while processing:
 /var/cache/apt/archives/postgresql-9.1_9.1.15-0ubuntu0.12.04_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@vps1484:/home# &gt;
This is how I fixed my issue:

`dpkg -l | grep postgres

will show you the postgresql packages that have been installed.  Run:

 sudo apt-get --purge remove 


with each package name, separated by a space, following remove.

root@vps1484:/home# dpkg -l | grep postgres
ii  postgresql                                                  9.3+146really9.1+148             all          object-relational SQL database (supported version)
ii  postgresql-9.1                                              9.1.13-0ubuntu0.13.10            amd64        object-relational SQL database, version 9.1 server
ii  postgresql-client                                           9.3+146really9.1+148             all          front-end programs for PostgreSQL (supported version)
ii  postgresql-client-9.1                                       9.1.13-0ubuntu0.13.10            amd64        front-end programs for PostgreSQL 9.1
ii  postgresql-client-common                                    148                              all          manager for multiple PostgreSQL client versions
ii  postgresql-common                                           148                              all          PostgreSQL database-cluster manager
ii  postgresql-contrib                                          9.3+146really9.1+148             all          additional facilities for PostgreSQL (supported version)
iU  postgresql-contrib-9.1                                      9.1.15-0ubuntu0.12.04            amd64        additional facilities for PostgreSQL
root@vps1484:/home# sudo apt-get --purge remove postgresql postgresql-9.1 postgresql-client postgresql-client-9.1 postgresql-client-comment postgresql-common postgresql-contrib postgresql-contrib-9.1
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package postgresql-client-comment
root@vps1484:/home# sudo apt-get --purge remove postgresql postgresql-9.1 postgresql-client postgresql-client-9.1 postgresql-client-common postgresql
-common postgresql-contrib postgresql-contrib-9.1
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  libaio1
Use 'apt-get autoremove' to remove it.
The following packages will be REMOVED:
  postgresql* postgresql-9.1* postgresql-client* postgresql-client-9.1* postgresql-client-common* postgresql-common* postgresql-contrib*
  postgresql-contrib-9.1*
0 upgraded, 0 newly installed, 8 to remove and 8 not upgraded.
1 not fully installed or removed.
After this operation, 16.3 MB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 98720 files and directories currently installed.)
Removing postgresql-contrib ...
Removing postgresql-contrib-9.1 ...
Removing postgresql ...
Removing postgresql-9.1 ...
 * Stopping PostgreSQL 9.1 database server                                                                                                    [ OK ] 
Purging configuration files for postgresql-9.1 ...
Dropping cluster main...
Removing postgresql-client ...
Removing postgresql-client-9.1 ...
update-alternatives: warning: alternative /usr/share/postgresql/9.1/man/man1/psql.1.gz (part of link group psql.1.gz) doesn't exist; removing from list of alternatives
update-alternatives: warning: /etc/alternatives/psql.1.gz is dangling; it will be updated with best choice
Removing postgresql-common ...
 * No PostgreSQL clusters exist; see "man pg_createcluster"
Removing 'diversion of /usr/bin/pg_config to /usr/bin/pg_config.libpq-dev by postgresql-common'
Purging configuration files for postgresql-common ...
dpkg: warning: while removing postgresql-common, directory '/var/lib/postgresql' not empty so not removed
Removing postgresql-client-common ...
Purging configuration files for postgresql-client-common ...
Processing triggers for man-db ...