RPM basics. Installing rpm packages in Linux Rpm description

RHEL, Fedora, Mandriva, AltLinux and some other distributions use the package manager to install, remove and update programs rpm. The rpm package manager allows you to install, remove, verify packages of the corresponding format, but does not have the means to automatically resolve dependencies and search in repositories. To automate the installation of packages, you can use the program yum(Yellowdog Update Manager), which automatically resolves dependencies between packages and downloads the necessary files. If you need to build a package with the program from source, you can use rpmbuild. To do this, you need to prepare a package in the .src.rpm format, which includes the source code of the program and a .spec file that describes the build process.

Package Structure

Packages are named according to the following scheme: name-version-assembly. Packages are distributed as files with.architecture.rpm appended to their names. For example, squid-2.5.STABLE8–1.FC3.1.i386.rpm stands for: squid program, version 2.5.STABLE8 , build 1.FC3.1 , i386 architecture (non-optimized application for i386 compatible processors). The build number may or may not include the distribution name (FC3 in this case). The noarch architecture means scripts independent of the processor architecture. The .src.rpm files contain program sources and are installed in a special way.

Each package contains files for programs, libraries, configuration, documentation, etc., packed with the cpio archiver. The package also contains additional sections:

  • PROVIDE– provided functionality (eg “mail server”) plus package files;
  • REQUIRENAME– packages, files, etc. necessary for correct operation. (what is required in REQUIRENAME, must be present in PROVIDE previously installed packages);
  • OBSOLETES– a list of packages that can be removed because their functionality and/or files are replaced by this package;
  • PREIN, POSTIN- scripts that run before installation (for example, stopping the daemon being updated), and scripts that run after installation (for example, editing configuration files for a specific car)
  • PREUN, POSTUN– scripts executed during removal;
  • SUMMARYshort description package;
  • DESCRIPTION- detailed description.

In addition, each package belongs to some group Internet, Software Development, Entertainment, etc. You can view the rpm file sections in mc.

In further descriptions<пакет>means the package name without i386.rpm (if one version of the program is installed, then the version and assembly number can also be omitted), and<файл>means file name.rpm. You can specify its URL as a file, for example, http://download.fedora.redhat.com/pub/fedora/linux/core/updates/3/i386/yum-2.2.0-0.fc3.noarch.rpm

Installing, uninstalling, updating programs

Auxiliary options: -v - verbose output of messages, -h - display of the installation progress indicator.

rpm-ivh<файл>... - install package(s)
rpm-Uvh<файл>... – update the package(s), if not installed – install
rpm-Fvh<файл>... – update already installed package(s)
rpm -e<пакет>... - remove package(s)

View information about installed packages or rpm files

Auxiliary options: -a - all installed packages, -p - information about the rpm file (in the examples will not be given everywhere).

rpm -q<пакет>... - check for the presence of an installed package and its version
rpm -qa - list all packages
rpm-qi<пакет>... - package DESCRIPTION
rpm-qip<файл>... - DESCRIPTION file
rpm-qR<пакет>... - Package REQUIERS
rpm-ql<пакет>... - list of package files
rpm-qf<файл_в_файловой_системе>... – determination of the belonging of an arbitrary file to one of the installed packages

Checking the integrity of an rpm package

Files placed in an rpm package are accompanied by a calculated checksum and are usually digitally signed by the package builder. After a package is installed, checksums and signatures are stored in the database of installed packages. This ancillary data allows you to perform several checks, for example, you can check that the package was created by a trusted publisher and that the package files were not tampered with after installation.

The first check is very important when downloading packages from the Internet, and the second when you suspect that your computer has been hacked.

Public keys for signature verification are automatically installed when installing from the distribution, and also semi-automatically added when installing rpm packages to connect yum repositories. Key files on CentOS are installed in the /etc/pki/rpm-gpg/ directory. You can add the key manually by specifying the path to a local file or its url. The key file must have text format"ASCII armored"

Rpm --import PUBKEY-file

After installation, the same commands apply to keys as to installed packages.

rpm -qa gpg-pubkey* - list all keys
rpm -qi gpg-pubkey-db42a60e - information (including owner name) about a particular key
rpm -e gpg-pubkey-db42a60e - deleting a key

Checking the package file for integrity

Rpm --checksig<файл>

Checking the integrity of an installed package

Rpm --verify<пакет>

After executing this command, a list of changed files will be displayed indicating what exactly has changed in them. The change type information consists of a string of abbreviations including:

  • S– size (Size)
  • M– file type or access rights (Mode)
  • 5 – checksum (MD5)
  • D– major or minor device device (Device)
  • L– contents of a symbolic link (Link)
  • U– owner (User)
  • G- group
  • T– modification time (mTime)
  • P– capacity

Extracting and packing rpm package files

The rpm2cpio program extracts files from an RPM package in the cpio archive format. To unpack files along with the directory structure, use the cpio command with the options -i - unpack and -d - create directories:

rpm2cpio<файл.rpm>| cpio -i -d

rpmrebuild

Special cases

If the package is already installed and needs to be reinstalled, or if the package version needs to be downgraded, then you can add the --force option to the install or upgrade commands.

If installing or removing a package formally breaks dependencies but is known to be fine, then the --nodeps option is used.

From the Rosalab Wiki

This document is intended to help people who want to release packages for the ROSA Desktop distribution. In particular, he highlights how ROSA packages differ from packages written for other RPM-based distributions. This document may be useful to ROSA developers as well as third party developers.

ROSA Desktop - distribution kit operating system GNU/Linux - produced and published by ROSA, by various volunteers, testers, translators.

Foreword

The reader is expected to have experience Linux usage. He should know the basic commands, the directory structure, and has already had to use rpm to at least install packages.

This document is structured to take the reader step by step to obtain an rpm package that can integrate well into ROSA Desktop.

As a first approximation, RPM represents three concepts:

  • a program designed to install or create packages;
  • format used in packages (binary or source) created by rpm ;
  • a file called a "package" containing a binary or source, and an information header. The header contains instructions for installing and uninstalling the program.

The rpm program is, from the user's point of view, a powerful package manager. She plays the role intermediary for any action performed on rpm packages. In addition, she can:

  • install or update a package, given dependencies;
  • during package installation prepare the steps to do installed program ready to use;
  • restore accidentally deleted files belonging to a package;
  • show information that the given package is already installed;
  • find the package to which a certain file belongs;
  • check the current installation to meet the requirement of dependencies of already installed packages;

From a programmer's point of view, an rpm program is a packer that hides in a single rpm file all the information needed to install a program on a given platform.

It is important to distinguish between .src.rpm source packages and binary packages (packages containing binary code) from the outset. .rpm

Software installation

Basics

Although originally developed for the Red Hat Linux distribution, rpm also works on other rpm-based distributions: OpenMandriva, Suse, Fedora, etc.; on all these systems, rpm is already installed.

The binary rpm package you will build for ROSA may not work on other distributions.

Building packages for ROSA Desktop

Building packages for Cooker (i.e. the development version of ROSA Desktop) is always accompanied by the application of patches and other improvements from the rpm side. Before starting the build, make sure that all of the following packages are installed on your system:

$ sudo urpmi rpm rpm-build spec-helper libtool rpmlint

  • rpm - rpm itself;
  • rpm-build - contains scripts used to build packages;
  • spec-helper - a tool for minimizing spec files with some automation: parsing binary files, compressing man pages;
  • libtool - used by some configuration scripts to build shared libraries;
  • rpmlint - used to validate the generated src.rpm file.

Preliminary tasks

Create the required folders

Before you start building, you need to take care of the organization of the "workplace": the rpm program needs a certain directory tree in your "home" directory. This tree can be created with the following command: mkdir -p ~/rpm/(BUILD,RPMS/$ARCH,RPMS/noarch,SOURCES,SRPMS,SPECS,tmp).

Replace $ARCH to the name of the architecture for which you plan to build. Usually this i586 or x86_64, but it can also be sparc, alpha or ppc.

Note
Assembly rpm-packaging as root can be dangerous because the binaries are installed on the system before packaging, so you should always build packages as a normal user if you don't want to accidentally clog the system.

The directory tree should have the following structure:

  • ~/rpm/BUILD : directory for built sources.
  • ~/rpm/RPMS : contains directories, one directory per architecture, where binary packages are placed after build.
  • ~/rpm/RPMS/i586 : directory for storing rpm packages for processors i586.
  • ~/rpm/RPMS/x86_64 : directory for storing rpm packages for processors x86_64.
  • ~/rpm/RPMS/noarch : A directory for storing architecture independent rpm packages.
  • ~/rpm/SOURCES : source code files (eg mypackage.tar.bz2 ).
  • ~/rpm/SPECS : The spec files we need to build.
  • ~/rpm/SRPMS : built src.rpm-packages.
  • ~/rpm/tmp : for temporary files that are created by the rpm program when packages are built.

