View this PageEdit this PageUploads to this PageVersions of this PageHomeRecent ChangesSearchHelp Guide

rpm cheat sheet

One-liners


NOTA: Sitio con todas las respuestas que no están aquí.
NOTA2: Hay un artículo muy completo en:
salchicha:/home/dario/Programacion/doc/rpm/l-rpm3.pdf
NOTA3: Learn Linux, 101: RPM and YUM package management.

Instalar un paquete

rpm -i nombre.rpm

Desinstalar un paquete

rpm -e nombre

Comprobar si un paquete está instalado

rpm -qa | grep nombrepaquete

Ver la información de un paquete ya instalado

rpm -qi nombrepaquete

Ver la información de un paquete antes de instalarlo

rpm -qip nombrepaquete.rpm

Ver el changelog de un paquete antes de instalarlo

rpm -qp nombrepaquete.rpm --changelog

Extraer un sólo archivo del rpm

rpm2cpio packageXyz.rpm | cpio -imvd ./usr/packageXyz/randomfile

Generar RPMs en el home del usuario


Requisitos previos:
  • Crear los directorios BUILD RPMS SOURCES SPECS SRPMS en /home/metro
  • Crear un fichero "$HOME/.rpmmacros" con el contenido "%_topdir /home/metro"

Preparar la script para generar el tar.gz y el spec:
  1. Se instala todo en la máquina a mano
  2. En el directorio SOURCES se pone una script que empaquete "lo que se ha metido a mano", p. ej.
    #!/bin/sh
    nombre="isacd"
    directorios="/home/metro/isacd"
    rm -f sico-${nombre}-op-1.0a.tar.gz
    tar czvf sico-${nombre}-op-1.0a.tar.gz ${directorios} > ./${nombre}.txt
    (cat ../SPECS/sico-${nombre}-op.spec | tr "
    " "@" | sed "s/\(%defattr(-,root,root)@\)./\1/g" | tr "@" "
    " ; cat ./${nombre}.txt ) > ../SPECS/sico-${nombre}-op.spec.new
    mv ../SPECS/sico-${nombre}-op.spec.new
  3. En el directorio SPECS se pone una spec con lo que tiene que hacer:
    %define name sico-isacd-op
    %define version 1.0
    %define release 1.%(date +"%Y%m%d%H%M")

    Summary: Ficheros necesarios en un puesto de operador para el isa/isacd/isatce
    Name: %{name}
    Version: %{version}
    Release: %{release}
    Source: %{name}-%{version}a.tar.gz
    License: Other/Propietary
    Group: System/Base
    Buildroot: %{_builddir}/%{name}-root
    %description
    Este fichero incluye los ficheros instalables en /home/metro/isacd
    %prep
    rm -rf $RPM_BUILD_ROOT
    %build
    echo Nothing to build
    %install
    mkdir -p $RPM_BUILD_ROOT
    cd $RPM_BUILD_ROOT && tar -xzpf /home/metro/SOURCES/%{name}-%{version}a.tar.gz
    %clean
    rm -rf $RPM_BUILD_ROOT
    %files
    %defattr(-,root,root)

Generar el rpm usando la script y el spec anterior:
  1. Te vas a /home/metro/SOURCES y ejecutas el "./gen-xxx" correspondiente
  2. Te vas a /home/metro/SPECS y haces el "rpmbuild -ba nombrespec.spec"
  3. Buscas el resultado en /home/metro/RPMS/i386



Información de http://www.han.de/~racke/rpm.html

NOTA: Hay que hacer malabarismos para poner las variables: se ponen en el .rpmmacros y con %_ delante y un espacio detrás (p.ej. "%_topdir /u02/RPMBuild")

Piled RPM Remarks

Concepts

Dependencies

Most packages can not work standalone, other packages are needed for proper usage. We say, a package depends on another one or requires it. These dependencies must satisfied at installation time. For example, package foo requires bar. So foo must be installed after package bar or at least simultaneously.

Querying Packages

List Packages

rpm -qa prints the installed packages on stdout, unfortunately unsorted. Just pass the output of rpm to sort for a convenient list:
rpmuser % rpm -qa | sort | tail -n5
vrfy-961113-3
w3-3.0.86-1
wwwoffle-1.2-1
zlib-1.0.4-1
zlib-devel-1.0.4-1

Configuration

Architecture and Operating System

These configuration variables define the architecture and operating system that RPM is running on resp. is building for.

Directories

topdir
Top level directory for builddir, rpmdir , sourcedir, specdir and srcrpmdir .
builddir
Directory in which RPM will build packages.
rpmdir
Directory in which RPM will store binary packages.
sourcedir
Directory in which RPM will look for sources and patches.
specdir
Directory in which RPM will look for spec files.
defaultdocdir
Directory which RPM will use as root directory for documentation files as specified by the %doc directive. Default is /usr/doc.

Building

optflags
Standard set of options for compilation.

Building Packages

Each spec file defines parameters and instructions for building one or more RPM packages.

Dependencies

Dependencies between packages are specified with the Requires and Provides tags:
	Requires: foo
	Requires: bar = 1.2.3
Other operators for version comparison are: <, >, >= and <=.

Environment Variables

The following environment variables are set before executing any of the build scripts:
RPM_ARCH
RPM_BUILD_DIR
RPM_BUILD_ROOT
RPM_DOC_DIR
RPM_OPT_FLAGS
RPM_OS
RPM_PACKAGE_NAME
RPM_PACKAGE_RELEASE
RPM_PACKAGE_VERSION
RPM_ROOT_DIR
RPM_SOURCE_DIR
Directory in which RPM will look for sources and patches.

Build Scripts

The %prep script

Unpacks the source archives into the build directory and applies patches:
%prep
%setup
After unpacking RPM changes to the main source directory, e.g. rpm-2.5.2. The -n switch of the %setup tag allows you to explicitly specify a directory:
%prep
%setup -n cgi.tcl-0.7

The File List

The package we are building will contain all files appearing in the file list:
%files
%defattr(-,root,root)
/usr/bin/foo
/usr/lib/libfoo.a
/usr/include/foo.h

Directives

The %doc Directive
The %doc directive instructs RPM to copy the specified files into the documentation directory. The -P flag is useful to preserve the directory structure.
The %ghost Directive
The %ghost directive instructs RPM not to install the specified file(s). They will be owned by that package and removed if they exists when the package is removed. This can be useful for things like log files and state files.

Dynamically Build File Lists

With the -f option RPM can be instructed to read the file names from a file generated during package building:
%files -f MANIFEST

Other tags

Obsoletes

Declares which packages are obsoleted by this one. Older versions of the package are automatically obsoleted.

Macros and variables

RPM defines the following environment variables:
RPM_INSTALL_PREFIX
value of the Prefix: tag

Variables

builddir
Directory in which RPM will build packages.
optflags
Standard set of options for compilation.
rpmdir
Directory in which RPM will store binary packages.
sourcedir
Directory in which RPM will look for sources and patches.
specdir
Directory in which RPM will look for spec files.

The RPM Library API

Status Codes

The error status codes are defined in rpmlib.h.

Index of Files and Directories

Index of Tags, Macros, Variables and Sections

Concept Index


Written by Stefan Hornburg <racke@gundel.han.de>
Translated from rpm.tcl by Info Prism's sgml2html v0.0.6
Last modified 12 January 1999



Información obtenida de http://www.justlinux.com/nhf/Distribution_Specific/Red_Hat_Linux


Help File Library: Red Hat RPM Guide

In general, normal usage of the rpm command can be summarised as follows:

Installation/Upgrading/Removal

To install a package type: rpm -ivh
ex. rpm -ivh somepackage.1.1-4.i386.rpm

To upgrade a package: rpm -Uvh [filename]
ex. rpm -Uvh somepackage.1.1-5.i386.rpm

To remove a package: rpm -e [packagename]
ex. rpm -evh somepackage

Also for upgrading or installing some packages you may need to use additional flags to force the install happen. It is only recommended to use these if you know why these flags were needed. --force will overwrite files that are owned by other packages. --nodeps will install even if the package needs packages that were not installed.

To see if a package is installed: rpm -q [packagename]
ex. rpm -q somepackage

To get info on an installed package: rpm -qi [packagename]
ex. rpm -qi somepackage

To list which files belong to a package: rpm -ql [packagename]
ex. rpm -ql somepackage

To see what package a file belongs to: rpm -qf
ex. rpm -qf /usr/bin/some_executable

One can usually join various query commands together, so rpm -qil will give info and list all the files in the package.

To look in a rpm filename that isnt installed, you tag on the p to the query line.
ex. rpm -qilp somepackage.1.1-4.i386.rpm will list the information and the files contained in somepackage.

--More Advanced usages can be found in the man page for rpm and at the web site: ftp.rpm.org

--Verification To see what files on the system may have changed from their initial settings you can use RPM, to check up on them. rpm -Va will give you a list of all files that have changed in one form or another since the package it is associated was installed. This can be a lot of files (and a lot may be changed due to post installation work).

To just see what packages have changed so that you can verify them more individually, you can do the following:
rpm -Va | awk '{print $2}' | xargs rpm -qf | sort -u &> /tmp/file1

Then look in the file /tmp/file1 for which packages have had changes from them.



Generar paquetes RPM


Ver los siguientes documentos:
Hay disponible mucha más información>http://www.google.es/search?hl=es&ie=ISO-8859-1&q=rpm+spec+howto&meta= sobre el tema.