PeterGordon/SpecFormattingGuidelines

From FedoraProject

Jump to: navigation, search

Contents

Personal Spec Formatting Guidelines

I'm pretty anal about consistency within one's code, so I've set a lot of guidelines for myself to make my spec files readable and easily editable. These are the guidelines I strive to adhere to in my own spec files, in addition to [wiki:Self:Packaging/Guidelines the standard guidelines] . They are here for the reference of myself and others only. (Violation of these guidelines is permitted where applicable, but should be heavily discouraged.)

Please note that this document is still a work in progress, and while attempts are made to update it regularly, it is likely still quite incomplete. Thank you.

Alignment & Whitespace

Comments

Example:
## This is a snapshot of code dated YYYY-MM-DD, so the URL is not valid for the
## time being.
#Source0: http://example.com/download/%{name}-%{version}.tar.bz2
Source0: %{name}-%{version}.cvsYYYYMMDD.tar.bz2

Intial Tags

These constitute a brief overview of what the package is and its version in regards to both upstream and downstream packaging.

These give us more information about the category of the package and where to find more information from the website of upstream or other relevant and appropriate URL.

These tags store the information describing the initial setup of the build environment.

Dependencies

Dependencies, both build- and run-time, can cause much havoc to one's spec files if he or she is not careful.

Sources

Patching

Example:
## [...] 
Patch42:	%{name}-configure.ac-fix-dependency-check.patch
Patch43:	%{name}-fix-CVE-2007-0123.patch
## [...] 
.

RPM Conditionals

Similar to a programming language, RPM's spec file format allows conditional blocks of code to be used dependent on various properties such as architecture (%ifarch / %ifnarch), operating system (%ifos / %ifnos), or any other conditional expression.

Example:
%build
%ifarch x86_64 sparc64 ppc64
make -D__64BIT__ %{?_smp_mflags}
%else
%ifarch ppc
make -D __PPC32__ %{?_smp_mflags}
%else
make %{?_smp_mflags}
%endif
%endif

Dates & Times

RPM ChangeLog Entries

Spec files contain a %changelog section, wherein notes are made about changes to each new EVR

Example (from the scribes package):
* Mon Dec 18 2006 Peter Gordon <peter@thecodergeek.com> - 0.3-3.20061218bzr
- Update to 2006-12-18 BZR snapshot. This should fix the longstanding bug
wherein a zombie .scribesclient process is left which becomes incredibly
processor-intensive, since the internal IPC has been reworked; also includes
various updated translations.
- Add CONTRIBUTORS, TRANSLATORS, and TODO files as %%doc
- Add patch to install plugins to proper $(DESTDIR) location:
  + fix-plugins-installation-dir.patch

RPM Subpackages

RPM spec files have a capability to produce multiple packages from a singe-sources build, known as subpackages.


TODO

License

This document was written by Peter Gordon <[[MailTo(peter@thecodergeek.com)] >, and is placed into the Public Domain.


Footnotes

1. SourceN is used to refer to numbered Source tags in a spec file, such as Source0, Source1, et al.; and likewise for the PatchN tags. 2. "EVR" refers to the combination of the Epoch, Version and Release of a package.