通过版本控制的存储库的确定性升级 - Amazon Linux 2023

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

通过版本控制的存储库的确定性升级

使用确定性升级系统

但您运行 dnf upgrade 命令时,系统会检查 releasever 变量指定的存储库中的升级。有效的版本要么releasever最新版本,要么是带有日期戳的版本,例如 2023.5.20240624。

您可以使用以下任一方法更改 releasever 的值。这些方法按系统优先级降序列出。这意味着方法 1 优先于方法 2 和 3,方法 2 优先于方法 3。

  1. 命令行标志中的值,--releasever=latest(如果使用)。

  2. 替代变量文件中指定的值,/etc/dnf/vars/releasever(如果设置)。

  3. 当前安装的 system-release 软件包版本。

在以下示例中,版本为 2023.0.20230210

$ rpm -q system-release system-release-2023.0.20230210-0.amzn2023.noarch

在新安装的系统中,替代变量不存在。由于系统锁定到 system-release 的已安装版本,所以无升级可用。

$ cat /etc/dnf/vars/releasever cat: /etc/dnf/vars/releasever: No such file or directory
$ sudo dnf upgrade Last metadata expiration check: 0:00:02 ago on Wed 15 Feb 2023 06:14:12 PM UTC. Dependencies resolved. Nothing to do. Complete!

要获取某个特定版本的软件包,您可以通过使用 releasever 标志来提供所需的版本。

$ rpm -q system-release system-release-2023.0.20230222-0.amzn2023.noarch
$ sudo dnf upgrade --releasever=2023.0.20230329 Amazon Linux 2023 repository 26 MB/s | 12 MB 00:00 Dependencies resolved. ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: kernel aarch64 6.1.21-1.45.amzn2023 amazonlinux 26 M Upgrading: amazon-linux-repo-s3 noarch 2023.0.20230329-0.amzn2023 amazonlinux 18 k ca-certificates noarch 2023.2.60-1.0.amzn2023.0.1 amazonlinux 828 k cloud-init noarch 22.2.2-1.amzn2023.1.7 amazonlinux 1.1 M ... [ list edited for clarity ] system-release noarch 2023.0.20230329-0.amzn2023 amazonlinux 29 k ... [ list edited for clarity ] vim-data noarch 2:9.0.1403-1.amzn2023.0.1 amazonlinux 25 k vim-minimal aarch64 2:9.0.1403-1.amzn2023.0.1 amazonlinux 753 k Transaction Summary ================================================================================ Install 1 Package Upgrade 42 Packages Total download size: 56 M

由于 --releasever 选项优先于 system-release/etc/dnf/vars/releasever,所以此升级的结果如下:

  1. 升级将替换在先前版本和新版本之间有所变化的所有已安装的软件包。

  2. 升级会将系统锁定到 system-release 的新版本的存储库。

选择性更新确定性升级系统

您或许想要安装来自最近版本的选定软件包,同时仍将系统锁定到原始发行版本。

您可以使用 dnf check-update 来确认要升级的软件包。

