LINUX

How to install all RPMs in a directory

How to install all RPMs in a directory - When you install a RPM, it checks whether your system is suitable for the software the RPM

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:
bash code
# chown -R root.root /home/user/repo
  • Install the createrepo package if not installed yet, and run
bash code
# createrepo /home/user/repo
# chmod -R o-w+r /home/user/repo
  • Create a repository configuration file, e.g. /etc/yum.repos.d/myrepo.repo containing
bash code
[local]
name=My Awesome Repo
baseurl=file:///home/user/repo
enabled=1
gpgcheck=0
  • Install your package using
bash code
# yum install packagename

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:
bash code
MySQL-client – Package Name
3.23.57 – Version
1 – Release
i386 – Architecture
  • 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.
bash code
# rpm -ivh  MySQL-client-3.23.57-1.i386.rpm
Preparing...                ########################################### [100%]
   1:MySQL-client           ########################################### [100%]
  • 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 :

bash code
# 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”.
bash code
# 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:
bash code
# createrepo --database /var/tmp/httpd
# rm -rf httpd-installroot
  • Configure the download directory as a repo. Note that for CentOS7 the gpgkey would be named “7” instead of 6:
bash code
# 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:
bash code
# repoclosure --repoid=offline-httpd   
  • 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:
bash code
# 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

 

READ  10 Best Linux Apps And Software

About the author

Venkatesan Prabu

Venkatesan Prabu

Wikitechy Founder, Author, International Speaker, and Job Consultant. My role as the CEO of Wikitechy, I help businesses build their next generation digital platforms and help with their product innovation and growth strategy. I'm a frequent speaker at tech conferences and events.

Add Comment

Click here to post a comment