RPM: Difference between revisions

From Leo's Notes
This page was last edited on 24 February 2017, at 19:13.
No edit summary
m Text replacement - "<code>" to "{{code|"
Line 47: Line 47:
== Building RPM ==
== Building RPM ==
=== Creating 32bit Dependency ===
=== Creating 32bit Dependency ===
In your RPM.spec file, have the following in your <code>Requires</code> line:
In your RPM.spec file, have the following in your {{code|Requires</code> line:


  Requires: nss-pam-ldapd(x86-32)
  Requires: nss-pam-ldapd(x86-32)
Line 55: Line 55:


=== Checking for Install/Upgrade/Remove in Install Scripts ===
=== Checking for Install/Upgrade/Remove in Install Scripts ===
To check whether a .rpm file is being installed, upgraded, or removed in the pre/post install scripts, check <code>$1</code> against the table below:
To check whether a .rpm file is being installed, upgraded, or removed in the pre/post install scripts, check {{code|$1</code> against the table below:
{| class="wikitable"
{| class="wikitable"
! $1 =
! $1 =
Line 98: Line 98:
  Warning: RPMDB altered outside of yum.
  Warning: RPMDB altered outside of yum.


... it probably means that you ran <code>rpm</code>. To fix this warning, clear <code>yum</code>'s cache and force a rebuild by running:
... it probably means that you ran {{code|rpm</code>. To fix this warning, clear {{code|yum</code>'s cache and force a rebuild by running:
<syntaxhighlight lang="bash" enclose="div">
<syntaxhighlight lang="bash" enclose="div">
  yum clean all
  yum clean all

Revision as of 19:13, 24 February 2017

Common RPM Tasks

Below are the common tasks I do with RPM.

List installed packages

 rpm -qa

Look for a specific package by name

 rpm -qi <package name>

Determine the origin of a file

 rpm -qf <path to file>

eg:

 # rpm -qf /etc/hosts
 setup-2.8.14-10.el6.noarch

Extracting a rpm package

Go into a directory and extract it using cpio. This will dump the files in the current directory, so make a directory to avoid having your files clobbered.

mkdir package && cd package
rpm2cpio ~/custom-package.rpm | cpio -idmv

Viewing / Editing rpm package scripts

Use the rpmrebuild utility to generate a .spec file from an existing RPM package. The spec file that gets generated will contain any scripts that may be bundled with rpm which you can modify.

# rpmrebuild -e -p some-package.rpm
## This should open your editor with the .spec file that was generated.
## Save and quit when done to have the option to rebuild the rpm.

Remove a package with a broken uninstall script

 rpm -e --noscripts <package>

Building RPM

Creating 32bit Dependency

In your RPM.spec file, have the following in your {{code|Requires line:

Requires: nss-pam-ldapd(x86-32)

Not:

Requires: nss-pam-ldapd.i686

Checking for Install/Upgrade/Remove in Install Scripts

To check whether a .rpm file is being installed, upgraded, or removed in the pre/post install scripts, check {{code|$1 against the table below:

$1 = 0 1 2
%pre Install Upgrade
%post Install Upgrade
%preun Uninstall Upgrade
%postun Uninstall Upgrade

Example usage:

%pre

if [ $1 -eq 1 ] ; then
  # Initial install
fi

Troubleshooting

Warning: RPMDB altered outside of yum.

If you ever get the error:

Warning: RPMDB altered outside of yum.

... it probably means that you ran {{code|rpm. To fix this warning, clear {{code|yum's cache and force a rebuild by running:

 yum clean all
 yum makecache