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.
52 This is the release number specific to the Arch Linux release. This
53 allows package maintainers to make updates to the package's configure
54 flags, for example. This is typically set to '1' for each new upstream
55 software release and incremented for intermediate PKGBUILD updates. The
56 variable is not allowed to contain hyphens.
59 This should be a brief description of the package and its functionality.
60 Try to keep the description to one line of text and not use the package's name.
63 Used to force the package to be seen as newer than any previous versions
64 with a lower epoch, even if the version number would normally not trigger
65 such an upgrade. This value is required to be a positive integer; the
66 default value if left unspecified is '0'. This is useful when the version
67 numbering scheme of a package changes (or is alphanumeric), breaking normal
68 version comparison logic. See linkman:pacman[8] for more information on
72 This field contains a URL that is associated with the software being
73 packaged. Typically the project's website.
76 This field specifies the license(s) that apply to the package.
77 Commonly used licenses can be found in '/usr/share/licenses/common'. If you
78 see the package's license there, simply reference it in the license
79 field (e.g., `license=('GPL')`). If the package provides a license not
80 available in '/usr/share/licenses/common', then you should include it
81 in the package itself and set `license=('custom')` or
82 `license=('custom:LicenseName')`. The license should be placed in
83 '$pkgdir/usr/share/licenses/$pkgname/' when building the package. If
84 multiple licenses are applicable, list all of them:
85 `license=('GPL' 'FDL')`.
88 Specifies a special install script that is to be included in the package.
89 This file should reside in the same directory as the PKGBUILD, and will
90 be copied into the package by makepkg. It does not need to be included
91 in the source array (e.g., `install=$pkgname.install`).
94 Specifies a changelog file that is to be included in the package.
95 This file should reside in the same directory as the PKGBUILD, and will
96 be copied into the package by makepkg. It does not need to be included
97 in the source array (e.g., `changelog=$pkgname.changelog`).
100 An array of source files required to build the package. Source files
101 must either reside in the same directory as the PKGBUILD, or be a
102 fully-qualified URL that makepkg can use to download the file.
103 To make the PKGBUILD as useful as possible, use the `$pkgname` and `$pkgver`
104 variables if possible when specifying the download location. Compressed files
105 will be extracted automatically unless found in
106 the noextract array described below.
108 It is also possible to change the name of the downloaded file, which is helpful
109 with weird URLs and for handling multiple source files with the same
110 name. The syntax is: `source=('filename::url')`.
112 Files in the source array with extensions `.sig`, `.sign` or `.asc` are recognized by
113 makepkg as PGP signatures and will be automatically used to verify the integrity
114 of the corresponding source file.
116 *noextract (array)*::
117 An array of filenames corresponding to those from the source array. Files
118 listed here will not be extracted with the rest of the source files. This
119 is useful for packages that use compressed data directly.
122 This array contains an MD5 hash for every source file specified in the
123 source array (in the same order). makepkg will use this to verify source
124 file integrity during subsequent builds. If 'SKIP' is put in the array
125 in place of a normal hash, the integrity check for that source file will
126 be skipped. To easily generate md5sums, run ``makepkg -g >> PKGBUILD''.
127 If desired, move the md5sums line to an appropriate location.
129 *sha1sums, sha256sums, sha384sums, sha512sums (arrays)*::
130 Alternative integrity checks that makepkg supports; these all behave
131 similar to the md5sums option described above. To enable use and generation
132 of these checksums, be sure to set up the `INTEGRITY_CHECK` option in
133 linkman:makepkg.conf[5].
136 An array of symbolic names that represent groups of packages, allowing
137 you to install multiple packages by requesting a single target. For
138 example, one could install all KDE packages by installing the 'kde' group.
141 Defines on which architectures the given package is available (e.g.,
142 `arch=('i686' 'x86_64')`). Packages that contain no architecture specific
143 files should use `arch=('any')`.
146 An array of filenames, without preceding slashes, that
147 should be backed up if the package is removed or upgraded. This is
148 commonly used for packages placing configuration files in /etc. See
149 Handling Config Files in linkman:pacman[8] for more information.
152 An array of packages this package depends on to run. Entries in
153 this list should be surrounded with single quotes and contain at least
154 the package name. Entries can also include a version requirement of the
155 form 'name<>version', where `<>` is one of five comparisons: `>=` (greater
156 than or equal to), `<=` (less than or equal to), `=` (equal to), `>`
157 (greater than), or `<` (less than).
159 If the dependency name appears to be a library (ends with .so), makepkg will
160 try to find a binary that depends on the library in the built package and
161 append the version needed by the binary. Appending the version yourself
162 disables auto detection.
164 *makedepends (array)*::
165 An array of packages this package depends on to build but are not
166 needed at runtime. Packages in this list follow the same format as
169 *checkdepends (array)*::
170 An array of packages this package depends on to run its test suite
171 but are not needed at runtime. Packages in this list follow the same
172 format as depends. These dependencies are only considered when the
173 check() function is present and is to be run by makepkg.
175 *optdepends (array)*::
176 An array of packages (and accompanying reasons) that are not essential for
177 base functionality, but may be necessary to make full use of the contents
178 of this package. optdepends are currently for informational purposes only
179 and are not utilized by pacman during dependency resolution. The format
180 for specifying optdepends is:
182 optdepends=('fakeroot: for makepkg usage as normal user')
184 *conflicts (array)*::
185 An array of packages that will conflict with this package (i.e. they
186 cannot both be installed at the same time). This directive follows the
187 same format as depends. Versioned conflicts are supported using the
188 operators as described in `depends`.
191 An array of ``virtual provisions'' this package provides. This allows
192 a package to provide dependencies other than its own package name. For
193 example, the dcron package can provide 'cron', which allows packages to
194 depend on 'cron' rather than 'dcron OR fcron'.
196 Versioned provisions are also possible, in the 'name=version' format. For
197 example, dcron can provide 'cron=2.0' to satisfy the 'cron>=2.0' dependency of
198 other packages. Provisions involving the `>` and `<` operators are invalid as
199 only specific versions of a package may be provided.
201 If the provision name appears to be a library (ends with .so), makepkg will
202 try to find the library in the built package and append the correct
203 version. Appending the version yourself disables auto detection.
206 An array of packages this package should replace. This can be used
207 to handle renamed/combined packages. For example, if the 'j2re' package
208 is renamed to 'jre', this directive allows future upgrades to continue
209 as expected even though the package has moved. Versioned replaces are
210 supported using the operators as described in `depends`.
212 Sysupgrade is currently the only pacman operation that utilizes this field.
213 A normal sync or upgrade will not use its value.
216 This array allows you to override some of makepkg's default behavior
217 when building packages. To set an option, just include the option name
218 in the options array. To reverse the default behavior, place an ``!'' at
219 the front of the option. Only specify the options you specifically want
220 to override, the rest will be taken from linkman:makepkg.conf[5].
221 *NOTE:* 'force' is a now-removed option in favor of the top level 'epoch'
225 Strip symbols from binaries and libraries. If you frequently
226 use a debugger on programs or libraries, it may be helpful to
230 Save doc directories. If you wish to delete doc directories,
231 specify `!docs` in the array.
234 Leave libtool (.la) files in packages. Specify `!libtool` to
238 Leave empty directories in packages.
241 Compress man and info pages with gzip.
244 Compress binary executable files using UPX.
247 Allow the use of ccache during build. More useful in its negative
248 form `!ccache` with select packages that have problems building
252 Allow the use of distcc during build. More useful in its negative
253 form `!distcc` with select packages that have problems building
257 Allow the use of user-specific buildflags (CPPFLAGS, CFLAGS, CXXFLAGS,
258 LDFLAGS) during build as specified in linkman:makepkg.conf[5]. More
259 useful in its negative form `!buildflags` with select packages that
260 have problems building with custom buildflags.
263 Allow the use of user-specific makeflags during build as specified
264 in linkman:makepkg.conf[5]. More useful in its negative form
265 `!makeflags` with select packages that have problems building with
266 custom makeflags such as `-j2` (or higher).
271 In addition to the above directives, the optional build() function usually
272 comprises the remainder of the PKGBUILD. This is directly sourced and executed
273 by makepkg, so anything that bash or the system has available is available for
274 use here. The function is run in `bash -e` mode, meaning any command that exits
275 with a non-zero status will cause the function to exit. Be sure any exotic
276 commands used are covered by `makedepends`.
278 All of the above variables such as `$pkgname` and `$pkgver` are available for use
279 in the build function. In addition, makepkg defines the following three
280 variables for use during the build and install process:
283 This contains the absolute path to the directory where the PKGBUILD is
284 located, which is usually the output of `$(pwd)` when makepkg is started.
285 Use of this variable is deprecated and strongly discouraged.
288 This contains the directory where makepkg extracts, or copies, all source
292 This contains the directory where makepkg bundles the installed package
293 (this directory will become the root directory of your built package).
295 If you create any variables of your own in the build function, it is
296 recommended to use the bash `local` keyword to scope the variable to inside
301 An optional check() function can be specified in which a packages test-suite
302 may be run. This function is run between the build() and package() functions.
303 The function is run in `bash -e` mode, meaning any command that exits with a
304 non-zero status will cause the function to exit. Be sure any exotic commands
305 used are covered by `checkdepends`.
309 An optional package() function can be specified in addition to the build()
310 function. This function is run after the build() and check() functions. The
311 function is run in `bash -e` mode, meaning any command that exits with a
312 non-zero status will cause the function to exit. When specified in combination
313 with the fakeroot BUILDENV option in linkman:makepkg.conf[5], fakeroot usage
314 will be limited to running the packaging stage. An existing build() function
315 will be run as the user calling makepkg.
319 makepkg supports building multiple packages from a single PKGBUILD. This is
320 achieved by assigning an array of package names to the `pkgname` directive.
321 Each split package uses a corresponding packaging function with name
322 `package_foo()`, where `foo` is the name of the split package.
324 All options and directives for the split packages default to the global values
325 given in the PKGBUILD. Nevertheless, the following ones can be overridden within
326 each split package's packaging function:
327 `pkgver`, `pkgrel`, `epoch`, `pkgdesc`, `arch`, `url`, `license`, `groups`,
328 `depends`, `optdepends`, `provides`, `conflicts`, `replaces`, `backup`,
329 `options`, `install` and `changelog`.
331 An optional global directive is available when building a split package:
334 The name used to refer to the group of packages in the output of makepkg
335 and in the naming of source-only tarballs. If not specified, the first
336 element in the `pkgname` array is used. The variable is not allowed to
339 Install/Upgrade/Remove Scripting
340 --------------------------------
341 Pacman has the ability to store and execute a package-specific script when it
342 installs, removes, or upgrades a package. This allows a package to configure
343 itself after installation and perform an opposite action upon removal.
345 The exact time the script is run varies with each operation, and should be
346 self-explanatory. Note that during an upgrade operation, none of the install
347 or remove scripts will be called.
349 Scripts are passed either one or two ``full version strings'', where a full
350 version string is either 'pkgver-pkgrel' or 'epoch:pkgver-pkgrel' if epoch is
354 Run right before files are extracted. One argument is passed:
355 new package full version string.
358 Run right after files are extracted. One argument is passed:
359 new package full version string.
362 Run right before files are extracted. Two arguments are passed in this
363 order: new package full version string, old package full version string.
366 Run after files are extracted. Two arguments are passed in this order:
367 new package full version string, old package full version string.
370 Run right before files are removed. One argument is passed:
371 old package full version string.
374 Run right after files are removed. One argument is passed:
375 old package full version string.
377 To use this feature, create a file such as 'pkgname.install' and put it in the
378 same directory as the PKGBUILD script. Then use the install directive:
380 install=pkgname.install
382 The install script does not need to be specified in the source array. A
383 template install file is available in '{pkgdatadir}' as 'proto.install' for
384 reference with all of the available functions defined.
387 Development Directives
388 ----------------------
389 makepkg supports building development versions of packages without having to
390 manually update the pkgver in the PKGBUILD. This was formerly done using the
391 separate utility 'versionpkg'. In order to utilize this functionality, your
392 PKGBUILD must use correct variable names depending on the SCM being fetched
393 from (e.g., 'makepkg-git', 'mplayer-svn').
396 The generated pkgver will be the date the package is built.
399 The root of the CVS repository.
402 The CVS module to fetch.
405 The generated pkgver will be the latest SVN revision number.
408 The trunk of the SVN repository.
411 The SVN module to fetch.
414 The generated pkgver will be the date the package is built.
417 The URL (all protocols supported) to the GIT repository.
420 GIT tag or branch to use.
423 The generated pkgver will be the hg tip revision number.
426 The URL of the mercurial repository.
429 The repository to follow.
432 The generated pkgver will be the date the package is built.
435 URL to the repository trunk.
441 The generated pkgver will be the latest Bazaar revision number (revno).
444 URL to the bazaar repository.
447 Bazaar module to use.
452 The following is an example PKGBUILD for the 'patch' package. For more
453 examples, look through the build files of your distribution's packages. For
454 those using Arch Linux, consult the ABS tree.
457 -------------------------------
458 include::PKGBUILD-example.txt[]
459 -------------------------------
463 linkman:makepkg[8], linkman:pacman[8], linkman:makepkg.conf[5]
465 include::footer.txt[]