apt-get更新/升级列表,无需更改任何内容


21

我想查看哪些软件包可用于更新/升级而无需实际更改任何文件,因为有些软件包我不想更新。这样便有可能获得异常更新。


apt需要通过来了解可用的更新apt-get update,这将改变一些事情。很棒的问题...在这里
bvj

Answers:


9

我用apt list --upgradable
下一个替代方法是apt-get --simulate upgrade。(基于@EightBitTony)
这是来自不同选项的输出(希望它对某人有帮助):

me@machine:~$ apt list --upgradable
    Listing... Done
    kubernetes-cni/kubernetes-xenial 0.7.5-00 amd64 [upgradable from: 0.6.0-00]
    N: There are 3 additional versions. Please use the '-a' switch to see them.
me@machine:~$ apt-get --simulate upgrade
    NOTE: This is only a simulation!
          apt-get needs root privileges for real execution.
          Keep also in mind that locking is deactivated,
          so don't depend on the relevance to the real current situation!
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Calculating upgrade... Done
    The following packages will be upgraded:
      kubernetes-cni
    1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    Inst kubernetes-cni [0.6.0-00] (0.7.5-00 kubernetes-xenial:kubernetes-xenial [amd64])
    Conf kubernetes-cni (0.7.5-00 kubernetes-xenial:kubernetes-xenial [amd64])
me@machine:~$ apt-get -u upgrade --assume-no
    E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
    E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
me@machine:~$ sudo apt-get -u upgrade --assume-no
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Calculating upgrade... Done
    The following packages will be upgraded:
      kubernetes-cni
    1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    Need to get 6,473 kB of archives.
    After this operation, 4,278 kB of additional disk space will be used.
    Do you want to continue? [Y/n] N
    Abort.
me@machine:~$ sudo apt-get -u -V upgrade
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Calculating upgrade... Done
    The following packages will be upgraded:
       kubernetes-cni (0.6.0-00 => 0.7.5-00)
    1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    Need to get 6,473 kB of archives.
    After this operation, 4,278 kB of additional disk space will be used.
    Do you want to continue? [Y/n] n
    Abort.

欢迎上车。
bvj

32

在apt-get手册页中,

   -s, --simulate, --just-print, --dry-run, --recon, --no-act
       No action; perform a simulation of events that would occur
       but do not actually change the system. Configuration Item:
       APT::Get::Simulate.

       Simulation run as user will deactivate locking (Debug::NoLocking)
       automatic. Also a notice will be displayed indicating that this
       is only a simulation, if the option APT::Get::Show-User-Simulation-Note
       is set (Default: true). Neither NoLocking nor the notice will be
       triggered if run as root (root should know what he is doing without
       further warnings by apt-get).

       Simulate prints out a series of lines each one representing a
       dpkg operation, Configure (Conf), Remove (Remv), Unpack (Inst).
       Square brackets indicate broken packages and empty set of square
       brackets meaning breaks that are of no consequence (rare).

所以,请确保您apt-get -s upgrade

如果您想升级某些软件包,只需apt-get install <package name>,如果已经安装,它将对其进行更新。但是,它还必须更新所有依赖项,并且取决于它们是什么,这些依赖项可以级联为许多更新。

如果我在软件包更新方面落后了,我将对apt-get install一些大型软件包(例如php,apache2等)进行处理,这样我就可以保留它们并检查所有问题,然后apt-get upgrade在完成后进行检查。


8

列出要升级的软件包及其版本:

$ sudo apt-get -u -V upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages have been kept back:
   mysql-client-5.5 (5.5.29-0ubuntu0.12.04.2 => 5.5.32-0ubuntu0.12.04.1)
   mysql-server-5.5 (5.5.29-0ubuntu0.12.04.2 => 5.5.32-0ubuntu0.12.04.1)
   mysql-server-core-5.5 (5.5.29-0ubuntu0.12.04.2 => 5.5.32-0ubuntu0.12.04.1)
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.

然后,您可以选择要升级的内容:

$ sudo apt-get --only-upgrade install mysql-client-5.5
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
firefox-globalmenu
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
libterm-readkey-perl
The following NEW packages will be installed:
libterm-readkey-perl
The following packages will be upgraded:
mysql-client-5.5
1 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
Need to get 8,123 kB of archives.
After this operation, 139 kB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Get:1 http://us.archive.ubuntu.com/ubuntu/ precise/main libterm-readkey-perl i386 2.30-4build3 [28.4 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main mysql-client-5.5 i386 5.5.32-0ubuntu0.12.04.1 [8,094 kB]
...

如果有任何旧的依赖项被删除,则可以运行apt-get autoremove,如您所见,将提示您安装任何新的依赖项。该--only-upgrade标志不是必需的,但是如果您要确保不要意外安装新软件包而不是升级现有软件包,那就很好了,例如,您遇到了其中一种情况并意外键入了错误的软件包:

$ sudo apt-get --only-upgrade install mysql-proxy
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Skipping mysql-proxy, it is not installed and only upgrades are requested.
The following package was automatically installed and is no longer required:
firefox-globalmenu
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.

1

这是否有助于您发布apt-get -s upgrade仅模拟的内容?然后,您可以使用来更新每个想要的软件包apt-get install <thepackage>

如果您希望通过一个不错的CLI GUI进行交互,请使用aptitude。如果尚未安装,请使用进行安装apt-get install aptitude

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.