我正在编写一个脚本来从 URL 安装软件包。如果未安装,该脚本需要安装该软件包;如果已安装,则将现有版本强制替换为指定的 RPM。不幸的是,如果包已经是正确的版本,则yum install
和返回 1。yum update
我如何告诉yum
绝对、积极地安装 RPM,并且仅在存在时返回退出代码实际错误?
答案1
我不会让脚本调用yum
进行下载和安装,而是让脚本下载文件(使用例如curl
或wget
),然后强制安装下载的.rpm
文件:
rpm --install --force file_name.rpm
正如OP所示,rpm
可以直接下载URL,没有问题。从手册页:
INSTALLING, UPGRADING, AND REMOVING PACKAGES:
rpm {-i|--install} [install-options] PACKAGE_FILE ...
rpm {-U|--upgrade} [install-options] PACKAGE_FILE ...
rpm {-F|--freshen} [install-options] PACKAGE_FILE ...
<snip>
In these options, PACKAGE_FILE can be either rpm binary file or ASCII
package manifest (see PACKAGE SELECTION OPTIONS), and may be specified
as an ftp or http URL, in which case the package will be downloaded
before being installed. See FTP/HTTP OPTIONS for information on rpm's
internal ftp and http client support.