$ sudo dnf check-update --releasever=latest --security Amazon Linux 2023 repository 13 MB/s | 10 MB 00:00 Last metadata expiration check: 0:00:02 ago on Wed 15 Feb 2023 02:52:21 AM UTC. bind-libs.aarch64 32:9.16.27-1.amzn2023.0.1 amazonlinux bind-license.noarch 32:9.16.27-1.amzn2023.0.1 amazonlinux bind-utils.aarch64 32:9.16.27-1.amzn2023.0.1 amazonlinux cryptsetup.aarch64 2.4.3-2.amzn2023.0.1 amazonlinux cryptsetup-libs.aarch64 2.4.3-2.amzn2023.0.1 amazonlinux curl-minimal.aarch64 7.85.0-1.amzn2023.0.1 amazonlinux glibc.aarch64 2.34-40.amzn2023.0.2 amazonlinux glibc-all-langpacks.aarch64 2.34-40.amzn2023.0.2 amazonlinux glibc-common.aarch64 2.34-40.amzn2023.0.2 amazonlinux glibc-locale-source.aarch64 2.34-40.amzn2023.0.2 amazonlinux gmp.aarch64 1:6.2.1-2.amzn2023.0.1 amazonlinux gnupg2-minimal.aarch64 2.3.7-1.amzn2023.0.2 amazonlinux gzip.aarch64 1.10-5.amzn2023.0.1 amazonlinux kernel.aarch64 6.1.12-17.42.amzn2023 amazonlinux kernel-tools.aarch64 6.1.12-17.42.amzn2023 amazonlinux libarchive.aarch64 3.5.3-2.amzn2023.0.1 amazonlinux libcurl-minimal.aarch64 7.85.0-1.amzn2023.0.1 amazonlinux libsepol.aarch64 3.4-3.amzn2023.0.2 amazonlinux libsolv.aarch64 0.7.22-1.amzn2023.0.1 amazonlinux libxml2.aarch64 2.9.14-1.amzn2023.0.1 amazonlinux logrotate.aarch64 3.20.1-2.amzn2023.0.2 amazonlinux lua-libs.aarch64 5.4.4-3.amzn2023.0.1 amazonlinux lz4-libs.aarch64 1.9.4-1.amzn2023.0.1 amazonlinux openssl.aarch64 1:3.0.5-1.amzn2023.0.3 amazonlinux openssl-libs.aarch64 1:3.0.5-1.amzn2023.0.3 amazonlinux pcre2.aarch64 10.40-1.amzn2023.0.1 amazonlinux pcre2-syntax.noarch 10.40-1.amzn2023.0.1 amazonlinux rsync.aarch64 3.2.6-1.amzn2023.0.2 amazonlinux vim-common.aarch64 2:9.0.475-1.amzn2023.0.1 amazonlinux vim-data.noarch 2:9.0.475-1.amzn2023.0.1 amazonlinux vim-enhanced.aarch64 2:9.0.475-1.amzn2023.0.1 amazonlinux vim-filesystem.noarch 2:9.0.475-1.amzn2023.0.1 amazonlinux vim-minimal.aarch64 2:9.0.475-1.amzn2023.0.1 amazonlinux xz.aarch64 5.2.5-9.amzn2023.0.1 amazonlinux xz-libs.aarch64 5.2.5-9.amzn2023.0.1 amazonlinux zlib.aarch64 1.2.11-32.amzn2023.0.3 amazonlinux

安装要升级的软件包。使用 sudo dnf upgrade --releasever=latest 和软件包名称来确保 system-release 软件包保持不变。

$ sudo dnf upgrade --releasever=latest openssl openssl-libs Last metadata expiration check: 0:01:28 ago on Wed 15 Feb 2023 02:52:21 AM UTC. Dependencies resolved. ================================================================================ Package Arch Version Repository Size ================================================================================ Upgrading: openssl aarch64 1:3.0.5-1.amzn2023.0.3 amazonlinux 1.1 M openssl-libs aarch64 1:3.0.5-1.amzn2023.0.3 amazonlinux 2.1 M Transaction Summary ================================================================================ Upgrade 2 Packages Total download size: 3.2 M
注意

使用 sudo dnf upgrade --releasever=latest 更新所有软件包,包括 system-release。然后,该版本仍锁定到新的 system-release,除非您设置了持久取代。

在确定性升级中使用持久取代

您可以不添加 --releasever=latest,而是使用持久取代,通过将变量值设置为 latest解锁 系统。

