While these distros are the target environment, it should be noted that lessons learned here should be applicable across all distributions that are RPM based but the examples will need to be adapted for distribution specific items such as prerequisite installation items, guidelines, or macros.
More on macros later. In this section we are going to hopefully cover everything you ever wanted to know about the RPM Packaging format, and if not then hopefully the contents of the Appendix will satisfy the craving for knowledge that has been left out of this section. An RPM package is simply a file that contains some files as well as information the system needs to know about those files. More specifically, it is a file containing a cpio archive and metadata about itself.
The cpio archive is the payload and the RPM Header contains the metadata. The package manager rpm uses this metadata to determine things like dependencies, where to install files, etc.
Both of these share a file format and tooling, but they represent very different things. In the Prerequisites section we installed a package named rpmdevtools which provides a number of handy utilities for RPM Packagers.
Feel free to explore the output of the following command and check out the various utilities manual pages or help dialogs. We will then define what each directory in the directory structure is meant for. It tells the build system what to do by defining instructions in a series of sections. The sections are defined between the Preamble and the Body.
Within the Preamble we will define a series of metadata items that will be used through out the Body and the Body is where the bulk of the work is accomplished. Here python is our Package Name, 2. There are a series of advanced items including what are known as scriptlets and triggers which take effect at different points through out the installation process on the target machine not the build process.
These are out of the scope of this document, but there is plenty of information on them in the Appendix. Ultimately the payload of the resulting Binary RPM is extracted from this environment and put into the cpio archive.
A rpm macro is a straight text substitution that can be conditionally assigned based on the optional evaluation of a statement when certain built-in functionality is used.
An example of how this can be extremely useful for a RPM Packager is if we wanted to reference the Version of the software we are packaging multiple times through out our SPEC file but only want to define it one time.
One handy utility of the rpm command for packagers is the --eval flag which allows you to ask rpm to evaluate a macro. For more information, please reference the More on Macros section of the Appendix.
The spec file is the recipe we use to tell rpmbuild how to actually perform a build. In this section we will discuss how to create and modify a spec file.
When it comes time to package new software, a new SPEC file must be created. This utility will create a new spec file for us. We will just fill in the various directives or add new fields as needed. This provides us with a nice baseline template. Some programmer focused text editors will pre-populate a new file with the extension.
Take a moment to look at the files using your favorite text editor, the directives should look familiar from the What is a SPEC File?
We will discuss the exact information we will input into these fields in the following sections that will focus specifically on each example. The rpmdev-newspec utility does not use Linux Distribution specific guidelines or conventions, however this document is targeted towards using conventions and guidelines for Fedora , CentOS , and RHEL so you will notice:. There are three examples below, each one is meant to be self-sufficient in instruction such that you can jump to a specific one if it matches your needs for packaging.
However, feel free to read them straight through for a full exploration of packaging different kinds of software. The following is the output template we were given from rpmdev-newspec. Let us begin with the first set of directives that rpmdev-newspec has grouped together at the top of the file: Name , Version , Release , Summary. The Name is already specified because we provided that information to the command line for rpmdev-newspec. When a new upstream release happens for example, bello version 0.
The Summary should be a short, one-line explanation of what this software is. The License field is the Software License associated with the source code from the upstream release. We can simplify this by only needing to update one field in the SPEC file and allowing it to be reused.
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Asked 5 years, 10 months ago. Active 5 years, 10 months ago. Viewed 12k times. Here are some CPack RPM generator wiki resources that are here for historic reasons and are no longer maintained but may still prove useful:. If enabled ON multiple packages are generated. By default a single package containing files of all components is generated.
New in version 3. Alternatively provided package file name must end with. By using user provided spec file, rpm macro extensions such as for generating debuginfo packages or by simply using multiple components more than one rpm file may be generated, either from a single spec file or from multiple spec files each component execution produces its own spec file.
In such cases duplicate file names may occur as a result of this variable setting or spec file content structure. Duplicate files get overwritten and it is up to the packager to set the variables in a manner that will prevent such errors.
This variable can be set to any component or group name so that component or group rpm package is generated without component suffix in filename and package name. Optional number that should be incremented when changing versioning schemas or fixing mistakes in the version numbers of older packages. Default : Native architecture output by uname -m. This may be set to noarch if you know you are building a noarch package. This is the numbering of the RPM package itself, i.
This is the string that goes into the RPM Release: field. Some distros e. The dist tag that is added RPM Release: field. For example some Linux distribution now default to lzma or xz compression whereas older cannot use such RPM. Using this one can enforce compression type to be used. May be used to enable 1 , yes or disable 0 , no automatic shared libraries dependency detection. Dependencies are added to requires list. May be used to enable 1 , yes or disable 0 , no automatic listing of shared libraries that are provided by the package.
Post as a guest Name. Email Required, but never shown. The Overflow Blog. Stack Gives Back Safety in numbers: crowdsourcing data on nefarious IP addresses. Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Related 3.
0コメント