Debian

Debian Stretch 想要在啟用反向移植後升級主包

  • June 1, 2018

Certbot要求我為它的安裝啟動拉伸反向埠。所以有了之後

$ cat /etc/apt/sources.list.d/backports.list
deb http://ftp.debian.org/debian stretch-backports main

並做一個sudo apt update我得到

$ apt list --upgradable
Listing... Done
libpam-systemd/stretch-backports 237-3~bpo9+1 amd64 [upgradable from: 232-25+deb9u3]
libsystemd0/stretch-backports 237-3~bpo9+1 amd64 [upgradable from: 232-25+deb9u3]
libudev1/stretch-backports 237-3~bpo9+1 amd64 [upgradable from: 232-25+deb9u3]
systemd/stretch-backports 237-3~bpo9+1 amd64 [upgradable from: 232-25+deb9u3]
systemd-sysv/stretch-backports 237-3~bpo9+1 amd64 [upgradable from: 232-25+deb9u3]
udev/stretch-backports 237-3~bpo9+1 amd64 [upgradable from: 232-25+deb9u3]

$ sudo apt upgrade
[...]
The following packages have been kept back:
 systemd-sysv
The following packages will be upgraded:
 libpam-systemd libsystemd0 libudev1 systemd udev
5 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
Need to get 4,795 kB of archives.
After this operation, 2,540 kB of additional disk space will be used.
Do you want to continue? [Y/n]

看起來它真的會繼續更新提到的包。

但是,從這個答案中,我引用:

來自反向移植的軟體包永遠不是從主記憶體儲庫升級的有效安裝候選者,僅用於從反向移植軟體包的先前版本升級;因此,雖然apt list --upgradable將其列為可升級包,apt upgrade但不會考慮將其升級。您可以在輸出中看到這一點apt-cache policy

所以檢查

$ apt policy systemd
systemd:
 Installed: 232-25+deb9u3
 Candidate: 237-3~bpo9+1
 Version table:
    237-3~bpo9+1 100
       100 http://ftp.debian.org/debian stretch-backports/main amd64 Packages
*** 232-25+deb9u3 100
       100 /var/lib/dpkg/status
    232-25+deb9u2 500
       500 http://ftp.debian.org/debian stretch/main amd64 Packages

似乎 backports 版本對升級有效。

我怎樣才能只為那些最初從 backports 安裝的包啟用從 backports 升級(即 via apt -t stretch-backports)?

編輯:我的sources.list

$ cat /etc/apt/sources.list
deb http://ftp.debian.org/debian stretch main
deb-src http://ftp.debian.org/debian stretch main

deb http://security.debian.org/debian-security stretch/updates main contrib
deb-src http://security.debian.org/debian-security stretch/updates main contrib

你不需要啟用任何東西來強制執行向後移植的記錄行為,但你需要確保系統知道你安裝的包來自哪裡。在您的情況下,您有一個systemdfrom版本stretch/updates,但您的來源沒有引用它,因此apt給出systemd分數為 100 的安裝版本,該分數小於或等於 backports 分數(請參閱您的apt policy輸出)。

要解決此問題,請確保您/etc/apt/sources.list有 的條目stretch-updates,例如

deb http://ftp.debian.org/debian stretch-updates main
deb-src http://ftp.debian.org/debian stretch-updates main

然後,您應該會看到apt policy systemd以下結果:

systemd:
 Installed: 232-25+deb9u3
 Candidate: 232-25+deb9u3
 Version table:
    237-3~bpo9+1 100
       100 http://ftp.debian.org/debian stretch-backports/main amd64 Packages
*** 232-25+deb9u3 500
       500 http://ftp.debian.org/debian stretch-updates/main amd64 Packages
       100 /usr/var/lib/dpkg/status
    232-25+deb9u2 500
       500 http://ftp.debian.org/debian stretch/main amd64 Packages

引用自:https://unix.stackexchange.com/questions/447335