如何修复从 Debian 源安装的软件包?

如何修复从 Debian 源安装的软件包?

由于某些我无法解释的原因(我想可能是因为我很笨),我从 Debian 源安装了软件包。我使用 Ubuntu 18.04。

我想修复我的错误并降级到 Ubuntu 软件包。我所做的是dpkg -l | grep -v ubuntu | grep deb列出具有“deb”版本而不是“ubuntu”的软件包。例如,我能够将 systemd 从 241 降级到 237。

但是,有些软件包不会接受降级,例如,除非我删除大量软件包(其中一些是关键软件包),否则 perl 不会降级,因此我不能接受这一点。例如:

root@KLK876:/etc/apt/preferences.d# apt-cache policy perl
perl:
  Installed: 5.28.1-6+deb10u1
  Candidate: 5.28.1-6+deb10u1
  Version table:
 *** 5.28.1-6+deb10u1 100
        100 /var/lib/dpkg/status
     5.26.1-6ubuntu0.5 500
        500 mirror://mirrors.ubuntu.com/mirrors.txt bionic-updates/main amd64 Packages
        500 mirror://mirrors.ubuntu.com/mirrors.txt bionic-security/main amd64 Packages
        500 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages
     5.26.1-6 500
        500 mirror://mirrors.ubuntu.com/mirrors.txt bionic/main amd64 Packages
        500 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 Packages

所以我尝试恢复到 ubuntu 版本:

root@KLK876:/etc/apt/preferences.d# aptitude install perl=5.26.1-6ubuntu0.5
The following packages will be DOWNGRADED:
  perl{b} 
0 packages upgraded, 0 newly installed, 1 downgraded, 0 to remove and 0 not upgraded.
Need to get 201 kB of archives. After unpacking 7168 B will be freed.
The following packages have unmet dependencies:
 perl-base : Breaks: perl (< 5.28.1~) but 5.26.1-6ubuntu0.5 is to be installed
 libnet-libidn-perl : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
 libb-hooks-op-check-perl : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
 libnet-ssleay-perl : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
 liblist-moreutils-perl : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
 libsereal-encoder-perl : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
 libvariable-magic-perl : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
 libdevel-callchecker-perl : Depends: perl (>= 5.28.1-4) but 5.26.1-6ubuntu0.5 is to be installed
 libdbi-perl : Depends: perl (>= 5.28.1-6+deb10u1) but 5.26.1-6ubuntu0.5 is to be installed
 perl-modules-5.28 : Breaks: perl (< 5.28.1~) but 5.26.1-6ubuntu0.5 is to be installed
 libfcgi-perl : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
 libsnmp-perl : Depends: perl (>= 5.28.1-6) but 5.26.1-6ubuntu0.5 is to be installed
 texinfo : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
 libclass-c3-xs-perl : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
 libpackage-stash-xs-perl : Depends: perl (>= 5.28.1-3) but 5.26.1-6ubuntu0.5 is to be installed
 libperlio-gzip-perl : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
 libdevel-lexalias-perl : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
 libsub-identify-perl : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
 libclass-xsaccessor-perl : Depends: perl (>= 5.28.1-1) but 5.26.1-6ubuntu0.5 is to be installed
 libparams-util-perl : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
 libposix-strptime-perl : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
 libdevel-caller-perl : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
 libterm-readkey-perl : Depends: perl (>= 5.28.1-3) but 5.26.1-6ubuntu0.5 is to be installed
 libunicode-utf8-perl : Depends: perl (>= 5.28.1-4) but 5.26.1-6ubuntu0.5 is to be installed
 libfile-fcntllock-perl : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
 libcairo-perl : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
 libparams-classify-perl : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
 libclone-perl : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
 libsub-name-perl : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
 libunicode-linebreak-perl : Depends: perl (>= 5.28.1-4) but 5.26.1-6ubuntu0.5 is to be installed
 libnet-dbus-perl : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
 libnet-dns-sec-perl : Depends: perl (>= 5.28.1-3) but 5.26.1-6ubuntu0.5 is to be installed
 libyaml-libyaml-perl : Depends: perl (>= 5.28.1-3) but 5.26.1-6ubuntu0.5 is to be installed
 libglib-perl : Depends: perl (>= 5.28.1-4) but 5.26.1-6ubuntu0.5 is to be installed
 libio-pty-perl : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
 libxml-libxml-perl : Depends: perl (>= 5.28.1-4) but 5.26.1-6ubuntu0.5 is to be installed
 libpadwalker-perl : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
 libmoose-perl : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
 libemail-address-xs-perl : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
 libsocket6-perl : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
 libdbd-mysql-perl : Depends: perl (>= 5.28.1-4) but 5.26.1-6ubuntu0.5 is to be installed
 libcairo-gobject-perl : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
 perl : Depends: perl-base (= 5.26.1-6ubuntu0.5) but 5.28.1-6+deb10u1 is installed
 libxml-parser-perl : Depends: perl (>= 5.28.1-4) but 5.26.1-6ubuntu0.5 is to be installed
 libglib-object-introspection-perl : Depends: perl (>= 5.28.1-4) but 5.26.1-6ubuntu0.5 is to be installed
 libsereal-decoder-perl : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
 libhtml-parser-perl : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
 libalgorithm-diff-xs-perl : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
 libperl-dev : Depends: perl:any (= 5.28.1-6+deb10u1) which is a virtual package, provided by:
                        - perl (5.28.1-6+deb10u1), but 5.26.1-6ubuntu0.5 is to be installed
                        - perl:i386 (5.26.1-6ubuntu0.5), but it is not going to be installed
                        - perl (5.26.1-6ubuntu0.5), but 5.26.1-6ubuntu0.5 is to be installed
                        - perl:i386 (5.26.1-6), but it is not going to be installed
                        - perl (5.26.1-6), but 5.26.1-6ubuntu0.5 is to be installed

 libclass-load-xs-perl : Depends: perl (>= 5.28.0-3) but 5.26.1-6ubuntu0.5 is to be installed
