Difference between revisions of "Arch packaging standards"

From ArchWiki
Jump to: navigation, search
(Packaging Standards)
(Package naming: add symbols from PKGBUILD#pkgname (and the man page), drop emphasis since "should" is not strict - see https://www.archlinux.org/packages/extra/any/libreoffice-fresh-zh-CN/)
 
(82 intermediate revisions by 12 users not shown)
Line 1: Line 1:
[[Category:About Arch (English)]]
+
[[Category:About Arch]]
[[Category:Package management (English)]]
+
[[Category:Package management]]
[[Category:Package development (English)]]
+
[[Category:Package development]]
[[Category:Guidelines (English)]]
+
[[es:Arch packaging standards]]
{{i18n|Arch Packaging Standards}}
+
[[fr:Standard paquetage]]
 +
[[it:Arch packaging standards]]
 +
[[ja:Arch パッケージングスタンダード]]
 +
[[pt:Arch packaging standards]]
 +
[[ru:Arch packaging standards]]
 +
[[sr:Arch packaging standards]]
 +
[[zh-hans:Arch packaging standards]]
 +
[[zh-hant:Arch packaging standards]]
 +
{{Related articles start}}
 +
{{Related|Creating packages}}
 +
{{Related|PKGBUILD}}
 +
{{Related|makepkg}}
 +
{{Related|Arch Build System}}
 +
{{Related|Arch User Repository}}
 +
{{Related articles end}}
  
==Packaging Standards==
+
When building packages for Arch Linux, '''adhere to the package guidelines''' below, especially if the intention is to '''contribute''' a new package to Arch Linux. You should also see the [https://archlinux.org/pacman/PKGBUILD.5.html PKGBUILD] and [https://archlinux.org/pacman/makepkg.8.html makepkg] manpages.
<strong>The submitted PKGBUILDs must not build applications already in any of the official binary repositories under any circumstances. Exception to this strict rule may only be packages having extra features enabled and/or patches in comparison to the official ones. In such an occasion, the pkgname array should be different.</strong>
 
  
When building packages for Arch Linux, <strong>adhere to the package guidelines</strong> below, especially if the intention is
+
==PKGBUILD prototype==
to <strong>contribute</strong> a new package
 
to Arch Linux. You should also see the [http://archlinux.org/pacman/PKGBUILD.5.html PKGBUILD] and
 
[http://archlinux.org/pacman/makepkg.8.html makepkg] manpages.
 
 
 
====PKGBUILD Prototype====
 
<pre>
 
# Maintainer: Your Name <youremail at domain dot com>
 
  
 +
{{bc|1=
 +
# Maintainer: Your Name <youremail@domain.com>
 
pkgname=NAME
 
pkgname=NAME
 
pkgver=VERSION
 
pkgver=VERSION
 
pkgrel=1
 
pkgrel=1
 
pkgdesc=""
 
pkgdesc=""
arch=('i686' 'x86_64')
+
arch=()
url="http://ADDRESS/"
+
url=""
 
license=('GPL')
 
license=('GPL')
 
groups=()
 
groups=()
Line 34: Line 42:
 
options=()
 
options=()
 
install=
 
install=
 +
changelog=
 
source=($pkgname-$pkgver.tar.gz)
 
source=($pkgname-$pkgver.tar.gz)
 
noextract=()
 
noextract=()
md5sums=() #generate with 'makepkg -g'
+
md5sums=() #autofill using updpkgsums
  
 
build() {
 
build() {
   cd $srcdir/$pkgname-$pkgver
+
   cd "$pkgname-$pkgver"
 +
 
 
   ./configure --prefix=/usr
 
   ./configure --prefix=/usr
 
   make
 
   make
Line 45: Line 55:
  
 
package() {
 
package() {
   cd $srcdir/$pkgname-$pkgver
+
   cd "$pkgname-$pkgver"
   make DESTDIR=$pkgdir install
+
 
 +
   make DESTDIR="$pkgdir/" install
 
}
 
}
</pre>
+
}}
 
 
====Package Etiquette====
 
 
 
<ul>
 
<li>Packages should <strong>never</strong> be installed to <code>/usr/local</code></li>
 
<li>
 
<strong>Do not introduce new variables</strong> into
 
your <code>PKGBUILD</code> build scripts, unless the package cannot be built without doing so, as these could
 
possibly <strong>conflict</strong> with variables used
 
in makepkg itself.
 
 
 
If a new variable is absolutely required,
 
<strong>prefix the variable name with an underscore</strong> (<code>_</code>) e.g
 
<pre>_customvariable=</pre>
 
 
 
The AUR cannot detect the use of custom variables and so cannot use them in substitutions.  This can most often be seen in the source array e.g.
 
<pre>http://downloads.sourceforge.net/directxwine/$patchname.$patchver.diff.bz2</pre>
 
Such a situation defeats the effective functionality of the AUR.
 
</li>
 
  
<li>
+
Other prototypes are found in {{ic|/usr/share/pacman}} from the pacman and abs packages.
<strong>Avoid</strong> using <code>/usr/libexec/</code> for
 
anything. Use <code>/usr/lib/${pkgname}/</code> instead.
 
</li>
 
<li>
 
The <code>packager</code> field from the package meta file can be
 
<strong>customized</strong> by the package builder by modifying
 
the appropriate option in the <code>/etc/makepkg.conf</code>
 
  
file, or alternatively override it by creating ~/.makepkg.conf
+
== Package etiquette ==
  
</li>
+
* Packages should '''never''' be installed to {{ic|/usr/local}}
<li>All
+
* '''Do not introduce new variables or functions''' into {{ic|PKGBUILD}} build scripts, unless the package cannot be built without doing so, as these could possibly '''conflict''' with variables and functions used in makepkg itself.
important messages should be echoed during install using an <strong>.install file</strong>. For
+
* If a new variable or a new function is absolutely required, '''prefix its name with an underscore''' ({{ic|_}}), e.g. {{bc|1=_customvariable=}}
example, if a package needs extra setup to work, directions should be included. </li>
+
* '''Avoid''' using {{ic|/usr/libexec/}} for anything. Use {{ic|/usr/lib/$pkgname/}} instead.
            <li>Any <strong>optional dependencies</strong> that aren't
+
* The {{ic|packager}} field from the package meta file can be '''customized''' by the package builder by modifying the appropriate option in the {{ic|/etc/makepkg.conf}} file, or alternatively override it by creating {{ic|~/.makepkg.conf}}.
needed to run the package or have it generally function shouldn't be
+
* All important messages should be echoed during install using an '''.install file'''. For example, if a package needs extra setup to work, directions should be included.
included; instead the information should be added to the <b>optdepends</b> array:
+
* '''Dependencies''' are the most common packaging error. Please take the time to verify them carefully, for example by running {{ic|ldd}} on dynamic executables, checking tools required by scripts or looking at the documentation of the software. The [[namcap]] utility can help you in this regard. This tool can analyze both PKGBUILD and the resulting package tarball and will warn you about bad permissions, missing dependencies, redundant dependencies, and other common mistakes.
<pre>
+
* Any '''optional dependencies''' that are not needed to run the package or have it generally function should not be included in the '''depends''' array; instead the information should be added to the '''optdepends''' array:
 +
:{{bc|<nowiki>
 
optdepends=('cups: printing support'
 
optdepends=('cups: printing support'
 
             'sane: scanners support'
 
             'sane: scanners support'
Line 95: Line 81:
 
             'libjpeg: JPEG images support'
 
             'libjpeg: JPEG images support'
 
             'libpng: PNG images support')
 
             'libpng: PNG images support')
</pre>
+
</nowiki>}}
 
+
:The above example is taken from the '''wine''' package in {{Ic|extra}}. The optdepends information is automatically printed out on installation/upgrade so one should '''not''' keep this kind of information in {{ic|.install}} files.
The above example is taken from the <b>wine</b> package in <tt>extra</tt>. The optdepends
+
* When creating a '''package description''' for a package, do not include the package name in a self-referencing way.  For example, "Nedit is a text editor for X11" could be simplified to "A text editor for X11".  Also try to keep the descriptions to ~80 characters or less.
information will automatically be printed out on installation/upgrade from pacman 3.2.1, so
+
* Try to keep the '''line length''' in the PKGBUILD below ~100 characters.
one should <b>not</b> keep this kind of information in .install files any longer.
+
* Where possible, '''remove empty lines''' from the {{ic|PKGBUILD}} ({{ic|provides}}, {{ic|replaces}}, etc.)
 
+
* It is common practice to '''preserve the order''' of the {{ic|PKGBUILD}} fields as shown above. However, this is not mandatory, as the only requirement in this context is '''correct bash syntax'''.
</li>
+
* '''Quote''' variables which may contain spaces, such as {{ic|"$pkgdir"}} and {{ic|"$srcdir"}}.
        <li>When creating a <strong>package description</strong> for a package, do not include
+
* To ensure the '''integrity''' of packages, make sure that the [[PKGBUILD#Integrity|integrity variables]] contain correct values. These can be updated using the {{ic|updpkgsums}} tool.
        the package name in a self-referencing way.  For example, "Nedit is a text editor for X11" could be simplified to "A text editor for X11".  Also try to keep the descriptions to ~80 characters or less.</li>
 
<li>Try to keep the <strong>line length</strong> in the PKGBUILD below ~100 characters.</li>
 
<li>Where possible, <strong>remove empty lines</strong> from the <code>PKGBUILD</code> (<code>provides</code>, <code>replaces</code>, etc.)</li>
 
<li>It is common practice to <strong>preserve the order</strong> of the <code>PKGBUILD</code> fields as shown above. However, this is not mandatory, as the only requirement in this context is <strong>correct bash syntax</strong>.</li>
 
</ul>
 
 
 
====Package Naming====
 
 
<ul>
 
<li>
 
Package names should consist of <strong>alphanumeric characters
 
only</strong>; all letters should be
 
<strong>lowercase</strong>.
 
</li>
 
<li>
 
Package versions <strong>should be the same as the version
 
released by the author</strong>. Versions can include
 
letters if need be (eg, nmap's version is 2.54BETA32).
 
<strong>Version tags may not include hyphens!</strong> Letters,
 
numbers, and periods only.
 
</li>
 
 
 
<li>
 
Package releases are <strong>specific to Arch Linux
 
packages</strong>. These allow users to differentiate
 
between newer and older package builds. When a new package
 
version is first released, the <strong>release count starts at
 
1</strong>. Then as fixes and optimizations are made,
 
the package will be <strong>re-released</strong> to the AL
 
public and the <strong>release number will increment</strong>.
 
When a new version comes out, the release count resets to 1.
 
Package release tags follow the <strong>same naming
 
restrictions as version tags</strong>.
 
</li>
 
</ul>
 
 
 
<h4>Directories</h4>
 
<ul>
 
<li>
 
<strong>Configuration files</strong> should be placed in the
 
<code>/etc</code> directory. If there's more than one
 
configuration file, it's customary to <strong>use a
 
subdirectory</strong> in order to keep the
 
<code>/etc</code> area as clean as possible. Use
 
<code>/etc/{pkgname}/</code>  where <code>{pkgname}</code> is
 
the name of your package (or a suitable alternative, eg, apache
 
uses <code>/etc/httpd/</code>).
 
</li>
 
 
 
<li>
 
Package files should follow these
 
<strong>general directory guidelines</strong>:
 
</li>
 
 
<table cellspacing="1" >
 
<tr>
 
<td><code>/etc</code></td>
 
<td style="padding-left: 1em;">
 
<strong>System-essential</strong> configuration files
 
</td>
 
</tr>
 
<tr>
 
<td><code>/usr/bin</code></td>
 
<td style="padding-left: 1em;">Application binaries</td>
 
</tr>
 
<tr>
 
<td><code>/usr/sbin</code></td>
 
 
 
<td style="padding-left: 1em;">System binaries</td>
 
</tr>
 
<tr>
 
<td><code>/usr/lib</code></td>
 
<td style="padding-left: 1em;">Libraries</td>
 
</tr>
 
<tr>
 
<td><code>/usr/include</code></td>
 
<td style="padding-left: 1em;">Header files</td>
 
</tr>
 
<tr>
 
<td><code>/usr/lib/{pkg}</code></td>
 
<td style="padding-left: 1em;">Modules, plugins, etc.</td>
 
</tr>
 
<tr>
 
<td><code>/usr/share/doc/{pkg}</code></td>
 
<td style="padding-left: 1em;">Application documentation</td>
 
</tr>
 
<tr>
 
<td><code>/usr/share/info</code></td>
 
<td style="padding-left: 1em;">GNU Info system files</td>
 
</tr>
 
<tr>
 
<td><code>/usr/share/man</code></td>
 
<td style="padding-left: 1em;">Manpages</td>
 
</tr>
 
<tr>
 
<td><code>/usr/share/{pkg}</code></td>
 
<td style="padding-left: 1em;">Application data</td>
 
</tr>
 
<tr>
 
<td><code>/var/lib/{pkg}</code></td>
 
<td style="padding-left: 1em;">Persistent application storage</td>
 
</tr>
 
<tr>
 
<td><code>/etc/{pkg}</code></td>
 
<td style="padding-left: 1em;">Configuration files for <code>{pkg}</code></td>
 
</tr>
 
<tr>
 
<td><code>/opt/{pkg}</code></td>
 
<td style="padding-left: 1em;">
 
Large self-contained packages such as Java,
 
etc.
 
</td>
 
</tr>
 
</table>
 
 
 
<li>
 
Package should not contain following directories:
 
<ul>
 
<li>/dev
 
<li>/home
 
<li>/srv
 
<li>/media
 
<li>/mnt
 
<li>/proc
 
<li>/root
 
<li>/selinux
 
<li>/sys
 
<li>/tmp
 
<li>/var/tmp
 
</ul>
 
</li>
 
 
 
</ul>
 
 
 
====[[Makepkg]] Duties====
 
 
 
<p>
 
When you use makepkg to build a package for you, it does the
 
following automatically:
 
</p>
 
 
 
<ol>
 
<li>
 
Checks if package <strong>dependencies</strong> and <strong>makedepends</strong> are installed
 
</li>
 
<li>
 
<strong>Downloads source</strong> files from servers
 
</li>
 
<li>
 
<strong>Checks the integrity</strong> of source files
 
</li>
 
<li>
 
<strong>Unpacks</strong> source files
 
</li>
 
<li>
 
Does any necessary <strong>patching</strong>
 
</li>
 
<li>
 
 
 
<strong>Builds</strong> the software and installs it in a fake
 
root
 
</li>
 
<li>
 
<strong>Strips</strong> symbols from binaries
 
</li>
 
<li>
 
<strong>Strips</strong> debugging symbols from libraries
 
</li>
 
<li>
 
<strong>Compresses</strong> manual and, or info pages
 
</li>
 
<li>
 
Generates the <strong>package meta file</strong> which is
 
included with each package
 
</li>
 
 
 
<li>
 
<strong>Compresses</strong> the fake root into the package file
 
</li>
 
<li>
 
<strong>Stores</strong> the package file in the configured
 
destination directory
 
(<span title="Current Working Directory" style="border-bottom:1px dotted">cwd</span> by
 
default)
 
</li>
 
 
 
</ol>
 
 
 
====Architectures====
 
The <tt>arch</tt> array should contain <tt>'i686'</tt> and/or <tt>'x86_64'</tt> depending on which architectures it can be built on. You can also use <tt>'any'</tt> for architecture independent packages.
 
 
 
====[[Licenses]]====
 
The license array is being implemented little by little in the official repos, and it <b>should</b> be used in your packages as well. You can use it as follows:
 
<ul>
 
<li>A licenses package has been created in [core] that stores common licenses in /usr/share/licenses/common ie. /usr/share/licenses/common/GPL.  If a package is licensed under one of these licenses, the licenses variable will be set to the directory name e.g. license=('GPL')</li>
 
<li>If the appropriate license is not included in the official licenses package, several things must be done:
 
<ol>
 
<li>The license file(s) should be included in /usr/share/licenses/$pkgname/ e.g. /usr/share/licenses/dibfoo/COPYING.</li>
 
<li>If the source tarball does NOT contain the license details and the license is only displayed on a website for example, then you need to copy the license to a file and include it. Remember to call it something appropriate too.
 
<li>Add 'custom' to the licenses array.  Optionally, you can replace 'custom' with 'custom:"name of license"'.</li>
 
</ol></li>
 
<li>Once a licenses is used in two or more packages in an official repo, including [community], it becomes common</li>
 
<li>The MIT, BSD, zlib/libpng and Python licenses are special cases and cannot be included in the 'common' licenses pkg.  For the sake of the license variable, it's treated like a common license (license=('BSD'), license=('MIT'), license=('ZLIB') or license=('Python')) but for the sake of the filesystem, it's a custom license, because each one has its own copyright line.  Each MIT, BSD, zlib/libpng or Python licensed package should have its unique license stored in /usr/share/licenses/$pkgname/.</li>
 
<li>Some packages may not be covered by a single license.  In these cases multiple entries may be made in the license array e.g. license=("GPL" "custom:some commercial license").  For the majority of packages these licenses apply in different cases, as opposed to applying at the same time.  When pacman gets the ability to filter on licenses (so you can say, "I only want GPL and BSD licensed software") dual (or more) licenses will be treated by pacman using OR, rather than AND logic, thus pacman will consider the above example as GPL licensed software, regardless of the other licenses listed.</li>
 
<li>The (L)GPL has many versions and permutations of those versions. For (L)GPL software, the convention is:
 
<ul>
 
<li>(L)GPL - (L)GPLv2 or any later version</li>
 
<li>(L)GPL2 - (L)GPL2 only</li>
 
<li>(L)GPL3 - (L)GPL3 or any later version</li>
 
</ul>
 
</li>
 
</ul>
 
 
 
====Submitting Packages to the AUR====
 
<p>Note the following before submitting any packages to the AUR:</p>
 
 
 
<ol>
 
        <li>
 
                The submitted PKGBUILDs <strong>MUST NOT</strong> build applications already in any of the official binary repositories under any circumstances. Exception to this strict rule may only be packages having extra features enabled and/or patches in compare to the official ones. In such an occasion the pkgname array should be different to express that difference.
 
eg. A GNU screen PKGBUILD submitted containing the sidebar patch, could be named screen-sidebar etc. Additionally the <strong>provides=('screen')</strong> PKGBUILD array should be used in order to avoid conflicts with the official package.
 
        </li>
 
<li>
 
To ensure the security of pkgs submitted to the AUR please <strong>ensure</strong> that you have correctly filled the <code>md5sum</code> field.  The <code>md5sum</code>'s can be generated using the <code>makepkg -g</code> command.
 
</li>
 
<li>
 
Please <strong>add a comment line</strong> to the top of your
 
<code>PKGBUILD</code> file that follows this format.  Remember to disguise
 
                your email to protect against spam:
 
 
 
<pre># Maintainer: Your Name <address at domain dot com></pre>
 
 
 
If you are assuming the role of maintainer for an existing PKGBUILD, add your name to the top as described above and change the title of the previous Maintainer(s) to Contributor:
 
 
 
<pre># Maintainer: Your Name <address at domain dot com>
 
# Contributor: Previous Name <address at domain dot com></pre>
 
  
</li>
+
==Package naming==
<li>
 
Verify the package <strong>dependencies</strong> (eg, run
 
<code>ldd</code> on dynamic executables, check tools required
 
by scripts, etc).
 
  
The TU team <strong>strongly</strong> recommend the use of the
+
* Package names can contain only alphanumeric characters and any of {{ic|@}}, {{ic|.}}, {{ic|_}}, {{ic|+}}, {{ic|-}}. Names are not allowed to start with hyphens or dots. All letters should be lowercase.
<code>namcap</code> utility, written by Jason Chu (jason@archlinux.org), to analyze the
+
* Package names should NOT be suffixed with the upstream major release version number (e.g. we don't want libfoo2 if upstream calls it libfoo v2.3.4) in case the library and its dependencies are expected to be able to keep using the most recent library version with each respective upstream release. However, for some software or dependencies, this can not be assumed. In the past this has been especially true for widget toolkits such as GTK and Qt. Software that depends on such toolkits can usually not be trivially ported to a new major version. As such, in cases where software can not trivially keep rolling alongside its dependencies, package names should carry the major version suffix (e.g. gtk2, gtk3, qt4, qt5). For cases where most dependencies can keep rolling along the newest release but some can't (for instance closed source that needs libpng12 or similar), a deprecated version of that package might be called libfoo1 while the current version is just libfoo.
sanity of your package. <code>namcap</code> will tell you about
+
* Package versions '''should be the same as the version released by the author'''. Versions can include letters if need be (eg, nmap's version is 2.54BETA32). '''Version tags may not include hyphens!''' Letters, numbers, and periods only.
bad permissions, missing dependencies, un-needed dependencies,
+
* Package releases are '''specific to Arch Linux packages'''. These allow users to differentiate between newer and older package builds. When a new package version is first released, the '''release count starts at 1'''. Then as fixes and optimizations are made, the package will be '''re-released''' to the Arch Linux public and the '''release number will increment'''. When a new version comes out, the release count resets to 1. Package release tags follow the '''same naming restrictions as version tags'''.
and other common mistakes. You can install the
 
<code>namcap</code> package with <code>pacman</code>.
 
  
Remember <code>namcap</code> can be used to check both pkg.tar.gz files and PKGBUILDs
+
==Directories==
</li>
 
<li> <strong>Dependencies</strong>
 
are the most common packaging error. Namcap can help detect them, but
 
it is not always correct. Verify dependencies by looking at source
 
documentation and the program website. </li>
 
<li>'''Don't use <tt>replaces</tt>''' in your PKGBUILD unless you want to rename your package, for example when ''Ethereal'' became ''Wireshark''. If you just provide an alternate version of an already existing package, use <tt>conflicts</tt> (and <tt>provides</tt> if that package is required by others). The main difference is: after syncing (-Sy) pacman immediately wants to replace an installed, 'offending' package upon encountering a package with the matching <tt>replaces</tt> anywhere in its repositories; <tt>conflicts</tt> on the other hand is only evaluated when actually installing the package, which is pretty much always the desired behavior because you don't push your package down other people's throat this way.</li>
 
<li>
 
All files uploaded to the AUR should be contained in a <strong>compressed tar
 
file</strong> containing a directory with the <strong><code>PKGBUILD</code></strong> and <strong>additional build files</strong> (patches, install, ...) in it.
 
<pre>foo/PKGBUILD
 
foo/foo.install
 
foo/foo_bar.diff
 
foo/foo.rc.conf</pre>
 
The archive name should contain the name of the package
 
e.g. foo.tar.gz.
 
  
You can easily build a tarball containing all the required files by using <tt>makepkg --source</tt>. This
+
* '''Configuration files''' should be placed in the {{ic|/etc}} directory. If there is more than one configuration file, it is customary to '''use a subdirectory''' in order to keep the {{ic|/etc}} area as clean as possible. Use {{ic|/etc/{pkgname}/}}  where {{ic|<nowiki>{pkgname}</nowiki>}} is the name of the package (or a suitable alternative, eg, apache uses {{ic|/etc/httpd/}}).
makes a tarball named <tt>$pkgname-$pkgver-$pkgrel.src.tar.gz</tt>, which you can then upload to the AUR.
 
 
The tarball <strong>should not</strong> contain the binary tarball created by makepkg, nor should it contain the filelist
 
</li>
 
  
</ol>
+
* Package files should follow these '''general directory guidelines''':
  
==Additional Guidelines==
+
:{|
Be sure to read the above guidelines first - important points are listed on this page that will not be repeated in the following guideline pages.  These specific guidelines are intended as an addition to the standards listed on this page.
+
|-
 +
| {{ic|/etc}}
 +
| '''System-essential''' configuration files
 +
|-
 +
| {{ic|/usr/bin}}
 +
| Binaries
 +
|-
 +
| {{ic|/usr/lib}}
 +
| Libraries
 +
|-
 +
| {{ic|/usr/include}}
 +
| Header files
 +
|-
 +
| {{ic|<nowiki>/usr/lib/{pkg}</nowiki>}}
 +
| Modules, plugins, etc.
 +
|-
 +
| {{ic|<nowiki>/usr/share/doc/{pkg}</nowiki>}}
 +
| Application documentation
 +
|-
 +
| {{ic|/usr/share/info}}
 +
| GNU Info system files
 +
|-
 +
| {{ic|/usr/share/man}}
 +
| Manpages
 +
|-
 +
| {{ic|<nowiki>/usr/share/{pkg}</nowiki>}}
 +
| Application data
 +
|-
 +
| {{ic|<nowiki>/var/lib/{pkg}</nowiki>}}
 +
| Persistent application storage
 +
|-
 +
| {{ic|<nowiki>/etc/{pkg}</nowiki>}}
 +
| Configuration files for {{ic|<nowiki>{pkg}</nowiki>}}
 +
|-
 +
| {{ic|<nowiki>/opt/{pkg}</nowiki>}}
 +
| Large self-contained packages
 +
|}
  
<h4>CVS/SVN Packages</h4>
+
* Packages should not contain any of the following directories:
Please see the [[Arch CVS & SVN PKGBUILD guidelines]]
+
** {{ic|/bin}}
 +
** {{ic|/sbin}}
 +
** {{ic|/dev}}
 +
** {{ic|/home}}
 +
** {{ic|/srv}}
 +
** {{ic|/media}}
 +
** {{ic|/mnt}}
 +
** {{ic|/proc}}
 +
** {{ic|/root}}
 +
** {{ic|/selinux}}
 +
** {{ic|/sys}}
 +
** {{ic|/tmp}}
 +
** {{ic|/var/tmp}}
 +
** {{ic|/run}}
  
<h4>Eclipse Plugin Packages</h4>
+
== Makepkg duties ==
Please see the [[Eclipse plugin package guidelines]]
 
  
        <h4>Gnome Packages</h4>
+
When [[makepkg]] is used to build a package, it does the following automatically:
Please see the [[Gnome package guidelines]]
 
  
<h4>Haskell Packages</h4>
+
# Checks if package '''dependencies''' and '''makedepends''' are installed
Please see the [[Haskell package guidelines]]
+
# '''Downloads source''' files from servers
 +
# '''Checks the integrity''' of source files
 +
# '''Unpacks''' source files
 +
# Does any necessary '''patching'''
 +
# '''Builds''' the software and installs it in a fake root
 +
# '''Strips''' symbols from binaries
 +
# '''Strips''' debugging symbols from libraries
 +
# '''Compresses''' manual and, or info pages
 +
# Generates the '''package meta file''' which is included with each package
 +
# '''Compresses''' the fake root into the package file
 +
# '''Stores''' the package file in the configured destination directory (<span title="Current Working Directory" style="border-bottom: 1px dotted">cwd</span> by default)
  
<h4>Java Packages</h4>
+
==Architectures==
Please see the [[Java Package Guidelines]]
 
  
        <h4>Kernel Module Packages</h4>
+
The {{Ic|arch}} array should contain {{Ic|'i686'}} and/or {{Ic|'x86_64'}} depending on which architectures it can be built on. You can also use {{Ic|'any'}} for architecture independent packages.
Please see the [[Kernel Module Package Guidelines]]
 
  
        <h4>Lisp Packages</h4>
+
==Licenses==
Please see the [[Lisp Package Guidelines]]
 
  
        <h4>Perl Packages</h4>
+
See [[PKGBUILD#license]].
Please see the [[Perl Package Guidelines]]
 
  
        <h4>Python Packages</h4>
+
==Additional guidelines==
Please see the [[Python Package Guidelines]]
+
Be sure to read the above guidelines first - important points are listed on this page that will not be repeated in the following guideline pages. These specific guidelines are intended as an addition to the standards listed on this page.
  
        <h4>Ruby Gem Packages</h4>
+
{{Package guidelines}}
Please see the [[Ruby Gem Package Guidelines]]
 
  
        <h4>Wine Packages</h4>
+
Packages submitted to the AUR must additionally comply with [[Arch User Repository#Rules of submission]].
Please see the [[Arch wine PKGBUILD guidelines]]
 

Latest revision as of 06:43, 13 August 2017

When building packages for Arch Linux, adhere to the package guidelines below, especially if the intention is to contribute a new package to Arch Linux. You should also see the PKGBUILD and makepkg manpages.

PKGBUILD prototype

# Maintainer: Your Name <youremail@domain.com>
pkgname=NAME
pkgver=VERSION
pkgrel=1
pkgdesc=""
arch=()
url=""
license=('GPL')
groups=()
depends=()
makedepends=()
optdepends=()
provides=()
conflicts=()
replaces=()
backup=()
options=()
install=
changelog=
source=($pkgname-$pkgver.tar.gz)
noextract=()
md5sums=() #autofill using updpkgsums

build() {
  cd "$pkgname-$pkgver"

  ./configure --prefix=/usr
  make
}

package() {
  cd "$pkgname-$pkgver"

  make DESTDIR="$pkgdir/" install
}

Other prototypes are found in /usr/share/pacman from the pacman and abs packages.

Package etiquette

  • Packages should never be installed to /usr/local
  • Do not introduce new variables or functions into PKGBUILD build scripts, unless the package cannot be built without doing so, as these could possibly conflict with variables and functions used in makepkg itself.
  • If a new variable or a new function is absolutely required, prefix its name with an underscore (_), e.g.
    _customvariable=
  • Avoid using /usr/libexec/ for anything. Use /usr/lib/$pkgname/ instead.
  • The packager field from the package meta file can be customized by the package builder by modifying the appropriate option in the /etc/makepkg.conf file, or alternatively override it by creating ~/.makepkg.conf.
  • All important messages should be echoed during install using an .install file. For example, if a package needs extra setup to work, directions should be included.
  • Dependencies are the most common packaging error. Please take the time to verify them carefully, for example by running ldd on dynamic executables, checking tools required by scripts or looking at the documentation of the software. The namcap utility can help you in this regard. This tool can analyze both PKGBUILD and the resulting package tarball and will warn you about bad permissions, missing dependencies, redundant dependencies, and other common mistakes.
  • Any optional dependencies that are not needed to run the package or have it generally function should not be included in the depends array; instead the information should be added to the optdepends array:
optdepends=('cups: printing support'
            'sane: scanners support'
            'libgphoto2: digital cameras support'
            'alsa-lib: sound support'
            'giflib: GIF images support'
            'libjpeg: JPEG images support'
            'libpng: PNG images support')
The above example is taken from the wine package in extra. The optdepends information is automatically printed out on installation/upgrade so one should not keep this kind of information in .install files.
  • When creating a package description for a package, do not include the package name in a self-referencing way. For example, "Nedit is a text editor for X11" could be simplified to "A text editor for X11". Also try to keep the descriptions to ~80 characters or less.
  • Try to keep the line length in the PKGBUILD below ~100 characters.
  • Where possible, remove empty lines from the PKGBUILD (provides, replaces, etc.)
  • It is common practice to preserve the order of the PKGBUILD fields as shown above. However, this is not mandatory, as the only requirement in this context is correct bash syntax.
  • Quote variables which may contain spaces, such as "$pkgdir" and "$srcdir".
  • To ensure the integrity of packages, make sure that the integrity variables contain correct values. These can be updated using the updpkgsums tool.

Package naming

  • Package names can contain only alphanumeric characters and any of @, ., _, +, -. Names are not allowed to start with hyphens or dots. All letters should be lowercase.
  • Package names should NOT be suffixed with the upstream major release version number (e.g. we don't want libfoo2 if upstream calls it libfoo v2.3.4) in case the library and its dependencies are expected to be able to keep using the most recent library version with each respective upstream release. However, for some software or dependencies, this can not be assumed. In the past this has been especially true for widget toolkits such as GTK and Qt. Software that depends on such toolkits can usually not be trivially ported to a new major version. As such, in cases where software can not trivially keep rolling alongside its dependencies, package names should carry the major version suffix (e.g. gtk2, gtk3, qt4, qt5). For cases where most dependencies can keep rolling along the newest release but some can't (for instance closed source that needs libpng12 or similar), a deprecated version of that package might be called libfoo1 while the current version is just libfoo.
  • Package versions should be the same as the version released by the author. Versions can include letters if need be (eg, nmap's version is 2.54BETA32). Version tags may not include hyphens! Letters, numbers, and periods only.
  • Package releases are specific to Arch Linux packages. These allow users to differentiate between newer and older package builds. When a new package version is first released, the release count starts at 1. Then as fixes and optimizations are made, the package will be re-released to the Arch Linux public and the release number will increment. When a new version comes out, the release count resets to 1. Package release tags follow the same naming restrictions as version tags.

Directories

  • Configuration files should be placed in the /etc directory. If there is more than one configuration file, it is customary to use a subdirectory in order to keep the /etc area as clean as possible. Use /etc/{pkgname}/ where {pkgname} is the name of the package (or a suitable alternative, eg, apache uses /etc/httpd/).
  • Package files should follow these general directory guidelines:
/etc System-essential configuration files
/usr/bin Binaries
/usr/lib Libraries
/usr/include Header files
/usr/lib/{pkg} Modules, plugins, etc.
/usr/share/doc/{pkg} Application documentation
/usr/share/info GNU Info system files
/usr/share/man Manpages
/usr/share/{pkg} Application data
/var/lib/{pkg} Persistent application storage
/etc/{pkg} Configuration files for {pkg}
/opt/{pkg} Large self-contained packages
  • Packages should not contain any of the following directories:
    • /bin
    • /sbin
    • /dev
    • /home
    • /srv
    • /media
    • /mnt
    • /proc
    • /root
    • /selinux
    • /sys
    • /tmp
    • /var/tmp
    • /run

Makepkg duties

When makepkg is used to build a package, it does the following automatically:

  1. Checks if package dependencies and makedepends are installed
  2. Downloads source files from servers
  3. Checks the integrity of source files
  4. Unpacks source files
  5. Does any necessary patching
  6. Builds the software and installs it in a fake root
  7. Strips symbols from binaries
  8. Strips debugging symbols from libraries
  9. Compresses manual and, or info pages
  10. Generates the package meta file which is included with each package
  11. Compresses the fake root into the package file
  12. Stores the package file in the configured destination directory (cwd by default)

Architectures

The arch array should contain 'i686' and/or 'x86_64' depending on which architectures it can be built on. You can also use 'any' for architecture independent packages.

Licenses

See PKGBUILD#license.

Additional guidelines

Be sure to read the above guidelines first - important points are listed on this page that will not be repeated in the following guideline pages. These specific guidelines are intended as an addition to the standards listed on this page.

Package creation guidelines

CLRCrossEclipseFree PascalGNOMEGoHaskellJavaKDEKernelLispMinGWNode.jsNonfreeOCamlPerlPHPPythonRubyVCSWebWine

Packages submitted to the AUR must additionally comply with Arch User Repository#Rules of submission.