Note
program rpm required directories for various architectures in ~/rpm/RPMS. If they are missing, you will receive an error message.

Don't create a .rpmmacros file

A number of guides for building RPM packages advise you to create an .rpmmacros configuration file in your "home" directory with personal information, which will be added to the package metadata, such as %packager, %vendor, and others. Do not do that. All such fields are filled in automatically by the build system. However, you can still create this file if you want to specify a build directory other than /home/user/rpm. In this case, provide values ​​only for the %_topdir and %_tmppath macros. Do not specify values ​​for other macros.

Build RPMs

From existing RPM "sources"

Building using existing sources is possible if the package is already in the distribution's repositories.

The latest rpm file can be downloaded from Cooker. A list of Cooker mirrors is on the Cooker mirror page. There you can find:

SRPMS Directory for storing rpm with "sources" ( main , contrib , non-free, etc.) for various processor architectures ( i586, x86_64, …); media/main For binary rpm from main ; media/contrib For binary rpm from contrib ; media/non-free For binary rpm from non-free ;

* "media/jpackage for binary rpm noarch. (jpackage no)

To change the source rpm for ROSA Linux, enter the command rpm -ivh my_package.src.rpm. This command will install all source files to the ~/rpm directory you created.

Note
program urpmi can be configured in such a way that it downloads the "sources" itself.

For example:

$ rpm -i /cooker/SRPMS/ktron-1.0.1-2mdv.src.rpm $ ls -R * SRPMS: SPECS: ktron.spec SOURCES: ktron-1.0.1.tar.bz2 RPMS: noarch/ i686/ i586 /i386/BUILD:

From the example above, you can see that the rpm program installed the ktron-1.0.1.tar.bz2 source file and the spec file into the rpm tree. It would be helpful to rebuild the current version of the package to see how it compiles. To do this, you need to use the rpmbuild program by running it with the buildall option:

$ cd ~/rpm/SPECS $ rpmbuild -ba ktron.spec $ ls -l ~/rpm/RPMS/i586/ktron-1.0.1-2mdv.i586.rpm $ ls -l ~/rpm/SRPMS/ktron-1.0 .1-2mdv.src.rpm

If the build completes without errors (which, by the way, can take several hours if some complex package is built, such as the kernel), the built package and the source package will be located in the ~/rpm/RPMS/i586 and ~/ rpm/SRPMS/ respectively. In order to install the built package, you need to get superuser rights. To do this, enter the su command in the terminal and enter the superuser password. To exit superuser mode, use the keyboard shortcut "Ctrl + D" or type the exit command. Superuser privileges are not required to build and rebuild "source" packages.

The build log can be quite large and can be saved for later review.

The ~/rpm/BUILD subdirectories can usually access patched "sources" (if one or more patches were in ~/rpm/SOURCES ), binaries, compiled libraries, manual pages, etc. The spec file describes the source code and patch files, how to build and install the package.

Now, to fix ktron , all you have to do is make changes to the spec file and then rebuild the package.

Note
Every package that ROSA Desktop builds uses the CVS version control system. This allows each state of the package to be recorded, i.e. the developer can refer to the archive to view the changes made. If the changes made are not desirable for any reason, the developer can cancel them.

Each spec file is stored in a module SPECS/ or contrib-SPECS/ . It can be accessed at cvs.mandriva.com.

Building from source

Let's say you found interesting program on the Freshmeat website or , and you want this program to be available to all ROSA Desktop users.

Download the source code archive and place it in the SOURCES directory.

Preliminary checks

License Despite the prevalence of the GPL license, there are still many non-GPL licenses. It is necessary to determine the exact license of the software in order to know if it can be included in the distribution. We do not accept software that uses proprietary licenses, but there are a few exceptions for the club. Also, we cannot accept programs that do not allow us to distribute them freely. The list of licenses allowed for use in the distribution is on the Mandriva page. Compressing the tar archive We recommend using the original tar archive without any modifications. If sources are distributed using various compression methods, we often prefer .tar.bz2 . Avoid compressing patches (obtained by diff and similar programs) and other text files (config files, scripts, etc.), as they tend to take up very little space in otherwise it will be harder to see changes in Subversion's diff files (Subversion itself uses some form of compression).

Note
For security-critical packages, we recommend that you do not change the source code, as this will change the checksum and signature. We recommend leaving such packages in their original state, OpenSSH being an example of such a package.

Inside the spec file

So we got to one of the most important chapters of this document. The spec file contains all the necessary information for:

  • compiling the program, building the source code and the binary rpm package;
  • installation and removal of the program.

In short, a spec file describes a simulated compilation and installation, tells rpm which files resulting from the installation should be packaged, and how they should eventually be installed on the system. Commands are executed using the /bin/sh command shell, thus command constructs like [ -f configure.in ] && autoconf are correct and can be applied.

We will look at the main features used in one of the spec files. As you build more and more rpm packages, you will realize that there are some additional options that we haven't covered. More detailed information can be obtained from the book Maximum RPM (see Section 7).

Consider the following example spec file taken from Cooker:

Name: gif2png Summary: Tools for converting websites from using GIFs to using PNGs Version: 2.0.1 Release: 1 Source0: http://www.tuxedo.org/~esr/gif2png/%(name)-%(version). tar.bz2 Source1: %(name)-%(version)-rosa-addon.tar.bz2 Patch0: gif2png-2.0.1-bugfix.patch URL: http://www.tuxedo.org/~esr/gif2png/ Group: Applications/Multimedia License: MIT-like Requires: python %description Tools for converting GIFs to PNGs. The program gif2png converts GIF files to PNG files. The Python script web2png converts an entire web tree, also patching HTML pages to keep IMG SRC references correct. %prep %setup -q -a 1 %patch -p1 %build %configure %make %install %makeinstall %files %defattr(0755,root,root) %doc README NEWS COPYING AUTHORS %(_mandir)/man1/gif2png.1 * %(_mandir)/man1/web2png.1* %(_bindir)/gif2png %(_bindir)/web2png # When preparing packages for ROSA, do not create the %changelog section yourself! %changelog * Mon Nov 02 1999 Camille Begnis 2.0.1-rosa2012 - Upgraded to 2.0.1 * Mon Oct 25 1999 Camille Begnis 2.0.0-rosa2012 - Specfile adaptations for Mandrake - add python requirement - gz to bz2 compression

The "%" character at the beginning of a line can mean:

  • beginning of section (section) ( prep, build, install, clean);
  • built-in shell script macro ( setup, patch);
  • directive used by special sections (sections) ( defattr, doc, ...).

header section ( header)

Name: gif2png Version: 2.0.1 Release: 1

These three lines automatically define constants that can be used in other sections of the spec file, called %(name) , %(version) , and %(release) . Some packages may generate a release using the deprecated %mkrel macro, which in ROSA distributions simply returns its argument.

In addition, there are a few tags that you might want to know about that are not in the sample spec file. There are some tags that you may come across. No one requires you to remember all the tags if you're just starting to build rpm packages, but after some time this list can be a good starting point!

Now it's time to explain how the package name is formed. It is very important to always follow this convention so that your work is understandable to others.

  • The binary package is denoted as follows: name-version-release.arch.rpm (name-version-release.arch.rpm)
  • A source package is denoted as follows: name-version-release.src.rpm (name-version-release.src.rpm) (i.e. in our case - gif2png-2.0.1-1mdk.src.rpm )

The name is generally chosen based on the name of the main binary package, although a different name may be used if there are good reasons.

Version is the number in the name of the original source file archive: name-version.tar.gz .

The release is the number following the version, incremented with each new build of the package, which can be due to the application of additional patches, changes made to the spec file, and even a trivial icon update.

Summary: tools for converting websites from using GIFs to using PNGs

This string is a description of the package.

Source0: http://www.tuxedo.org/~esr/gif2png/%(name)-%(version).tar.bz2

This line tells rpm which source file should be used to build the package. Note that the file name is preceded by the full URL (which, in general case, optional) pointing to the website where the original source code is located. rpm will strip the URL, keeping only the filename, and will search the SOURCES directory. While providing the full URL is not mandatory, its use is strongly recommended so that anyone can find out where to download the source code.

If there are multiple source files, use multiple lines starting with Source1: ..., Source2: ... and so on, respectively.

Patch0: gif2png-2.0.1-bugfix.patch

