为了重新编译rpm包,需要在rpm包的源码包上编译, 每次到互联网上搜索下载,挺麻烦的, 可以通过rpm的工具直接下载.

命令为yumdownloader, 需要通过

yum install yum-utils

来安装, 在Redhat的系统中,可能需要配置SRC package的源仓库,/etc/yum.repos.d/rhel-src.repo

[rhel-src]
name=Red Hat Enterprise Linux $releasever - $basearch - Source
baseurl=ftp://ftp.redhat.com/pub/redhat/linux/enterprise/$releasever/en/os/SRPMS/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

在Centos7.x系统上直接执行命令就可以了.

[root@server ~]# yumdownloader --source iscsi-initiator-utils
Loaded plugins: fastestmirror
Enabling updates-source repository
Enabling base-source repository
Enabling extras-source repository
Loading mirror speeds from cached hostfile
 * base: mirrors.cn99.com
 * extras: mirrors.cqu.edu.cn
 * updates: mirrors.cn99.com
base-source                                                                     | 2.9 kB  00:00:00
extras-source                                                                   | 2.9 kB  00:00:00
updates-source                                                                  | 2.9 kB  00:00:00
(1/3): extras-source/7/primary_db                                               |  27 kB  00:00:00
(2/3): updates-source/7/primary_db                                              | 115 kB  00:00:01
(3/3): base-source/7/primary_db                                                 | 966 kB  00:00:15
iscsi-initiator-utils-6.2.0.874-10.el7.src.rpm                                  | 978 kB  00:00:15

命令执行完成后,这个文件就在执行命令的当前目录下.