The following actions will resolve these dependencies:

     Keep the following packages at their current version:
1)     perl [5.28.1-6+deb10u1 (now)]                      



Accept this solution? [Y/n/q/?] n
The following actions will resolve these dependencies:

       Remove the following packages:                                                              
1)       apache2 [2.4.38-3+deb10u4 (now)]                                                          
2)       apache2-bin [2.4.38-3+deb10u4 (now)]                                                      
3)       apt-file [3.2.2 (now)]                                                                    
4)       apt-rdepends [1.3.0-6 (bionic, now)]                                                      
5)       autoconf [2.69-11.1 (now)]                                                                
6)       automake [1:1.16.1-4 (now)]                                                               
7)       build-essential [12.4ubuntu1 (bionic, now)]                                               
8)       cloc [1.74-1 (bionic, now)]                                                               
9)       command-not-found [18.04.5-1 (now)]                                                       
10)      debhelper [12.1.1ubuntu1~ubuntu18.04.1 (bionic-backports, now)]                           
11)      dh-autoreconf [19 (now)]                                                                  
12)      dh-strip-nondeterminism [1.8.0-1 (now)]                                                   
13)      dkms [2.3-3ubuntu9.7+elementary11~ubuntu5.0.1 (bionic, now)]                              
14)      doc-base [0.10.9 (now)]                                                                   
15)      dpkg-dev [1.19.7 (now)]                                                                   
16)      git [1:2.20.1-2+deb10u3 (now)]                                                            
17)      gnome-user-share [3.28.0-2 (now)]                                                         
18)      intltool-debian [0.35.0+20060710.5 (now)]                                                 
19)      libalgorithm-c3-perl [0.10-1 (bionic, now)]                                               
20)      libalgorithm-diff-perl [1.19.03-2 (now)]                                                  
21)      libalgorithm-diff-xs-perl [0.04-5+b1 (now)]                                               
22)      libalgorithm-merge-perl [0.08-3 (bionic, now)]                                            
23)      libapache2-mod-dnssd [0.6-3.2 (bionic, now)]                                              
24)      libapache2-mod-php7.4 [7.4.15-1+ubuntu18.04.1+deb.sury.org+1 (bionic, now)]               
25)      libarchive-cpio-perl [0.10-1 (bionic, now)]                                               
26)      libarchive-zip-perl [1.64-1 (now)]                                                        
27)      libasync-mergepoint-perl [0.04-2 (bionic, now)]                                           
28)      libauthen-sasl-perl [2.1600-1 (bionic, now)]                                              
29)      libb-hooks-endofscope-perl [0.24-1 (now)]                                                 
30)      libb-hooks-op-check-perl [0.22-1+b1 (now)]                                                
31)      libcairo-gobject-perl [1.004-3+b1 (now)]                                                  
32)      libcairo-perl [1.106-3+b1 (now)]                                                          
33)      libcapture-tiny-perl [0.48-1 (bionic, now)]                                               
34)      libcgi-fast-perl [1:2.15-1 (now)]                                                         
35)      libcgi-pm-perl [4.47-1 (now)]                                                             
36)      libclass-accessor-perl [0.51-1 (bionic, now)]                                             
37)      libclass-c3-perl [0.34-1 (now)]                                                           
38)      libclass-c3-xs-perl [0.14-1+b3 (now)]                                                     
39)      libclass-load-perl [0.25-1 (now)]                                                         
40)      libclass-load-xs-perl [0.10-1+b3 (now)]                                                   
41)      libclass-method-modifiers-perl [2.13-1 (now)]                                             
42)      libclass-tiny-perl [1.006-1 (bionic, now)]                                                
43)      libclass-xsaccessor-perl [1.19-3+b2 (now)]                                                
44)      libclone-perl [0.41-1+b1 (now)]                                                           
45)      libconvert-binhex-perl [1.125-1 (bionic, now)]                                            
46)      libdata-dump-perl [1.23-1 (bionic, now)]                                                  
47)      libdata-optlist-perl [0.110-1 (bionic, now)]                                              
48)      libdbd-mysql-perl [4.050-2 (now)]                                                         
49)      libdbi-perl [1.642-1+deb10u1 (now)]                                                       
50)      libdbus-1-dev [1.12.2-1ubuntu1.2 (bionic-security, bionic-updates, now)]                  
51)      libdevel-callchecker-perl [0.008-1 (now)]                                                 
52)      libdevel-caller-perl [2.06-2+b1 (now)]                                                    
53)      libdevel-globaldestruction-perl [0.14-1 (bionic, now)]                                    
54)      libdevel-lexalias-perl [0.05-2+b1 (now)]                                                  
55)      libdevel-overloadinfo-perl [0.005-1 (now)]                                                
56)      libdevel-partialdump-perl [0.20-1 (bionic, now)]                                          
57)      libdevel-stacktrace-perl [2.0400-1 (now)]                                                 
58)      libdigest-bubblebabble-perl [0.02-2 (bionic, now)]                                        
59)      libdigest-hmac-perl [1.03+dfsg-2 (now)]                                                   
60)      libdist-checkconflicts-perl [0.11-1 (bionic, now)]                                        
61)      libdpkg-perl [1.19.7 (now)]                                                               
62)      libdynaloader-functions-perl [0.003-1 (bionic, now)]                                      
63)      libemail-abstract-perl [3.008-2 (now)]                                                    
64)      libemail-address-xs-perl [1.04-1+b1 (now)]                                                
65)      libemail-date-format-perl [1.005-1 (bionic, now)]                                         
66)      libemail-foldertype-perl [0.813-1.2 (bionic, now)]                                        
67)      libemail-localdelivery-perl [1.200-1 (bionic, now)]                                       
68)      libemail-messageid-perl [1.406-1 (bionic, now)]                                           
69)      libemail-mime-contenttype-perl [1.022-1 (bionic, now)]                                    
70)      libemail-mime-encodings-perl [1.315-2 (bionic, now)]                                      
[...]                        
270)     aptitude recommends libparse-debianchangelog-perl                                         
271)     libnet-dns-perl recommends libdigest-bubblebabble-perl                                    
272)     libnet-dns-perl recommends libnet-libidn-perl                                             
273)     libio-socket-ssl-perl recommends libnet-libidn-perl | libnet-idn-encode-perl | liburi-perl
274)     libhtml-tree-perl recommends libhtml-format-perl                                          
275)     dpkg-dev recommends libalgorithm-merge-perl                                               
276)     libimage-exiftool-perl recommends libposix-strptime-perl                                  
[...]
296)     libwww-perl recommends libhtml-form-perl                                                  
297)     libwww-perl recommends libhtml-format-perl                                                
298)     libwww-perl recommends libhttp-daemon-perl                                                
299)     libwww-perl recommends libmailtools-perl                                                  
300)     libfile-stripnondeterminism-perl recommends libarchive-cpio-perl                          
301)     libxml-sax-perl recommends libxml-sax-expat-perl                                          
302)     libpackage-stash-perl recommends libpackage-stash-xs-perl                                 