This is an optional tag. It can be used in two cases:

  1. You have fixed a bug in the source code of the program and created a patch that must be applied to the source code of the program before compiling.
  2. You found out that there is a patch for this software package somewhere on the net, and downloaded this patch.

All patches must be in the SOURCES directory. If there are several patches, then they should be named Patch1, Patch2 etc.

URL: http://www.tuxedo.org/~esr/gif2png/

This line points to homepage programs. Its use is optional, but we still recommend that you specify it.

Group: Multimedia

This snippet tells rpm where to place our package in the package tree. This feature is used by front-end package managers such as rpmdrake and kpackage .

The complete structure of the groups, which, by the way, differs from similar groups red hat, presented on the Packaging group page. It's very important to follow accepted grouping conventions, otherwise your package will mess up the package tree.

License: MIT-like

This tag specifies the license chosen by the copyright holder that will apply to the software contained in the package. Most often it is GPL. The ROSA license pages and the licensing policy provide complete lists licenses allowed to be used.

BuildRequires: python

Indicates that python libraries are required to compile rpm, it is often necessary to specify, for example, libpyglib-gi2, python-devel, if some package is not found immediately, then you can search for it using the urpmi -p PackageName command, as it can contained in another package, this is indicated by the command

Provides: libgif2png

Provides specifies the name of a library that can be used by other programs (provided)

Requires: python

This line was added because one of the programs included in the package is a script written in the Python programming language. This means that the python interpreter is required for the program to work correctly.

You can use a minimum (or specific) version requirement. For example:

Requires: python >= 1.5.1

In rare cases, the application may conflict with other already installed libraries or old versions of applications, in order to remove them from the system during installation, you need to inform the user about this, for this the tag is used

conflicts: python<= 1.0.0

Some packages become obsolete after new libraries are installed, a tag is used to tag them and remove them.

Obsoletes: gif2png< 2.0.0

Below is the description tag:

%description Tools for converting GIFs to PNGs. The program gif2png converts GIF files to PNG files. The Python script web2png converts an entire web tree, also patching HTML pages to keep IMG SRC references correct.

This is a very special tag inside the spec file header because it contains text that can span an arbitrary number of lines and paragraphs. The text contains a full description of the software, which helps the user decide whether to install the given package or not. In order to improve the perception of spec files, tag translations summary and description stored in special files called Po.

%defattr(0755,root,root)

This tag specifies the attributes that will be applied to all files copied to the user's system. Arguments mean:

  • -: all attributes for regular files remain unchanged;
  • root: the owner of the file is root;
  • root: file group - root;
  • 0755: attributes applied to all directories owned by a package - 0755 ( rwxr-xr-x).
%doc README NEWS COPYING AUTHORS

The special tag %doc marks files that are part of the package's documentation. Documentation files will be placed in /usr/share/doc/gif2png-2.0.1/ . This directory will be created automatically. The %doc files are relative to the source directory extracted from the tarball in the BUILD directory.

%(_mandir)/man1/gif2png.1* %(_mandir)/man1/web2png.1*