$ echo latest | sudo tee /etc/dnf/vars/releasever latest
$ sudo dnf upgrade Last metadata expiration check: 0:03:36 ago on Wed 15 Feb 2023 02:52:21 AM UTC. Dependencies resolved. ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: kernel aarch64 6.1.73-45.135.amzn2023 amazonlinux 24 M Upgrading: acl aarch64 2.3.1-2.amzn2023.0.1 amazonlinux 72 k alternatives aarch64 1.15-2.amzn2023.0.1 amazonlinux 36 k amazon-ec2-net-utils noarch 2.3.0-1.amzn2023.0.1 amazonlinux 16 k at aarch64 3.1.23-6.amzn2023.0.1 amazonlinux 60 k attr aarch64 2.5.1-3.amzn2023.0.1 amazonlinux 59 k audit aarch64 3.0.6-1.amzn2023.0.1 amazonlinux 249 k audit-libs aarch64 3.0.6-1.amzn2023.0.1 amazonlinux 116 k aws-c-auth-libs aarch64 0.6.5-6.amzn2023.0.2 amazonlinux 79 k aws-c-cal-libs aarch64 0.5.12-7.amzn2023.0.2 amazonlinux 34 k aws-c-common-libs aarch64 0.6.14-6.amzn2023.0.2 amazonlinux 119 k aws-c-compression-libs aarch64 0.2.14-5.amzn2023.0.2 amazonlinux 22 k aws-c-event-stream-libs aarch64 0.2.7-5.amzn2023.0.2 amazonlinux 47 k aws-c-http-libs aarch64 0.6.8-6.amzn2023.0.2 amazonlinux 147 k aws-c-io-libs aarch64 0.10.12-5.amzn2023.0.6 amazonlinux 109 k aws-c-mqtt-libs aarch64 0.7.8-7.amzn2023.0.2 amazonlinux 61 k aws-c-s3-libs aarch64 0.1.27-5.amzn2023.0.3 amazonlinux 54 k aws-c-sdkutils-libs aarch64 0.1.1-5.amzn2023.0.2 amazonlinux 26 k aws-checksums-libs aarch64 0.1.12-5.amzn2023.0.2 amazonlinux 50 k awscli-2 noarch 2.7.8-1.amzn2023.0.4 amazonlinux 7.3 M basesystem noarch 11-11.amzn2023.0.1 amazonlinux 7.8 k bash aarch64 5.1.8-2.amzn2023.0.1 amazonlinux 1.6 M bash-completion noarch 1:2.11-2.amzn2023.0.1 amazonlinux 292 k bc aarch64 1.07.1-14.amzn2023.0.1 amazonlinux 120 k bind-libs aarch64 32:9.16.27-1.amzn2023.0.1 amazonlinux 1.2 M bind-license noarch 32:9.16.27-1.amzn2023.0.1 amazonlinux 14 k bind-utils aarch64 32:9.16.27-1.amzn2023.0.1 amazonlinux 206 k binutils aarch64 2.38-20.amzn2023.0.3 amazonlinux 4.6 M boost-filesystem aarch64 1.75.0-4.amzn2023.0.1 amazonlinux 55 k boost-system aarch64 1.75.0-4.amzn2023.0.1 amazonlinux 14 k boost-thread aarch64 1.75.0-4.amzn2023.0.1 amazonlinux 54 k bzip2 aarch64 1.0.8-6.amzn2023.0.1 amazonlinux 53 k bzip2-libs aarch64 1.0.8-6.amzn2023.0.1 amazonlinux 44 k c-ares aarch64 1.17.2-1.amzn2023.0.1 amazonlinux 107 k ca-certificates noarch 2021.2.50-1.0.amzn2023.0.3 amazonlinux 343 k checkpolicy aarch64 3.4-3.amzn2023.0.1 amazonlinux 345 k chkconfig aarch64 1.15-2.amzn2023.0.1 amazonlinux 162 k chrony aarch64 4.2-7.amzn2023.0.4 amazonlinux 314 k cloud-init noarch 22.2.2-1.amzn2023.1.7 amazonlinux 1.1 M cloud-utils-growpart aarch64 0.31-8.amzn2023.0.2 amazonlinux 31 k coreutils aarch64 8.32-30.amzn2023.0.2 amazonlinux 1.1 M coreutils-common aarch64 8.32-30.amzn2023.0.2 amazonlinux 2.0 M cpio aarch64 2.13-10.amzn2023.0.1 amazonlinux 269 k cracklib aarch64 2.9.6-27.amzn2023.0.1 amazonlinux 83 k cracklib-dicts aarch64 2.9.6-27.amzn2023.0.1 amazonlinux 3.6 M crontabs noarch 1.11-24.20190603git.amzn2023.0.1 amazonlinux 19 k crypto-policies noarch 20230128-1.gitdfb10ea.amzn2023.0.1 amazonlinux 61 k crypto-policies-scripts noarch 20230128-1.gitdfb10ea.amzn2023.0.1 amazonlinux 81 k ... Installing dependencies: amazon-linux-repo-cdn noarch 2023.0.20230210-0.amzn2023 amazonlinux 16 k xxhash-libs aarch64 0.8.0-3.amzn2023.0.1 amazonlinux 32 k Installing weak dependencies: amazon-chrony-config noarch 4.2-7.amzn2023.0.4 amazonlinux 14 k gawk-all-langpacks aarch64 5.1.0-3.amzn2023.0.1 amazonlinux 207 k Transaction Summary ================================================================================ Install 5 Packages Upgrade 413 Packages Total download size: 199 M
注意

如果您使用了取代变量 /etc/dnf/vars/releasever,请使用以下命令,通过擦除取代值来恢复默认锁定行为。

$ sudo rm /etc/dnf/vars/releasever