Accept this solution? [Y/n/q/?] q
Abandoning all efforts to resolve these dependencies.
Abort.

如您所见,所提出的解决方案是不可接受的。我按了“n”多次,但没有提供任何解决方案,导致 perl 及其所有依赖项降级,没有任何重大删除或未满足的依赖项。

我列出了“deb”版本的所有软件包,并要求 aptitude 安装它们的“ubuntu”对应版本,但结果是一样的,aptitude 要么放弃,要么给出不必要的解决方案(删除太多软件包或什么也不做)。

我怎样才能安全地改正我的错误?

答案1

我的回答是基于你使用的是 ubuntu bionic 作为操作系统

这并不容易。首先备份重要数据。删除您自己所做的任何配置;我的意思是

500 镜像://mirrors.ubuntu.com/mirrors.txt bionic-updates/main amd64 软件包 500 镜像://mirrors.ubuntu.com/mirrors.txt bionic-security/main amd64 软件包

当然,删除 debian buster 源。如果集成了 bionc-backports,也可以创建

/etc/apt/preferences.d/ubuntu.pref

内容如下。我们用origin来尝试一下。

Package: *
Pin: origin us.archive.ubuntu.com
Pin-Priority: 1001 

Package: *
Pin: origin security.ubuntu.com
Pin-Priority: 1001 

