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 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.
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.
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.
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.
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
71 This field contains a URL that is associated with the software being
72 packaged. Typically the project's website.
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')`.
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`).
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`).
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 Files in the source array with extensions `.sig`, `.sign` or `.asc` are recognized by
112 makepkg as PGP signatures and will be automatically used to verify the integrity
113 of the corresponding source file.
115 *noextract (array)*::
116 An array of filenames corresponding to those from the source array. Files
117 listed here will not be extracted with the rest of the source files. This
118 is useful for packages that use compressed data directly.
121 This array contains an MD5 hash for every source file specified in the
122 source array (in the same order). makepkg will use this to verify source
123 file integrity during subsequent builds. If 'SKIP' is put in the array
124 in place of a normal hash, the integrity check for that source file will
125 be skipped. To easily generate md5sums, run ``makepkg -g >> PKGBUILD''.
126 If desired, move the md5sums line to an appropriate location.
128 *sha1sums, sha256sums, sha384sums, sha512sums (arrays)*::
129 Alternative integrity checks that makepkg supports; these all behave
130 similar to the md5sums option described above. To enable use and generation
131 of these checksums, be sure to set up the `INTEGRITY_CHECK` option in
132 linkman:makepkg.conf[5].
135 An array of symbolic names that represent groups of packages, allowing
136 you to install multiple packages by requesting a single target. For
137 example, one could install all KDE packages by installing the 'kde' group.
140 Defines on which architectures the given package is available (e.g.,
141 `arch=('i686' 'x86_64')`). Packages that contain no architecture specific
142 files should use `arch=('any')`.
145 An array of filenames, without preceding slashes, that
146 should be backed up if the package is removed or upgraded. This is
147 commonly used for packages placing configuration files in /etc. See
148 Handling Config Files in linkman:pacman[8] for more information.
151 An array of packages this package depends on to run. Entries in
152 this list should be surrounded with single quotes and contain at least
153 the package name. Entries can also include a version requirement of the
154 form 'name<>version', where `<>` is one of five comparisons: `>=` (greater
155 than or equal to), `<=` (less than or equal to), `=` (equal to), `>`
156 (greater than), or `<` (less than).
158 If the dependency name appears to be a library (ends with .so), makepkg will
159 try to find a binary that depends on the library in the built package and
160 append the version needed by the binary. Appending the version yourself
161 disables auto detection.
163 *makedepends (array)*::
164 An array of packages this package depends on to build but are not
165 needed at runtime. Packages in this list follow the same format as
168 *checkdepends (array)*::
169 An array of packages this package depends on to run its test suite
170 but are not needed at runtime. Packages in this list follow the same
171 format as depends. These dependencies are only considered when the
172 check() function is present and is to be run by makepkg.
174 *optdepends (array)*::
175 An array of packages (and accompanying reasons) that are not essential for
176 base functionality, but may be necessary to make full use of the contents
177 of this package. optdepends are currently for informational purposes only
178 and are not utilized by pacman during dependency resolution. The format
179 for specifying optdepends is:
181 optdepends=('fakeroot: for makepkg usage as normal user')
183 *conflicts (array)*::
184 An array of packages that will conflict with this package (i.e. they
185 cannot both be installed at the same time). This directive follows the
186 same format as depends. Versioned conflicts are supported using the
187 operators as described in `depends`.
190 An array of ``virtual provisions'' this package provides. This allows
191 a package to provide dependencies other than its own package name. For
192 example, the dcron package can provide 'cron', which allows packages to
193 depend on 'cron' rather than 'dcron OR fcron'.
195 Versioned provisions are also possible, in the 'name=version' format. For
196 example, dcron can provide 'cron=2.0' to satisfy the 'cron>=2.0' dependency of
197 other packages. Provisions involving the `>` and `<` operators are invalid as
198 only specific versions of a package may be provided.
200 If the provision name appears to be a library (ends with .so), makepkg will
201 try to find the library in the built package and append the correct
202 version. Appending the version yourself disables auto detection.
205 An array of packages this package should replace. This can be used
206 to handle renamed/combined packages. For example, if the 'j2re' package
207 is renamed to 'jre', this directive allows future upgrades to continue
208 as expected even though the package has moved. Versioned replaces are
209 supported using the operators as described in `depends`.
211 Sysupgrade is currently the only pacman operation that utilizes this field.
212 A normal sync or upgrade will not use its value.
215 This array allows you to override some of makepkg's default behavior
216 when building packages. To set an option, just include the option name
217 in the options array. To reverse the default behavior, place an ``!'' at
218 the front of the option. Only specify the options you specifically want
219 to override, the rest will be taken from linkman:makepkg.conf[5].
220 *NOTE:* 'force' is a now-removed option in favor of the top level 'epoch'
224 Strip symbols from binaries and libraries. If you frequently
225 use a debugger on programs or libraries, it may be helpful to
229 Save doc directories. If you wish to delete doc directories,
230 specify `!docs` in the array.
233 Leave libtool (.la) files in packages. Specify `!libtool` to
237 Leave empty directories in packages.
240 Compress man and info pages with gzip.
243 Compress binary executable files using UPX.
246 Allow the use of ccache during build. More useful in its negative
247 form `!ccache` with select packages that have problems building
251 Allow the use of distcc during build. More useful in its negative
252 form `!distcc` with select packages that have problems building
256 Allow the use of user-specific buildflags (CFLAGS, CXXFLAGS, LDFLAGS)
257 during build as specified in linkman:makepkg.conf[5]. More useful in
258 its negative form `!buildflags` with select packages that have problems
259 building with custom buildflags.
262 Allow the use of user-specific makeflags during build as specified
263 in linkman:makepkg.conf[5]. More useful in its negative form
264 `!makeflags` with select packages that have problems building with
265 custom makeflags such as `-j2` (or higher).
270 In addition to the above directives, the optional build() function usually
271 comprises the remainder of the PKGBUILD. This is directly sourced and executed
272 by makepkg, so anything that bash or the system has available is available for
273 use here. The function is run in `bash -e` mode, meaning any command that exits
274 with a non-zero status will cause the function to exit. Be sure any exotic
275 commands used are covered by `makedepends`.
277 All of the above variables such as `$pkgname` and `$pkgver` are available for use
278 in the build function. In addition, makepkg defines the following three
279 variables for use during the build and install process:
282 This contains the absolute path to the directory where the PKGBUILD is
283 located, which is usually the output of `$(pwd)` when makepkg is started.
284 Use of this variable is deprecated and strongly discouraged.
287 This contains the directory where makepkg extracts, or copies, all source
291 This contains the directory where makepkg bundles the installed package
292 (this directory will become the root directory of your built package).
294 If you create any variables of your own in the build function, it is
295 recommended to use the bash `local` keyword to scope the variable to inside
300 An optional check() function can be specified in which a packages test-suite
301 may be run. This function is run between the build() and package() functions.
302 The function is run in `bash -e` mode, meaning any command that exits with a
303 non-zero status will cause the function to exit. Be sure any exotic commands
304 used are covered by `checkdepends`.
308 An optional package() function can be specified in addition to the build()
309 function. This function is run after the build() and check() functions. The
310 function is run in `bash -e` mode, meaning any command that exits with a
311 non-zero status will cause the function to exit. When specified in combination
312 with the fakeroot BUILDENV option in linkman:makepkg.conf[5], fakeroot usage
313 will be limited to running the packaging stage. An existing build() function
314 will be run as the user calling makepkg.
318 makepkg supports building multiple packages from a single PKGBUILD. This is
319 achieved by assigning an array of package names to the `pkgname` directive.
320 Each split package uses a corresponding packaging function with name
321 `package_foo()`, where `foo` is the name of the split package.
323 All options and directives for the split packages default to the global values
324 given in the PKGBUILD. Nevertheless, the following ones can be overridden within
325 each split package's packaging function:
326 `pkgver`, `pkgrel`, `epoch`, `pkgdesc`, `arch`, `license`, `groups`, `depends`,
327 `optdepends`, `provides`, `conflicts`, `replaces`, `backup`, `options`,
328 `install` and `changelog`.
330 An optional global directive is available when building a split package:
333 The name used to refer to the group of packages in the output of makepkg
334 and in the naming of source-only tarballs. If not specified, the first
335 element in the `pkgname` array is used. The variable is not allowed to
338 Install/Upgrade/Remove Scripting
339 --------------------------------
340 Pacman has the ability to store and execute a package-specific script when it
341 installs, removes, or upgrades a package. This allows a package to configure
342 itself after installation and perform an opposite action upon removal.
344 The exact time the script is run varies with each operation, and should be
345 self-explanatory. Note that during an upgrade operation, none of the install
346 or remove scripts will be called.
348 Scripts are passed either one or two ``full version strings'', where a full
349 version string is either 'pkgver-pkgrel' or 'epoch:pkgver-pkgrel' if epoch is
353 Run right before files are extracted. One argument is passed:
354 new package full version string.
357 Run right after files are extracted. One argument is passed:
358 new package full version string.
361 Run right before files are extracted. Two arguments are passed in this
362 order: new package full version string, old package full version string.
365 Run after files are extracted. Two arguments are passed in this order:
366 new package full version string, old package full version string.
369 Run right before files are removed. One argument is passed:
370 old package full version string.
373 Run right after files are removed. One argument is passed:
374 old package full version string.
376 To use this feature, create a file such as 'pkgname.install' and put it in the
377 same directory as the PKGBUILD script. Then use the install directive:
379 install=pkgname.install
381 The install script does not need to be specified in the source array. A
382 template install file is available in '{pkgdatadir}' as 'proto.install' for
383 reference with all of the available functions defined.
386 Development Directives
387 ----------------------
388 makepkg supports building development versions of packages without having to
389 manually update the pkgver in the PKGBUILD. This was formerly done using the
390 separate utility 'versionpkg'. In order to utilize this functionality, your
391 PKGBUILD must use correct variable names depending on the SCM being fetched
392 from (e.g., 'makepkg-git', 'mplayer-svn').
395 The generated pkgver will be the date the package is built.
398 The root of the CVS repository.
401 The CVS module to fetch.
404 The generated pkgver will be the latest SVN revision number.
407 The trunk of the SVN repository.
410 The SVN module to fetch.
413 The generated pkgver will be the date the package is built.
416 The URL (all protocols supported) to the GIT repository.
419 GIT tag or branch to use.
422 The generated pkgver will be the hg tip revision number.
425 The URL of the mercurial repository.
428 The repository to follow.
431 The generated pkgver will be the date the package is built.
434 URL to the repository trunk.
440 The generated pkgver will be the latest Bazaar revision number (revno).
443 URL to the bazaar repository.
446 Bazaar module to use.
451 The following is an example PKGBUILD for the 'patch' package. For more
452 examples, look through the build files of your distribution's packages. For
453 those using Arch Linux, consult the ABS tree.
456 -------------------------------
457 include::PKGBUILD-example.txt[]
458 -------------------------------
462 linkman:makepkg[8], linkman:pacman[8], linkman:makepkg.conf[5]
464 include::footer.txt[]