Use ignoregroup rather than ignoregrp in the handle
[pacman-ng.git] / doc / PKGBUILD.5.txt
blob4d761214aabb264dcfe0f48d362dc1bd02c4ef43
1 /////
2 vim:set ts=4 sw=4 syntax=asciidoc noet:
3 /////
4 PKGBUILD(5)
5 ===========
7 Name
8 ----
9 PKGBUILD - Arch Linux package build description file
12 Synopsis
13 --------
14 PKGBUILD
17 Description
18 -----------
19 This manual page describes general rules about PKGBUILDs. Once a
20 PKGBUILD is written, the actual package is built using makepkg and installed
21 with pacman.
23 NOTE: An example PKGBUILD, useful for reference, is located in '{pkgdatadir}'
24 along with other example files such as a ChangeLog and an install
25 script. You can copy the provided PKGBUILD.proto file to a new package build
26 directory and make customizations to suit your needs.
29 Options and Directives
30 ----------------------
31 The following is a list of standard options and directives available for use
32 in a PKGBUILD. These are all understood and interpreted by makepkg, and most
33 of them will be directly transferred to the built package.
35 If you need to create any custom variables for use in your build process, it is
36 recommended to prefix their name with an '_' (underscore).
37 This will prevent any possible name clashes with internal makepkg variables.
38 For example, to store the base kernel version in a variable, use something
39 similar to `$_basekernver`.
41 *pkgname (array)*::
42         Either the name of the package or an array of names for split packages.
43         Because it will be used in the package filename, this has to be unix-friendly.
44         Members of the array are not allowed to start with hyphens.
46 *pkgver*::
47         The version of the software as released from the author (e.g., '2.7.1').
48         The variable is not allowed to contain colons or hyphens.
50 *pkgrel*::
51         This is the release number specific to the Arch Linux release. This
52         allows package maintainers to make updates to the package's configure
53         flags, for example. This is typically set to '1' for each new upstream
54         software release and incremented for intermediate PKGBUILD updates. The
55         variable is not allowed to contain hyphens.
57 *pkgdesc*::
58         This should be a brief description of the package and its functionality.
59         Try to keep the description to one line of text and not use the package's name.
61 *epoch*::
62         Used to force the package to be seen as newer than any previous versions
63         with a lower epoch, even if the version number would normally not trigger
64         such an upgrade. This value is required to be a positive integer; the
65         default value if left unspecified is '0'. This is useful when the version
66         numbering scheme of a package changes (or is alphanumeric), breaking normal
67         version comparison logic. See linkman:pacman[8] for more information on
68         version comparisons.
70 *url*::
71         This field contains a URL that is associated with the software being
72         packaged. Typically the project's website.
74 *license (array)*::
75         This field specifies the license(s) that apply to the package.
76         Commonly used licenses can be found in '/usr/share/licenses/common'. If you
77         see the package's license there, simply reference it in the license
78         field (e.g., `license=('GPL')`). If the package provides a license not
79         available in '/usr/share/licenses/common', then you should include it
80         in the package itself and set `license=('custom')` or
81         `license=('custom:LicenseName')`. The license should be placed in
82         '$pkgdir/usr/share/licenses/$pkgname/' when building the package. If
83         multiple licenses are applicable, list all of them:
84         `license=('GPL' 'FDL')`.
86 *install*::
87         Specifies a special install script that is to be included in the package.
88         This file should reside in the same directory as the PKGBUILD, and will
89         be copied into the package by makepkg. It does not need to be included
90         in the source array (e.g., `install=pkgname.install`).
92 *changelog*::
93         Specifies a changelog file that is to be included in the package.
94         This file should reside in the same directory as the PKGBUILD, and will
95         be copied into the package by makepkg. It does not need to be included
96         in the source array (e.g., `changelog=$pkgname.changelog`).
98 *source (array)*::
99         An array of source files required to build the package. Source files
100         must either reside in the same directory as the PKGBUILD, or be a
101         fully-qualified URL that makepkg can use to download the file.
102         To make the PKGBUILD as useful as possible, use the `$pkgname` and `$pkgver`
103         variables if possible when specifying the download location. Compressed files
104         will be extracted automatically unless found in
105         the noextract array described below.
107 It is also possible to change the name of the downloaded file, which is helpful
108 with weird URLs and for handling multiple source files with the same
109 name. The syntax is: `source=('filename::url')`.
111 *noextract (array)*::
112         An array of filenames corresponding to those from the source array. Files
113         listed here will not be extracted with the rest of the source files. This
114         is useful for packages that use compressed data directly.
116 *md5sums (array)*::
117         This array contains an MD5 hash for every source file specified in the
118         source array (in the same order). makepkg will use this to verify source
119         file integrity during subsequent builds. To easily generate md5sums, run
120         ``makepkg -g >> PKGBUILD''. If desired, move the md5sums line to an
121         appropriate location.
123 *sha1sums, sha256sums, sha384sums, sha512sums (arrays)*::
124         Alternative integrity checks that makepkg supports; these all behave
125         similar to the md5sums option described above. To enable use and generation
126         of these checksums, be sure to set up the `INTEGRITY_CHECK` option in
127         linkman:makepkg.conf[5].
129 *groups (array)*::
130         An array of symbolic names that represent groups of packages, allowing
131         you to install multiple packages by requesting a single target. For
132         example, one could install all KDE packages by installing the 'kde' group.
134 *arch (array)*::
135         Defines on which architectures the given package is available (e.g.,
136         `arch=('i686' 'x86_64')`). Packages that contain no architecture specific
137         files should use arch=('any').
139 *backup (array)*::
140         An array of filenames, without preceding slashes, that
141         should be backed up if the package is removed or upgraded. This is
142         commonly used for packages placing configuration files in /etc. See
143         Handling Config Files in linkman:pacman[8] for more information.
145 *depends (array)*::
146         An array of packages this package depends on to run. Entries in
147         this list should be surrounded with single quotes and contain at least
148         the package name. Entries can also include a version requirement of the
149         form 'name<>version', where <> is one of five comparisons: >= (greater
150         than or equal to), <= (less than or equal to), = (equal to), > (greater
151         than), or < (less than).
153 If the dependency name appears to be a library (ends with .so), makepkg will
154 try to find a binary that depends on the library in the built package and
155 append the version needed by the binary. Appending the version yourself
156 disables auto detection.
158 *makedepends (array)*::
159         An array of packages this package depends on to build but are not
160         needed at runtime. Packages in this list follow the same format as
161         depends.
163 *checkdepends (array)*::
164         An array of packages this package depends on to run its test suite
165         but are not needed at runtime. Packages in this list follow the same
166         format as depends. These dependencies are only considered when the
167         check() function is present and is to be run by makepkg.
169 *optdepends (array)*::
170         An array of packages (and accompanying reasons) that are not essential for
171         base functionality, but may be necessary to make full use of the contents
172         of this package. optdepends are currently for informational purposes only
173         and are not utilized by pacman during dependency resolution. The format
174         for specifying optdepends is:
176         optdepends=('fakeroot: for makepkg usage as normal user')
178 *conflicts (array)*::
179         An array of packages that will conflict with this package (i.e. they
180         cannot both be installed at the same time). This directive follows the
181         same format as depends. Versioned conflicts are also supported.
183 *provides (array)*::
184         An array of ``virtual provisions'' this package provides. This allows
185         a package to provide dependencies other than its own package name. For
186         example, the dcron package can provide 'cron', which allows packages to
187         depend on 'cron' rather than 'dcron OR fcron'.
188         Versioned provisions are also possible, in the 'name=version' format.
189         For example, dcron can provide 'cron=2.0' to satisfy the 'cron>=2.0'
190         dependency of other packages. Provisions involving the '>' and '<'
191         operators are invalid as only specific versions of a package may be
192         provided.
194 If the provision name appears to be a library (ends with .so), makepkg will
195 try to find the library in the built package and append the correct
196 version. Appending the version yourself disables auto detection.
198 *replaces (array)*::
199         An array of packages this package should replace. This can be used
200         to handle renamed/combined packages. For example, if the 'j2re' package
201         is renamed to 'jre', this directive allows future upgrades to continue
202         as expected even though the package has moved. Sysupgrade is currently
203         the only pacman operation that utilizes this field, a normal sync will
204         not use its value.
206 *options (array)*::
207         This array allows you to override some of makepkg's default behavior
208         when building packages. To set an option, just include the option name
209         in the options array. To reverse the default behavior, place an ``!'' at
210         the front of the option. Only specify the options you specifically want
211         to override, the rest will be taken from linkman:makepkg.conf[5].
212         *NOTE:* 'force' is a now-removed option in favor of the top level 'epoch'
213         variable.
215         *strip*;;
216                 Strip symbols from binaries and libraries. If you frequently
217                 use a debugger on programs or libraries, it may be helpful to
218                 disable this option.
220         *docs*;;
221                 Save doc directories. If you wish to delete doc directories,
222                 specify `!docs` in the array.
224         *libtool*;;
225                 Leave libtool (.la) files in packages. Specify `!libtool` to
226                 remove them.
228         *emptydirs*;;
229                 Leave empty directories in packages.
231         *zipman*;;
232                 Compress man and info pages with gzip.
234         *upx*;;
235                 Compress binary executable files using UPX.
237         *ccache*;;
238                 Allow the use of ccache during build. More useful in its negative
239                 form `!ccache` with select packages that have problems building
240                 with ccache.
242         *distcc*;;
243                 Allow the use of distcc during build. More useful in its negative
244                 form `!distcc` with select packages that have problems building
245                 with distcc.
247         *buildflags*;;
248                 Allow the use of user-specific buildflags (CFLAGS, CXXFLAGS, LDFLAGS)
249                 during build as specified in linkman:makepkg.conf[5]. More useful in
250                 its negative form `!buildflags` with select packages that have problems
251                 building with custom buildflags.
253         *makeflags*;;
254                 Allow the use of user-specific makeflags during build as specified
255                 in linkman:makepkg.conf[5]. More useful in its negative form
256                 `!makeflags` with select packages that have problems building with
257                 custom makeflags such as `-j2` (or higher).
260 build() Function
261 ----------------
262 In addition to the above directives, the optional build() function usually
263 comprises the remainder of the PKGBUILD. This is directly sourced and executed
264 by makepkg, so anything that bash or the system has available is available for
265 use here. The function is run in `bash -e` mode, meaning any command that exits
266 with a non-zero status will cause the function to exit. Be sure any exotic
267 commands used are covered by `makedepends`.
269 All of the above variables such as `pkgname` and `pkgver` are available for use
270 in the build function. In addition, makepkg defines the following three
271 variables for use during the build and install process:
273 *startdir*::
274         This contains the absolute path to the directory where the PKGBUILD is
275         located, which is usually the output of `$(pwd)` when makepkg is started.
277 *srcdir*::
278         This contains the directory where makepkg extracts, or copies, all source
279         files.
281 *pkgdir*::
282         This contains the directory where makepkg bundles the installed package
283         (this directory will become the root directory of your built package).
285 If you create any variables of your own in the build function, it is
286 recommended to use the bash `local` keyword to scope the variable to inside
287 the build function.
289 check() Function
290 ----------------
291 An optional check() function can be specified in which a packages test-suite
292 may be run. This function is run between the build() and package() functions.
293 The function is run in `bash -e` mode, meaning any command that exits with a
294 non-zero status will cause the function to exit. Be sure any exotic commands
295 used are covered by `checkdepends`.
297 package() Function
298 ------------------
299 An optional package() function can be specified in addition to the build()
300 function. This function is run after the build() and check() functions. The
301 function is run in `bash -e` mode, meaning any command that exits with a
302 non-zero status will cause the function to exit. When specified in combination
303 with the fakeroot BUILDENV option in linkman:makepkg.conf[5], fakeroot usage
304 will be limited to running the packaging stage. An existing build() function
305 will be run as the user calling makepkg.
307 Package Splitting
308 -----------------
309 makepkg supports building multiple packages from a single PKGBUILD. This is
310 achieved by assigning an array of package names to the `pkgname` directive.
311 Each split package uses a corresponding packaging function with name
312 `package_foo()`, where `foo` is the name of the split package.
314 All options and directives for the split packages default to the global values
315 given in the PKGBUILD. Nevertheless, the following ones can be overridden within
316 each split package's packaging function:
317 `pkgver`, `pkgrel`, `pkgdesc`, `arch`, `license`, `groups`, `depends`,
318 `optdepends`, `provides`, `conflicts`, `replaces`, `backup`, `options`,
319 `install` and `changelog`.
321 An optional global directive is available when building a split package:
323 *pkgbase*::
324         The name used to refer to the group of packages in the output of makepkg
325         and in the naming of source-only tarballs.  If not specified, the first
326         element in the `pkgname` array is used.  The variable is not allowed to
327         begin with a hyphen.
329 Install/Upgrade/Remove Scripting
330 --------------------------------
331 Pacman has the ability to store and execute a package-specific script when it
332 installs, removes, or upgrades a package. This allows a package to configure
333 itself after installation and perform an opposite action upon removal.
335 The exact time the script is run varies with each operation:
337 *pre_install*::
338         script is run right before files are extracted. One argument is passed:
339         new package version.
341 *post_install*::
342         script is run right after files are extracted. One argument is passed:
343         new package version.
345 *pre_upgrade*::
346         script is run right before files are extracted. Two arguments are passed
347         in the following order: new package version, old package version.
349 *post_upgrade*::
350         script is run after files are extracted. Two arguments are passed
351         in the following order: new package version, old package version.
353 *pre_remove*::
354         script is run right before files are removed. One argument is passed:
355         old package version.
357 *post_remove*::
358         script is run right after files are removed. One argument is passed:
359         old package version.
361 To use this feature, create a file such as 'pkgname.install' and put it in the
362 same directory as the PKGBUILD script. Then use the install directive:
364         install=pkgname.install
366 The install script does not need to be specified in the source array. A
367 template install file is available in '{pkgdatadir}' as 'proto.install' for
368 reference with all of the available functions defined.
371 Development Directives
372 ----------------------
373 makepkg supports building development versions of packages without having to
374 manually update the pkgver in the PKGBUILD. This was formerly done using the
375 separate utility 'versionpkg'. In order to utilize this functionality, your
376 PKGBUILD must use correct variable names depending on the SCM being fetched
377 from (e.g., 'makepkg-git', 'mplayer-svn').
379 *CVS*::
380         The generated pkgver will be the date the package is built.
382         *_cvsroot*;;
383                 The root of the CVS repository.
385         *_cvsmod*;;
386                 The CVS module to fetch.
388 *SVN*::
389         The generated pkgver will be the latest SVN revision number.
391         *_svntrunk*;;
392                 The trunk of the SVN repository.
394         *_svnmod*;;
395                 The SVN module to fetch.
397 *Git*::
398         The generated pkgver will be one formatted by the 'git-describe'
399         command, with '-' characters converted to '_' characters.
401         *_gitroot*;;
402                 The URL (all protocols supported) to the GIT repository.
404         *_gitname*;;
405                 GIT tag or branch to use.
407 *Mercurial*::
408         The generated pkgver will be the hg tip revision number.
410         *_hgroot*;;
411                 The URL of the mercurial repository.
413         *_hgrepo*;;
414                 The repository to follow.
416 *Darcs*::
417         The generated pkgver will be the date the package is built.
419         *_darcstrunk*;;
420                 URL to the repository trunk.
422         *_darcsmod*;;
423                 Darcs module to use.
425 *Bazaar*::
426         The generated pkgver will be the latest Bazaar revision number (revno).
428         *_bzrtrunk*;;
429                 URL to the bazaar repository.
431         *_bzrmod*;;
432                 Bazaar module to use.
435 Example
436 -------
437 The following is an example PKGBUILD for the 'patch' package. For more
438 examples, look through the build files of your distribution's packages. For
439 those using Arch Linux, consult the ABS tree.
441 [source,sh]
442 -------------------------------
443 include::PKGBUILD-example.txt[]
444 -------------------------------
446 See Also
447 --------
448 linkman:makepkg[8], linkman:pacman[8], linkman:makepkg.conf[5]
450 include::footer.txt[]