Error output:
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):
Child process has pre installed-The removal script returned error number 2
dpkg: postgresql-client-9.1: dependency problems, but removing anyway as you requested:
postgresql-9.1 Depends on 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):
Child process has pre installed-The removal script returned error number 2/var/lib/dpkg/info/postgresql-client-9.1.postinst:7:.: Can't open /usr/share/postgresql-common/maintscripts-functions
dpkg: error while cleaning:
Child process has installed post-The installation script returned error number 2
An error occurred during processing:
postgresql-9.1
postgresql-client-9.1
E: Sub-process /usr/bin/dpkg returned an error code(1)
Use the following command:
sudo rm -r /var/lib/dpkg/info/postgresq*
Afterwards
sudo apt-get autoremove postgresql*
Finally, you can see:
dpkg: warning: files list file forpackage'postgresql-9.1' missing; assuming package has no files currently installed
dpkg: warning: files list file forpackage'postgresql-client-9.1' missing; assuming package has no files currently installed(Reading database...There are currently 146453 files and directories installed in the system.)
Removing postgresql-9.1(9.1.18-0ubuntu0.12.04)...
Removing postgresql-client-9.1(9.1.18-0ubuntu0.12.04)...
In fact, it feels that the first command deletes dpkg's metadata information about postgresql, and then when using the autoremove command, dpkg thinks that postgresql is not installed, and then prompts that the uninstallation was successful.
Recommended Posts