Creating RPM packages :: Fedora Docs Site (2024)

Use this guide for information about the specific macros in a .spec file.

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 Package Naming Guidelines and write the file name in lower-case letters.

Version

Add the upstream version number. See 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 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 SpecFile 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 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.

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 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 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 requirements by 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.

%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 #.

  • Avoid inline comments on the same line as script commands.

Creating RPM packages :: Fedora Docs Site (2024)

FAQs

How to create an RPM in Fedora? ›

You must run the following two commands as the root user.
  1. Install the fedora-packager and fedora-review tools: ...
  2. Add yourself to the mock group: ...
  3. 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:

How to make a package in Fedora? ›

Creating the package directory

In Fedora, package build instructions are organized in so called dist-git repositories. There is a separate repository for each package. We mimic this system by creating a new directory for this tutorial. In dist-git, the repository name matches the package name.

Should I use RPM or DNF? ›

DNF maintains the system integrity and forces a system integrity check if packages are installed or removed using another application, such as RPM, instead of DNF. For these reasons, it is highly recommended that you use DNF instead of RPM whenever possible to perform package-management tasks.

How to download RPM packages in Fedora? ›

Using dnf Command (Fedora, RHEL, Rocky Linux)

Another method to install RPM files on Fedora and RHEL is to use the dnf (Dandified YUM) utility. This tool is used primarily in RPM-based Linux distributions (Fedora, RHEL, CentOS, and other derivatives).

Does RPM work on Fedora? ›

Fedora is a distribution that uses a package management system. This system is based on rpm , the RPM Package Manager, with several higher level tools built on top of it, most notably PackageKit (default gui) and DNF.

How to create custom RPM? ›

Build and install custom RPMs
  1. Create the . rpmmacros file. Use your preferred text editor to create the . rpmmacros file in the /root/ directory. ...
  2. Create the directories to rebuild the RPM. If not present on your server, create the following directories: 1 2 3 4 5 6.
Feb 22, 2024

How to create an RPM package from source code? ›

To build an RPM, you must:
  1. Set up a directory hierarchy per the rpmbuild specifications.
  2. Place your source code and supplemental files in the proper locations in the hierarchy.
  3. Create your spec file.
  4. Build the RPM. You can optionally build a source RPM to share your source code with others.
Jan 12, 2010

What is the RPM package format? ›

An RPM format file consists of 4 sections, the Lead, Signature, Header, and the Payload. All values are stored in network byte order. These 4 sections shall exist in the order specified. The lead section is used to identify the package file.

What are the different types of Fedora packages? ›

There are two types of Fedora system; “traditional”, which use DNF, and “image-based” which use rpm-ostree.

Is YUM replaced by DNF? ›

Dnf is yum's replacement and is superior in every way. But it can be hard to switch to another package manager, so here are all the ways in which dnf is superior to yum, and how you can make the transition.

Why did YUM change to DNF? ›

DNF stands for Dandified YUM and is basically an improved version of the YUM package manager. Provides more functionality when installing, updating, or removing software packages on RedHat-based Linux systems.

Did DNF replace YUM? ›

DNF and YUM are package management tools used in RHEL distributions like Fedora, CentOS, and Rocky Linux. They simplify package management, installation, updates, and removal by handling all the package dependencies. YUM is the older tool, and DNF is its modern successor, offering improved performance and features.

What is the difference between RPM and yum? ›

While RPM is the packaging format, yum is the command you will use to do the installation. For example, yum will resolve and download the dependencies for the package you want to install; rpm will simply complain if you want to install a package that does not have all its dependencies installed.

What package manager does Fedora use? ›

DNF or Dandified YUM is the package manager of Fedora and Fedora derivatives and is the successor of Yellow-dog Updater Modified or YUM package manager. It is used to manage packages, i.e. install, upgrade, update, reinstall, and uninstall them among other things.

Is Fedora RPM or Deb? ›

In the land of Linux, there are two main package managers: RPM and DEB. RPM is used by Red Hat-based distributions such as Fedora and CentOS, while DEB is used by Debian-based distributions such as Ubuntu and Linux Mint. Both RPM and DEB are used to install, update, and remove software packages on Linux computers.

How to create RPM repository in Linux? ›

RPM-Based Distributions
  1. Install createrepo utility.
  2. Create a repository directory.
  3. Put RPM files into the repository directory.
  4. Create the repository metadata.
  5. Create the repository configuration file.
Jan 2, 2020

How to use RPM command in Linux? ›

The RPM command in Linux, also known as Red Hat Package Manager, is a command-line utility used for managing software packages. It is used with the syntax, rpm [option] package_name . In this example, rpm -i package_name. rpm is the command used to install a software package.

How to enable RPM in Linux? ›

Standard RPM installation
  1. Open a terminal and navigate to the location of the . rpm file.
  2. Execute the following command with superuser permissions: rpm -i filename .rpm. This installs the product to the following default location - /opt/microfocus/VisualCOBOL.

How to install RPM file in Fedora terminal? ›

Install RPM packages on Linux, CentOS, and Fedora
  1. Step 1: Download the RPM Installation File. A web browser is typically used to find and download. ...
  2. Step 2: After Downloading, Install the RPM File on the Linux. Take a terminal: To launch the terminal on your Linux machine, press Ctrl+Alt+T. ...
  3. Step 3: Install RPM on Fedora.
Nov 10, 2023

Top Articles
Latest Posts
Article information

Author: Dong Thiel

Last Updated:

Views: 6214

Rating: 4.9 / 5 (59 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Dong Thiel

Birthday: 2001-07-14

Address: 2865 Kasha Unions, West Corrinne, AK 05708-1071

Phone: +3512198379449

Job: Design Planner

Hobby: Graffiti, Foreign language learning, Gambling, Metalworking, Rowing, Sculling, Sewing

Introduction: My name is Dong Thiel, I am a brainy, happy, tasty, lively, splendid, talented, cooperative person who loves writing and wants to share my knowledge and understanding with you.