Installing yum packages on airgapped (offline) CentOS 6 system

If you are concerned about compatibility between installed release and latest stable, you may want to determine your centos version in /etc/redhat-release and to use packages from http://vault.centos.org/, however bear in mind that they won't contain any security updates or bug fixes.

To download packages - use official redhat instrucions: https://access.redhat.com/solutions/10154

yum install yum-plugin-downloadonly
yum install --downloadonly --downloaddir=<directory> <package>

or

yum install yum-utils
yumdownloader --resolve

You may also look at replicating yum history on vm where you want to download rpms to with techniques from this answer: https://unix.stackexchange.com/a/83115

The easiest way, and it's worked for a long time is:

yum-debug-dump => gives file.
yum-debug-restore <file-from-debug-dump>

...which works much like the get/set selections dpkg command, AIUI. Also note that if you are replaying history you can use:

yum history addon-info last saved_tx => gives file
yum load-tx <file-from-addon-info>

...instead of having to parse it yourself.

Edit:

To install all rpms from directory, cd to it and simply use rpm -ivh *.rpm if you want to install them, or rpm -Uvh *.rpm if some downloaded files are newer than already present ones, and you are okay with updating them.


edit: NOPE, nothing is every this easy. Still getting this error on a fresh stack: Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again

If I let yum access the internet for just long enough to configure itself, the following works:

First I was able to pull down all the dependency packages with calls to

yum install -y --downloadonly --downloaddir=$pkgdir <package>

and

yum reinstall -y --downloadonly --downloaddir=$pkgdir <package>

to force any already installed packages to pull their .rpm and dependencies. Then, once I had procured my tarball of packages, I put that on a fresh system.

First, I ran sed -i 's/enabled=1/enabled=0/' '/etc/yum/pluginconf.d/fastestmirror.conf' to disable the fastmirror plugin.

Then, I was able to install all the packages I needed by cd'ing into the directory with the packages, then carefully calling

yum install --disablerepo=\* packag*

in the order required by the dependencies. So that looked kinda like

yum install --disablerepo=\* epel*
yum install --disablerepo=\* ius*
yum install --disablerepo=\* libstd*
yum install --disablerepo=\* mpfr*
yum install --disablerepo=\* cpp*
yum install --disablerepo=\* libgcc*
yum install --disablerepo=\* libgomp*
yum install --disablerepo=\* libg*
yum install --disablerepo=\* ppl*
yum install --disablerepo=\* cloog*
yum install --disablerepo=\* gcc*
yum install --disablerepo=\* atlas*
yum install --disablerepo=\* python*

And voila! I was able to run python3.5 on a fully airgapped system.