Make rpm auto install dependencies:

Create a (local) repository and use yum to have it resolve the dependencies for you.

  • Create a directory for you local repository, e.g. /home/user/repo.
  • Move the RPMs into that directory.
  • Fix some ownership and file system permissions:
[pastacode lang=”bash” manual=”%23%20chown%20-R%20root.root%20%2Fhome%2Fuser%2Frepo%0A” message=”bash code” highlight=”” provider=”manual”/]
  • Install the createrepo package if not installed yet, and run
[pastacode lang=”bash” manual=”%23%20createrepo%20%2Fhome%2Fuser%2Frepo%0A%23%20chmod%20-R%20o-w%2Br%20%2Fhome%2Fuser%2Frepo” message=”bash code” highlight=”” provider=”manual”/] [ad type=”banner”]
  • Create a repository configuration file, e.g. /etc/yum.repos.d/myrepo.repo containing
[pastacode lang=”bash” manual=”%5Blocal%5D%0Aname%3DMy%20Awesome%20Repo%0Abaseurl%3Dfile%3A%2F%2F%2Fhome%2Fuser%2Frepo%0Aenabled%3D1%0Agpgcheck%3D0%0A” message=”bash code” highlight=”” provider=”manual”/]
  • Install your package using
[pastacode lang=”bash” manual=”%23%20yum%20install%20packagename” message=”bash code” highlight=”” provider=”manual”/]

Installing a RPM package Using rpm –ivh

  • RPM filename has packagename, version, release and architecture name.
  • For example, In the MySQL-client-3.23.57-1.i386.rpm file:
[pastacode lang=”bash” manual=”MySQL-client%20%E2%80%93%20Package%20Name%0A3.23.57%20%E2%80%93%20Version%0A1%20%E2%80%93%20Release%0Ai386%20%E2%80%93%20Architecture%0A” message=”bash code” highlight=”” provider=”manual”/] [ad type=”banner”]
  • When you install a RPM, it checks whether your system is suitable for the software the RPM package contains, figures out where to install the files located inside the rpm package, installs them on your system, and adds that piece of software into its database of installed RPM packages.
  • The following rpm command installs Mysql client package.
[pastacode lang=”bash” manual=”%23%20rpm%20-ivh%20%20MySQL-client-3.23.57-1.i386.rpm%0APreparing…%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%20%5B100%25%5D%0A%20%20%201%3AMySQL-client%20%20%20%20%20%20%20%20%20%20%20%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%20%5B100%25%5D%0A” message=”bash code” highlight=”” provider=”manual”/]
  • rpm command and options
    • -i : install a package
    • -v : verbose
    • -h : print hash marks as the package archive is unpacked.

Install the stuff you need and make a place to put the downloaded RPMs :

[pastacode lang=”bash” manual=”%23%20yum%20install%20yum-plugin-downloadonly%20yum-utils%20createrepo%0A%23%20mkdir%20%2Fvar%2Ftmp%2Fhttpd%0A%23%20mkdir%20%2Fvar%2Ftmp%2Fhttpd-installroot%0A” message=”bash code” highlight=”” provider=”manual”/]
  • 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”.
[pastacode lang=”bash” manual=”%23%20yum%20install%20–downloadonly%20–installroot%3D%2Fvar%2Ftmp%2Fhttpd-installroot%20–releasever%3D6%20–downloaddir%3D%2Fvar%2Ftmp%2Fhttpd%20httpd%0A” message=”bash code” highlight=”” provider=”manual”/] [ad type=”banner”]
  • 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:
[pastacode lang=”bash” manual=”%23%20createrepo%20–database%20%2Fvar%2Ftmp%2Fhttpd%0A%23%20rm%20-rf%20httpd-installroot%0A” message=”bash code” highlight=”” provider=”manual”/]
  • Configure the download directory as a repo. Note that for CentOS7 the gpgkey would be named “7” instead of 6:
[pastacode lang=”bash” manual=”%23%20vi%20%2Fetc%2Fyum.repos.d%2Foffline-httpd.repo%0A%5Boffline-httpd%5D%0Aname%3DCentOS-%24releasever%20-%20httpd%0Abaseurl%3Dfile%3A%2F%2F%2Fvar%2Ftmp%2Fhttpd%0Aenabled%3D0%0Agpgcheck%3D1%0Agpgkey%3Dfile%3A%2F%2F%2Fetc%2Fpki%2Frpm-gpg%2FRPM-GPG-KEY-CentOS-6%0A” message=”bash code” highlight=”” provider=”manual”/]
  • To check the missing dependencies:
[pastacode lang=”bash” manual=”%23%20repoclosure%20–repoid%3Doffline-httpd%20%20%20%0A” message=”bash code” highlight=”” provider=”manual”/] [ad type=”banner”]
  • 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 –download only method above.
  • When offline or after copying the /var/tmp/httpd repo directory to the other server set up the repo there:
[pastacode lang=”bash” manual=”%23%20vi%20%2Fetc%2Fyum.repos.d%2Foffline-httpd.repo%0A%5Boffline-httpd%5D%0Aname%3DCentOS-%24releasever%20-%20httpd%0Abaseurl%3Dfile%3A%2F%2F%2Fvar%2Ftmp%2Fhttpd%0Aenabled%3D0%0Agpgcheck%3D1%0Agpgkey%3Dfile%3A%2F%2F%2Fetc%2Fpki%2Frpm-gpg%2FRPM-GPG-KEY-CentOS-6%0A%23%20yum%20–disablerepo%3D%5C*%20–enablerepo%3Doffline-httpd%20install%20httpd%0A” message=”bash code” highlight=”” provider=”manual”/]

 

Categorized in: