如何重新安装 APT 包

如何重新安装 APT 包

如何重新安装 APT 包

大家好。

为了解决我的旧问题,我删除了 apt 包。现在新的问题如下。要参考我以前的问题,请参考此链接:

设置 python3-aptdaemon 时出现语法错误

$sudo apt-get update
sudo: apt-get: command not found

ariel@ariel:~$ sudo dpkg -install apt
dpkg: error: unknown option -n

Type dpkg --help for help about installing and deinstalling packages [*];
Use 'apt' or 'aptitude' for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;

Options marked [*] produce a lot of output - pipe it through 'less' or 'more' !

ariel@ariel:~$ sudo dpkg -install apt-get
dpkg: error: unknown option -n

Type dpkg --help for help about installing and deinstalling packages [*];
Use 'apt' or 'aptitude' for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;

Options marked [*] produce a lot of output - pipe it through 'less' or 'more' !

ariel@ariel:~$ sudo dpkg -i *

dpkg: error: archive 'Desktop' is not a regular file

ariel@ariel:~$ sudo dpkg -i *

dpkg: error: archive 'Desktop' is not a regular file

ariel@ariel:~$ wget http://security.ubuntu.com/ubuntu/pool/main/a/apt/apt_1.0.1ubuntu2.17_amd64.deb -O apt.deb
--2019-08-11 21:04:37--  http://security.ubuntu.com/ubuntu/pool/main/a/apt/apt_1.0.1ubuntu2.17_amd64.deb
Resolving security.ubuntu.com (security.ubuntu.com)... 91.189.88.24, 91.189.91.26, 91.189.91.23, ...
Connecting to security.ubuntu.com (security.ubuntu.com)|91.189.88.24|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2019-08-11 21:04:38 ERROR 404: Not Found.

ariel@ariel:~$ sudo dpkg -i apt.deb

dpkg-deb: error: 'apt.deb' is not a Debian format archive

dpkg: error processing archive apt.deb (--install):
 dpkg-deb --control subprocess returned error exit status 2

Errors were encountered while processing:
 apt.deb

ariel@ariel:~$ pkexec dpkg -i apt.deb

dpkg: error: cannot access archive 'apt.deb': No such file or directory

ariel@ariel:~$ 

N0rbert 第一次解决之后:

$ sudo apt-get update

apt-get: error while loading shared libraries: libapt-pkg.so.5.0: cannot open shared object file: No such file or directory

ariel@ariel:~/Downloads$ sudo apt install --reinstall apt-utils ubuntu-minimal ub

apt: error while loading shared libraries: libapt-pkg.so.5.0: cannot open shared object file: No such file or directory

ariel@ariel:~/Downloads$ sudo apt update

apt: error while loading shared libraries: libapt-pkg.so.5.0: cannot open shared object file: No such file or directory

第二个解决方案之后:

$lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.2 LTS
Release:    18.04
Codename:   bionic

谢谢大家,安装库文件后它确实起作用了,但又出现了两个错误。但我也不明白它的重要性。如果您知道的话,请提出建议。这些新错误有什么解决方案吗?

$ wget http://mirrors.kernel.org/ubuntu/pool/main/a/apt/libapt-pkg5.0_1.6.11_amd64.deb

--2019-08-11 23:37:16--  http://mirrors.kernel.org/ubuntu/pool/main/a/apt/libapt-pkg5.0_1.6.11_amd64.deb
Resolving mirrors.kernel.org (mirrors.kernel.org)... 198.145.21.9, 2001:19d0:306:6:0:1994:3:14
Connecting to mirrors.kernel.org (mirrors.kernel.org)|198.145.21.9|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://mirrors.edge.kernel.org/ubuntu/pool/main/a/apt/libapt-pkg5.0_1.6.11_amd64.deb [following]
--2019-08-11 23:37:17--  http://mirrors.edge.kernel.org/ubuntu/pool/main/a/apt/libapt-pkg5.0_1.6.11_amd64.deb
Resolving mirrors.edge.kernel.org (mirrors.edge.kernel.org)... 147.75.95.133, 2604:1380:3000:1500::1
Connecting to mirrors.edge.kernel.org (mirrors.edge.kernel.org)|147.75.95.133|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 806284 (787K) [application/octet-stream]
Saving to: ‘libapt-pkg5.0_1.6.11_amd64.deb’

libapt-pkg5.0_1.6.11_amd64.deb      100%[=================================================================>] 787.39K  20.3KB/s    in 43s     

2019-08-11 23:38:01 (18.4 KB/s) - ‘libapt-pkg5.0_1.6.11_amd64.deb’ saved [806284/806284]

