Rpm spec files have several sections which allow packages to run code on installation and removal. You could grep to get the source lines, sed to extract the string containing the macro and then rpm eval string to evaluate it. Previously one had to manually specify each patch to be applied, eg. In the above example, fileutils has a patch for 64 bit machines. Looking up the %setup options in a tutorial at rpm. For example, it includes a list of default path definitions which are used by the build system macros, and definitions for rpm package build specific directories. With no additional options specified, it will apply the patch file specified by the patch. The first part of the spec should contains macros definitions, as illustrated below. Table 105 lists these debugging and special spec file macros.
In this section we will discuss how to create and modify a spec file. Here is a complete, working rpm spec file with several. Directives used in the %files list to direct rpm to handle certain files in a. The %patch macro, which is used to apply patches to the original sources. Group tag in spec files is not considered mandatory anymore, unspecified will be used unless specifically set.
In general, the % files section is about files you have installed into the buildroot. How to patch and rebuild an rpm package brad the mad. This page offers a quick overview of rpm scriptlets and a number of common recipes for scriptlets in packages. In part two my ambition is to take the things i wrote about here to package a real world application into an rpm.
There are a number of different types of entries that comprise a spec file, and every one will be documented here. Here is an example patch definition from usrlib rpm macros. An rpm package is simply a file that contains some files as well as information the. Note that this will only expand the global macros, not the ones defined in this spec. This section describes the basic structure of an rpm spec file and how that applies to rpm specfile. The specfile build section looks like %build cd pathsources make if the spec file path can be detected then the hardcoding of the pathsources can be avoided. In its simplest form, the macro is used with no options and gets the name of the source archive from the source tag specified earlier in the spec file. The fedora project hosts the best documentation on rpm out there in html format.
Which man page describes the usage of the toplevel rpm spec file macros that are defined in rpm source files directly. The specs directory is where the specfile included with an srpm will be placed. Rpmspecfile perl extension for creating rpm specfiles. I have a macro that checks the init system that is defined like so. And is the %1 valid, as ive never seen an example and if not. Most times you will need to make a patch or two that is specific to one architecture only. Finally, %setup makes sure every file in the build tree is owned by root and has.
The way we direct rpm in the build process is to create a spec file. To tell rpm about the file, enter the following information to the % files section. When you build a package, rpm creates a list of the shared libraries that it includes and a list of the shared libraries to which it is linked. Some tips on rpm conditional macros posted by waldner on 17 september 2011, 3. Like the % files list in a spec file, the file named using the f option should contain one filename per line and also include any of the directives named in this section. Automating patch application in specs %autosetup description. The spec file is split into several sections, which will be examined individually. With that being said this first part will cover the bascis like installing rpm tools, the structure of a spec file, macros and lastly a simple rpm build.
See chapter 9, working with spec files for details. As we mentioned above, the %setup macro is used to unpack the original sources, in preparation for the build. One to indicate that there is a new patch file and another in the %setup section to apply the patch. Contribute to rpm software managementrpm development by creating an account on github. In rpm terms, building the package is split into four steps. Rpm spec file macro not expanding on conditional statement.
The spec file is the recipe we use to tell rpmbuild how to actually perform a build. Fix sources and patches lua vars to not depend on ording of the spec file rhbug. Rpm spec files are divided into the following sections. Enable nobackupifmismatch by default in % patch macro. The spec file is present inside the source directory. Lets go through each section and create cdplayers spec file as we go. If you must patch the files after you extract them.
Of course, if we already have a patch for the kernel, all we have do is copy it to the sources directory with a proper name, add it to the spec file by using the applypatch macro, and rebuild the rpm rpmbuild ba. To display the current set, add %dump to the beginning of any spec file, process with rpm, and examine the output from stderr. It does not attempt to give a full description of rpm spec file syntax. Anyway, the macro is easily changed by adding something like the following. The %ifarch macro is very important to all of this. Third, modify or create a spec file describing how to start with the original archive and one or more patch files and build either a binary rpm package file that can be installed, or a source rpm package file containing the original code plus your modifications and the spec file, or both source and binary rpm files. Macros may also be automatically included from usrlib rpm macros. Bug 850355 introduce new systemd rpm macros in utillinux spec file. Like the %setup macro, the %patch directive applies a patch to the sources. Inside the spec file in this chapter, were going to cover the spec file in detail. In this chapter, were going to cover the spec file in detail. Patches are applied with zero fuzz tolerance by default. In this case, rpm will allow you to apply that patch to just one architecture only.
Most of the predefined rpm macros hold directory paths or architecture information. Here is an example % patch definition from usrlib rpm macros. Like all rpms, the fedora kernel starts with a spec file and a set of tarballs and patches. Add a new config patch to a linux kernel rpm blogger. The spec file should contain all the commands needed to build the application or library you want to. How to create and use patch files for rpm packages.
Shorthand for package builders describes %setup and %patch macros. To expand those as well youd probably need to grep for them and feed them to rpm as your custom macros file. Rpm, %config, and noreplace jon warbrick university of cambridge computing service rpm spec files have a macro, %config, that is used to mark config files so that edits to config files wont get lost during a subsequent upgrade. I have a very simple rpm spec file that installs one binary and a service file depending on the init system. Without this, the config files from an upgrade would tend to overrite the edited files from the previous version. Rpm enforces buildroot for all packages and ignores the directive in spec. This was not covered in the spec file section of this guide because it is almost always a bad idea to introduce an epoch value as it will skew what you would normally otherwise expect rpm to do when comparing versions of packages.
The macros for build system invocations for example, %configure, %cmake, or %meson use the values defined by rpm to set installation paths for packages. In order to write spec files, it is important to understand rpm s dependency checking, macros and directory structure. As we saw in the previous chapter, the spec file contains eight different sections, most of which are required. Its default value is 0 and this is assumed if an epoch directive is not listed in the rpm spec file. The newest threads will be at the top of this page, the oldest will be at the bottom. This page will describe some of the sections of the kernel. There are a few important macros that we modify often. Reference for rpm spec macros %setup, %buildroot, etc server. Rpm also includes a set of useful macros that you can use to help debug problematic spec files and well as perform common tasks in spec files. The % patch macro, as its name implies, is used to apply patches to the unpacked sources. The second, at the end of the %prep area, tells how to use it with the patch command. You will need either p0 or p1 specifying how many levels to strip off the path names, depending on how you built the patch file compared to how the tar file is contructed.
Cleanups to ima file signing, queryverify filtering, ordering, macro engine, spec parsing, build script running, signature generation, main rpm executable consolidate dependency knowledge into a structtable. Place the patch file into the usrsrc rpm sources directory and edit the header of your. Also, macro definitions are generally put at the top of the preamble. In source packages, you have the pristine sources along with any patches that. Fedora 18 changes the way how to work with services in spec files.
The first part of the spec should contain macros definitions, as illustrated below. The %setup macro is used to unpack the original sources in preparation for the build. If you see a macro in a spec file that youre not familiar with, you can quickly. Add two lines to the spec file for each patch file. Its crazy that there is no fundamental public reference for the.
643 389 1158 1290 512 1032 842 372 76 37 563 1149 1500 607 1448 1371 180 795 1310 53 1187 576 140 1188 885 864 873 1450 1001 1440 1124 1397 1180 561 602 10 956