26
32

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

rpmもyumもURLを直接指定してインストールできる

Last updated at Posted at 2017-03-03

wget や curl でダウンロードしてから rpm or yum するのは二度手間だと思いませんか?

たとえば、RedHat Enterprise Linux に epel リポジトリを追加する手順として、次のような方法を紹介しているのを見かけたりしますが、そもそも一発で出来ないものかと思いますよねー。

wget https://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm
rpm -ivh epel-release-7-9.noarch.rpm
curl -O https://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm
rpm -ivh epel-release-7-9.noarch.rpm

実は rpm も yum も URL 指定でインストールできるんですよ

ダウンロードした rpm のハッシュを手作業で検証するとか、インターネット側と直接通信できない機材ならともかく、そうでないならURL指定で一発でインストールしたほうがシンプルになります。

ただし指定するURLの信頼性は予め確認しておくべきですね。

たとえば rpm の例

依存パッケージが無い場合はこれでいけます。

$ sudo rpm -ivh https://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm
https://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm を 取得中
警告: /var/tmp/rpm-tmp.WoLaxZ: ヘッダー V3 RSA/SHA256 Signature、鍵 ID 352c64e5: NOKEY
準備しています...              ################################# [100%]
更新中 / インストール中...
   1:epel-release-7-9                 ################################# [100%]
$

あるいは yum の例

yumの場合は依存パッケージを自動的に追加インストールしてくれますから、通常はこちらを使うとよいです。

$ sudo yum install http://ftp.riken.jp/Linux/centos/7.5.1804/updates/x86_64/Packages/gcc-4.8.5-28.el7_5.1.x86_64.rpm
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror, ovl
gcc-4.8.5-28.el7_5.1.x86_64.rpm                                                                                          |  16 MB  00:00:03     
Examining /var/tmp/yum-root-utmdtS/gcc-4.8.5-28.el7_5.1.x86_64.rpm: gcc-4.8.5-28.el7_5.1.x86_64
Marking /var/tmp/yum-root-utmdtS/gcc-4.8.5-28.el7_5.1.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.8.5-28.el7_5.1 will be installed
--> Processing Dependency: cpp = 4.8.5-28.el7_5.1 for package: gcc-4.8.5-28.el7_5.1.x86_64
Loading mirror speeds from cached hostfile
 * base: ftp-srv2.kddilabs.jp
 * epel: mirror.dmmlabs.jp
 * extras: ftp-srv2.kddilabs.jp
 * updates: ftp-srv2.kddilabs.jp
--> Processing Dependency: libgomp = 4.8.5-28.el7_5.1 for package: gcc-4.8.5-28.el7_5.1.x86_64
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-4.8.5-28.el7_5.1.x86_64
--> Processing Dependency: libgomp.so.1()(64bit) for package: gcc-4.8.5-28.el7_5.1.x86_64
--> Processing Dependency: libmpc.so.3()(64bit) for package: gcc-4.8.5-28.el7_5.1.x86_64
--> Processing Dependency: libmpfr.so.4()(64bit) for package: gcc-4.8.5-28.el7_5.1.x86_64
--> Running transaction check
---> Package cpp.x86_64 0:4.8.5-28.el7_5.1 will be installed
---> Package glibc-devel.x86_64 0:2.17-222.el7 will be installed
--> Processing Dependency: glibc-headers = 2.17-222.el7 for package: glibc-devel-2.17-222.el7.x86_64
--> Processing Dependency: glibc-headers for package: glibc-devel-2.17-222.el7.x86_64
---> Package libgomp.x86_64 0:4.8.5-28.el7_5.1 will be installed
---> Package libmpc.x86_64 0:1.0.1-3.el7 will be installed
---> Package mpfr.x86_64 0:3.1.1-4.el7 will be installed
--> Running transaction check
---> Package glibc-headers.x86_64 0:2.17-222.el7 will be installed
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.17-222.el7.x86_64
--> Processing Dependency: kernel-headers for package: glibc-headers-2.17-222.el7.x86_64
--> Running transaction check
---> Package kernel-headers.x86_64 0:3.10.0-862.11.6.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================
 Package                        Arch                   Version                               Repository                                    Size
================================================================================================================================================
Installing:
 gcc                            x86_64                 4.8.5-28.el7_5.1                      /gcc-4.8.5-28.el7_5.1.x86_64                  37 M
Installing for dependencies:
 cpp                            x86_64                 4.8.5-28.el7_5.1                      updates                                      5.9 M
 glibc-devel                    x86_64                 2.17-222.el7                          base                                         1.1 M
 glibc-headers                  x86_64                 2.17-222.el7                          base                                         678 k
 kernel-headers                 x86_64                 3.10.0-862.11.6.el7                   updates                                      7.1 M
 libgomp                        x86_64                 4.8.5-28.el7_5.1                      updates                                      156 k
 libmpc                         x86_64                 1.0.1-3.el7                           base                                          51 k
 mpfr                           x86_64                 3.1.1-4.el7                           base                                         203 k

Transaction Summary
================================================================================================================================================
Install  1 Package (+7 Dependent packages)

Total size: 53 M
Total download size: 15 M
Installed size: 60 M
Is this ok [y/d/N]: 

おなじことを rpm でやると、こうなります。依存するパッケージがあることは教えてくれますが、それ以上のフォローはないわけです。

$ sudo rpm -ivh http://ftp.riken.jp/Linux/centos/7.5.1804/updates/x86_64/Packages/gcc-4.8.5-28.el7_5.1.x86_64.rpm
Retrieving http://ftp.riken.jp/Linux/centos/7.5.1804/updates/x86_64/Packages/gcc-4.8.5-28.el7_5.1.x86_64.rpm
error: Failed dependencies:
	cpp = 4.8.5-28.el7_5.1 is needed by gcc-4.8.5-28.el7_5.1.x86_64
	glibc-devel >= 2.2.90-12 is needed by gcc-4.8.5-28.el7_5.1.x86_64
	libgomp = 4.8.5-28.el7_5.1 is needed by gcc-4.8.5-28.el7_5.1.x86_64
	libgomp.so.1()(64bit) is needed by gcc-4.8.5-28.el7_5.1.x86_64
	libmpc.so.3()(64bit) is needed by gcc-4.8.5-28.el7_5.1.x86_64
	libmpfr.so.4()(64bit) is needed by gcc-4.8.5-28.el7_5.1.x86_64
26
32
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
26
32

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?