#下一个是只有当你有合作伙伴在你的资源中

Package: *
Pin : release v=18.04,o=Canonical
Pin-Priority: 1001

刷新

sudo apt update

那么你可以先进行模拟。

apt -s full-upgrade

请注意这是否可行。

答案2

@nobody 的回答有助于修复一些软件包,但不是全部。

我注意到所有 debian 软件包都是使用 /var/lib/dpkg/status 安装的,优先级为 100,而 ubuntu 软件包都是从在线源安装的,优先级为 500。

因此,我列出了所有使用 100 版本而不是 500 版本的软件包,并强制将它们全部(几乎一个接一个,总共约 1200 个)安装到 ubuntu 版本,有时会删除仅限 debian 的软件包。

这花了我将近一天的时间,但最终所有软件包都恢复到了 ubuntu 版本并且一切恢复正常。

如果有人感兴趣的话,以下是我识别破损包裹的方法:

#!/bin/bash
dpkg -l \
         | awk '/^ii/{print $2}' \
         | while read p
do
        pol=$(apt-cache policy $p)
        ko=$(echo "$pol" | grep -P '\*{3} .* 100$')
        if [ "$ko" != "" ]; then
                echo $p=$(echo "$pol" | awk '/500$/{print $1;exit}')
        fi
done

我将此脚本的输出保存到一个文件中,然后从此文件中随机挑选 10 或 20 个并使用aptitude install(如aptitude install $(shuf -n 10 /tmp/pkg | tr \\n \ ))并使用在发生冲突时提出各种解决方案的强大功能aptitude。我总是选择仅降级或建议降级+删除 debian 专用软件包的选项。

我完成了清理我的来源和偏好设置的工作,然后运行apt updateapt upgrade然后apt full-upgrade一切都修复了。

这会教会我!谢谢你的帮助。

相关内容