Vir*_*inh 3 package-management apt dpkg 12.04 software-installation
我正在使用安装在 Dell Vostro 15 3000 系列笔记本电脑上的 Ubuntu 12.04。当我打
sudo apt-get update
Run Code Online (Sandbox Code Playgroud)
它工作正常然后我打了
sudo apt-get upgrade
Run Code Online (Sandbox Code Playgroud)
然后当我按下Y它时会出现如下错误:
(Reading database ... 204809 files and directories currently installed.)
Preparing to replace postgresql-9.1 9.1.16-0ubuntu0.12.04 (using .../postgresql-9.1_9.1.17-0ubuntu0.12.04_amd64.deb) ...
* Stopping PostgreSQL 9.1 database server * Insecure directory in $ENV{PATH} while running with -T switch at /usr/bin/pg_ctlcluster line 246.
Insecure directory in $ENV{PATH} while running with -T switch at /usr/bin/pg_ctlcluster line 255.
(does not shutdown gracefully, now stopping immediately)
[fail]
invoke-rc.d: initscript postgresql, action "stop" failed.
dpkg: warning: subprocess old pre-removal script returned error exit status 1
dpkg - trying script from the new package instead ...
* Stopping PostgreSQL 9.1 database server * Insecure directory in $ENV{PATH} while running with -T switch at /usr/bin/pg_ctlcluster line 246.
Insecure directory in $ENV{PATH} while running with -T switch at /usr/bin/pg_ctlcluster line 255.
(does not shutdown gracefully, now stopping immediately)
[fail]
invoke-rc.d: initscript postgresql, action "stop" failed.
dpkg: error processing /var/cache/apt/archives/postgresql-9.1_9.1.17-0ubuntu0.12.04_amd64.deb (--unpack):
subprocess new pre-removal script returned error exit status 1
dpkg: considering deconfiguration of postgresql-9.1, which would be broken by installation of postgresql-client-9.1 ...
dpkg: yes, will deconfigure postgresql-9.1 (broken by postgresql-client-9.1).
Preparing to replace postgresql-client-9.1 9.1.16-0ubuntu0.12.04 (using .../postgresql-client-9.1_9.1.17-0ubuntu0.12.04_amd64.deb) ...
De-configuring postgresql-9.1 ...
* Stopping PostgreSQL 9.1 database server * Insecure directory in $ENV{PATH} while running with -T switch at /usr/bin/pg_ctlcluster line 246.
Insecure directory in $ENV{PATH} while running with -T switch at /usr/bin/pg_ctlcluster line 255.
(does not shutdown gracefully, now stopping immediately)
[fail]
invoke-rc.d: initscript postgresql, action "stop" failed.
dpkg: error processing /var/cache/apt/archives/postgresql-client-9.1_9.1.17-0ubuntu0.12.04_amd64.deb (--unpack):
subprocess installed pre-removal script returned error exit status 1
Errors were encountered while processing:
/var/cache/apt/archives/postgresql-9.1_9.1.17-0ubuntu0.12.04_amd64.deb
/var/cache/apt/archives/postgresql-client-9.1_9.1.17-0ubuntu0.12.04_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
vgo@vgo-dell:~$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be upgraded:
postgresql-9.1 postgresql-client-9.1
2 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/5,282 kB of archives.
After this operation, 4,096 B of additional disk space will be used.
Do you want to continue [Y/n]? Y
(Reading database ... 204809 files and directories currently installed.)
Preparing to replace postgresql-9.1 9.1.16-0ubuntu0.12.04 (using .../postgresql-9.1_9.1.17-0ubuntu0.12.04_amd64.deb) ...
* Stopping PostgreSQL 9.1 database server * Insecure directory in $ENV{PATH} while running with -T switch at /usr/bin/pg_ctlcluster line 246.
Insecure directory in $ENV{PATH} while running with -T switch at /usr/bin/pg_ctlcluster line 255.
(does not shutdown gracefully, now stopping immediately)
[fail]
invoke-rc.d: initscript postgresql, action "stop" failed.
dpkg: warning: subprocess old pre-removal script returned error exit status 1
dpkg - trying script from the new package instead ...
* Stopping PostgreSQL 9.1 database server * Insecure directory in $ENV{PATH} while running with -T switch at /usr/bin/pg_ctlcluster line 246.
Insecure directory in $ENV{PATH} while running with -T switch at /usr/bin/pg_ctlcluster line 255.
(does not shutdown gracefully, now stopping immediately)
[fail]
invoke-rc.d: initscript postgresql, action "stop" failed.
dpkg: error processing /var/cache/apt/archives/postgresql-9.1_9.1.17-0ubuntu0.12.04_amd64.deb (--unpack):
subprocess new pre-removal script returned error exit status 1
dpkg: considering deconfiguration of postgresql-9.1, which would be broken by installation of postgresql-client-9.1 ...
dpkg: yes, will deconfigure postgresql-9.1 (broken by postgresql-client-9.1).
Preparing to replace postgresql-client-9.1 9.1.16-0ubuntu0.12.04 (using .../postgresql-client-9.1_9.1.17-0ubuntu0.12.04_amd64.deb) ...
De-configuring postgresql-9.1 ...
* Stopping PostgreSQL 9.1 database server * Insecure directory in $ENV{PATH} while running with -T switch at /usr/bin/pg_ctlcluster line 246.
Insecure directory in $ENV{PATH} while running with -T switch at /usr/bin/pg_ctlcluster line 255.
(does not shutdown gracefully, now stopping immediately)
[fail]
invoke-rc.d: initscript postgresql, action "stop" failed.
dpkg: error processing /var/cache/apt/archives/postgresql-client-9.1_9.1.17-0ubuntu0.12.04_amd64.deb (--unpack):
subprocess installed pre-removal script returned error exit status 1
Errors were encountered while processing:
/var/cache/apt/archives/postgresql-9.1_9.1.17-0ubuntu0.12.04_amd64.deb
/var/cache/apt/archives/postgresql-client-9.1_9.1.17-0ubuntu0.12.04_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
Run Code Online (Sandbox Code Playgroud)
现在我该怎么做才能解决这个问题并升级?
您可以通过运行来解决您的问题:
sudo nano /var/lib/dpkg/info/postgresql*.prerm
Run Code Online (Sandbox Code Playgroud)
添加
exit 0
Run Code Online (Sandbox Code Playgroud)
紧随其后
#!/bin/sh
set -e
Run Code Online (Sandbox Code Playgroud)
所以新文件会是这样的:
#!/bin/sh
set -e
exit 0
VERSION=9.1
. /usr/share/postgresql-common/maintscripts-functions
stop_version $VERSION
if [ "$1" = remove ]; then
remove_version $VERSION
fi
Run Code Online (Sandbox Code Playgroud)
现在运行
sudo apt-get upgrade
Run Code Online (Sandbox Code Playgroud)
这应该有效