在 apt --upgradeable 中选择相关软件包进行选择性安装

在 apt --upgradeable 中选择相关软件包进行选择性安装

在运行 Debian 时,我经常遇到大量可以升级的软件包。我不想只是apt upgrade不小心地做,所以我想先安装“非严重”软件包(及其相关的库等 - 分组),然后再查看“严重”软件包。

这样做的一种黑客方法是在这个问题的末尾,但我确信有更好的方法,并且这个问题可能会带来更好的想法或担忧。

问题:如何从 一起安装相关软件包的子组apt list --upgradeable

如果这是上面命令的输出;

apparmor/testing 2.13.3-5+b1 amd64 [upgradable from: 2.13.3-5]
gir1.2-atk-1.0/testing 2.34.1-1 amd64 [upgradable from: 2.34.0-1]
gir1.2-totem-1.0/testing 3.34.1-2 amd64 [upgradable from: 3.34.0-1+b1]
gjs/testing 1.58.1-1 amd64 [upgradable from: 1.58.0-2]
gnome-calculator/testing 3.34.1-1 amd64 [upgradable from: 3.34.0-1]
graphviz/testing 2.42.2-3 amd64 [upgradable from: 2.40.1-7]
hexchat/testing 2.14.2-5+b1 amd64 [upgradable from: 2.14.2-5]
imagemagick-6.q16/testing 8:6.9.10.23+dfsg-2.1+b2 amd64 [upgradable from: 8:6.9.10.23+dfsg-2.1+b1]
imagemagick/testing 8:6.9.10.23+dfsg-2.1+b2 amd64 [upgradable from: 8:6.9.10.23+dfsg-2.1+b1]
iputils-ping/testing 3:20190709-2 amd64 [upgradable from: 3:20190709-1]
libalgorithm-diff-xs-perl/testing 0.04-5+b2 amd64 [upgradable from: 0.04-5+b1]
libapparmor1/testing 2.13.3-5+b1 amd64 [upgradable from: 2.13.3-5]
libapt-pkg-perl/testing 0.1.36+b2 amd64 [upgradable from: 0.1.36+b1]
libatk-adaptor/testing 2.34.1-1 amd64 [upgradable from: 2.34.0-3]
libatk-bridge2.0-0/testing 2.34.1-1 amd64 [upgradable from: 2.34.0-3]
libatk-bridge2.0-dev/testing 2.34.1-1 amd64 [upgradable from: 2.34.0-3]
libatk1.0-0/testing 2.34.1-1 amd64 [upgradable from: 2.34.0-1]
libatk1.0-data/testing 2.34.1-1 all [upgradable from: 2.34.0-1]
libatk1.0-dev/testing 2.34.1-1 amd64 [upgradable from: 2.34.0-1]
libatk1.0-doc/testing 2.34.1-1 all [upgradable from: 2.34.0-1]
libb-hooks-op-check-perl/testing 0.22-1+b2 amd64 [upgradable from: 0.22-1+b1]
libcairo-gobject-perl/testing 1.005-2+b1 amd64 [upgradable from: 1.005-2]
libcairo-perl/testing 1.106-3+b2 amd64 [upgradable from: 1.106-3+b1]
libcdt5/testing 2.42.2-3 amd64 [upgradable from: 2.40.1-7]
libcgraph6/testing 2.42.2-3 amd64 [upgradable from: 2.40.1-7]
libclass-xsaccessor-perl/testing 1.19-3+b3 amd64 [upgradable from: 1.19-3+b2]
libclone-perl/testing 0.41-1+b2 amd64 [upgradable from: 0.41-1+b1]
libcommon-sense-perl/testing 3.74-2+b8 amd64 [upgradable from: 3.74-2+b7]
libdbd-mysql-perl/testing 4.050-2+b1 amd64 [upgradable from: 4.050-2]
libdbi-perl/testing 1.642-1+b2 amd64 [upgradable from: 1.642-1+b1]
libdevel-callchecker-perl/testing 0.008-1+b1 amd64 [upgradable from: 0.008-1]
libfcgi-perl/testing 0.78-2+b4 amd64 [upgradable from: 0.78-2+b3]
libfile-fcntllock-perl/testing 0.22-3+b6 amd64 [upgradable from: 0.22-3+b5]
libgd-perl/testing 2.71-2+b1 amd64 [upgradable from: 2.71-2]
libgdal-dev/testing 2.4.2+dfsg-1+b3 amd64 [upgradable from: 2.4.2+dfsg-1+b2]
libgdal20/testing 2.4.2+dfsg-1+b3 amd64 [upgradable from: 2.4.2+dfsg-1+b2]
libgjs0g/testing 1.58.1-1 amd64 [upgradable from: 1.58.0-2]
libglib-object-introspection-perl/testing 0.047-1+b1 amd64 [upgradable from: 0.047-1]
libglib-perl/testing 3:1.329.1-1+b1 amd64 [upgradable from: 3:1.329.1-1]
libglib2.0-0/testing 2.62.1-1 amd64 [upgradable from: 2.62.0-3]
libglib2.0-bin/testing 2.62.1-1 amd64 [upgradable from: 2.62.0-3]
libglib2.0-data/testing 2.62.1-1 all [upgradable from: 2.62.0-3]
libglib2.0-dev-bin/testing 2.62.1-1 amd64 [upgradable from: 2.62.0-3]
libglib2.0-dev/testing 2.62.1-1 amd64 [upgradable from: 2.62.0-3]
libglib2.0-doc/testing 2.62.1-1 all [upgradable from: 2.62.0-3]
libgvc6/testing 2.42.2-3 amd64 [upgradable from: 2.40.1-7]
libgvpr2/testing 2.42.2-3 amd64 [upgradable from: 2.40.1-7]
libhtml-parser-perl/testing 3.72-3+b4 amd64 [upgradable from: 3.72-3+b3]
libimage-magick-q16-perl/testing 8:6.9.10.23+dfsg-2.1+b2 amd64 [upgradable from: 8:6.9.10.23+dfsg-2.1+b1]
libio-pty-perl/testing 1:1.08-1.1+b6 amd64 [upgradable from: 1:1.08-1.1+b5]
libjson-xs-perl/testing 4.020-1+b1 amd64 [upgradable from: 4.020-1]
liblab-gamut1/testing 2.42.2-3 amd64 [upgradable from: 2.40.1-7]
libldap-2.4-2/testing 2.4.48+dfsg-1+b1 amd64 [upgradable from: 2.4.48+dfsg-1]
liblinux-epoll-perl/testing 0.016-1+b2 amd64 [upgradable from: 0.016-1+b1]
liblist-moreutils-perl/testing 0.416-1+b5 amd64 [upgradable from: 0.416-1+b4]
liblocale-gettext-perl/testing 1.07-3+b5 amd64 [upgradable from: 1.07-3+b4]
liblz4-1/testing 1.9.1-2 amd64 [upgradable from: 1.8.3-1+b1]
libmagick++-6.q16-8/testing 8:6.9.10.23+dfsg-2.1+b2 amd64 [upgradable from: 8:6.9.10.23+dfsg-2.1+b1]
libmagickcore-6.q16-6/testing 8:6.9.10.23+dfsg-2.1+b2 amd64 [upgradable from: 8:6.9.10.23+dfsg-2.1+b1]
libmagickwand-6.q16-6/testing 8:6.9.10.23+dfsg-2.1+b2 amd64 [upgradable from: 8:6.9.10.23+dfsg-2.1+b1]
libnet-dbus-perl/testing 1.1.0-6+b1 amd64 [upgradable from: 1.1.0-6]
libnet-dns-sec-perl/testing 1.13-1+b1 amd64 [upgradable from: 1.13-1]
libnet-libidn-perl/testing 0.12.ds-3+b2 amd64 [upgradable from: 0.12.ds-3+b1]
libnet-ssleay-perl/testing 1.88-1+b1 amd64 [upgradable from: 1.88-1]
libpango-perl/testing 1.227-3+b2 amd64 [upgradable from: 1.227-3+b1]
libparams-classify-perl/testing 0.015-1+b2 amd64 [upgradable from: 0.015-1+b1]
libpathplan4/testing 2.42.2-3 amd64 [upgradable from: 2.40.1-7]
libperlio-gzip-perl/testing 0.19-1+b6 amd64 [upgradable from: 0.19-1+b5]
libpurple0/testing 2.13.0-2.2+b1 amd64 [upgradable from: 2.13.0-2.2]
libpython2.7-dev/testing 2.7.17~rc1-1 amd64 [upgradable from: 2.7.16-4]
libpython2.7-minimal/testing 2.7.17~rc1-1 amd64 [upgradable from: 2.7.16-4]
libpython2.7-stdlib/testing 2.7.17~rc1-1 amd64 [upgradable from: 2.7.16-4]
libpython2.7/testing 2.7.17~rc1-1 amd64 [upgradable from: 2.7.16-4]
libpython3.7-dev/testing 3.7.5~rc1-2 amd64 [upgradable from: 3.7.5~rc1-1]
libpython3.7-minimal/testing 3.7.5~rc1-2 amd64 [upgradable from: 3.7.5~rc1-1]
libpython3.7-stdlib/testing 3.7.5~rc1-2 amd64 [upgradable from: 3.7.5~rc1-1]
libpython3.7/testing 3.7.5~rc1-2 amd64 [upgradable from: 3.7.5~rc1-1]
libref-util-xs-perl/testing 0.117-1+b2 amd64 [upgradable from: 0.117-1+b1]
libsereal-decoder-perl/testing 4.007+ds-1+b1 amd64 [upgradable from: 4.007+ds-1]
libsereal-encoder-perl/testing 4.007+ds-1+b1 amd64 [upgradable from: 4.007+ds-1]
libsnmp30/testing 5.7.3+dfsg-5+b2 amd64 [upgradable from: 5.7.3+dfsg-5+b1]
libsqlite3-0/testing 3.30.0-1 amd64 [upgradable from: 3.29.0-2]
libsqlite3-dev/testing 3.30.0-1 amd64 [upgradable from: 3.29.0-2]
libsub-name-perl/testing 0.21-1+b4 amd64 [upgradable from: 0.21-1+b3]
libsvn1/testing 1.10.6-1+b1 amd64 [upgradable from: 1.10.6-1]
libterm-readkey-perl/testing 2.38-1+b1 amd64 [upgradable from: 2.38-1]
libtext-charwidth-perl/testing 0.04-9+b1 amd64 [upgradable from: 0.04-9]
libtext-iconv-perl/testing 1.7-6+b2 amd64 [upgradable from: 1.7-6]
libtotem0/testing 3.34.1-2 amd64 [upgradable from: 3.34.0-1+b1]
libtype-tiny-xs-perl/testing 0.016-1+b1 amd64 [upgradable from: 0.016-1]
libunicode-utf8-perl/testing 0.62-1+b1 amd64 [upgradable from: 0.62-1]
libxdot4/testing 2.42.2-3 amd64 [upgradable from: 2.40.1-7]
libxml-libxml-perl/testing 2.0134+dfsg-1+b1 amd64 [upgradable from: 2.0134+dfsg-1]
libxml-parser-perl/testing 2.46-1+b1 amd64 [upgradable from: 2.46-1]
libyaml-libyaml-perl/testing 0.80+repack-2+b1 amd64 [upgradable from: 0.80+repack-2]
libzbar0/testing 0.23-1.1+b1 amd64 [upgradable from: 0.23-1.1]
linux-compiler-gcc-8-x86/testing 5.2.17-1+b1 amd64 [upgradable from: 5.2.17-1]
linux-headers-5.2.0-3-amd64/testing 5.2.17-1+b1 amd64 [upgradable from: 5.2.17-1]
linux-kbuild-5.2/testing 5.2.17-1+b1 amd64 [upgradable from: 5.2.17-1]
linux-libc-dev/testing 5.2.17-1+b1 amd64 [upgradable from: 5.2.17-1]
meson/testing 0.52.0-1 all [upgradable from: 0.51.2-1]
node-yargs-parser/testing 15.0.0-1 all [upgradable from: 14.0.0-2]
openjdk-11-jdk-headless/testing 11.0.5+9-1 amd64 [upgradable from: 11.0.5+6-2]
openjdk-11-jdk/testing 11.0.5+9-1 amd64 [upgradable from: 11.0.5+6-2]
openjdk-11-jre-headless/testing 11.0.5+9-1 amd64 [upgradable from: 11.0.5+6-2]
openjdk-11-jre/testing 11.0.5+9-1 amd64 [upgradable from: 11.0.5+6-2]
openssh-client/testing 1:8.1p1-1 amd64 [upgradable from: 1:8.0p1-7]
openssh-server/testing 1:8.1p1-1 amd64 [upgradable from: 1:8.0p1-7]
openssh-sftp-server/testing 1:8.1p1-1 amd64 [upgradable from: 1:8.0p1-7]
perl-base/testing 5.30.0-6 amd64 [upgradable from: 5.28.1-6]
perl/testing 5.30.0-6 amd64 [upgradable from: 5.28.1-6]
pidgin/testing 2.13.0-2.2+b1 amd64 [upgradable from: 2.13.0-2.2]
python2.7-dev/testing 2.7.17~rc1-1 amd64 [upgradable from: 2.7.16-4]
python2.7-minimal/testing 2.7.17~rc1-1 amd64 [upgradable from: 2.7.16-4]
python2.7/testing 2.7.17~rc1-1 amd64 [upgradable from: 2.7.16-4]
python3.7-dev/testing 3.7.5~rc1-2 amd64 [upgradable from: 3.7.5~rc1-1]
python3.7-minimal/testing 3.7.5~rc1-2 amd64 [upgradable from: 3.7.5~rc1-1]
python3.7/testing 3.7.5~rc1-2 amd64 [upgradable from: 3.7.5~rc1-1]
subversion/testing 1.10.6-1+b1 amd64 [upgradable from: 1.10.6-1]
texinfo/testing 6.6.0.dfsg.1-2+b1 amd64 [upgradable from: 6.6.0.dfsg.1-2]
totem-common/testing 3.34.1-2 all [upgradable from: 3.34.0-1]
totem-plugins/testing 3.34.1-2 amd64 [upgradable from: 3.34.0-1+b1]
totem/testing 3.34.1-2 amd64 [upgradable from: 3.34.0-1+b1]
usb.ids/testing 2019.10.05-1 all [upgradable from: 2019.07.27-1]

