2 vim:set ts=4 sw=4 syntax=asciidoc noet:
9 PKGBUILD - Arch Linux package build description file
19 This manual page is meant to describe general rules about PKGBUILDs. Once a
20 PKGBUILD is written, the actual package is built using makepkg and installed
23 NOTE: If you are using Arch Linux and have a local copy of the Arch Build
24 System (ABS) tree on your computer, or are using another distribution that
25 provides a similar tree of build files, you can copy the provided
26 PKGBUILD.proto file to a new package build directory and make customizations to
27 suit your needs. An up to date prototype file can also be found in the source
28 distribution of this package.
31 Options and Directives
32 ----------------------
33 The following is a list of standard options and directives available for use
34 in a PKGBUILD. These are all understood and interpreted by makepkg, and most
35 will be directly transferred to the built package.
37 If you need to create any custom variables for use in your build process, it is
38 recommended to name your custom variables with an '_' (underscore) prefix.
39 This will prevent any possible name clashes with internal makepkg variables.
40 For example, to store the base kernel version in a variable, use something
41 similar to `$_basekernver`.
44 The name of the package. This has be a unix-friendly name as it will be
45 used in the package filename.
48 The version of the software as released from the author (e.g. '2.7.1').
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. A pkgrel of 1 is typically used for each upstream
54 software release and is incremented for intermediate PKGBUILD updates.
57 This should be a brief description of the package and its functionality.
58 Try to keep the description to one line of text.
61 This field contains a URL that is associated with the software being
62 packaged. This is typically the project's website.
65 This field specifies the license(s) that apply to the package.
66 Commonly-used licenses are found in '/usr/share/licenses/common'. If you
67 see the package's license there, simply reference it in the license
68 field (e.g. `license=('GPL')`). If the package provides a license not
69 found in '/usr/share/licenses/common', then you should include the license
70 in the package itself and set `license=('custom')` or
71 `license=('custom:LicenseName')`. The license should be placed in
72 '$pkgdir/usr/share/licenses/$pkgname' when building the package. If
73 multiple licenses are applicable for a package, list all of them:
74 `license=('GPL' 'FDL')`.
77 Specifies a special install script that is to be included in the package.
78 This file should reside in the same directory as the PKGBUILD, and will
79 be copied into the package by makepkg. It does not need to be included
80 in the source array (e.g. `install=pkgname.install`).
83 An array of source files required to build the package. Source files
84 must either reside in the same directory as the PKGBUILD file, or be a
85 fully-qualified URL that makepkg will use to download the file. In order
86 to make the PKGBUILD as useful as possible, use the $pkgname and $pkgver
87 variables if possible when specifying the download location. Any files
88 that are compressed will automatically be extracted, unless found in
89 the noextract array listed below.
91 It is also possible to specify an optional filename, which is helpful
92 with weird URLs and for handling multiple source files with the same
93 name. The syntax is: `source=('filename::url')`.
96 An array of filenames corresponding to those from the source array. Files
97 listed here will not be extracted with the rest of the source files. This
98 is useful for packages which use compressed data which is downloaded but
99 not necessary to uncompress.
102 This array contains an MD5 hash for every source file specified in the
103 source array (in the same order). makepkg will use this to verify source
104 file integrity during subsequent builds. To easily generate md5sums, run
105 ``makepkg -g >> PKGBUILD''. If desired, move the md5sums line to an
106 appropriate location.
108 *sha1sums, sha256sums, sha384sums, sha512sums (arrays)*::
109 Alternative integrity checks that makepkg supports; these all behave
110 similar to the md5sums option described above. To enable use and generation
111 of these checksums, be sure to set up the `INTEGRITY_CHECK` option in
112 linkman:makepkg.conf[5].
115 An array of symbolic names that represent groups of packages, allowing
116 you to install multiple packages by requesting a single target. For
117 example, one could install all KDE packages by installing the 'kde' group.
120 Defines on which architectures the given package is available (e.g.
121 `arch=('i686' 'x86_64')`).
124 A space-delimited array of filenames, without preceding slashes, that
125 should be backed up if the package is removed or upgraded. This is
126 commonly used for packages placing configuration files in /etc. See
127 Handling Config Files in linkman:pacman[8] for more information.
130 An array of packages that this package depends on to run. Packages in
131 this list should be surrounded with single quotes and contain at least
132 the package name. Entries can also include a version requirement of the
133 form 'name<>version', where <> is one of five comparisons: >= (greater
134 than or equal to), <= (less than or equal to), = (equal to), > (greater
135 than), or < (less than).
137 *makedepends (array)*::
138 An array of packages that this package depends on to build, but are not
139 needed at runtime. Packages in this list follow the same format as
142 *optdepends (array)*::
143 An array of packages (and accompanying reasons) that are not essential for
144 base functionality, but may be necessary to make full use of the contents
145 of this package. optdepends are currently for informational purposes only
146 and are not utilized by pacman during dependency resolution. The format
147 should be similar to the following:
149 optdepends=('fakeroot: for makepkg usage as normal user')
151 *conflicts (array)*::
152 An array of packages that will conflict with this package (i.e. they
153 cannot both be installed at the same time). This directive follows the
154 same format as depends. Versioned conflicts are also supported.
157 An array of ``virtual provisions'' that this package provides. This allows
158 a package to provide dependencies other than its own package name. For
159 example, the dcron package can provide 'cron', which allows packages to
160 depend on 'cron' rather than 'dcron OR fcron'.
161 Versioned provisions are also possible, in the 'name=version' format.
162 For example, dcron can provide 'cron=2.0' to satisfy the 'cron>=2.0'
163 dependency of other packages. Provisions involving the '>' and '<'
164 operators are invalid as only specific versions of a package may be
168 An array of packages that this package should replace, and can be used
169 to handle renamed/combined packages. For example, if the 'j2re' package
170 is renamed to 'jre', this directive allows future upgrades to continue
171 as expected even though the package has moved. Sysupgrade is currently
172 the only pacman operation that utilizes this field, a normal sync will
176 This array allows you to override some of makepkg's default behavior
177 when building packages. To set an option, just include the option name
178 in the options array. To reverse the default behavior, place an ``!'' at
179 the front of the option. Only specify the options you specifically want
180 to override, the rest will be taken from linkman:makepkg.conf[5].
181 *NOTE:* 'force' is a special option only used in a linkman:PKGBUILD[5],
182 do not use it unless you know what you are doing.
185 Strip symbols from binaries and libraries. If you frequently
186 use a debugger on programs or libraries, it may be helpful to
190 Save doc directories. If you wish to delete doc directories,
191 specify `!docs` in the array.
194 Leave libtool (.la) files in packages. Specify `!libtool` to
198 Leave empty directories in packages.
201 Compress man and info pages with gzip.
204 Allow the use of ccache during build. More useful in its negative
205 form `!ccache` with select packages that have problems building
209 Allow the use of distcc during build. More useful in its negative
210 form `!distcc` with select packages that have problems building
214 Allow the use of user-specific makeflags during build as specified
215 in linkman:makepkg.conf[5]. More useful in its negative form
216 `!makeflags` with select packages that have problems building with
217 custom makeflags such as `-j2` (or higher).
220 Force the package to be upgraded by a pacman system upgrade
221 operation, even if the version number would normally not trigger
222 such an upgrade. This is useful when the version numbering scheme
223 of a package changes (or is alphanumeric). See linkman:pacman[8] for
224 more information on version comparisons.
229 In addition to the above directives, the build() bash function comprises the
230 remainder of the PKGBUILD. This is directly sourced and executed by makepkg, so
231 anything that bash or the system has available is available for use here. Be
232 sure any exotic commands used are covered by `makedepends`.
234 All of the above variables such as `pkgname` and `pkgver` are available for use
235 in the build function. In addition, makepkg defines three variables for your
236 use during the build and install process. These three variables are as follows:
239 This contains the absolute path to the directory where the PKGBUILD was
240 located, which is usually the output of `$(pwd)` when makepkg is started.
243 This points to the directory where makepkg extracts or copies all source
247 This points to the directory where makepkg bundles the installed package
248 (this directory will become the root directory of your built package).
250 If you create any variables of your own in the build function, it is
251 recommended to use the bash `local` keyword to scope the variable to inside
256 An optional package() function can be specified in addition to the build() function.
257 This function is run immediately after the build() function. When specified in
258 combination with the fakeroot BUILDENV option in linkman:makepkg.conf[5], fakeroot
259 usage will be limited to running the packaging stage. The build() function will be
260 run as the user calling makepkg.
264 makepkg supports building multiple packages from a single PKGBUILD. This is achieved
265 by assigning an array of package names to the `pkgname` directive. Each split package
266 uses a corresponding packaging function with name `package_foo()`, where `foo` is the
267 name of the split package.
269 All options and directives for the split packages default to the global values given
270 within the PKGBUILD. However, some of these can be overridden within each split
271 package's packaging function. The following variables can be overridden: `pkgdesc`,
272 `license`, `groups`, `depends`, `optdepends`, `provides`, `conflicts`, `replaces`,
273 `backup`, `options` and `install`.
275 An optional global directive is available when building a split package:
278 The name used to refer to the group of packages in the output of makepkg
279 and in the naming of source-only tarballs. If not specified, the first
280 element in the `pkgname` array is used.
282 Install/Upgrade/Remove Scripting
283 --------------------------------
284 Pacman has the ability to store and execute a package-specific script when it
285 installs, removes, or upgrades a package. This allows a package to configure
286 itself after installation and perform an opposite action upon removal.
288 The exact time the script is run varies with each operation:
291 script is run right before files are extracted. One argument is passed:
295 script is run right after files are extracted. One argument is passed:
299 script is run right before files are extracted. Two arguments are passed
300 in the following order: new package version, old package version.
303 script is run after files are extracted. Two arguments are passed
304 in the following order: new package version, old package version.
307 script is run right before files are removed. One argument is passed:
311 script is run right after files are removed. One argument is passed:
314 To use this feature, create a file such as 'pkgname.install' and put it in the
315 same directory as the PKGBUILD script. Then use the install directive:
317 install=pkgname.install
319 The install script does not need to be specified in the source array. A
320 template install file is available with the source distribution of this
321 program, or one may be provided by your distribution. For example, Arch Linux
322 provides prototype install files in the ABS tree.
325 Development Directives
326 ----------------------
327 makepkg supports building development versions of packages without having to
328 manually update the pkgver in the PKGBUILD. This was formerly done using the
329 separate utility 'versionpkg'. In order to utilize this functionality, your
330 PKGBUILD must use correct variable names depending on the SCM being fetched
334 The generated pkgver will be the date the package is built.
337 The root of the CVS repository.
340 The CVS module to fetch.
343 The generated pkgver will be the latest SVN revision number.
346 The trunk of the SVN repository.
349 The SVN module to fetch.
352 The generated pkgver will be one formatted by the 'git-describe'
353 command, with '-' characters converted to '_' characters.
356 The URL (all protocols supported) to the GIT repository.
359 GIT tag or branch to use.
362 The generated pkgver will be the hg tip revision number.
365 The URL of the mercurial repository.
368 The repository to follow.
371 The generated pkgver will be the date the package is built.
374 URL to the repository trunk.
380 The generated pkgver will be the latest Bazaar revision number (revno).
383 URL to the bazaar repository.
386 Bazaar module to use.
391 The following is an example PKGBUILD for the 'patch' package. For more
392 examples, look through the build files of your distribution's packages. For
393 those using Arch Linux, consult the ABS tree.
396 -------------------------------
397 include::PKGBUILD-example.txt[]
398 -------------------------------
402 linkman:makepkg[8], linkman:pacman[8], linkman:makepkg.conf[5]
404 include::footer.txt[]