Wed dec 05 2008 eric gerbier do not use popt any more. Note the fedora kernel spec file builds several flavours of the same kernel architecture, for instance. If a patch is rediffed because the old patch does not apply to a new version, a new patch must be created with the appropriate name it is inappropriate to rediff foo1. Since we plan to create rpm package from scratch, we would need a spec file. Just add exit 1 to your spec file in the appropriate section. For example, its not uncommon to put a spec file inside pkgfedora. Building a custom kernelsource rpm fedora project wiki. If they are not detected rpmbuild will fail, and tell you a dependancy is missing, and then you list that dependancy here. In the prior example, the version banner line started. An srpm contains source code, optionally patches to it, and a spec file, which describes how to. A spec file can be thought of the as the recipe that the rpmbuild utility uses to actually build an rpm. Patches must make only one logical change each, so its quite possible to. Lets go through each section and create cdplayers spec file as we go.
How to create and use patch files for rpm packages bob cromwell. Now when you build the package if youve properly included the patch information in the spec file, the rpm will be created with whatever changes you made to the source code as specified in the patch. Or you can use below spec file template for your rpm. Ive have placed my patch file, as directed, in rpmbuildsources. Directives for the %files list rpm package manager. I will explain the layout of the specfile in detail. The spec file is present inside the source directory. After doing this, i uncomment the patch command and then use rpmbuild bp to produce my working sources,with the patch applied. If there was one thing that you should know about creating a rpm its how to write the spec file. 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. The argument used is b if a spec file is being used to build the package, r if a source package is to be rebuild and t if rpmbuild should look inside of a possibly compressed tar file for the spec file to use. You can replace those print statements and place your scripts accordingly. So, with that being said, here is the command i used. It tells the build system what to do by defining instructions in a series of sections.
The second, at the end of the %prep area, tells how to use it with the patch command. The rpmbuild ba command will run through all the steps of the rpm building process, and at the end it will create an rpm package file which will be saved under rpmbuildrpmsi386, or the directory appropriate for your architecture, and also a new srpm file. Rpmbuild create rpm package build rpm from source code. As we saw in the previous chapter, the spec file contains eight different sections, most of which are required. Finally, you can place bash i in a spec file to stop rpmbuild and drop to a shell where you can take a look around. Another option would be to remove the hyphen when generating the spec file. Building a source rpm using rpmbuild command nixcraft. Removing wnopointersign from the cflags line in the php. The preamble contains a series of metadata items that are used in the body. The %patch macro, which is used to apply patches to the original sources. Place the patch file into the usrsrcrpmsources directory and edit the header of your. Or, if starting from source code and patches only, you create the spec file by hand and then use it to build the binary and source rpm files.
Each section generates a shell script that is embedded into the rpm and run subsequently as part of the installation. One to indicate that there is a new patch file and another in the %setup section to apply the patch. The spec file is a description of the software along with instructions on how to build it and a file list for. Kernel patch and compile the fedora way kicking and. This step makes the necessary changes to the kernel. How to rebuild andor patch a rpm package syscookbook.
The following sections summarize the spec file syntax. 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. Patches must make only one logical change each, so its quite possible to have multiple patch files. A spec file is basically a set of instructions on how to build the rpm package. When rpmbuild applies patches, it calls patch with the s option even if in the. My last step is to build the rpm rpmbuild ba nfsutilslib. But it always fails with the message below, any ideas anyone what i am doing wrong.
This will exit and spit out a list of defined environment variables. While reading this section of the tutorial it may be. The command rpmbuild creates the actual rpm package. When the package is being built rpmbuild should detect these requirements, but it may not. The tarball mode of rpmbuild presumes youre in the sources directory more proof that rpms tarball mode is probably a legacy feature. If you must patch the files after you extract them, edit the files and save their differences as a.
This hides warnings from build log, which could lead to things like. As i wrote earlier a spec file consists of instructions on how to package the software into an rpm. In a case like this, i go into the spec file and comment out the patch command in the %prep section, then use rpmbuild bp to expand the original sources. I did some more digging around and while i cannot extract the spec file into another file such as text, i can use rpmrebuild to view the spec file and edit it. This step is required for building a custom kernel. I dont think we can support building with a different specfile name. If applying a patch to your kernel, copy the patch file to rpmbuildsource giving it a suffex of.
The spec file should contain all the commands needed to build the. Install the binaryrpm that was produced in the rpms. How to patch and rebuild an rpm package brad the mad. The %prep, %build, and %install sections are next, consecutively. We make sure it is safe to unpack the tarball in the cwd that is, that it unpacks to a subdirectory we do not mind overwriting. Add two lines to the spec file for each patch file. 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. Big joes editor we choose a change which will show up well in a diff. Notice in the gtkglarea spec file below source0 there is the line patch0.
Enter the name of the first patch to apply to the source code. Assume, for the sake of this demonstration that we want it to read. A spec file can be thought of as the recipe that the rpmbuild utility uses to actually build an rpm. 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. Automating patch application in specs %autosetup description. The author is the creator of nixcraft and a seasoned sysadmin, devops engineer, and a trainer for the linux operating systemunix shell scripting. The build system is detecting the patch as it tries to apply the patches. However, there are two parts of rpms build process that are fairly constant from. The sections are defined between the preamble and the body. The problem is not with the php distribution itself, but with the fedora supplied php. This is important to ensure the custom kernel is not confused with any released kernel. It is probably a bugfix that was applied upstream already e.
In the gtkglarea spec file on the previous page you may have noticed some information mentioning a patch. The sections are defined in the preamble and the body. As a side effect of this there are some clever utilities that are popular among upstream open source projects that work around this problem by either storing the spec file where the source code is in a vcs i. Previously one had to manually specify each patch to be applied, eg. The way we direct rpm in the build process is to create a spec file.