我想首先更新/安装所有与 python2 相关的东西。所以我会这样做:

 sudo apt-get -s install $(sudo apt list --upgradeable | cut -d " " -f 1 | sed 's/\/[a-z]*$//' | awk '/python3/' | tr "\n" " ")

当然,每一次pipe都可以将其分解成碎片,甚至可能>分解成文件。

我还注意到,apt声称脚本不稳定。

当然,它似乎apt-get也会接受包的“垂直列表”,例如

 sudo apt-get -s install $(sudo apt list --upgradeable | cut -d " " -f 1 | sed 's/\/[a-z]*$//' | awk '/python3/')

当然只使用一个sudo。这是我经常做的事情,所以希望(最有可能)有更好的方法和/或也可以帮助其他人。

PS我以为这个如何使用 apt 选择不完整的软件包? 和这个如何使用 apt 选择不完整的软件包?问题很接近,但并不完全是我想要的。

我试图让@Jasen 回答工作 -apt:安装所有 php 软件包apt-cache search但它是从和 not的池中提取的apt list --upgradeable,但即使他似乎也不喜欢它(尽管它比我使用的优雅得多)。

答案1

作为费伦茨·瓦格纳 建议,aptitude每当我想要对比“所有可以升级的东西”更细粒度的软件包选择进行操作时,我都会使用它。我假设您没有预定义的包集,您可以在脚本中为其编写匹配测试,因此更具交互性的方法是合适的;aptitude的TUI非常适合这种工作。

