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:
- Se instala todo en la máquina a mano
- 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 |
- 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:
- Te vas a /home/metro/SOURCES y ejecutas el "./gen-xxx" correspondiente
- Te vas a /home/metro/SPECS y haces el "rpmbuild -ba nombrespec.spec"
- Buscas el resultado en /home/metro/RPMS/i386
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
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.
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
These configuration variables define the architecture and operating system
that RPM is running on resp. is building for.
- 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.
- optflags
- Standard set of options for compilation.
Each spec file defines parameters and instructions for building one or
more RPM packages.
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 <=.
The following environment variables are set before executing any of the build scripts:
RPM_ARCHRPM_BUILD_DIRRPM_BUILD_ROOTRPM_DOC_DIRRPM_OPT_FLAGSRPM_OS
RPM_PACKAGE_NAME-
RPM_PACKAGE_RELEASE RPM_PACKAGE_VERSIONRPM_ROOT_DIRRPM_SOURCE_DIR-
Directory in which RPM will look for sources and patches.
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 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
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 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.
With the -f option RPM can be instructed to read the file names
from a file generated during package building: %files -f MANIFEST
Declares which packages are obsoleted by this one. Older versions of the
package are automatically obsoleted.
RPM defines the following environment variables:
RPM_INSTALL_PREFIX- value of the
Prefix:
tag
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 error status codes are defined in rpmlib.h.
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
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.
|