出错输出:

Removing postgresql-9.1 (9.1.18-0ubuntu0.12.04) ...
/var/lib/dpkg/info/postgresql-9.1.prerm: 9: .: Can't open /usr/share/postgresql-common/maintscripts-functions
dpkg: error processing package postgresql-9.1 (--remove):
子进程 已安装 pre-removal 脚本 返回了错误号 2
dpkg: postgresql-client-9.1: dependency problems, but removing anyway as you requested:
postgresql-9.1 依赖于 postgresql-client-9.1.

Removing postgresql-client-9.1 (9.1.18-0ubuntu0.12.04) ...
/var/lib/dpkg/info/postgresql-client-9.1.prerm: 10: .: Can't open /usr/share/postgresql-common/maintscripts-functions
dpkg: error processing package postgresql-client-9.1 (--remove):
子进程 已安装 pre-removal 脚本 返回了错误号 2
/var/lib/dpkg/info/postgresql-client-9.1.postinst: 7: .: Can't open /usr/share/postgresql-common/maintscripts-functions
dpkg:清理时出错:
子进程 已安装 post-installation 脚本 返回了错误号 2
在处理时有错误发生:
postgresql-9.1
postgresql-client-9.1
E: Sub-process /usr/bin/dpkg returned an error code (1)

使用下面的命令:

sudo rm -r /var/lib/dpkg/info/postgresq*

然后是

sudo

最后可以看到:

dpkg:警告:files list file for package 'postgresql-9.1' missing; assuming package has no files currently installed
dpkg:警告:files list file for package 'postgresql-client-9.1' missing; assuming package has no files currently installed
(正在读取数据库 ... 系统当前共安装有 146453 个文件和目录。)
Removing postgresql-9.1 (9.1.18-0ubuntu0.12.04) ...
Removing postgresql-client-9.1 (9.1.18-0ubuntu0.12.04) ...

其实感觉是第一个命令删除了dpkg关于postgresql的元数据信息,然后使用autoremove命令的时候,dpkg以为postgresql没有安装,然后提示卸载成功了。