aptはパッケージを削除できません(postgresql)

aptはパッケージを削除できません(postgresql)

Ubuntu 21.10クライアントにpostgresをインストールしようとしています。

sudo apt install postgresql postgresql-contrib

これで警告が発生しましたが、とにかくインストールすることにしました。依存関係の問題(以下を参照)と最終的にパッケージの破損を引き起こす可能性があるため、これは賢明な方法ではありません。

私は試した:

sudo dpkg --configure -a
sudo apt -f install
sudo apt update
sudo apt autoremove

もっとあります。これで、特定のファイルが必要なpostgresql-client-13に帰結しますが、そのファイルが見つからず、アンインストールが中断されます(または新しいpostgresqlバージョンのインストール)。この状況でpostgresqlを削除して適切にする方法を知っている人はいますか?

$ sudo apt remove --purge postgresql
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package 'postgresql' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up postgresql-client-13 (13.5-0ubuntu0.21.10.1) ...
/var/lib/dpkg/info/postgresql-client-13.postinst: 7: .: cannot open /usr/share/postgresql-common/mai
ntscripts-functions: No such file
dpkg: error processing package postgresql-client-13 (--configure):
 installed postgresql-client-13 package post-installation script subprocess returned error exit stat
us 2
Errors were encountered while processing:
 postgresql-client-13
E: Sub-process /usr/bin/dpkg returned an error code (1)

オリジナルインストール:

$ sudo apt install postgresql postgresql-contrib
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  postgresql-13 postgresql-client-13
Suggested packages:
  postgresql-doc postgresql-doc-13
The following NEW packages will be installed:
  postgresql postgresql-13 postgresql-client-13 postgresql-contrib
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 16.2 MB of archives.
After this operation, 46.0 MB of additional disk space will be used.
Do you want to continue? [Y/n] 
Get:1 http://nl.archive.ubuntu.com/ubuntu impish-updates/main amd64 postgresql-client-13 amd64 13.5-0ubuntu0.21.10.1 [1,145 kB]
Get:2 http://nl.archive.ubuntu.com/ubuntu impish-updates/main amd64 postgresql-13 amd64 13.5-0ubuntu0.21.10.1 [15.0 MB]
Get:3 http://nl.archive.ubuntu.com/ubuntu impish/main amd64 postgresql all 13+226 [4,624 B]
Get:4 http://nl.archive.ubuntu.com/ubuntu impish/main amd64 postgresql-contrib all 13+226 [4,636 B]
Fetched 16.2 MB in 5s (3,223 kB/s)            
Preconfiguring packages ...
Selecting previously unselected package postgresql-client-13.
dpkg: warning: files list file for package 'postgresql-14' missing; assuming package has no files cu
rrently installed
dpkg: warning: files list file for package 'postgresql-client-common' missing; assuming package has 
no files currently installed
dpkg: warning: files list file for package 'postgresql-client-14' missing; assuming package has no f
iles currently installed
dpkg: warning: files list file for package 'postgresql-common' missing; assuming package has no file
s currently installed
(Reading database ... 444111 files and directories currently installed.)
Preparing to unpack .../postgresql-client-13_13.5-0ubuntu0.21.10.1_amd64.deb ...
Unpacking postgresql-client-13 (13.5-0ubuntu0.21.10.1) ...
Selecting previously unselected package postgresql-13.
Preparing to unpack .../postgresql-13_13.5-0ubuntu0.21.10.1_amd64.deb ...
Unpacking postgresql-13 (13.5-0ubuntu0.21.10.1) ...
Selecting previously unselected package postgresql.
Preparing to unpack .../postgresql_13+226_all.deb ...
Unpacking postgresql (13+226) ...
Selecting previously unselected package postgresql-contrib.
Preparing to unpack .../postgresql-contrib_13+226_all.deb ...
Unpacking postgresql-contrib (13+226) ...
Setting up postgresql-client-13 (13.5-0ubuntu0.21.10.1) ...
/var/lib/dpkg/info/postgresql-client-13.postinst: 7: .: cannot open /usr/share/postgresql-common/mai
ntscripts-functions: No such file
dpkg: error processing package postgresql-client-13 (--configure):
 installed postgresql-client-13 package post-installation script subprocess returned error exit stat
us 2
dpkg: dependency problems prevent configuration of postgresql-13:
 postgresql-13 depends on postgresql-client-13; however:
  Package postgresql-client-13 is not configured yet.

dpkg: error processing package postgresql-13 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of postgresql:
 postgresql depends on postgresql-13; however:
  Package postgresql-13 is not configured yet.

dpkg: error processing package postgresql (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of postgresql-contrib:
 postgresql-contrib depends on postgresql-contrib-13; however:
  Package postgresql-contrib-13 is not installed.
  Package postgresql-13 which provides postgresql-contrib-13 is not configured yet.

dpkg: error processing package postgresql-contrib (--configure):
 dependency problems - leaving unconfigured
Processing triggers for postgresql-comNo apport report written because the error message indicates i
ts a followup error from a previous failure.
                                            No apport report written because the error message indic
ates its a followup error from a previous failure.
                                                  No apport report written because MaxReports is rea
ched already
            mon (232.pgdg21.10+1) ...
Errors were encountered while processing:
 postgresql-client-13
 postgresql-13
 postgresql
 postgresql-contrib
E: Sub-process /usr/bin/dpkg returned an error code (1)

修正する

@PersianGulfの提案を試してみました。するpostgresql-client-13を削除するように求められましたが、それでも削除できません。

$ sudo apt --force-yes remove postgresql-client-13
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
  postgresql-client-13
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 3,609 kB disk space will be freed.
W: --force-yes is deprecated, use one of the options starting with --allow instead.
Do you want to continue? [Y/n] 
dpkg: warning: files list file for package 'postgresql-client-common' missing; assuming package has 
no files currently installed
dpkg: warning: files list file for package 'postgresql-client-14' missing; assuming package has no f
iles currently installed
(Reading database ... 446025 files and directories currently installed.)
Removing postgresql-client-13 (13.5-0ubuntu0.21.10.1) ...
/var/lib/dpkg/info/postgresql-client-13.prerm: 11: remove_client_version: not found
dpkg: error processing package postgresql-client-13 (--remove):
 installed postgresql-client-13 package pre-removal script subprocess returned error exit status 127
dpkg: too many errors, stopping
Errors were encountered while processing:
 postgresql-client-13
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)

ベストアンサー1

損傷は問題によって引き起こされますpostgresql-client-common。このパッケージは他のパッケージを削除できるはずですが、コンテンツの少なくとも一部が欠落しているため、次のことが発生します。

/var/lib/dpkg/info/postgresql-client-13.postinst: 7: .: cannot open /usr/share/postgresql-common/maintscripts-functions: No such file

dpkgパッケージの状態はかなり不満足です。

dpkg: warning: files list file for package 'postgresql-client-common' missing; assuming package has no files currently installed

問題を解決するには、このパッケージを強制的に再インストールする必要がありますpostgreql-common

sudo apt reinstall postgreql-client-common

完了したら、PostgreSQL 13パッケージを削除できます。

おすすめ記事