$ sudo dpkg -i libapt-pkg5.0_1.6.11_amd64.deb

Selecting previously unselected package libapt-pkg5.0:amd64.
(Reading database ... 182918 files and directories currently installed.)
Preparing to unpack libapt-pkg5.0_1.6.11_amd64.deb ...
Unpacking libapt-pkg5.0:amd64 (1.6.11) ...
Setting up libapt-pkg5.0:amd64 (1.6.11) ...
Processing triggers for libc-bin (2.28-10) ...

$ sudo apt update

Hit:1 http://in.archive.ubuntu.com/ubuntu bionic InRelease
Get:2 http://in.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]                                                                 
Get:3 http://in.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]                                                               
Hit:4 http://ppa.launchpad.net/diesch/testing/ubuntu bionic InRelease                                    
Get:5 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 DEP-11 Metadata [282 kB]        
Get:6 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]                                     
Ign:7 http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic InRelease                                                      
Get:8 http://in.archive.ubuntu.com/ubuntu bionic-updates/main DEP-11 48x48 Icons [66.7 kB]                                                   
Get:9 http://in.archive.ubuntu.com/ubuntu bionic-updates/main DEP-11 64x64 Icons [138 kB]                                                    
Get:10 http://in.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 DEP-11 Metadata [252 kB]                                            
Err:11 http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic Release                                                       
  404  Not Found [IP: 91.189.95.83 80]
Get:12 http://in.archive.ubuntu.com/ubuntu bionic-updates/universe DEP-11 48x48 Icons [197 kB]    
Get:13 http://in.archive.ubuntu.com/ubuntu bionic-updates/universe DEP-11 64x64 Icons [438 kB]         
Get:14 http://in.archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 DEP-11 Metadata [2,464 B]
Get:15 http://in.archive.ubuntu.com/ubuntu bionic-backports/universe amd64 DEP-11 Metadata [7,700 B]
Get:16 http://security.ubuntu.com/ubuntu bionic-security/main amd64 DEP-11 Metadata [22.7 kB] 
Get:17 http://security.ubuntu.com/ubuntu bionic-security/main DEP-11 48x48 Icons [10.4 kB]                             
Get:18 http://security.ubuntu.com/ubuntu bionic-security/main DEP-11 64x64 Icons [31.7 kB]
Get:19 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 DEP-11 Metadata [42.1 kB]
Get:20 http://security.ubuntu.com/ubuntu bionic-security/universe DEP-11 48x48 Icons [16.4 kB]
Get:21 http://security.ubuntu.com/ubuntu bionic-security/universe DEP-11 64x64 Icons [116 kB]
Get:22 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 DEP-11 Metadata [2,464 B]

(appstreamcli:6798): GLib-CRITICAL **: 23:39:19.478: g_atomic_ref_count_dec: assertion 'g_atomic_int_get (arc) > 0' failed
Reading package lists... Done
E: The repository 'http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

修复最后一个错误的第四种解决方案:

$ sudo add-apt-repository -r ppa:ubuntu-wine/ppa

sudo: add-apt-repository: command not found

第五个解决方案:

$ sudo apt-get install software-properties-common

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 software-properties-common : Depends: python3-software-properties (= 0.96.24.32.9) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

$ sudo add-apt-repository -r ppa:ubuntu-wine/ppa

sudo: add-apt-repository: command not found

解决方案6:

我已经运行了命令$ sudo apt-get upgrade,该命令成功执行而没有返回错误。然后我运行了下面的命令,它返回了相同的错误。因此我重新启动了系统并再次运行下面的命令,它返回了相同的错误。

$ sudo apt-get install software-properties-common

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 software-properties-common : Depends: python3-software-properties (= 0.96.24.32.9) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

$ sudo add-apt-repository -r ppa:ubuntu-wine/ppa

sudo: add-apt-repository: command not found

因为它显示了对 Python 3 软件属性的某种依赖,我怀疑它与我之前提出的问题有关(设置 python3-aptdeamon 时出现语法错误的链接)是吗?


第七个解决方案:

运行命令后,在注释框中输出如下:

$ grep -r ubuntu-wine /etc/apt --include="*.list"
/etc/apt/sources.list.d/ubuntu-wine-ubuntu-ppa-bionic.list:deb http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic main
/etc/apt/sources.list.d/ubuntu-wine-ubuntu-ppa-bionic.list:# deb-src http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic main
/etc/apt/sources.list.d/ubuntu-wine-ubuntu-ppa-bionic.list:# deb-src http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic main

解决方案8:

