Buscar

Este contenido no está disponible en el idioma seleccionado.

Chapter 1. Getting started with RPM packaging

download PDF

The following section introduces the concept of RPM packaging and its main advantages.

1.1. Introduction to RPM packaging

The RPM Package Manager (RPM) is a package management system that runs on RHEL, CentOS, and Fedora. You can use RPM to distribute, manage, and update software that you create for any of the operating systems mentioned above.

1.2. RPM advantages

The RPM package management system brings several advantages over distribution of software in conventional archive files.

RPM enables you to:

  • Install, reinstall, remove, upgrade and verify packages with standard package management tools, such as Yum or PackageKit.
  • Use a database of installed packages to query and verify packages.
  • Use metadata to describe packages, their installation instructions, and other package parameters.
  • Package software sources, patches and complete build instructions into source and binary packages.
  • Add packages to Yum repositories.
  • Digitally sign your packages by using GNU Privacy Guard (GPG) signing keys.

1.3. Creating your first rpm package

Creating an RPM package can be complicated. Here is a complete, working RPM Spec file with several things skipped and simplified.

Name:       hello-world
Version:    1
Release:    1
Summary:    Most simple RPM package
License:    FIXME

%description
This is my first RPM package, which does nothing.

%prep
# we have no source, so nothing here

%build
cat > hello-world.sh <<EOF
#!/usr/bin/bash
echo Hello world
EOF

%install
mkdir -p %{buildroot}/usr/bin/
install -m 755 hello-world.sh %{buildroot}/usr/bin/hello-world.sh

%files
/usr/bin/hello-world.sh

%changelog
# let's skip this for now

Save this file as hello-world.spec.

Now use these commands:

$ rpmdev-setuptree
$ rpmbuild -ba hello-world.spec

The command rpmdev-setuptree creates several working directories. As those directories are stored permanently in $HOME, this command does not need to be used again.

The command rpmbuild creates the actual rpm package. The output of this command can be similar to:

... [SNIP]
Wrote: /home/<username>/rpmbuild/SRPMS/hello-world-1-1.src.rpm
Wrote: /home/<username>/rpmbuild/RPMS/x86_64/hello-world-1-1.x86_64.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.wgaJzv
+ umask 022
+ cd /home/<username>/rpmbuild/BUILD
+ /usr/bin/rm -rf /home/<username>/rpmbuild/BUILDROOT/hello-world-1-1.x86_64
+ exit 0

The file /home/<username>/rpmbuild/RPMS/x86_64/hello-world-1-1.x86_64.rpm is your first RPM package. It can be installed in the system and tested.

Red Hat logoGithubRedditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

© 2024 Red Hat, Inc.