Tuesday, 8 November 2016

Working With RPMs

The RPM Package Manager (RPM) is an open packaging system that runs on Red Hat Enterprise Linux as well as other Linux and UNIX systems. The RPM Package Manager only works with packages built in the RPM format RPMmaintains a database of installed packages and their files, so you can invoke powerful queries and verifications on your system.
For the developer, RPM enables software source code to be packaged into source and binary packages for end users. This process is quite simple and is driven from a single file and optional patches that you create.

RPM Design Goals:

Upgradability
                      With RPM, you can upgrade individual components of your system without a complete reinstallation. When you get a new release of an operating system based on RPM, such as Red Hat Enterprise Linux, you do not need to reinstall a fresh copy of the operating system on your machine (as you might need to with operating systems based on other packaging systems). RPM allows for intelligent, fully-automated, in-place upgrades of your system. In addition, configuration files in packages are preserved across upgrades, so you do not lose your customizations. There are no special upgrade files needed to upgrade a package because the same RPM file is used to both install and upgrade the package on the system.

Powerful Querying
                               RPM
is designed to provide powerful querying options. You can perform searches on your copy of the database for packages or even just certain files. You can also easily find out what package a file belongs to and where the package came from. The files an RPM package contains are in a compressed archive, with a custom binary header containing useful information about the package and its contents, allowing you to query individual packages quickly and easily.

System Verification
                                Another powerful RPM feature is the ability to verify packages. It allows you to verify that the files installed on the system are the same as the ones supplied by a given package. If an inconsistency is detected, RPM notifies you, and you can reinstall the package if necessary. Any configuration files that you modified are preserved during reinstallation.

Pristine Sources
                            A crucial design goal was to allow the use of pristine software sources, as distributed by the original authors of the software. With RPM, you have the pristine sources along with any patches that were used, plus complete build instructions. This is an important advantage for several reasons. For example, if a new version of a program is released, you do not necessarily have to start from scratch to get it to compile. You can look at the patch to see what you might need to do. All the compiled-in defaults, and all of the changes that were made to get the software to build properly, are easily visible using this technique.

Operations in RPM 


  1. Installation
        It  is used to install a given package to the system
  2. Upgrading:       Upgrade is used to upgrade the existing package to the newer version, or, if the package is not installed it will install the package. Upgrade is therefore able to either upgrade or install.
    1. Installation of Package: rpm -Uvh tree-1.6.0-10.el7.x86_64.rpm
    2. If the package is already installed it will give error,
      “Package is already installed
    3. If you want to initiate the re-install, to get the default conf files or to get back some deleted files,
      rpm -Uvh --replacepkgs tree-1.6.0-10.el7.x86_64.rpm
    4. To downgrade the package, rpm -Uvh --oldpackage older_package.rpm
    5. If you attempt to install a package that contains a file that has already been installed by another package, a conflict message is displayed. To ignore it, 
      rpm -Uvh --replacefiles package.rpm
    6. Force rpm to install a package that has an unresolved dependency. rpm -Uvh —-nodeps package.rpm               
  3. Uninstallation: 
    rpm -e package
     Note:- You can encounter dependency errors when uninstalling a package if another installed package depends on the one you are trying to remove
  4. Verification :
    1. To verify your entire system and see what files are missing, issue the following command as rootrpm -Va [Note:If some files are missing or appear corrupted, consider reinstalling relevant packages.]
    2. Packages can be verified with, rpm -V <package_name> .  It compares the files to be installed with the one that is already installed and shows the difference.
  5. Querying: rpm -qa : lists all the rpm packages.
    1. rpm -qi <package_name>  : Information about the installed package
    2. rpm -qip <package_name>  : Information about the non-installed package
    3. To determine which package owns given file:
      rpm -qf <file>
    4. To query the documentation of the package to while the file belongs, rpm -qdf <file>
    5. To list the files in the package: rpm -qlp package.rpm

  Other Misc Operations:-
       
  1. To determine which package contains the required file, use the --whatprovides option: rpm -q --whatprovides required_file
  2. To determine which package requires this package: use ——whatrequires: rpm -q --whatrequires <package_name>



Notes:


  • For most package-management tasks, the Yum package manager offers equal and often greater capabilities and utility than RPMYum also performs and tracks complicated system-dependency resolutions. Yum maintains the system integrity and forces a system integrity check if packages are installed or removed using another application, such as RPM, instead of Yum. For these reasons, it is highly recommended that you use Yum instead of RPM whenever possible to perform package-management tasks.
  • It is always recommended to use rpm -Uvh to install as new packages, EXCEPT for kernel packages.

No comments:

Post a Comment