2 vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
9 PKGBUILD - Arch Linux package build description file
19 This manual page describes general rules about PKGBUILDs. Once a
20 PKGBUILD is written, the actual package is built using makepkg and installed
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`.
42 Either the name of the package or an array of names for split packages.
43 Valid characters for members of this array are alphanumerics, and any of
44 the following characters: ```@ . _ + -`''. Additionally, names are not
45 allowed to start with hyphens.
48 The version of the software as released from the author (e.g., '2.7.1').
49 The variable is not allowed to contain colons or hyphens.
51 The `pkgver` variable can be automatically updated by providing a `pkgver()` function
52 in the PKGBUILD that outputs the new package version. This is run after downloading
53 and extracting the sources so can use those files in determining the new `pkgver`.
54 This is most useful when used with sources from version control systems (see below).
57 This is the release number specific to the Arch Linux release. This
58 allows package maintainers to make updates to the package's configure
59 flags, for example. This is typically set to '1' for each new upstream
60 software release and incremented for intermediate PKGBUILD updates. The
61 variable is not allowed to contain hyphens.
64 This should be a brief description of the package and its functionality.
65 Try to keep the description to one line of text and not use the package's name.
68 Used to force the package to be seen as newer than any previous versions
69 with a lower epoch, even if the version number would normally not trigger
70 such an upgrade. This value is required to be a positive integer; the
71 default value if left unspecified is '0'. This is useful when the version
72 numbering scheme of a package changes (or is alphanumeric), breaking normal
73 version comparison logic. See linkman:pacman[8] for more information on
77 This field contains a URL that is associated with the software being
78 packaged. Typically the project's website.
81 This field specifies the license(s) that apply to the package.
82 Commonly used licenses can be found in '/usr/share/licenses/common'. If you
83 see the package's license there, simply reference it in the license
84 field (e.g., `license=('GPL')`). If the package provides a license not
85 available in '/usr/share/licenses/common', then you should include it
86 in the package itself and set `license=('custom')` or
87 `license=('custom:LicenseName')`. The license should be placed in
88 '$pkgdir/usr/share/licenses/$pkgname/' when building the package. If
89 multiple licenses are applicable, list all of them:
90 `license=('GPL' 'FDL')`.
93 Specifies a special install script 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., `install=$pkgname.install`).
99 Specifies a changelog file that is to be included in the package.
100 This file should reside in the same directory as the PKGBUILD, and will
101 be copied into the package by makepkg. It does not need to be included
102 in the source array (e.g., `changelog=$pkgname.changelog`).
105 An array of source files required to build the package. Source files
106 must either reside in the same directory as the PKGBUILD, or be a
107 fully-qualified URL that makepkg can use to download the file.
108 To make the PKGBUILD as useful as possible, use the `$pkgname` and `$pkgver`
109 variables if possible when specifying the download location. Compressed files
110 will be extracted automatically unless found in
111 the noextract array described below.
113 It is also possible to change the name of the downloaded file, which is helpful
114 with weird URLs and for handling multiple source files with the same
115 name. The syntax is: `source=('filename::url')`.
117 makepkg also supports building developmental versions of packages using sources
118 downloaded from version control systems (VCS). For more information, see
119 <<VCS,Using VCS Sources>> below.
121 Files in the source array with extensions `.sig`, `.sign` or `.asc` are recognized by
122 makepkg as PGP signatures and will be automatically used to verify the integrity
123 of the corresponding source file.
125 *noextract (array)*::
126 An array of filenames corresponding to those from the source array. Files
127 listed here will not be extracted with the rest of the source files. This
128 is useful for packages that use compressed data directly.
131 This array contains an MD5 hash for every source file specified in the
132 source array (in the same order). makepkg will use this to verify source
133 file integrity during subsequent builds. If 'SKIP' is put in the array
134 in place of a normal hash, the integrity check for that source file will
135 be skipped. To easily generate md5sums, run ``makepkg -g >> PKGBUILD''.
136 If desired, move the md5sums line to an appropriate location.
138 *sha1sums, sha256sums, sha384sums, sha512sums (arrays)*::
139 Alternative integrity checks that makepkg supports; these all behave
140 similar to the md5sums option described above. To enable use and generation
141 of these checksums, be sure to set up the `INTEGRITY_CHECK` option in
142 linkman:makepkg.conf[5].
145 An array of symbolic names that represent groups of packages, allowing
146 you to install multiple packages by requesting a single target. For
147 example, one could install all KDE packages by installing the 'kde' group.
150 Defines on which architectures the given package is available (e.g.,
151 `arch=('i686' 'x86_64')`). Packages that contain no architecture specific
152 files should use `arch=('any')`.
155 An array of filenames, without preceding slashes, that
156 should be backed up if the package is removed or upgraded. This is
157 commonly used for packages placing configuration files in /etc. See
158 Handling Config Files in linkman:pacman[8] for more information.
161 An array of packages this package depends on to run. Entries in
162 this list should be surrounded with single quotes and contain at least
163 the package name. Entries can also include a version requirement of the
164 form 'name<>version', where `<>` is one of five comparisons: `>=` (greater
165 than or equal to), `<=` (less than or equal to), `=` (equal to), `>`
166 (greater than), or `<` (less than).
168 If the dependency name appears to be a library (ends with .so), makepkg will
169 try to find a binary that depends on the library in the built package and
170 append the version needed by the binary. Appending the version yourself
171 disables auto detection.
173 *makedepends (array)*::
174 An array of packages this package depends on to build but are not
175 needed at runtime. Packages in this list follow the same format as
178 *checkdepends (array)*::
179 An array of packages this package depends on to run its test suite
180 but are not needed at runtime. Packages in this list follow the same
181 format as depends. These dependencies are only considered when the
182 check() function is present and is to be run by makepkg.
184 *optdepends (array)*::
185 An array of packages (and accompanying reasons) that are not essential for
186 base functionality, but may be necessary to make full use of the contents
187 of this package. optdepends are currently for informational purposes only
188 and are not utilized by pacman during dependency resolution. The format
189 for specifying optdepends is:
191 optdepends=('fakeroot: for makepkg usage as normal user')
193 *conflicts (array)*::
194 An array of packages that will conflict with this package (i.e. they
195 cannot both be installed at the same time). This directive follows the
196 same format as depends. Versioned conflicts are supported using the
197 operators as described in `depends`.
200 An array of ``virtual provisions'' this package provides. This allows
201 a package to provide dependencies other than its own package name. For
202 example, the dcron package can provide 'cron', which allows packages to
203 depend on 'cron' rather than 'dcron OR fcron'.
205 Versioned provisions are also possible, in the 'name=version' format. For
206 example, dcron can provide 'cron=2.0' to satisfy the 'cron>=2.0' dependency of
207 other packages. Provisions involving the `>` and `<` operators are invalid as
208 only specific versions of a package may be provided.
210 If the provision name appears to be a library (ends with .so), makepkg will
211 try to find the library in the built package and append the correct
212 version. Appending the version yourself disables auto detection.
215 An array of packages this package should replace. This can be used
216 to handle renamed/combined packages. For example, if the 'j2re' package
217 is renamed to 'jre', this directive allows future upgrades to continue
218 as expected even though the package has moved. Versioned replaces are
219 supported using the operators as described in `depends`.
221 Sysupgrade is currently the only pacman operation that utilizes this field.
222 A normal sync or upgrade will not use its value.
225 This array allows you to override some of makepkg's default behavior
226 when building packages. To set an option, just include the option name
227 in the options array. To reverse the default behavior, place an ``!'' at
228 the front of the option. Only specify the options you specifically want
229 to override, the rest will be taken from linkman:makepkg.conf[5].
230 *NOTE:* 'force' is a now-removed option in favor of the top level 'epoch'
234 Strip symbols from binaries and libraries. If you frequently
235 use a debugger on programs or libraries, it may be helpful to
239 Save doc directories. If you wish to delete doc directories,
240 specify `!docs` in the array.
243 Leave libtool (.la) files in packages. Specify `!libtool` to
247 Leave empty directories in packages.
250 Compress man and info pages with gzip.
253 Compress binary executable files using UPX.
256 Allow the use of ccache during build. More useful in its negative
257 form `!ccache` with select packages that have problems building
261 Allow the use of distcc during build. More useful in its negative
262 form `!distcc` with select packages that have problems building
266 Allow the use of user-specific buildflags (CPPFLAGS, CFLAGS, CXXFLAGS,
267 LDFLAGS) during build as specified in linkman:makepkg.conf[5]. More
268 useful in its negative form `!buildflags` with select packages that
269 have problems building with custom buildflags.
272 Allow the use of user-specific makeflags during build as specified
273 in linkman:makepkg.conf[5]. More useful in its negative form
274 `!makeflags` with select packages that have problems building with
275 custom makeflags such as `-j2` (or higher).
280 In addition to the above directives, the optional build() function usually
281 comprises the remainder of the PKGBUILD. This is directly sourced and executed
282 by makepkg, so anything that bash or the system has available is available for
283 use here. The function is run in `bash -e` mode, meaning any command that exits
284 with a non-zero status will cause the function to exit. Be sure any exotic
285 commands used are covered by `makedepends`.
287 All of the above variables such as `$pkgname` and `$pkgver` are available for use
288 in the build function. In addition, makepkg defines the following three
289 variables for use during the build and install process:
292 This contains the absolute path to the directory where the PKGBUILD is
293 located, which is usually the output of `$(pwd)` when makepkg is started.
294 Use of this variable is deprecated and strongly discouraged.
297 This contains the directory where makepkg extracts, or copies, all source
301 This contains the directory where makepkg bundles the installed package
302 (this directory will become the root directory of your built package).
304 If you create any variables of your own in the build function, it is
305 recommended to use the bash `local` keyword to scope the variable to inside
310 An optional prepare() function can be specified in which operations that are
311 to be run in order to prepare the sources for building (such as patching) are
312 performed. This function is run after the source extraction and before the
313 build() function and is skipped when source extraction is skipped. The
314 function is run in `bash -e` mode, meaning any command that exits with a
315 non-zero status will cause the function to exit.
319 An optional check() function can be specified in which a packages test-suite
320 may be run. This function is run between the build() and package() functions.
321 The function is run in `bash -e` mode, meaning any command that exits with a
322 non-zero status will cause the function to exit. Be sure any exotic commands
323 used are covered by `checkdepends`.
327 An optional package() function can be specified in addition to the build()
328 function. This function is run after the build() and check() functions. The
329 function is run in `bash -e` mode, meaning any command that exits with a
330 non-zero status will cause the function to exit. When specified in combination
331 with the fakeroot BUILDENV option in linkman:makepkg.conf[5], fakeroot usage
332 will be limited to running the packaging stage. An existing build() function
333 will be run as the user calling makepkg.
337 makepkg supports building multiple packages from a single PKGBUILD. This is
338 achieved by assigning an array of package names to the `pkgname` directive.
339 Each split package uses a corresponding packaging function with name
340 `package_foo()`, where `foo` is the name of the split package.
342 All options and directives for the split packages default to the global values
343 given in the PKGBUILD. Nevertheless, the following ones can be overridden within
344 each split package's packaging function:
345 `pkgver`, `pkgrel`, `epoch`, `pkgdesc`, `arch`, `url`, `license`, `groups`,
346 `depends`, `optdepends`, `provides`, `conflicts`, `replaces`, `backup`,
347 `options`, `install` and `changelog`.
349 An optional global directive is available when building a split package:
352 The name used to refer to the group of packages in the output of makepkg
353 and in the naming of source-only tarballs. If not specified, the first
354 element in the `pkgname` array is used. The variable is not allowed to
357 Install/Upgrade/Remove Scripting
358 --------------------------------
359 Pacman has the ability to store and execute a package-specific script when it
360 installs, removes, or upgrades a package. This allows a package to configure
361 itself after installation and perform an opposite action upon removal.
363 The exact time the script is run varies with each operation, and should be
364 self-explanatory. Note that during an upgrade operation, none of the install
365 or remove scripts will be called.
367 Scripts are passed either one or two ``full version strings'', where a full
368 version string is either 'pkgver-pkgrel' or 'epoch:pkgver-pkgrel' if epoch is
372 Run right before files are extracted. One argument is passed:
373 new package full version string.
376 Run right after files are extracted. One argument is passed:
377 new package full version string.
380 Run right before files are extracted. Two arguments are passed in this
381 order: new package full version string, old package full version string.
384 Run after files are extracted. Two arguments are passed in this order:
385 new package full version string, old package full version string.
388 Run right before files are removed. One argument is passed:
389 old package full version string.
392 Run right after files are removed. One argument is passed:
393 old package full version string.
395 To use this feature, create a file such as 'pkgname.install' and put it in the
396 same directory as the PKGBUILD script. Then use the install directive:
398 install=pkgname.install
400 The install script does not need to be specified in the source array. A
401 template install file is available in '{pkgdatadir}' as 'proto.install' for
402 reference with all of the available functions defined.
404 Using VCS Sources[[VCS]]
405 ------------------------
406 Building a developmental version of a package using sources from a version control
407 system (VCS) is enabled by specifying the source in the form
408 `source=('folder::url#fragment')`. Currently makepkg supports the `git`, `hg` and
411 The source URL is divided into three components:
414 (optional) Specifies an alternate folder name for makepkg to download the VCS
418 The url to the VCS repo. This must include the the vcs in the URL protocol for
419 makepkg to recognize this as a VCS source. If the protocol does not include
420 the VCS name, it can be added by prefixing the URL with `vcs+`. For example,
421 using a git repository over `http` would have a source URL in the form
425 (optional) Allows specifying a revision number or branch for makepkg to checkout
426 from the VCS. For example, to checkout a given revision, the source line would
427 have the format `source=(url#revision=123)`. The available fragments depends on
434 branch, revision, tag
441 The following is an example PKGBUILD for the 'patch' package. For more
442 examples, look through the build files of your distribution's packages. For
443 those using Arch Linux, consult the ABS tree.
446 -------------------------------
447 include::PKGBUILD-example.txt[]
448 -------------------------------
452 linkman:makepkg[8], linkman:pacman[8], linkman:makepkg.conf[5]
454 include::footer.txt[]