Here's a specific example using "httpd" as the package to download and install. This process was tested on both CentOS6 and CentOS7.
Install the stuff you need and make a place to put the downloaded RPMs:
# yum install yum-plugin-downloadonly yum-utils createrepo
# mkdir /var/tmp/httpd
# mkdir /var/tmp/httpd-installroot
Download the RPMs. This uses the installroot trick suggested here to force a full download of all dependencies since nothing is installed in that empty root. Yum will create some metadata in there, but we're going to throw it all away. Note that for CentOS7 releasever
would be "7".
# yum install --downloadonly --installroot=/var/tmp/httpd-installroot --releasever=6 --downloaddir=/var/tmp/httpd httpd
Yes, that was the small version. You should have seen the size of the full-repo downloads!
Generate the metadata needed to turn our new pile of RPMs into a YUM repo and clean up the stuff we no longer need:
# createrepo --database /var/tmp/httpd
# rm -rf /var/tmp/httpd-installroot
Configure the download directory as a repo. Note that for CentOS7 the gpgkey would be named "7" instead of "6":
# vi /etc/yum.repos.d/offline-httpd.repo
[offline-httpd]
name=CentOS-$releasever - httpd
baseurl=file:///var/tmp/httpd
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
To check the missing dependencies:
# repoclosure --repoid=offline-httpd
I haven't figured out why on CentOS7 this reports things like libssl.so.10(libssl.so.10)(64bit)
missing from httpd-tools
when openssl-libs-1.0.1e-51.el7_2.2.x86_64.rpm
(the provider of that library) is clearly present in the directory. Still, if you see something obviously missing, this might be a good chance to go back and add it using the same yum install --downloadonly
method above.
When offline or after copying the /var/tmp/httpd
repo directory to the other server set up the repo there:
# vi /etc/yum.repos.d/offline-httpd.repo
[offline-httpd]
name=CentOS-$releasever - httpd
baseurl=file:///var/tmp/httpd
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
# yum --disablerepo=\* --enablerepo=offline-httpd install httpd
Hopefully no missing dependencies!