mirror of
https://pagure.io/fedora-docs/quick-docs.git
synced 2024-12-01 07:39:48 +00:00
Create modules for procedure to create RPM
Create module for prereq procedures Create concept for spec file Create concept for RPM terminology Create file for old content I didn't have time to update but is still relevant Create assembly in create-an-rpm.adoc file
This commit is contained in:
parent
714fb2a991
commit
ee62b7d68e
6 changed files with 1886 additions and 1945 deletions
1514
en-US/create-an-rpm-old.adoc
Normal file
1514
en-US/create-an-rpm-old.adoc
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
62
en-US/modules/con_rpm_packaging_overview.adoc
Normal file
62
en-US/modules/con_rpm_packaging_overview.adoc
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
[[introduction]]
|
||||||
|
== RPM Packaging Overview
|
||||||
|
|
||||||
|
Use this guide to create RPM packages and `.spec` files. Despite the focus on Fedora, you can apply much of this document to other RPM-based
|
||||||
|
distributions.
|
||||||
|
|
||||||
|
Fedora Documentation had released a draft guide for packagers, see
|
||||||
|
http://docs-old.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/Packagers_Guide[Packagers
|
||||||
|
Guide]. It is archived.
|
||||||
|
|
||||||
|
|
||||||
|
[NOTE]
|
||||||
|
This document is not an official Fedora packaging guideline. This page
|
||||||
|
is open for editing by the general Fedora packaging community, while the
|
||||||
|
actual packaging guidelines are managed by the
|
||||||
|
https://fedoraproject.org/wiki/Packaging_Committee?rd=Packaging:Committee[Packaging Committee].
|
||||||
|
|
||||||
|
For more information about packaging guidelines, see the following guides:
|
||||||
|
|
||||||
|
* https://rpm-packaging-guide.github.io/#introduction[Packaging Guidelines]
|
||||||
|
* http://fedoraproject.org/wiki/Packaging:LicensingGuidelines[Licensing Guidelines]
|
||||||
|
* http://fedoraproject.org/wiki/Packaging:Naming[ Package Naming Guidelines]
|
||||||
|
* http://fedoraproject.org/wiki/Packaging:DistTag[ Dist Tag Guidelines]
|
||||||
|
* http://fedoraproject.org/wiki/Packaging:ReviewGuidelines[ Package Review Guidelines]
|
||||||
|
* http://fedoraproject.org/wiki/Packaging:Scriptlets[ Recipes for RPM scriptlets]
|
||||||
|
|
||||||
|
|
||||||
|
If you plan to submit a package to the official Fedora repository, follow the procedure in http://fedoraproject.org/wiki/Join_the_package_collection_maintainers[Join the package collection
|
||||||
|
maintainers].
|
||||||
|
|
||||||
|
Before you begin, select a text editor that you want to use, and ensure that you understand the following terminology.
|
||||||
|
|
||||||
|
[[some-terminology]]
|
||||||
|
== RPM terminology
|
||||||
|
|
||||||
|
.RPM
|
||||||
|
The package manager used by Fedora, Red Hat Enterprise Linux, Mageia, OpenSUSE and others. Originally RPM stood for "Red Hat Package Manager" but now it is a recursive acronym "RPM Package Manager".
|
||||||
|
|
||||||
|
.spec file
|
||||||
|
A plain text file that contains information about a package and instructions that RPM uses for compiling the package's software. To name the file, use the name of the package with the file extension `.spec`.
|
||||||
|
|
||||||
|
.tag
|
||||||
|
A string, generally capitalized and followed by a colon, which appears at the top of the `.spec` file to provide some important data about the RPM, such as `Name:`, `Version:` or `Summary:`.
|
||||||
|
|
||||||
|
.section
|
||||||
|
A segment of the `.spec` file that tells RPM how to perform some portion of the package construction process. Many, but not all, sections contain code that is simply passed to the shell, though RPM has significant flexibility around this that is outside of the scope of this document.
|
||||||
|
|
||||||
|
.section header
|
||||||
|
A short string, starting with `%` at the beginning of a line, which introduces a section. Examples include `%description`, `%prep` and `%files`.
|
||||||
|
|
||||||
|
.macro
|
||||||
|
A short string, always prefixed by `%` and generally surrounded by curly brackets `{}` which RPM converts to a different and usually longer string. Some macros can take arguments and some arguments are quite complex. Some macros are provided by RPM, some are part of https://apps.fedoraproject.org/packages/redhat-rpm-config[redhat-rpm-config] and https://apps.fedoraproject.org/packages/fedora-rpm-macros[fedora-rpm-macros] packages, but many other packages also provide macros. You can run `rpm --showrc` to view all of the macros currently available on your system, but you do not need to run most of the macros you see there.
|
||||||
|
+
|
||||||
|
For a full list of guidelines related to macros, see http://fedoraproject.org/wiki/Packaging:Guidelines#Macros[Macros] in the Packaging Guidelines.
|
||||||
|
|
||||||
|
|
||||||
|
.mock
|
||||||
|
A system for building RPMs within their own separate small Fedora installation. This avoids the need to install a full set of build dependencies on your operating system installation, and allows you to build packages for different Fedora releases.
|
||||||
|
|
||||||
|
.koji
|
||||||
|
The main Fedora build system: https://koji.fedoraproject.org[1].
|
||||||
|
|
123
en-US/modules/con_rpm_spec_file_overview.adoc
Normal file
123
en-US/modules/con_rpm_spec_file_overview.adoc
Normal file
|
@ -0,0 +1,123 @@
|
||||||
|
== Spec file overview
|
||||||
|
[[con_rpm_spec_file_overview]]
|
||||||
|
|
||||||
|
Use this guide for information about the specific macros in a `.spec` file.
|
||||||
|
|
||||||
|
|
||||||
|
[NOTE]
|
||||||
|
You can use the macros `%{name}`, `%{version}` and `%{release}` to refer to the Name, Version and Release tags respectively. When you change the tag, the macros automatically update to use the new value.
|
||||||
|
|
||||||
|
.Name
|
||||||
|
Add the base name of the package, which must match the `.spec` file name. Follow the http://fedoraproject.org/wiki/Packaging:Naming[Package Naming Guidelines] and write the file name in lower-case letters.
|
||||||
|
|
||||||
|
.Version
|
||||||
|
Add the upstream version number. See http://fedoraproject.org/wiki/Packaging:Versioning[Package Versioning]. If the version contains tags that are non-numeric, you might need to include the non-numeric characters in the `Release` tag. If upstream uses full dates to distinguish versions, consider using version numbers of the form. For example, `yy.mm[dd]` where `2008-05-01` becomes `8.05`.
|
||||||
|
|
||||||
|
.Release
|
||||||
|
Set the initial value to `1%{?dist}`. Increment the number every time you release a new package for the same version of software. When a new upstream version is released, change the `Version` tag to match and reset the `Release` number to `1`. For more information, see the http://fedoraproject.org/wiki/Packaging:Versioning[Versioning Guide] of the packaging guidelines.
|
||||||
|
|
||||||
|
.Summary
|
||||||
|
Enter a brief, one-line summary of the package. Use American English. Do not end with a period.
|
||||||
|
|
||||||
|
.Group
|
||||||
|
This tag is deprecated since Fedora 17. See https://docs-old.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/Packagers_Guide/chap-Packagers_Guide-Spec_File_Reference-Preamble.html[Spec
|
||||||
|
File Reference Preamble]
|
||||||
|
|
||||||
|
.License
|
||||||
|
Enter an open source software license. Do not use the old Copyright tag. Use a standard abbreviation, for example, "`GPLv2+`" and be specific. For example, use "`GPLv2+`" for GPL version 2 or greater rather than "`GPL`" or "`GPLv2`" where it's true). For more information, see the http://fedoraproject.org/wiki/Packaging:LicensingGuidelines[Licensing Guidelines].
|
||||||
|
|
||||||
|
You can list multiple licenses by combining them with "`and`" and "`or`" (e.g. "`GPLv2 and BSD`".
|
||||||
|
|
||||||
|
.URL
|
||||||
|
The full URL for more information about the program. For example, the project website.
|
||||||
|
|
||||||
|
[NOTE]
|
||||||
|
Do not add a link to the original source code. Add the link to the source code to the `Source0` tag.
|
||||||
|
|
||||||
|
.Source0
|
||||||
|
Enter the full URL for the compressed archive that contains the original, pristine source code, as upstream released it. "`Source`" is synonymous with "`Source0`".
|
||||||
|
|
||||||
|
The full URL basename is used when looking in the `SOURCES` directory. If possible, embed `%{name}` and `%{version}`, so that changes to the go to the right place. Preserve the timestamps when downloading source files. For more information, see http://fedoraproject.org/wiki/Packaging:Guidelines#Timestamps[Preserve timestamps].
|
||||||
|
|
||||||
|
If there is more than one source, name them `Source1`, `Source2`.
|
||||||
|
|
||||||
|
If you add whole new files in addition to the pristine sources, list them as sources after the pristine sources. A copy of each of these sources is included in any source RPM(SRPM) you create, unless you specifically direct otherwise. For more information on special cases, for example, revision control, see https://fedoraproject.org/wiki/Packaging:SourceURL?rd=Packaging/SourceURL[Source URL].
|
||||||
|
|
||||||
|
.Patch0
|
||||||
|
Enter the name of the first patch to apply to the source code. If you must patch the files after you extract them, edit the files and save their differences as a "patch" file in your `~/rpmbuild/SOURCES` directory. Patches must make only one logical change each, so it's quite possible to have multiple patch files.
|
||||||
|
|
||||||
|
.BuildArch
|
||||||
|
If you package files that are architecture-independent, for example shell scripts, data files, then add `BuildArch: noarch`. The architecture for the binary RPM is then `noarch`.
|
||||||
|
|
||||||
|
.BuildRoot
|
||||||
|
This is now redundant in Fedora and is only needed for EPEL5. By default, the build root is placed in "`%{_topdir}/BUILDROOT/`".
|
||||||
|
|
||||||
|
In EPEL5, this is where files are installed during the %install process (after the %build process).
|
||||||
|
|
||||||
|
.BuildRequires
|
||||||
|
Add a comma-separated list of packages that are required for compiling the program. Usually, this field is repeated on multiple lines. These dependencies are not automatically determined. You must include everything that the package needs to build the program.
|
||||||
|
|
||||||
|
Verify that you have specified all the necessary build requirementss by link:Using_Mock_to_test_package_builds[performing a "mock
|
||||||
|
build"] of your package. You can specify a minimum version if necessary, for example, `ocaml >= 3.08`.
|
||||||
|
|
||||||
|
If you need the file `/EGGS`, determine the package that owns it by running `rpm -qf /EGGS`.
|
||||||
|
|
||||||
|
If you need the program `EGGS`, determine the package that owns it by running "`rpm -qf \`which EGGS\``". Keep dependencies to a minimum. For example, use `sed` instead of `perl` if you do not need perl, but note that some applications permanently disable functions if the associated dependency is not present; in those cases you might need to include the additional packages.
|
||||||
|
|
||||||
|
.Requires
|
||||||
|
Enter a comma-separate list of packages that are required when the program is installed. Note that the `BuildRequires` tag lists what is required to build the binary RPM, while the `Requires` tag lists what is required when installing and running the program; a package may be in one list or in both.
|
||||||
|
|
||||||
|
|
||||||
|
.%description
|
||||||
|
Enter a longer, multi-line description of the program. Use American English. All lines must be 80 characters or less. Blank lines indicate a new paragraph.
|
||||||
|
|
||||||
|
Some graphical user interface installation programs reformat paragraphs; lines that start with whitespace might be treated as preformatted text and displayed as is, normally with a fixed-width font. See
|
||||||
|
https://docs-old.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch09s03.html[RPM
|
||||||
|
Guide].
|
||||||
|
|
||||||
|
.%prep
|
||||||
|
Add script commands to "prepare" the program. For example, to extract the program, so that it is ready for building. Typically this is just "`%autosetup`"; a common variation is "`%autosetup -n NAME`" if the
|
||||||
|
source file unpacks into `NAME`.
|
||||||
|
|
||||||
|
.%build
|
||||||
|
Add script commands to compile the program and get it ready for installing. The program must come with instructions on how to do this.
|
||||||
|
|
||||||
|
.%install
|
||||||
|
Add script commands to "install" the program. The commands must copy the files from the `BUILD` directory `%{_builddir}` into the buildroot directory, `%{buildroot}`.
|
||||||
|
|
||||||
|
.%check
|
||||||
|
Add script commands to "test" the program. This is run after the `%install` procedure, so place it there if you have this section. Often it contains `make test` or `make check`. This is separated from `%build` so that people can skip the self-test if they desire.
|
||||||
|
|
||||||
|
.%clean
|
||||||
|
Note that this section is now redundant in Fedora and is only necessary for EPEL.
|
||||||
|
Typically this contains only the following command:
|
||||||
|
|
||||||
|
`rm -rf %{buildroot}`
|
||||||
|
|
||||||
|
.%files
|
||||||
|
Add the list of files to be installed.
|
||||||
|
|
||||||
|
.%changelog
|
||||||
|
Add changes in the package. Use the format example above.
|
||||||
|
|
||||||
|
Do not put software's change log here. This change log is only for the RPM.
|
||||||
|
|
||||||
|
.ExcludeArch
|
||||||
|
If the package does not successfully compile, build or work on a particular architecture, list those architectures under this
|
||||||
|
tag.
|
||||||
|
|
||||||
|
|
||||||
|
RPM also supports the creation of several packages called subpackages from a single `.spec` file, such as `name-libs` and `name-devel` packages.
|
||||||
|
|
||||||
|
Do *not* create a "relocatable" package; they do not add value in Fedora and make things more complicated.
|
||||||
|
|
||||||
|
|
||||||
|
.Inserting comments
|
||||||
|
|
||||||
|
Insert comments with a leading "`#`" character, and beware of macros (beginning with `%`) that are potentially multi-line, as they are expanded first.
|
||||||
|
|
||||||
|
When commenting out a line, double the percent signs (`%%`) of the macros appearing after the "`#`".
|
||||||
|
|
||||||
|
Also avoid inline comments on the same line as script commands.
|
||||||
|
|
||||||
|
|
139
en-US/modules/proc_rpm_creating_a_rpm.adoc
Normal file
139
en-US/modules/proc_rpm_creating_a_rpm.adoc
Normal file
|
@ -0,0 +1,139 @@
|
||||||
|
[[creating_rpm_package]]
|
||||||
|
== Creating an RPM package
|
||||||
|
|
||||||
|
.Overview
|
||||||
|
|
||||||
|
To create an RPM package, you must complete the following steps:
|
||||||
|
|
||||||
|
. Create a directory to store the package. Within the package directory, create a `.spec` file.
|
||||||
|
. In the `.spec` file, add information about your software, instructions for unpacking it, building it, and installing it, as well as a list of files that are in the package.
|
||||||
|
. Run the `fedpkg` command with the appropriate options to build your package.
|
||||||
|
|
||||||
|
. To create a directory, add a package, and within the package, create a simple program, enter the following commands:
|
||||||
|
+
|
||||||
|
-----------
|
||||||
|
mkdir -p ~/packaging-work/howdy
|
||||||
|
cd ~/packaging-work/howdy
|
||||||
|
cat << EOF > howdy
|
||||||
|
#!/bin/bash
|
||||||
|
echo "Howdy, partner!"
|
||||||
|
EOF
|
||||||
|
chmod 644 howdy
|
||||||
|
-----------
|
||||||
|
+
|
||||||
|
[NOTE]
|
||||||
|
The directory `packaging-work`, the package `howdy`, and program `howdy` names are for example purposes. Edit these names to suit your project.
|
||||||
|
You can use any location you want but the directory name for the package should match the name of the package.
|
||||||
|
+
|
||||||
|
. To verify that everything built correctly, enter the following command:
|
||||||
|
+
|
||||||
|
-------
|
||||||
|
$ bash ./howdy
|
||||||
|
-------
|
||||||
|
+
|
||||||
|
. Create a new file `howdy.spec` and open `howdy.spec` in your text editor. Populate the `howdy.spec` file using the following example as a guide but change anything you require:
|
||||||
|
+
|
||||||
|
[NOTE]
|
||||||
|
When you create the file, use spaces and do not use tabs to align the text.
|
||||||
|
+
|
||||||
|
---------
|
||||||
|
....
|
||||||
|
Name: howdy
|
||||||
|
Version: 1
|
||||||
|
Release: 1%{?dist}
|
||||||
|
Summary: Say hello, Texas style
|
||||||
|
|
||||||
|
License: Public Domain
|
||||||
|
Source0: howdy
|
||||||
|
|
||||||
|
%description
|
||||||
|
A simple program to greet the user, Texas style.
|
||||||
|
|
||||||
|
%install
|
||||||
|
|
||||||
|
%files
|
||||||
|
|
||||||
|
%changelog
|
||||||
|
....
|
||||||
|
---------
|
||||||
|
+
|
||||||
|
. To instruct the package how to install the program, add thie following information to the `%install` section of the `.spec` file. Add the information to the line that follows `%install`:
|
||||||
|
+
|
||||||
|
--------
|
||||||
|
mkdir -p %{buildroot}/%{_bindir}
|
||||||
|
install -p -m 755 %{SOURCE0} %{buildroot}/%{_bindir}
|
||||||
|
--------
|
||||||
|
+
|
||||||
|
[NOTE]
|
||||||
|
In this example, we use the following three macros: `%{buildroot}`, `%{_bindir}`, and `%{SOURCE0}`. This method ignores the origin of the files and directories and focuses on the destination of the files. Without `%{buildroot}` the files might install directly onto your development machine. This is not recommended, especially if you run as root. For more information on macros and `.spec` file entries, see xref:con_rpm_spec_file_overview[].
|
||||||
|
+
|
||||||
|
. To tell RPM about the file, enter the following information to the `%files` section:
|
||||||
|
+
|
||||||
|
-------
|
||||||
|
%{_bindir}/howdy
|
||||||
|
-------
|
||||||
|
+
|
||||||
|
[NOTE]
|
||||||
|
In general, the `%files` section is about files you have installed into the buildroot. You do not use the `%{buildroot}` macro when listing
|
||||||
|
files there.
|
||||||
|
+
|
||||||
|
. Save your edits and to run a local build, enter the following command:
|
||||||
|
+
|
||||||
|
-----
|
||||||
|
$ fedpkg --release f`` local
|
||||||
|
-----
|
||||||
|
|
||||||
|
This updates the two RPMs.
|
||||||
|
|
||||||
|
.Adding no architecture dependencies
|
||||||
|
|
||||||
|
In this example, the package is a shell script and there is no requirement for the package to build separately on every architecture that Fedora supports.
|
||||||
|
|
||||||
|
. To specify that this package independent of architectures, open the file in your text editor and add the following information after the `Source0:` line:
|
||||||
|
+
|
||||||
|
---------
|
||||||
|
BuildArch: noarch
|
||||||
|
---------
|
||||||
|
+
|
||||||
|
. Delete the existing `.rpm` files in this directory and run another local build:
|
||||||
|
+
|
||||||
|
-----
|
||||||
|
$ fedpkg --release f`` local
|
||||||
|
-----
|
||||||
|
|
||||||
|
.Result
|
||||||
|
|
||||||
|
After you complete the procedure, ensure that you have the following two files:
|
||||||
|
|
||||||
|
. One source file that contains the latest source.
|
||||||
|
. One binary file with the `.noarch.rpm`.
|
||||||
|
|
||||||
|
.What to do next
|
||||||
|
|
||||||
|
Validate your RPM package with RPM lint, using the following command:
|
||||||
|
|
||||||
|
----
|
||||||
|
fedpkg --release f`` lint
|
||||||
|
----
|
||||||
|
|
||||||
|
At this stage, there are four or more errors because of the lack of `%prep`, `%build` sections, and `URL` tag.
|
||||||
|
|
||||||
|
To view the list of dependencies, enter the following command:
|
||||||
|
|
||||||
|
-----
|
||||||
|
rpm -qp --requires howdy-1-1.fc``.noarch.rpm
|
||||||
|
-----
|
||||||
|
|
||||||
|
RPM adds some internal `rpmlib` dependencies, and one in `/bin/bash` which matches up with the first line of the howdy program.
|
||||||
|
|
||||||
|
|
||||||
|
To view a list of what the RPM provides, enter the following commnad:
|
||||||
|
|
||||||
|
-----
|
||||||
|
rpm -qp --provides howdy-1-1.fc``.noarch.rpm
|
||||||
|
-----
|
||||||
|
|
||||||
|
This command is more important when your RPM package gains complexity and has dependencies.
|
||||||
|
|
||||||
|
For more information about building a more complete and complex RPM package, see https://fedoraproject.org/wiki/How_to_create_a_GNU_Hello_RPM_package[How to create a GNU Hello RPM package].
|
||||||
|
|
43
en-US/modules/proc_rpm_preparing_your_system.adoc
Normal file
43
en-US/modules/proc_rpm_preparing_your_system.adoc
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
[[preparing-your-system]]
|
||||||
|
== Preparing your system to create RPM packages
|
||||||
|
|
||||||
|
Before you create RPM packages on Fedora, you must install packaging tools and set up any accounts that you want to use.
|
||||||
|
|
||||||
|
For general information about preparing your environment, understanding source code, building and patching software, see the https://rpm-packaging-guide.github.io/#preparing-software-for-packaging[Preparing Software for Packaging] section in the RPM packaging guide.
|
||||||
|
|
||||||
|
This installs the utilities that you require to work with and build packages in the same manner as official Fedora packages, including the tool that the package reviewers use to check package quality.
|
||||||
|
|
||||||
|
To prepare your build environment to create RPM packages, complete the following steps:
|
||||||
|
|
||||||
|
[NOTE]
|
||||||
|
You must run the following two commands as the root user.
|
||||||
|
|
||||||
|
. To install the `fedora-packager` and `fedora-review` tools, enter the following command:
|
||||||
|
+
|
||||||
|
------------
|
||||||
|
# dnf install fedora-packager fedora-review`
|
||||||
|
------------
|
||||||
|
+
|
||||||
|
. To add yourself to the mock group, run the following command:
|
||||||
|
+
|
||||||
|
-----------
|
||||||
|
# usermod -a -G mock yourusername
|
||||||
|
-----------
|
||||||
|
+
|
||||||
|
. Change from the root user to your user name and enter the `newgrp` command or log in and out for this change to take effect:
|
||||||
|
+
|
||||||
|
-------------
|
||||||
|
$ newgrp
|
||||||
|
-------------
|
||||||
|
+
|
||||||
|
. Run the `id` command to verify that the "mock" group appears in your group list, enter the following command:
|
||||||
|
+
|
||||||
|
----------------
|
||||||
|
$ id
|
||||||
|
----------------
|
||||||
|
+
|
||||||
|
|
||||||
|
|
||||||
|
[NOTE]
|
||||||
|
You can also create a separate user and use it for doing RPM development. Ensure that the user is part of the "mock"
|
||||||
|
group and enters the `fedora-packager-setup` command.
|
Loading…
Reference in a new issue