是否有用于 RPM 将软件包降级到旧版本的多合一命令?

Mik*_*e B 3 rpm centos package-management

我想降级几个 RPM。有没有开关组合?例如,在升级时,我通常会运行,rpm -Uvh foo.rpm但我的理解是-U切换意味着它仅在包较旧时才替换它......因此它不适用于降级。

slm*_*slm 8

使用 RPM

请尝试以下操作:

$ rpm -Uvh --oldpackage pkg1.rpm pkg2.rpm
Run Code Online (Sandbox Code Playgroud)

摘自 rpm 手册页

   rpm {-U|--upgrade} [install-options] PACKAGE_FILE ...

   This upgrades or installs the package currently installed to a newer 
   version.  This is the same as install, except all other version(s) of the  
   package are removed after the new package is installed.

   --oldpackage
          Allow an upgrade to replace a newer package with an older one.
Run Code Online (Sandbox Code Playgroud)

使用 YUM + 降级

随着yum你应该能够做到以下几点,以及:

$ yum downgrade /path/pkg1.rpm /path/pkg2.rpm
Run Code Online (Sandbox Code Playgroud)

使用 YUM + 历史撤销

如果您之前安装了 pkgX-1.0,然后将其升级到 pkgX-1.1,您应该能够使用yum history查看此升级并yum history undo恢复此升级。

摘自 yum man page on history

撤消/重做/回滚命令采用单个事务 id 或关键字 last 和最后一个事务的偏移量(例如,如果您完成了 250 个事务,“last”指的是事务 250,而“last-4”指的是到交易 246)。在指定事务之前,重做命令还可以采用一些可选参数。“强制重新安装”告诉它重新安装在该事务中安装的任何软件包(通过安装、升级或降级)。“force-remove”告诉它强制删除任何更新或降级的包。

撤消/重做命令作用于指定的事务,撤消或重复该事务的工作。而回滚命令将撤消直到指定事务点的所有事务。例如,如果您有 3 个交易,其中包 A;B 和 C 分别安装。然后“undo 1”将尝试删除包A,“redo 1”将尝试安装包A(如果尚未安装),而“rollback 1”将尝试删除包B和C。注意在“ rollback 1" 您将有第四个事务,尽管结束 rpmdb 版本(请参阅:yum 版本)在事务 1 和 4 中应该相同。

要查看您的 YUM 历史记录:

$ sudo yum history | head
Loaded plugins: fastestmirror, langpacks, refresh-packagekit
ID     | Command line             | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
   120 | install httpd            | 2014-08-26 09:19 | Install        |    5   
   119 | install pydf             | 2014-08-22 17:11 | Install        |    1   
   118 | install xsel             | 2014-08-22 13:29 | Install        |    1   
   117 | install pastebinit       | 2014-08-22 13:26 | Install        |    2   
   116 | install xorg-x11-apps-0: | 2014-08-21 11:04 | Install        |    2   
   115 | remove adobe-release-x86 | 2014-08-21 02:18 | Erase          |    1   
   114 | update                   | 2014-08-21 02:15 | E, I, O, U     |   67  <
Run Code Online (Sandbox Code Playgroud)

要撤消特定事务:

$ sudo yum history undo 120
Loaded plugins: fastestmirror, langpacks, refresh-packagekit, tsflags
Undoing transaction 120, from Tue Aug 26 09:19:17 2014
    Dep-Install apr-1.5.1-1.fc20.x86_64                 @updates
    Dep-Install apr-util-1.5.3-1.fc20.x86_64            @updates
    Dep-Install fedora-logos-httpd-21.0.1-1.fc20.noarch @fedora
    Install     httpd-2.4.10-1.fc20.x86_64              @updates
    Dep-Install httpd-tools-2.4.10-1.fc20.x86_64        @updates
Resolving Dependencies
--> Running transaction check
---> Package apr.x86_64 0:1.5.1-1.fc20 will be erased
---> Package apr-util.x86_64 0:1.5.3-1.fc20 will be erased
---> Package fedora-logos-httpd.noarch 0:21.0.1-1.fc20 will be erased
---> Package httpd.x86_64 0:2.4.10-1.fc20 will be erased
---> Package httpd-tools.x86_64 0:2.4.10-1.fc20 will be erased
--> Finished Dependency Resolution
...
Run Code Online (Sandbox Code Playgroud)