默认情况下,它按“虚拟”状态显示包(安全更新、其他可升级包、新包、已安装包、未安装包、过时包、虚拟包和任务;aptitude将其称为“状态”),并且在每个包中状态,按部分,最后按存档。因此,今天的 OpenSSL 更新集显示为

屏幕截图显示 <code>aptitude</code> 中“安全更新”下的 OpenSSL 更新,按部分划分:<code>doc</code>、<code>libdevel</code>、<code>libs</code> , <code>实用程序</code>

这与您所追求的不太相符,但是aptitude的显示是高度可定制的,并且包可以按源包名称甚至您关心的任何模式进行分组;例如,按状态、优先级和源包:

显示 <code>aptitude</code> 中 OpenSSL 更新的屏幕截图,位于“安全更新”下,按优先级和源包名称进行分类

您可以在运行时切换视图 ( G),或在aptitude的配置文件中配置您喜欢的视图。

+将选择要升级的软件包以及任何相关升级;aptitude还将突出显示任何损坏的东西。因此,选择仅libssl1.1升级后:

屏幕截图显示选择进行升级的 <code>libssl1.1</code>、自动选择的 <code>libssl1.1:i386</code> 以及因升级而损坏的 <code>libssl-dev</code>

此时我可以寻求aptitude帮助来解决损坏问题,或者继续自己选择软件包进行升级。会在实际执行之前向g我展示我要求执行的所有操作。aptitude在继续之前,我还可以查看软件包的更改日志,并检查所有可用版本等。

以这种方式使用还可以避免任何涉及(或)aptitude的方法的显着缺点:它不会丢失“自动安装”标志。apt installapt-get install

相关内容