无需重新启动即可sudo apt-get dist-upgrade成功执行。但sudo apt-get update返回以下错误。

$ sudo apt-get update

Hit:1 http://in.archive.ubuntu.com/ubuntu bionic InRelease
Get:2 http://in.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]                                                                 
Hit:3 http://ppa.launchpad.net/diesch/testing/ubuntu bionic InRelease                                                                        
Get:4 http://in.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Get:5 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]                                                         
Ign:6 http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic InRelease                              
Get:7 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 DEP-11 Metadata [282 kB]
Get:8 http://in.archive.ubuntu.com/ubuntu bionic-updates/main DEP-11 48x48 Icons [66.7 kB]                                                   
Get:9 http://in.archive.ubuntu.com/ubuntu bionic-updates/main DEP-11 64x64 Icons [134 kB]                                   
Err:10 http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic Release                                                      
  404  Not Found [IP: 91.189.95.83 80]
Get:11 http://in.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 DEP-11 Metadata [252 kB]                          
Get:12 http://in.archive.ubuntu.com/ubuntu bionic-updates/universe DEP-11 48x48 Icons [195 kB]        
Get:13 http://in.archive.ubuntu.com/ubuntu bionic-updates/universe DEP-11 64x64 Icons [437 kB]       
Get:14 http://in.archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 DEP-11 Metadata [2,468 B]
Get:15 http://in.archive.ubuntu.com/ubuntu bionic-backports/universe amd64 DEP-11 Metadata [7,712 B]

(appstreamcli:3027): GLib-CRITICAL **: 00:51:25.846: g_atomic_ref_count_dec: assertion 'g_atomic_int_get (arc) > 0' failed
Reading package lists... Done
E: The repository 'http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

$ sudo apt-get dist-upgrade

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages were automatically installed and are no longer required:
  docbook-xml librarian0 rarian-compat sgml-base sgml-data xml-core
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  linux-headers-5.0.0-23 linux-headers-5.0.0-23-generic linux-image-5.0.0-23-generic linux-modules-5.0.0-23-generic
  linux-modules-extra-5.0.0-23-generic
The following packages will be upgraded:
  linux-generic-hwe-18.04 linux-headers-generic-hwe-18.04 linux-image-generic-hwe-18.04
