“sudo apt-get upgrade”不起作用

“sudo apt-get upgrade”不起作用

我在 Dell Vostro 15 3000 系列笔记本电脑上安装了 Ubuntu 12.04。当我点击

sudo apt-get update

它工作正常,然后我点击

sudo apt-get upgrade

它告诉我: 在此处输入图片描述

然后当我按下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)

现在我该怎么做才能解决这个问题并进行升级?

答案1

您可以通过运行来解决您的问题:

 sudo nano /var/lib/dpkg/info/postgresql*.prerm

添加

exit 0

紧接着

#!/bin/sh

set -e

因此新文件将是这样的:

#!/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

现在运行

sudo apt-get upgrade 

这应该有效

相关内容