Наши партнеры








Книги по Linux (с отзывами читателей)

Библиотека сайта rus-linux.net

The prefix tag: Relocation Central

The best way to explain how the prefix tag is used is to step through an example. Here's a sample prefix tag:
Prefix: /opt
        
In this example, the prefix path is defined as /opt. This means that, by default, the package will install its files under /opt. Let's assume the spec file contains the following line in its %files list:
/opt/bin/baz
        

If the package is installed without any relocation, this file will be installed in /opt/bin. This is identical to how a non-relocatable package is installed.

However, if the package is to be relocated on installation, the path of every file in the %files list is modified according to the following steps:

  1. The part of the file's path that corresponds to the path specified on the prefix tag line is removed.

  2. The user-specified relocation prefix is prepended to the file's path.

Using our /opt/bin/baz file as an example, let's assume that the user installing the package wishes to override the default prefix (/opt), with a new prefix, say, /usr/local/opt. Following the steps above, we first remove the original prefix from the file's path:
/opt/bin/baz
        
becomes:
/bin/baz
        
Next, we add the user-specified prefix to the front of the remaining part of the filename:
/usr/local/opt + /bin/baz = /usr/local/opt/bin/baz
        

Now that the file's new path has been created, RPM installs the file normally. This part of it seems simple enough, and it is. But as we mentioned above, there are a few things the package builder needs to consider before getting on the relocatable package bandwagon.