3 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 66.9 MB of archives.
After this operation, 330 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-modules-5.0.0-23-generic amd64 5.0.0-23.24~18.04.1 [13.6 MB]
Get:2 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-image-5.0.0-23-generic amd64 5.0.0-23.24~18.04.1 [8,356 kB]        
Get:3 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-modules-extra-5.0.0-23-generic amd64 5.0.0-23.24~18.04.1 [33.1 MB] 
Get:4 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-generic-hwe-18.04 amd64 5.0.0.23.80 [1,884 B]                      
Get:5 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-image-generic-hwe-18.04 amd64 5.0.0.23.80 [2,564 B]                
Get:6 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-headers-5.0.0-23 all 5.0.0-23.24~18.04.1 [10.7 MB]                 
Get:7 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-headers-5.0.0-23-generic amd64 5.0.0-23.24~18.04.1 [1,135 kB]      
Get:8 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-headers-generic-hwe-18.04 amd64 5.0.0.23.80 [2,524 B]              
Fetched 66.9 MB in 55s (1,214 kB/s)                                                                                                          
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package linux-modules-5.0.0-23-generic.
(Reading database ... 182970 files and directories currently installed.)
Preparing to unpack .../0-linux-modules-5.0.0-23-generic_5.0.0-23.24~18.04.1_amd64.deb ...
Unpacking linux-modules-5.0.0-23-generic (5.0.0-23.24~18.04.1) ...
Selecting previously unselected package linux-image-5.0.0-23-generic.
Preparing to unpack .../1-linux-image-5.0.0-23-generic_5.0.0-23.24~18.04.1_amd64.deb ...
Unpacking linux-image-5.0.0-23-generic (5.0.0-23.24~18.04.1) ...
Selecting previously unselected package linux-modules-extra-5.0.0-23-generic.
Preparing to unpack .../2-linux-modules-extra-5.0.0-23-generic_5.0.0-23.24~18.04.1_amd64.deb ...
Unpacking linux-modules-extra-5.0.0-23-generic (5.0.0-23.24~18.04.1) ...
Preparing to unpack .../3-linux-generic-hwe-18.04_5.0.0.23.80_amd64.deb ...
Unpacking linux-generic-hwe-18.04 (5.0.0.23.80) over (4.18.0.25.74) ...
Preparing to unpack .../4-linux-image-generic-hwe-18.04_5.0.0.23.80_amd64.deb ...
Unpacking linux-image-generic-hwe-18.04 (5.0.0.23.80) over (4.18.0.25.74) ...
Selecting previously unselected package linux-headers-5.0.0-23.
Preparing to unpack .../5-linux-headers-5.0.0-23_5.0.0-23.24~18.04.1_all.deb ...
Unpacking linux-headers-5.0.0-23 (5.0.0-23.24~18.04.1) ...
Selecting previously unselected package linux-headers-5.0.0-23-generic.
Preparing to unpack .../6-linux-headers-5.0.0-23-generic_5.0.0-23.24~18.04.1_amd64.deb ...
Unpacking linux-headers-5.0.0-23-generic (5.0.0-23.24~18.04.1) ...
Preparing to unpack .../7-linux-headers-generic-hwe-18.04_5.0.0.23.80_amd64.deb ...
Unpacking linux-headers-generic-hwe-18.04 (5.0.0.23.80) over (4.18.0.25.74) ...
Setting up linux-headers-5.0.0-23 (5.0.0-23.24~18.04.1) ...
Setting up linux-headers-5.0.0-23-generic (5.0.0-23.24~18.04.1) ...
Setting up linux-modules-5.0.0-23-generic (5.0.0-23.24~18.04.1) ...
Setting up linux-image-5.0.0-23-generic (5.0.0-23.24~18.04.1) ...
I: /vmlinuz.old is now a symlink to boot/vmlinuz-4.18.0-25-generic
I: /initrd.img.old is now a symlink to boot/initrd.img-4.18.0-25-generic
I: /vmlinuz is now a symlink to boot/vmlinuz-5.0.0-23-generic
I: /initrd.img is now a symlink to boot/initrd.img-5.0.0-23-generic
Setting up linux-headers-generic-hwe-18.04 (5.0.0.23.80) ...
Setting up linux-modules-extra-5.0.0-23-generic (5.0.0-23.24~18.04.1) ...
Setting up linux-image-generic-hwe-18.04 (5.0.0.23.80) ...
Setting up linux-generic-hwe-18.04 (5.0.0.23.80) ...
Processing triggers for linux-image-5.0.0-23-generic (5.0.0-23.24~18.04.1) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.0.0-23-generic
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.0.0-23-generic
Found initrd image: /boot/initrd.img-5.0.0-23-generic
Found linux image: /boot/vmlinuz-4.18.0-25-generic
Found initrd image: /boot/initrd.img-4.18.0-25-generic
Found linux image: /boot/vmlinuz-4.18.0-21-generic
Found initrd image: /boot/initrd.img-4.18.0-21-generic
Adding boot menu entry for EFI firmware configuration
done

解决方案 9:

wine ppa 已成功删除。

$ sudo rm -v /etc/apt/sources.list.d/ubuntu-wine-ubuntu-ppa-bionic.list
removed '/etc/apt/sources.list.d/ubuntu-wine-ubuntu-ppa-bionic.list'

解决方案 10:sudo apt update 成功执行,没有返回错误。

$sudo apt update

Hit:1 http://in.archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://in.archive.ubuntu.com/ubuntu bionic-updates InRelease                                                                           
Hit:3 http://in.archive.ubuntu.com/ubuntu bionic-backports InRelease                                                                         
Hit:4 http://ppa.launchpad.net/diesch/testing/ubuntu bionic InRelease                                                           
Get:5 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]                            
Fetched 88.7 kB in 2s (40.2 kB/s)                             
Reading package lists... Done
Building dependency tree       
Reading state information... Done
All packages are up to date.

答案1

请确保您的设备已连接到互联网并下载apt/apt-get包裹手动并在低级上安装:

cd ~/Downloads
wget http://mirrors.kernel.org/ubuntu/pool/main/a/apt/apt_1.6.11_amd64.deb
sudo dpkg -i apt_1.6.11_amd64.deb

重新安装带有库的软件包libapt-pkg.so.5.0

wget http://mirrors.kernel.org/ubuntu/pool/main/a/apt/libapt-pkg5.0_1.6.11_amd64.deb
sudo dpkg -i libapt-pkg5.0_1.6.11_amd64.deb

然后照常使用 APT:

sudo apt-get update
sudo apt-get upgrade

要修复最后一个错误葡萄酒 PPA只需使用以下命令将其删除:

sudo rm /etc/apt/sources.list.d/ubuntu-wine-ubuntu-ppa-bionic.list

然后安装所有新的依赖项

sudo apt-get update
sudo apt-get dist-upgrade

相关内容