Also, you might be wondering: why is gif2png.1* used instead of gif2png.1.lzma ? This is to maintain compatibility with other systems that use gzip compression instead of lzma. If you find such references to lzma compression in the spec, replace them with a regular expression, as in the example above. Most often, you can use %(_mandir)/man1/* , which matches all files in the man1 directory.

%(_bindir)/gif2png %(_bindir)/web2png

As you can see, for each required path, there is a macro of the required type. Here are the most useful ones: (full list available in /usr/lib/rpm/macros ): %(_prefix) , %(_bindir) , %(_sbindir) , %(_datadir) , %(_libdir) , %(_sysconfdir) . %(_mandir) , %(_infodir) . For games use %(_gamesbindir) and %(_gamesdatadir) .

Changelog section ( changelog)

Attention! Here is general information about the section changelog. You should not add this section to the spec file yourself, since it is generated automatically from the change history in the version control system.

What are change logs

%changelog

This section is intended to keep a record of the various changes made to the package. Each new build of the package must be accompanied by a paragraph in this section, as well as each new version number of the program. The following structure of these paragraphs is observed:

* Mon Nov 02 1999 Camille Begnis 2.0.1-1mdk

  • the first line of a paragraph begins with an asterisk "*" and is separated from it by a space;
  • three letters indicating the day of the week;
  • three letters representing the month;
  • two digits of the day of the month;
  • four digits of the year;
  • the name of the person who created the package;
  • his own last name;
  • his own email address in angle brackets "<>»;
  • current version and release.
- Upgraded to 2.0.1

This is followed by a single line beginning with "-" that describes the change in the package.

Spec file stolen from korganizer. - last snapshot before release - ROSA adaptations. - Fix bug in /etc/zsh use USERNAME instead of USER. - Remove petit bouchon which annoys other players. - Improve /etc/z* to source the /etc/profile.d/ files. - fix typo in examples directory name - fixed QT libs version requirements - add patch to handle Earl Gray tea

By default, only records no older than 1 year are placed in the compiled package. This behavior can be changed by setting the value of %_changelog_truncate

History of changes in the version control system

Information for the section changelog automatically generated from the change history of the version control system. Each message line from the change history becomes a section entry changelog, starting with a hyphen. Messages are automatically grouped by author's name and email address.

If you don't want a line from the changelog to be included in the package's changelog, add "SILENT: " at the beginning of the line. Blank lines are also ignored.

Assembly

Finally, our spec file is ready. Take a deep breath, sit down and type rpmbuild -ba mypackage.spec .

You can also add the --clean option, which will clean up the BUILD directory after the package is built. This can be useful if you don't have much free hard disk space.

The process may end with the following results:

  • exit0;
  • all other cases.

There are then two possibilities for the last line of your process:

  • 0.01% probabilities: + exit 0
  • 99.99% probabilities for other cases.

Are you in the second case? Congratulations you passed the test, you are not an alien.

Good luck, so long, have a look to rpm building options (man rpmbuild ) to debug your work, look at other persons" specfiles, etc..

There is a very clean way to build packages: use rpmbuild -bs --rmspec --rmsource(in order to remove anything from the original build) and then do a rpmbuild --rebuild .

Build Process Optimization

When you run the command to build your package, you are sure to be notified with a message like: foo-devel is necessary for foo2.

This means that you need information from other packages used for development (usually, such files have names like foo.h ). If you don't have them, the compilation will stop, or even if the compilation succeeds, the package will be stripped of some features.

The ROSA build cluster has many of these pre-installed development packages ( devel-packets). In case one of the required packages was not listed in the spec file, the package will be built on the cluster anyway. But the lack of such information will prevent the package from being built on machines that lack the devel package, making debugging and upgrading more difficult.

Take a look at the website of the program you are preparing the package for, there you can find information about the required components.

To find these "missing BuildRequires" when doing a build, only the most basic development packages should be present on the system:

  • glibc-devel
  • libncurses5-devel
  • libstdc++6-devel

After that, install only the developer packages that the rpm build command asks for.

When starting the build, follow the messages checking for...

If you see something like checking for foo... foo.h not found, this means that the header file was not found on your system. Find the development package containing foo.h, but be careful: you may find more than one package. So choose the one that suits you the most. For example, you should not select a package related to a computer network if you are building an application designed to work with sound.

Then, install the package on the system, don't forget to add its name to the section BuildRequires your spec file.

Missing header files can be found at compile time. If it stops, check for other foo.h and do the same.

Checking an RPM Package

Basic Checks

First things first, you need to check the following:

  • are the rpms created in the proper directories with the correct names (in the ~/rpm/SRPMS/ and ~/rpm/RPMS/i586/ directories);
  • Is the information received with the command correct? rpm -qlivp --changelog mypackage.(src.)rpm.

Running Rpmlint

After that, you should use the Rpmlint utility, which will perform various checks on the package. Before running rpmlint, make sure you have the rpmlint-mandriva-policy package installed, which contains the Rosa validation rules. Dial rpmlint mypackage. .rpm to get a report on a specific package. For more detailed information, use the -i switch. You should check rpm and src.rpm . For more information on build errors, see the Package Building Issues page.

install test

Now you need to check the installation and update of the package on any machine (preferably different from the one on which the build took place), and make sure that:

  • Created all the necessary files with the right permissions and owners
  • All scripts that run during installation have completed successfully
  • All executable files have the bit set executable, and documentation files are available to all users

For complete testing, you can also check the process of removing the package, the functionality of the installed software, and the like.

If all the tests pass successfully, then you are almost there - all that remains is to submit the package to the repository.

Something went wrong?

If you are reading this document, then it is already good. If you don't find the answer to your question here, you can also try the following resources:

  1. Official document RPM-HOWTO(installed on the system along with the rpm program).
  2. Red Hat book Maximum RPM which is available at http://www.redhat.com/docs/books/max-rpm/max-rpm-html/ .
  3. look at the spec files of similar packages - their authors may have encountered similar problems
  4. Ask a question in the mailing list of ROSA developers.

If you think that the solutions you found may be useful to others, please inform the authors of the documents in which you would like to add descriptions of these solutions.

Pre-installation and post-installation scripts

Basics

An RPM package is more than just an archive of files that are extracted to specific directories on client systems.

The system provides programmers with a powerful feature: pre-installation and post-installation scripts. These scripts allow the package builder to write in a piece of code that will be run on the client machine when the package is installed or removed.

These scripts are generated from any valid command line interpreter commands. Here are four of them:

There are some warnings regarding these scenarios. Firstly, you must keep within the buffer size of 8192, and secondly, the scripts must not be interactive. Anything that requires manual input from the user is wrong, as it breaks the non-interactivity of the RPM installation procedures.

  • %pre - This script is executed before the package is installed on the system.
  • %post - This script is executed after the package is installed on the system.
  • %preun - This script is executed before a package is removed from the system.
  • %postun - This script is executed after the package has been removed from the system.

The purpose of such scenarios can be extremely diverse. Scripts must be designed in such a way that they do not harm the system. Remember that scripts are run as superuser. They pertain to system administration tasks that complete the installation of a new application. For example:

  • Add to cron running the program at regular intervals
  • Run chkconfig to start the service at boot time

Working with updates

Working with packages is complicated by the fact that a package can be upgraded rather than just installed or removed. the problem is that when upgrading, the %postun script of the new version of the package is run after the %post script of the old version, and what the last script did might be lost.

It is often useful to make sure that certain actions are performed only when installing/removing a package, but not when updating. To handle such situations, RPM passes a special argument to the %pre , %preun , %post , and %postun scripts.

The argument contains the number of different versions of this package that will be installed on the machine after the execution of this script. For example, when installing a new package, the %pre and %post scripts will be given the value "1". When updating a package, the %pre and %post scripts of the new version will be set to "2", the %preun and %postun scripts of the old version will be set to "1".

The presence of such a parameter allows programmers to distinguish in what situation the script is run - when installing or updating a package.

  • For installation scripts (%post , %pre ) - if the $1 parameter is equal to "1", then the initial installation takes place
  • For removal scripts (%postun , %preun ) - if the $1 parameter is equal to "0", then the package is removed; otherwise it is an upgrade or an installation with the --force option.

To check the value of a parameter, you can use the following construct:

%postun if [ $1 -eq 0 ]; then ### Perform actions specific to package removal fi if [ $1 -eq 1 ]; then ### Perform actions specific to updating the fi package

File triggers

To avoid the need to perform common tasks - such as running "%post -p /sbin/ldconfig" or "%update_menus" - ROSA uses RPM file triggers.

More macros

When building packages for Rosa, you can use various macros in the spec file to perform common tasks.

  • Processing info pages:
%post %__install_info %(name).info %preun %__install_info %(name).info
  • Menu system update. Rosa uses the XDG Menu.
%post %(update_menus) %postun %(clean_menus)
  • Processing localization files. It is good practice not to manually list all .mo files, which are usually found in the /usr/share/locale/.. subdirectories, but to use a special macro in the %install section, which will create a separate file with a list of files with localizations:
%find_lang %(name)

The created file must be specified in the section files:

%files -f %(name).lang

  • The macros used in the build are %configure and %makeinstall . They automatically set the installation prefix, as well as various directories (such as bindir, datadir, and others). These macros generally work great for small packages, but may require additional tweaking when building complex products. The %make macro invokes the make command with the appropriate -j option , parallelizing assembly on multi-core machines. If you still need to call the script ./configure directly, never do not specify the name of the target hardware architecture. For these purposes, there is a macro %( target platform) (or even %( target cpu) if more information is needed).
  • Building server software. For a build that requires increased reliability at the expense of performance, we use a special macro %serverbuild , which must be called before the build itself begins. This macro sets the required optimization flags. The %build section looks like this:
%build %serverbuild %configure %make
  • Macros for init scripts. When installing a package that contains an init script (file in the /etc/init.d directory), you must register the script with chkconfig --add .. ; when updating, this is not necessary, but if the script works, then it must be restarted; When you remove a package, you must remove the script information. For these purposes, we have the corresponding macro:
%post%_post_service %preun %_preun_service
  • Treatment ghost-files. Some packages (in particular, many games) contain files that may not be present on the system at some point in time. Such files should be marked as ghost and process using special macros:
%install (...) mkdir -p %(buildroot)/var/lib/games touch %(buildroot)/var/lib/games/powermanga.hi %post %create_ghostfile /var/lib/games/powermanga.hi root games 664 (...) %files %attr(664, root, games) %ghost /var/lib/games/powermanga.hi

The %create_ghostfile macro will expand into the following construct:

If[! -f /var/lib/games/powermanga.hi ]; then touch /var/lib/games/powermanga.hi chown root.games /var/lib/games/powermanga.hi chmod 664 /var/lib/games/powermanga.hi fi

  • Associating .desktop / MIME file types with applications: The XDG menu system allows applications to be associated with files with a given MIME type in .desktop files. When installing or removing a .desktop file, you must run the utility update-desktop-database , using the appropriate macros:
%post %update_desktop_database %postun %clean_desktop_database
  • Freedesktop.org MIME Type Database: The database used to retrieve all possible MIME types with their respective file extensions or their "magic" numbers must be updated by calling the following macros:
%post %update_mime_database %postun %clean_mime_database
  • Icon cache: all packages containing icons installed in /usr/share/icons/hicolor (or other directories provided by the freedesktop specs, such as /usr/share/icons/gnome or /usr/share/icons/crystalsvg ) must update the icon cache as shown in the following example (this requirement does not apply to icons stored in /usr/share/icons , /usr/share/icons/mini , or /usr/share/icons/large ):
... %file ... %(_iconsdir)/hicolor/* %(_iconsdir)/crystalsvg/* .... %post %update_icon_cache hicolor %update_icon_cache crystalsvg %postun %update_icon_cache hicolor %update_icon_cache crystalsvg
  • Registering GConf Schemas: GNOME GConf schemas must be installed and uninstalled using the following macros:
... # each schema key corresponds to a file named /etc/gconf/schemas/ .schemas %define schemas apps_gnome_settings_daemon_default_editordesktop_gnome_font_rendering desktop_gnome_peripherals_keyboard_xkb fontilus themus %post %post_install_gconf_schemas %(schemas) %preun %preun_uninstall_gconf_schemas %(schemas)
  • Updating the scrollkeeper database: If an .omf file is being installed, the scrollkeeper database (used to index docbook documentation) needs to be updated:
... %post %update_scrollkeeper %postun %clean_scrollkeeper

Interaction with urpmi and rpmdrake

Sometimes it"s necessary to warn the user about some particular care that should be taken when upgrading or installing a specific version of a package. rpmdrake-2.1.3-11mdk and above supports this: it searches in rpms for text files named README. install.urpmi , README.update.urpmi or README.urpmi , and displays them.

README.install.urpmi is displayed only for installed packages; README.update.urpmi only for upgraded packages; README.urpmi is displayed in both cases.

ROSA Package Groups

Each package must belong to one of the RPM groups used by ROSA.

Licenses

For questions regarding licenses for packaged software, please refer to the Licensing policy .

Alternative: check install

A very easy way to build RPMs for personal use is to install the checkinstall package; compile from source as usual (./configure && make && sudo make install), but just replace the make install step by checkinstall . This automates building an RPM, and is very simple to use. The advantage is that you don't ever have to bypass the package manager when compiling from source. (However, it's probably A Good Idea to build RPMs "properly" as described above, if you intend to distribute them to others.)

When a buyer tries to assemble a computer from components on his own or simply choose a hard drive for a PC, he often encounters the concept of "RPM". What is it and is it important? RPM is not just important, but one of the key parameters of a hard drive that must be considered first of all when choosing. Let's take a closer look at what RPM is.

concept

The abbreviation RPM (Rounds per minute) literally translates into Russian as "Revolutions per minute". This unit denotes a hard drive, but the concept itself does not say anything to the average user. The RPM of a hard drive plays a role in system performance, and the higher the rotation speed, the faster the entire system will work. Most often, this parameter is indicated in the characteristics of the hard drive, and between two hard drives it is advisable to choose the one with the higher RPM.

If you take two disks that are identical in all respects, but with different spindle speeds, you can immediately notice a significant difference in system performance.

What is a spindle?

A hard drive consists of several sealed round platters that are stacked on top of each other and covered with a layer of ferromagnetic material. There is also a reading head in the housing. These plates rotate during operation using a spindle - a special rotating shaft. This shaft is driven by an electric motor. When the plates rotate, the reading heads do not touch the surface of the discs, but are located as close as possible to them. As a result, with the help of the heads it is possible to write and read information from solid media - disks.

For thousands of hours, the spindle stably rotates the plates at a tremendous speed, so this element must be reliable. Due to the absence of direct physical contact between the spindle and the disk, information can be written and erased on the latter. It is believed that on average one disk can be written and erased information 100 thousand times.

This is what the hard drive spindles look like. Of course, they may differ depending on the device model and manufacturer.

So, we found out that this is RPM. The parameter determines at what speed the plates can rotate during normal operation. In turn, this allows you to understand how quickly the computer system can get information from the hard disk when accessing it. The higher the speed, the faster the data exchange between the system and the disk will be.

How it works?

To understand more precisely what it is - RPM, you need to understand the principle of operation of the device itself. When certain information is requested, the head unit jumps to the requested track. This requires a certain time to search (Seek latency). After the reading heads move to the desired sector, it is necessary to wait for the discs to rotate so that the desired area is under the reading head. This period of time is called the rotation delay. It is this parameter that depends on the speed of rotation of the spindle, and the higher it is, the lower the delay for rotation.

Both delays (for spindle movement and disk rotation) determine the speed of system access to data. Many benchmark programs calculate this parameter and display it below the "Access to data time" lines. This allows you to determine the actual speed of the disk. This parameter directly affects the performance of the entire system. Today there are many powerful laptops that are equipped with powerful graphics cards and processors, a large amount of RAM. But at the same time, together with good hardware, very slow hard drives with a rotation speed of 5400 rpm are used. As a result, all these powerful components do not work at full capacity due to the slow speed of data access. So the RPM of the disk is important on a par with the frequency of the processor and the bus width of the video card.

Impact of RPM HDD on performance

Winchesters (as hard drives are often called) can be in LFF and SFF formats. To put it simply, one type of disk has a 2.5-inch format, the other has a 3.5-inch format. The first is often used in laptops and servers, the second - in conventional system units. It is this type of hard drive that most often has a high spindle speed - 7200 rpm. In such models, the half-turn time is 4.2 ms, and the average seek time is 8.5 ms. Therefore, the data access time will be 12.7 ms.

Note that most desktop computers use SATA hard drives. 7200 RPM is the standard speed for these models. There are also 5400 RPM drives, but they are not recommended for use on modern systems, although they are cheaper. There are also 10000 RPM discs - in such models, search and rotation delays are about 3 ms. Such devices are most often used on gaming computers, but even they can be called outdated. Modern desktop PCs and laptops are increasingly using SSD drives, which work in a completely different way. We will talk about this a little later.

Non-standard RPM setting

There are also models on the market with a spindle speed of 15,000 rpm. As you may have guessed, the latency is even lower there - about 2 ms, and the average seek time is 3.8 ms. This allows you to provide access to data in 5.8 ms. Therefore, disks with a large RPM have a low search time for the desired information, thereby ensuring a fast exchange between the information store and the system.

However, it is important to note that when accessing large data, the performance difference between disks with high and low RPM parameters will not be significant, since there will be no information access delays at all.

How to know the spindle speed?

Determining this parameter is as easy as shelling pears - it is always indicated on a sticker on the device itself. It is enough to open the case of your system unit and look at the sticker. There may be many obscure options, but there is always one of the following lines:

  1. RPM HDD: 5400.
  2. RPM: 7200
  3. RPM: 10000

If the hard drive is hidden under the laptop case, which is quite difficult to open, then you can use a special hardware testing program.

The following are popular:

  1. crystalmark.
  2. Aida64.
  3. Speccy.

They are available for download from the Internet for free. By running one of these programs, you can quickly find information about the storage device. There will be displayed in detail the parameters of the hard disk. We are primarily interested in the "Rotation Rate" line and the value opposite it. In the Russian version of the Aida64 program, on the left side, click on "Data storage" - "Windows data storage", then in the upper part you need to select the hard drive, after which information about it will appear below, including the line "Rotational speed".

Disadvantages of high speed

Of course, with a high RPM, the performance of the system as a whole is ensured, but there are also disadvantages. The faster the spindle rotates, the more the disk itself heats up, and it works noisier. Also, such hard drives consume more electricity. However, modern technology makes it possible to set the RPM and reduce power consumption and noise by reducing the spindle speed. In this case, performance losses are compensated by a special data caching algorithm.

SSD as an alternative

In the development of modern computer platforms, the use of hard drives with platters and a spindle is abandoned. Today, solid-state drives are used, in which there are no moving parts at all. The "innards" of these drives are microcircuits on the board. Such devices work like ordinary flash drives, but the performance and data access speed in them is very high and far exceeds the performance of HDD standard disks. In addition, they do not make noise, are very light and consume little energy. The high price is the only drawback. 7200 RPM at 1 TB will cost less than a 128 or 256 GB SSD.

If we draw an analogy, then the difference between an SSD and an HDD is about the same as the difference between a regular DVD and a flash drive. They have already moved away from disks, and today only flash drives are mainly used.

Conclusion

When choosing a hard drive in the first place, it is important to consider the performance parameter, which is determined by the spindle speed in the first place. Unfortunately, most users look at disk capacity, although this is not the most important thing. It is better to give preference to a hard drive with a capacity of 500 GB and a spindle speed of 7200 rpm than to choose a 1 TB drive with an RPM 5400 parameter. In general, today we need to move away from using such systems, since SSD drives are superior to outdated HDD devices in everything .

*.RPM - files similar to Windows SFX archives and installers.
As a rule, they contain collected source texts of programs that are easy to edit.
The source code of the package itself is assembled with the .SRPM extension at the user's command.

Operations with packages from the console are performed by the RPM command.
I remind you:
help can be obtained by typing "rpm --help" or "rpm -?"; and the detailed manual is "man rpm"
(to exit the manual and return to the terminal, you need to press "q" ).

Here it is proposed to familiarize yourself first with the description of the programs themselves for installing packages
(the main one is rpm) followed by a list of commands and options for that program.

Installing software on Linux.

On the Linux operating system, there are three ways to install software:

  • Traditional.
  • From RPM packages.
  • From packages containing source code.

Let's take a look at all three methods.

This method lies in the fact that the program is distributed not in assembled form, but in the form of source texts. This method is called traditional because it was the first way to install software before RPM or similar (apt-get) came along.

1. Traditional way of installation - installation from source texts.

Usually, source text distributed in the archive. Usually the file containing the source text has a double extension: for example, tar.gz or tar.bz2. This means that this file is compressed by two archivers: first tar and then gzip.

You need to unpack the archive according to the stack principle: first with an external archiver, and then with an internal one. Let's assume that prg-2.00.tar.gz is the filename of our archive. To unpack it, you need to enter the commands:

gunzip prg-2.00.tar.gz
tar xvf prg-2.00.tar

The first command will unpack the prg-2.00.tar file, which we will specify as one of the arguments in the second command. The x option of the tar program means that we need to extract the files from the archive (the c option is create). You can specify the v parameter at your own discretion, it provides more information when the program is running.
The last parameter f is required when working with files.
The tar program was originally designed to work with tape tapes, so we need to use the f option to tell the program that we need to work with files.
If the external extension is not gz, but bz or bz2, then instead of the first command you need to enter the commands (respectively):

bunzip prg-2.00.tar.bz
bunzip2 prg-2.00.tar.bz2


Then, as in the first case, you need to run the tar command (with the same parameters).

Sometimes source files have only one tgz extension. In this case, you only need to enter one command:

tar xzf prg-2.00.tgz


The z option means extracting files using the gzunzip unpacker. This extension is usually given to archive files created with the tar program and passed through the gzip archiver's filter.

The next step is the actual installation of the program. After the successful completion of the first stage (unpacking), go to the directory containing the source texts. This is usually a directory<имя_программы-версия>:

cd prg-2.00

. /configure
make
make install

The first command configures the installer to work with your system. This program also checks if the program being installed can run on your system. If the program is not possible,
you will see a corresponding message and the installation process will be interrupted.

This usually happens when one of the libraries required by the new program is not installed on your system. To continue with the installation, you must install the required library and try re-typing the ./configure command. After successful completion of the ./configure program, a Makefile will be created, which will contain the necessary parameters (paths to libraries, path to install the program) for the make program.

The second command (make) "builds" the program. At this stage, the program is compiled, that is, binary executable files are created from source texts.

The third command, make install, installs the program and help files in the appropriate directories. Programs are usually installed in the /usr/bin directory, but this depends on the contents of the Makefile configuration file.

After the program has been successfully installed, you can run it after reading the documentation for this program.

2. Installing the program from the RPM package.

Software installation on Red Hat and Mandrake distributions is done using the rpm program. RPM (Red Hat Package Manager) is Red Hat's package manager. Although it has "Red Hat" in the name, it is fully intended to operate as an open packaging system available for anyone to use. It allows users to take the source code for new software and package it in source and binary form so that the binaries can be easily installed and tracked and the source code is easily
built. This system also maintains a database of all packages and their files, which can be used to check packages and query information about files and/or packages.

Unlike the familiar InstallShield wizards that are used to install programs for Windows, RPM packages (files with the .rpm extension) are not executable files, that is, programs. Packages contain files (as in an archive) that need to be installed, as well as various information about this package: which package is required for this package to work, which package conflicts with, information about the developer, as well as information indicating what actions to take when installing this package, such as which directories to create. The RPM package manager is used in many Linux distributions(Red Hat, Mandrake, ASP, Black Cat) and is quite easy and flexible to use, which makes it popular.

For example, for the package software-1.0-I.i386.rpm the following takes place: software - name;

1.0 - program version;
1 - package release;
i386 - Intel 386 platform.

Usually, the package file name contains its name, version, release, platform. The last four characters - ".rpm" - an indication that this file is a package. Linux has no such thing as an extension or file type.

Note the difference between the software version and package release. The version indicated in the package name is the version of the software contained in it. The version number is set by the program's author, who is usually not the package's manufacturer.
The version number characterizes and refers to the software. As for the release number, it characterizes the package itself - it indicates the number of the existing version of the package. In some cases, even if not changed software may need to be repackaged.

With the name and version of the program, I think everything is clear. But the architecture is a little more complicated. The most "universal" packages are packages designed for the Intel 386 architecture. This program should
run on any Intel processor starting with 80386DX (or compatible). But if you have an 80486 processor, a package designed to work with the 80586 architecture (Pentium) will most likely not install on your system.
Typically, the following designations are used for CISC architecture processors (with the x86 instruction set):

i386 - Intel 80368DX;
i586 - Intel Pentium (MMX), AMD K5 (K6);
i686 - Intel PPro, Celeron, PII, RSH, PIV.

In the simplest case, the package installation command looks like this:

rpm -i<пакет>

Before installing a program, RPM will check the package's dependencies, that is, whether you have other packages installed on your system that the new program needs or conflicts with. If all required
packages (or the program does not need any additional packages at all), and also, if the new program does not conflict with any already installed package, the RPM manager will install the program.
Otherwise, you will receive a message that the program needs some additional package to work, or the program conflicts with an already installed package.

If you need an additional package, just install it. But if the program conflicts with an already installed package, then you will need to choose which package you need more: already installed or new.

When installing the program, I recommend specifying two additional parameters: h and v. The first tells the program to display a status bar for the installation process, and the second displays additional messages. The status bar will be displayed as # symbols. Given these two parameters, the installation command becomes a little more complicated:

rpm -ihv software-1.0-1.i386.rpm

Installation can be performed not only from a local disk, but also via FTP:

To remove a package, use the command:

rpm -e<пакет>

Once again, remember that when installing or removing packages, keep in mind that some packages may require other packages to be present on the system - this is called a package dependency. Therefore, sometimes you won't be able to install a certain package until you have installed all the packages that are required for it to work. When uninstalling a program, the package manager also checks for dependencies between packages. If the package being removed is needed by some other packages, you will not be able to remove it.

To skip dependency checking, use the --nodeps option.
This is sometimes useful. For example, you have postfix installed and you need to install sendmail. Both programs are used to send mail.

However, many mail programs require an MTA agent (Mail Transfer Agent) - a program for sending mail (postfix or sendmail).
Therefore, you cannot uninstall the postfix program using the -e option.
You can't install sendmail without uninstalling postfix either, because the packages conflict with each other. In this case, the command will help you:

rpm -e -nodeps postfix

After such a removal, other programs that need the MTA cannot work normally, so you need to install the sendmail program (or another MTA) right away. In this case, you need to install the program, as usual, using the -i parameter.

The -U option is used to update programs. I recommend using it when installing programs too, because if the package being installed has already been installed, then it will be updated, and if not, it will simply install a new package. To see a text indicator when installing packages, use the h option. Command to update the package:

rpm -Uhv<пакет>

For example:

rpm -Uhv software-1.1-4.i386.rpm

The text indicator will be displayed as # symbols. You can view all installed packages with the command:

rpm -qa I less

If you need to know if a particular package is installed, run the command:

rpm-qa | grep package_name

You can view general information about a package with the command:

rpm -qi package

and information about the files that are included in the package:

rpm -ql package

Programs gnorpm, kpackage, apt.

The RPM package manager is a powerful tool for performing operations on packages - creating, installing, updating, deleting. However, the command line interface may not appeal to everyone, and especially to a novice administrator. There are also graphical (under X Window) implementations of the package manager - for example, kpackage from KDE, gnorpm and others.
I recommend using the gnorpm program, which has an intuitive GUI. RPM is more suitable for creating new packages, as well as updating a large number of packages. For installing one or two packages, it is better and more convenient to use gnorpm.

Functions of the gnorpm program:

Installing packages.
Removing packages.
Get information about a package.
Checking the package.
Search for a package in the RPM database.

To install a package, click the "Install" button. If there is an installation CD in the CD-ROM drive, then in the window that appears you will see a list of packages not yet installed in the system.

If the package is not listed or you want to install a package that is not included in the distribution, click the Add button and add the packages you want to install to the list. Click on the "Inquiry" button to get information about the package.

If the package is not installed yet and you have enough disk space to install it, click on the "Install" button. After that, the package will be checked for dependency satisfaction: does this package require the presence of any uninstalled package and does it conflict with already installed packages. If everything is in order, you will see the package installation status window.

You can find a package using the Search operation. To do this, click on the "Search" button on the gnorpm toolbar or execute the menu command Operations -> Search. In the window that opens, you can set the search criteria and click on the "Search" button.

KDE comes with a graphical user interface program that manages packages, kpackage. Its functions are similar to the gnorpm program. Which of these programs to use is a matter of taste and habit.

Also worth mentioning is the APT program. The APT program is a software package management system. APT was originally developed for Debian Linux. Now included with some Red Hat compatibles
distributions (for example, apt-get and is included with AltLinux, but you will not find it in Red Hat Linux). Apt-get is used to manage packages. The format for invoking the apt-get program is as follows:

apt-get [options] [commands] [package. . .]


The Linux distribution Mandrake includes own remedy package management - rpmdrake. By the tenth version of the distribution, it has changed a bit. Now it consists of three parts:

/usr/sbin/edit-urpm-media - package source manager (I have already said what sources are, so we will not dwell on this);
rpmdrake - package manager;
rpmdrake-remove is a package removal manager.
You can launch any of the parts from the K menu: System | Setting | Packages.

Install from packages containing source code.

Sometimes RPM packages do not contain compiled versions of programs, but their source code. This is indicated by the word src instead of the name of the architecture. To install such a package, enter:

rpm --rebuild software-2.00-1.src.rpm

Of course, instead of software-2.00-l.src.rpm, you need to specify the real file name. Before a program is installed, its source code will be compiled and then the program will be installed.

GENERAL OPTIONS.

These options can be used in all operating modes.

"-vv" Output a lot of debug information.

"--quiet" Output as few messages as possible - usually only error messages are displayed.

"--help" Print more detailed than usual help about using rpm.

"--version" Print a single line containing the version number of the rpm used.

"--rcfile<список-файлов>" Each of the files from colon-separated<списка-файлов>rpm is read sequentially for configuration information.
Default<список-файлов>looks like /usr/lib/rpm/rpmrc:/etc/rpmrc:~/.rpmrc.
Only the first row must exist in this list; all tildes will be replaced by the value of $HOME.

"--root<каталог>"Use for all operations file system rooted in<каталог>.
Note that this means that the database will also be read and modified under<каталог>, and all pre and post scripts will be executed after chroot() in<каталог>.

"--dbpath<путь>" Use the RPM database in<путь>.

"--justdb" Update only the database, not the file system.

"--ftpproxy , --httpproxy " Use as an FTP or HTTP proxy.

"--ftpport<порт>, --httpport<порт>" Use<порт>as FTP or HTTP proxy server port.

"--pipe " Redirects rpm output to command input .

Database maintenance:

rpm -i [--initdb]

rpm -i [--rebuilddb]

DATABASE REBUILDING OPTIONS.

The general form of the RPM database rebuild command is:
rpm --rebuilddb
To build a new database:
rpm --initdb
This mode only supports two options, --dbpath and --root.

launch
rpm --showrc
prints out the values ​​that rpm will use for all options that can be set in rpmrc files.

Assembly:
rpm [-b|t] +
rpm [--rebuild] +
rpm [--tarbuild] +

OPTIONS FOR BUILDING (BUILDING) PACKAGES.

The general form of the rpm package build command looks like this:
rpm -O [build-options] +
The -bfR argument is used if a spec file is used to build the package. If rpmfR is to extract this file from a gzip (or compress) archive, the -tfR argument is used. After the first argument, the next (OfR) is specified, indicating which assembly and packaging steps should be performed. This is one of:

"-bp" Execute the "%prep" stage of the spec file. This usually involves unpacking the sources and applying patches to them.

"-bl" Perform "list check". In the "%files" section of the spec file, macros are expanded and the listed files are checked for existence.

"-bc" Execute the "%build" stage of the spec file (after executing the %prep stage). It usually boils down to doing some equivalent of "make".

"-bi" Execute the "%install" stage of the spec file (after executing the %prep and %build stages). It usually boils down to doing some equivalent
"make install".

"-bb" Build a binary package (previously executing the %prep, %build and %install stages).

"-bs" Build only the source package (after running the %prep, %build and %install stages).

"-ba" Build binary (RPM) and source (SRPM) packages (after running %prep, %build and %install stages).

The following options can also be used:

"--short-circuit" Execute the specified stage directly, skipping the previous ones. Can only be used with -bc and -bi.

"--timecheck" Set age for "timecheck" (0 to disable). This value can also be set by defining the "_timecheck" macro.
The timecheck value determines the maximum age (in seconds) of files to be packaged. All files older than this age will be warned.

"--clean" Remove the build tree after the packages have been built.

"--rmsource" Remove sources and spec file after build (can be used separately, eg "rpm --rmsource foo.spec").

"--test" Do not execute any build steps. Useful for testing spec files.

"--sign" Embed a PGP signature in the package. This signature can be used to verify the integrity and origin of the package. See section
PGP SIGNATURES for PGP options.

"--buildroot<каталог>" Use directory<каталог>as the root for building packages.

"--target<платформа>" When building a package, interpret<платформа>as arch-vendor-os
and set the _target, _target_arch and _target_os macros accordingly.

"--buildarch " Build package for architecture regardless of architecture
build system. This option is deprecated, in RPM 3.0 the --target option should be used instead.

"--buildos " Build a package for the operating system ignoring
the architecture of the system on which the assembly is performed. This option is deprecated, in RPM 3.0 the --target option should be used instead.

REBUILD AND RECOMPILATE OPTIONS.

There are two other ways to start rpm:

rpm --recompile<файл_исходного_пакета>+"

rpm --rebuild<файл_исходного_пакета>+"

When called in this way, rpm installs the specified source package and executes %prep, %build, and %install. In addition, --rebuild builds a new binary package. After the build is complete, the tree used for the build is removed (as with the --clean option), the sources themselves, and the spec file.

SIGNATURE EXISTING RPM.

rpm --resign<файл_бинарного_пакета>+ This option generates and inserts new signatures into the specified packages.
All existing signatures from packages are removed.

rpm --addsign<файл_бинарного_пакета>+ This option generates and adds new signatures to the specified packages.
All existing package signatures are preserved.

PGP SIGNATURES.

In order to use the signing feature, rpm must be configured to run PGP and must be able to find a public key ring with an RPM key in it. By default, rpm uses the PGP defaults to find keyrings (observing PGPPATH).
If your key rings are not located where PGP expects them to be, you must set the "_pgp_path" macro to the directory containing your key rings.

If you want to be able to sign the packages you create, you also need to create your own public/private key pair (see the PGP documentation). In addition to the above macro, you also need to configure the macros

"_signature" Signature type. Currently only pgp is supported.

"_pgp_name" The name of the "user", whose keys you want to use to sign your packages.

When building packages, you add to command line the --sign option. You will be asked for a password and your package will be assembled and signed.

For example, in order to use PGP to sign packages as the user "John Doe " from key rings located in /etc/rpm/.pgp, you must include

"%_signature"
pgp
"%_pgp_name"
/etc/rpm/.pgp
"%_pgp_name"
John Doe "

in the macro configuration file. Use /etc/rpm/macros for system wide and ~/.rpmmacros for user configuration.

Maintenance of installed packages:

rpm [--install] [install-options] [package-file]+
rpm [--eshen|-F] [install-options] [package-file]+
rpm [--uninstall|-e] [uninstall-options] [package]+
rpm [--verify|-V] [verify-options] [package]+

INSTALLATION AND UPDATE OPTIONS.

The general form of the rpm install command looks like this:
rpm -i [install-options]<файл_пакета>+
This command installs new packages.

The general form of the rpm update command looks like this:
rpm -U [install-options]<файл_пакета>+
This command updates installed packages. This command works exactly like the install command, except that all other package versions are removed from the system.

rpm [-F|--eshen] [install-options]<файл_пакета>+
Such a command updates packages, but only if earlier versions of those packages exist on the system.
Job allowed<файл_пакета>as ftp or http style URL. In this case, before installation, the file will be obtained from the server specified in the URL.

"--force" Same as a combination of --replacepkgs, --replacefiles, and --oldpackage.

"-h, --hash" Display 50 "#" characters as the archive with the package is unpacked. Used with -v for prettierness.

"--oldpackage" Allows you to replace a new package with an older one when upgrading (roll back).

"--percent" Display the percentage of completion as the archive with the package is unpacked. Designed to make it easier to use rpm from other utilities.

"--replacefiles" Install packages even if they overwrite files from other already installed packages.

"--replacepkgs" Install packages even if some of them are already installed on the system.

"--allfiles" Install or update all files specified as "missingok", even if they already exist.

"--nodeps" Don't check dependencies before installing or updating a package.

"--noscripts" Do not execute pre- and post-installation scripts.

"--notriggers" Do not execute trigger scripts set to install this package.

"--ignoresize" Don't check the file system for enough free space before installing this package.

"--excludepath<путь>"Do not install files whose names begin with<путь>.

"--excludedocs" Do not install any files marked as documentation files (includes manuals and texinfo documents).

"--includedocs" Install documentation files. This is the default behavior.

"--test" Don't install the package, just test the installability and report any problems.

"--ignorearch" Install or upgrade even if the architectures of the binary RPM and the machine do not match.

"--ignoreos" Install or upgrade even if the operating systems of the binary RPM and the machine do not match.

"--prefix<путь>" Set installation prefix to<путь>for relocatable packages.

"--relocate<старый_путь>=<новый_путь>" For relocatable packages: converts files that should have been installed to<старый_путь>in<новый_путь>.

"--badreloc" For use with --relocate. Performs a relocation even if the package is not relocatable.

"--noorder" Do not reorder the list of packages to be installed. Usually the list is reordered to satisfy dependencies.

Request:
rpm [--query] [query-options]
rpm [--querytags]

REQUEST OPTIONS.

The general form of the rpm query (inspection) command looks like this:
rpm -q [query-options]
You can set the format in which information about the package will be displayed. This is done using the --queryformat option followed by a format string.

Request formats are a modified version of the standard printf(3) formatting. The format consists of static strings (which may include standard C escape sequences for newlines, tabs, and other special characters) and formats like those used in printf(3). Since rpm already knows the types of the data to be output, the type specifiers must be omitted and replaced by the tag names (keys) of the headers to be output, enclosed in (). The RPMTAG_ part of the tag name may be omitted.

Alternate output formats can be specified by adding :typetag to the tag name. The currently supported types are octal, date, shescape, perms, fflags, and depflags.

For example, to display only the names of loaded packages, you can use %(NAME) as a format string. You can use %-30(NAME)%(DISTRIBUTION) to display package names and distribution information in two columns.

When run with the --querytags argument, rpm will list all the tags it knows about.

There are two sets of options for a query - package selection and information selection.

Package selection options:

"<название_пакета>" Requesting an installed package called<название_пакета>.

"-a, --all" Query all installed packages.

"--whatrequires " Query all packages that require for proper functioning.

"--whatprovides " Query all packages that provide service.

"-f<файл>, --file<файл>" Request the package that owns a file<файл>.

"-g<группа>, --group<группа>" Request packages from a group<группа>.

"-p<файл_пакета>" Requesting an (uninstalled) package<файл_пакета>.
File<файл_пакета>can be given as ftp or http style URL; in this case, the package header will be retrieved from the specified server.

"--specfile "Parse and Query as if it were a package. While not all information (such as file lists) is available, this type of query allows rpm to be used to extract information from spec files without having to write a spec file parser.

"--querybynumber " Query directly database entry number . Useful for debugging purposes.

"--triggeredby<имя_пакета>" Query all packages containing trigger scripts activated by the package<имя_пакета>.

Information selection options:

"-i"
Displays information about the package, including name, version, and description. Uses --queryformat if one is given.

"-R, --requires" Print a list of packages that this package depends on.

"--provides" Lists the services and libraries provided by this package.

"--changelog" Displays the change log for this package.

"-l, --list" Displays a list of files included in the given package.

"-s, --state" Print the state of the files in the package (implies -l).

Each file can be in one of the following states: normal, not installed, or replaced.

"-d, --docfiles" List only documentation files (implies -l).

"-c, --configfiles" List configuration files only (implies -l).

"--scripts" Output package-specific scripts used as part of the install/uninstall processes, if any.

"--triggers, --triggerscripts" Show all trigger scripts, if any, contained in the package.

"--dump" Dump file information like this: path size mtime md5sum mode owner group isconfig isdoc rdev symlink.
This option must be used in conjunction with at least one of -l, -c, -d.

"--last" Orders the list of packages by installation time, with the most recent packages at the top of the list.

"--filesbypkg" Shows all files in each package.

"--triggerscripts" Shows all trigger scripts for the selected packages.

VERIFICATION OPTIONS.

The general form of the rpm verification command looks like this:
rpm -V|-y|--verify [verify-options]
During the package verification process, information about the package's installed files is compared with information from the original package and from the RPM database. Verification checks the size, MD5 checksum, permissions, type, owner, and group of each file, among others. All discrepancies are reported. The options for selecting packages are the same as for requesting (inspecting) packages.

Files that were not installed from the package (for example, documentation files that were excluded from the installation process with the "--excludedocs" option) are silently ignored.

Options that can be used in the verification process:

"--nofiles" Ignore missing files.

"--nomd5" Ignore MD5 checksum errors.
"--nopgp" Ignore PGP signing errors.

The output format is an eight-character string, possibly a "c" indicating a configuration file, and the file name. Each of the eight characters represents the result of comparing one of the file's attributes with the value stored in the RPM database. The dot indicates that the test passed. The following symbols indicate some test errors:

"5" MD5 checksum.

"S" File size.

"L" Symlink.

"T" Modification time.

"D" device.

"U" Owner.

"G" Group.

"M" Permissions (includes permissions and file type).

SIGNATURE VERIFICATION

The general form of the RPM signature verification command looks like this:
rpm --checksig<файл_с_пакетом>+
This command verifies the PGP signature embedded in the package to verify the integrity and origin of the package.
PGP configuration information is read from configuration files. See the PGP SIGNING section for more details.

UNINSTALLATION OPTIONS

The general form of the rpm uninstall command looks like this:
rpm -e<название_пакета>+

"--allmatches" Remove all versions of a package that match<название_пакета>Usually if<название_пакета>responds to multiple packets, issued
error message and deletion is not performed.

"--noscripts" Do not execute pre- and post-installation scripts.

"--notriggers" Do not execute trigger scripts set to remove this package.

"--nodeps" Don't check dependencies before removing packages.

"--test" Don't delete, just pretend :) Useful in combination with the -vv option.

Miscellaneous:
rpm [--showrc]
rpm [--setperms] [package]+
rpm [--setgids] [package]+

FTP/HTTP OPTIONS.

rpm contains simple FTP clients and HTTP to make it easier to install and explore packages available over the Internet. Package files to install,
updates and requests can be specified as ftp or http style URLs:
ftp:// :@hostname: /path/to/package.rpm
If part Omitted, the password will be prompted (once for each user/hostname pair). If neither , nor Not specified, anonymous ftp will be used. Passive (PASV) transfer over FTP is used in all cases.

Rpm allows you to use the following options with ftp URLs:

"--ftpproxy " System will be used as a proxy for all transfers, allowing FTP connections to be made through a firewall that uses the proxy to reach the outside world. This option can also be set by setting the _ftpproxy macro.

"--ftpport " Specifies the TCP port number to use for FTP connections instead of the default port.
This option can also be set by setting the _ftpport macro.

Rpm allows you to use the following options with http URLs:

"--httpproxy " System will be used as a proxy for all forwarding, allowing HTTP connections to be made through a firewall that uses the proxy to reach the outside world. This option can also be set by setting the _httpproxy macro.

"--httpport " Specifies the TCP port number to use for HTTP connections instead of the default port.
This option can also be specified by setting the _httpport macro.

Prepared by Dvoe4nik85

Sooner or later, we have to install software from non-official repositories. Not all packages are there, and not always there are the newest versions of newly released programs. Very often, developers post packages for the most popular distributions on their official website. Usually these are deb and rpm. The latter is a little less common, but if you're using a Red Hat-based distribution, this is the package format you need. Also on the net you can often find libraries and other components that are not in the repositories in the form of packages.

Previously, we have already considered the installation deb packages in Ubuntu. And in this article, the installation of rpm packages in linux will be analyzed in detail.

RPM or RPM Package Manager is package manager, used in Linux distributions based on Red Hat. The file format of this package manager has the same name.

This format is not very different from the same Deb. You can see their detailed comparison in the article what. Here, I’ll just note that the rpm file is a regular cpio archive that contains the program files themselves, as well as metadata describing where they need to be installed. The database of all installed packages is located in the /var/lib/rpm directory. Of the features, it can be noted that rpm does not support recommended packages, as well as either-or format dependencies.

To manage packages, as well as in Debian systems, there is a console, low-level utility with the same name - rpm. We will consider it further in the article. Different systems use different package managers, for example Red Hat uses Yum, Fedora uses DNF, and OpenSUSE uses zypper, but rpm will work on all of these systems.

Installing RPM Packages on Linux

Let's first look at the syntax of the rpm utility itself:

$ rpm -option mode package

The utility can work in one of the modes:

  • -q- request, obtaining information;
  • -i- installation;
  • -V- checking packages;
  • -U- update;
  • -e- removal.

Consider only the most interesting program options that we will need in this article:

  • -v- show detailed information;
  • -h- display status bar;
  • --force- perform an action forcibly;
  • --nodeps- do not check dependencies;
  • --replacefiles- replace all old files with new ones without warning;
  • -i- get information about the package;
  • -l- list of package files;

Now that you already have an idea how to work with this utility, installing the rpm package on Linux can be considered. The simplest installation command would look like this:

sudo rpm -i packagename.rpm

To work with the command current directory, there must be a folder with the package. Here we set the install mode and pass the package file. Upon successful installation, the utility will not display anything, if an error occurs, you will know about it.

To view more detailed information during the installation process, use the -v option:

sudo rpm -iv packagename.rpm

You can also enable the display of the bar status during the installation process:

sudo rpm -ivh packagename.rpm

To check if a package is installed, we already need to use query mode:

sudo rpm -q packagename

You can also immediately remove the package if it is not needed:

sudo rpm -e packagename

But rpm, like dpkg, has one major drawback. The program cannot resolve dependencies. If the required package does not exist in the system, you will simply receive an error message and the package will not be installed.

For automatic download dependencies during rpm linux installation, you need to use the distribution's package manager. Let's look at a few commands for the most popular RPM distributions. On RedHat and other distributions that use Yum, use this command:

sudo yum --nogpgcheck localinstall packagename.rpm

The first option disables the GPG key check, and the second says that we will install a local package. On Fedora, dnf makes things even easier:

sudo dnf install packagename.rpm

The Zypper package manager and OpenSUSE do just as well:

sudo zypper install packagename.rpm

This is how it is very easy to install rpm with dependencies. But not everyone likes to work in the console, many new users want to use GUI to solve all problems, including this one. Next, we will look at several of these utilities.

Installing RPM file in GUI

If you are using OpenSUSE, this is very easy to do. The YaST universal system configurator, among other things, allows you to install rpm packages. You can do it with file manager by selecting the item context menu for the file, open with Yast or by running the command:

yast2 -i packagename.rpm

On Fedora, you can use the distribution's application manager for the same purpose. There used to be a few more universal utilities to solve this problem, but now they are all outdated.

conclusions

Now you know how to install an rpm file in Linux. In fact, it is very simple and there is even not only one way, but several. Although there are a bit less graphical utilities here than in Ubuntu. But console utilities are completely enough. If you have any questions, ask in the comments!

A computer