update arch pkg
This commit is contained in:
parent
f1ac09f57f
commit
ad237ca6d2
3 changed files with 827 additions and 24 deletions
|
@ -1,17 +1,18 @@
|
||||||
---
|
---
|
||||||
arch-wiki: https://wiki.archlinux.org/title/PKGBUILD
|
arch-wiki: https://wiki.archlinux.org/title/PKGBUILD
|
||||||
obj: concept
|
obj: concept
|
||||||
|
rev: 2024-12-19
|
||||||
---
|
---
|
||||||
|
|
||||||
# PKGBUILD
|
# PKGBUILD
|
||||||
|
|
||||||
A `PKGBUILD` is a shell script containing the build information required by [Arch Linux](../../../linux/Arch%20Linux.md) packages. [Arch Wiki](https://wiki.archlinux.org/title/PKGBUILD)
|
A `PKGBUILD` is a shell script containing the build information required by [Arch Linux](../../../linux/Arch%20Linux.md) packages. [Arch Wiki](https://wiki.archlinux.org/title/PKGBUILD)
|
||||||
|
|
||||||
Packages in [Arch Linux](../../../linux/Arch%20Linux.md) are built using the [makepkg](makepkg.md) utility. When [makepkg](makepkg.md) is run, it searches for a PKGBUILD file in the current directory and follows the instructions therein to either compile or otherwise acquire the files to build a package archive (pkgname.pkg.tar.zst). The resulting package contains binary files and installation instructions, readily installable with [pacman](Pacman.md).
|
Packages in [Arch Linux](../../../linux/Arch%20Linux.md) are built using the [makepkg](makepkg.md) utility. When [makepkg](makepkg.md) is run, it searches for a `PKGBUILD` file in the current directory and follows the instructions therein to either compile or otherwise acquire the files to build a package archive (`pkgname.pkg.tar.zst`). The resulting package contains binary files and installation instructions, readily installable with [pacman](Pacman.md).
|
||||||
|
|
||||||
Mandatory variables are `pkgname`, `pkgver`, `pkgrel`, and `arch`. `license` is not strictly necessary to build a package, but is recommended for any PKGBUILD shared with others, as [makepkg](makepkg.md) will produce a warning if not present.
|
Mandatory variables are `pkgname`, `pkgver`, `pkgrel`, and `arch`. `license` is not strictly necessary to build a package, but is recommended for any `PKGBUILD` shared with others, as [makepkg](makepkg.md) will produce a warning if not present.
|
||||||
|
|
||||||
# Example
|
## Example
|
||||||
PKGBUILD:
|
PKGBUILD:
|
||||||
```sh
|
```sh
|
||||||
# Maintainer: User <mail>
|
# Maintainer: User <mail>
|
||||||
|
@ -49,3 +50,186 @@ package() {
|
||||||
install -Dm755 ./app "$pkgdir/usr/bin/app"
|
install -Dm755 ./app "$pkgdir/usr/bin/app"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Directives
|
||||||
|
The following is a list of standard options and directives available for use in a `PKGBUILD`. These are all understood and interpreted by `makepkg`, and most of them will be directly transferred to the built package.
|
||||||
|
|
||||||
|
If you need to create any custom variables for use in your build process, it is recommended to prefix their name with an `_` (underscore). This will prevent any possible name clashes with internal `makepkg` variables. For example, to store the base kernel version in a variable, use something similar to `$_basekernver`.
|
||||||
|
|
||||||
|
### Name and Version
|
||||||
|
|
||||||
|
#### `pkgname`
|
||||||
|
Either the name of the package or an array of names for split packages.
|
||||||
|
Valid characters for members of this array are alphanumerics, and any of the following characters: `@ . _ + -`. Additionally, names are not allowed to start with hyphens or dots.
|
||||||
|
|
||||||
|
#### `pkgver`
|
||||||
|
The version of the software as released from the author (e.g., `2.7.1`). The variable is not allowed to contain colons, forward slashes, hyphens or whitespace.
|
||||||
|
|
||||||
|
The pkgver variable can be automatically updated by providing a `pkgver()` function in the `PKGBUILD` that outputs the new package version. This is run after downloading and extracting the sources and running the `prepare()` function (if present), so it can use those files in determining the new `pkgver`. This is most useful when used with sources from version control systems.
|
||||||
|
|
||||||
|
#### `pkgrel`
|
||||||
|
This is the release number specific to the distribution. This allows package maintainers to make updates to the package’s configure flags, for example. This is typically set to `1` for each new upstream software release and incremented for intermediate `PKGBUILD` updates. The variable is a positive integer, with an optional subrelease level specified by adding another positive integer separated by a period (i.e. in the form `x.y`).
|
||||||
|
|
||||||
|
#### `epoch`
|
||||||
|
Used to force the package to be seen as newer than any previous versions with a lower epoch, even if the version number would normally not trigger such an upgrade. This value is required to be a positive integer; the default value if left unspecified is 0. This is useful when the version numbering scheme of a package changes (or is alphanumeric), breaking normal version comparison logic.
|
||||||
|
|
||||||
|
### Generic
|
||||||
|
|
||||||
|
#### `pkgdesc`
|
||||||
|
This should be a brief description of the package and its functionality. Try to keep the description to one line of text and to not use the package’s name.
|
||||||
|
|
||||||
|
#### `url`
|
||||||
|
This field contains a URL that is associated with the software being packaged. This is typically the project’s web site.
|
||||||
|
|
||||||
|
#### `license` (array)
|
||||||
|
This field specifies the license(s) that apply to the package. If multiple licenses are applicable, list all of them: `license=('GPL' 'FDL')`.
|
||||||
|
|
||||||
|
#### `arch` (array)
|
||||||
|
Defines on which architectures the given package is available (e.g., `arch=('i686' 'x86_64')`). Packages that contain no architecture specific files should use `arch=('any')`. Valid characters for members of this array are alphanumerics and `_`.
|
||||||
|
|
||||||
|
#### `groups` (array)
|
||||||
|
An array of symbolic names that represent groups of packages, allowing you to install multiple packages by requesting a single target. For example, one could install all KDE packages by installing the kde group.
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
|
#### `depends` (array)
|
||||||
|
An array of packages this package depends on to run. Entries in this list should be surrounded with single quotes and contain at least the package name. Entries can also include a version requirement of the form `name<>version`, where `<>` is one of five comparisons: `>=` (greater than or equal to), `<=` (less than or equal to), `=` (equal to), `>` (greater than), or `<` (less than).
|
||||||
|
|
||||||
|
If the dependency name appears to be a library (ends with `.so`), `makepkg` will try to find a binary that depends on the library in the built package and append the version needed by the binary. Appending the version yourself disables automatic detection.
|
||||||
|
|
||||||
|
Additional architecture-specific depends can be added by appending an underscore and the architecture name e.g., `depends_x86_64=()`.
|
||||||
|
|
||||||
|
#### `makedepends` (array)
|
||||||
|
An array of packages this package depends on to build but are not needed at runtime. Packages in this list follow the same format as `depends`.
|
||||||
|
|
||||||
|
Additional architecture-specific `makedepends` can be added by appending an underscore and the architecture name e.g., `makedepends_x86_64=()`.
|
||||||
|
|
||||||
|
#### `checkdepends` (array)
|
||||||
|
An array of packages this package depends on to run its test suite but are not needed at runtime. Packages in this list follow the same format as depends. These dependencies are only considered when the `check()` function is present and is to be run by `makepkg`.
|
||||||
|
|
||||||
|
Additional architecture-specific checkdepends can be added by appending an underscore and the architecture name e.g., `checkdepends_x86_64=()`
|
||||||
|
|
||||||
|
#### `optdepends` (array)
|
||||||
|
An array of packages (and accompanying reasons) that are not essential for base functionality, but may be necessary to make full use of the contents of this package. optdepends are currently for informational purposes only and are not utilized by pacman during dependency resolution. Packages in this list follow the same format as depends, with an optional description appended. The format for specifying optdepends descriptions is:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
optdepends=('python: for library bindings')
|
||||||
|
```
|
||||||
|
|
||||||
|
Additional architecture-specific optdepends can be added by appending an underscore and the architecture name e.g., `optdepends_x86_64=()`.
|
||||||
|
|
||||||
|
### Package Relations
|
||||||
|
|
||||||
|
#### `provides` (array)
|
||||||
|
An array of “virtual provisions” this package provides. This allows a package to provide dependencies other than its own package name. For example, the `dcron` package can provide `cron`, which allows packages to depend on `cron` rather than `dcron` OR `fcron`.
|
||||||
|
|
||||||
|
Versioned provisions are also possible, in the `name=version` format. For example, `dcron` can provide `cron=2.0` to satisfy the `cron>=2.0` dependency of other packages. Provisions involving the `>` and `<` operators are invalid as only specific versions of a package may be provided.
|
||||||
|
|
||||||
|
If the provision name appears to be a library (ends with `.so`), makepkg will try to find the library in the built package and append the correct version. Appending the version yourself disables automatic detection.
|
||||||
|
|
||||||
|
Additional architecture-specific provides can be added by appending an underscore and the architecture name e.g., `provides_x86_64=()`.
|
||||||
|
|
||||||
|
#### `conflicts` (array)
|
||||||
|
An array of packages that will conflict with this package (i.e. they cannot both be installed at the same time). This directive follows the same format as `depends`. Versioned conflicts are supported using the operators as described in `depends`.
|
||||||
|
|
||||||
|
Additional architecture-specific conflicts can be added by appending an underscore and the architecture name e.g., `conflicts_x86_64=()`.
|
||||||
|
|
||||||
|
#### `replaces` (array)
|
||||||
|
An array of packages this package should replace. This can be used to handle renamed/combined packages. For example, if the `j2re` package is renamed to `jre`, this directive allows future upgrades to continue as expected even though the package has moved. Versioned replaces are supported using the operators as described in `depends`.
|
||||||
|
|
||||||
|
Sysupgrade is currently the only pacman operation that utilizes this field. A normal sync or upgrade will not use its value.
|
||||||
|
|
||||||
|
Additional architecture-specific replaces can be added by appending an underscore and the architecture name e.g., `replaces_x86_64=()`.
|
||||||
|
|
||||||
|
### Other
|
||||||
|
|
||||||
|
#### `backup` (array)
|
||||||
|
An array of file names, without preceding slashes, that should be backed up if the package is removed or upgraded. This is commonly used for packages placing configuration files in `/etc`.
|
||||||
|
|
||||||
|
#### `options` (array)
|
||||||
|
This array allows you to override some of makepkg’s default behavior when building packages. To set an option, just include the option name in the `options` array. To reverse the default behavior, place an `!` at the front of the option. Only specify the options you specifically want to override, the rest will be taken from `makepkg.conf`
|
||||||
|
|
||||||
|
| Option | Description |
|
||||||
|
| ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
|
| `strip` | Strip symbols from binaries and libraries. If you frequently use a debugger on programs or libraries, it may be helpful to disable this option. |
|
||||||
|
| `docs` | Save doc directories. If you wish to delete doc directories, specify `!docs` in the array. |
|
||||||
|
| `libtool` | Leave libtool (`.la`) files in packages. Specify `!libtool` to remove them. |
|
||||||
|
| `staticlibs` | Leave static library (`.a`) files in packages. Specify `!staticlibs` to remove them (if they have a shared counterpart). |
|
||||||
|
| `emptydirs` | Leave empty directories in packages. |
|
||||||
|
| `zipman` | Compress man and info pages with gzip. |
|
||||||
|
| `ccache` | Allow the use of ccache during `build()`. More useful in its negative form `!ccache` with select packages that have problems building with ccache. |
|
||||||
|
| `distcc` | Allow the use of distcc during `build()`. More useful in its negative form `!distcc` with select packages that have problems building with distcc. |
|
||||||
|
| `buildflags` | Allow the use of user-specific buildflags (`CPPFLAGS`, `CFLAGS`, `CXXFLAGS`, `LDFLAGS`) during `build()` as specified in `makepkg.conf`. More useful in its negative form `!buildflags` with select packages that have problems building with custom buildflags. |
|
||||||
|
| `makeflags` | Allow the use of user-specific makeflags during `build()` as specified in `makepkg.conf`. More useful in its negative form `!makeflags` with select packages that have problems building with custom makeflags such as `-j2`. |
|
||||||
|
| `debug` | Add the user-specified debug flags (`DEBUG_CFLAGS`, `DEBUG_CXXFLAGS`) to their counterpart buildflags as specified in `makepkg.conf`. When used in combination with the `strip` option, a separate package containing the debug symbols is created. |
|
||||||
|
| `lto` | Enable building packages using link time optimization. Adds `-flto` to both `CFLAGS` and `CXXFLAGS`. |
|
||||||
|
|
||||||
|
#### `install`
|
||||||
|
Specifies a special install script that is to be included in the package. This file should reside in the same directory as the `PKGBUILD` and will be copied into the package by `makepkg`. It does not need to be included in the source array (e.g., `install=$pkgname.install`).
|
||||||
|
|
||||||
|
Pacman has the ability to store and execute a package-specific script when it installs, removes, or upgrades a package. This allows a package to configure itself after installation and perform an opposite action upon removal.
|
||||||
|
|
||||||
|
The exact time the script is run varies with each operation, and should be self-explanatory. Note that during an upgrade operation, none of the install or remove functions will be called.
|
||||||
|
|
||||||
|
Scripts are passed either one or two “full version strings”, where a full version string is either `pkgver-pkgrel` or `epoch:pkgver-pkgrel`, if `epoch` is non-zero.
|
||||||
|
|
||||||
|
- `pre_install`: Run right before files are extracted. One argument is passed: new package full version string.
|
||||||
|
- `post_install`: Run right after files are extracted. One argument is passed: new package full version string.
|
||||||
|
- `pre_upgrade`: Run right before files are extracted. Two arguments are passed in this order: new package full version string, old package full version string.
|
||||||
|
- `post_upgrade`: Run after files are extracted. Two arguments are passed in this order: new package full version string, old package full version string.
|
||||||
|
- `pre_remove`: Run right before files are removed. One argument is passed: old package full version string.
|
||||||
|
- `post_remove`: Run right after files are removed. One argument is passed: old package full version string.
|
||||||
|
|
||||||
|
To use this feature, create a file such as `pkgname.install` and put it in the same directory as the `PKGBUILD` script. Then use the install directive: `install=pkgname.install`
|
||||||
|
|
||||||
|
#### `changelog`
|
||||||
|
Specifies a changelog file that is to be included in the package. The changelog file should end in a single newline. This file should reside in the same directory as the `PKGBUILD` and will be copied into the package by `makepkg`. It does not need to be included in the source array (e.g., `changelog=$pkgname.changelog`).
|
||||||
|
|
||||||
|
### Sources
|
||||||
|
|
||||||
|
#### `source` (array)
|
||||||
|
An array of source files required to build the package. Source files must either reside in the same directory as the `PKGBUILD`, or be a fully-qualified URL that `makepkg` can use to download the file. To simplify the maintenance of `PKGBUILDs`, use the `$pkgname` and `$pkgver` variables when specifying the download location, if possible. Compressed files will be extracted automatically unless found in the `noextract` array described below.
|
||||||
|
|
||||||
|
Additional architecture-specific sources can be added by appending an underscore and the architecture name e.g., `source_x86_64=()`. There must be a corresponding integrity array with checksums, e.g. `cksums_x86_64=()`.
|
||||||
|
|
||||||
|
It is also possible to change the name of the downloaded file, which is helpful with weird URLs and for handling multiple source files with the same name. The syntax is: `source=('filename::url')`.
|
||||||
|
|
||||||
|
Files in the source array with extensions `.sig`, `.sign` or, `.asc` are recognized by makepkg as PGP signatures and will be automatically used to verify the integrity of the corresponding source file.
|
||||||
|
|
||||||
|
#### `noextract` (array)
|
||||||
|
An array of file names corresponding to those from the source array. Files listed here will not be extracted with the rest of the source files. This is useful for packages that use compressed data directly.
|
||||||
|
|
||||||
|
#### `validpgpkeys` (array)
|
||||||
|
An array of PGP fingerprints. If this array is non-empty, `makepkg` will only accept signatures from the keys listed here and will ignore the trust values from the keyring. If the source file was signed with a subkey, `makepkg` will still use the primary key for comparison.
|
||||||
|
|
||||||
|
Only full fingerprints are accepted. They must be uppercase and must not contain whitespace characters.
|
||||||
|
|
||||||
|
### Integrity
|
||||||
|
|
||||||
|
#### `cksums` (array)
|
||||||
|
This array contains CRC checksums for every source file specified in the source array (in the same order). `makepkg` will use this to verify source file integrity during subsequent builds. If `SKIP` is put in the array in place of a normal hash, the integrity check for that source file will be skipped. To easily generate cksums, run `makepkg -g >> PKGBUILD`. If desired, move the cksums line to an appropriate location. Note that checksums generated by `makepkg -g` should be verified using checksum values provided by the software developer.
|
||||||
|
|
||||||
|
#### `md5sums`, `sha1sums`, `sha224sums`, `sha256sums`, `sha384sums`, `sha512sums`, `b2sums` (arrays)
|
||||||
|
Alternative integrity checks that `makepkg` supports; these all behave similar to the cksums option described above. To enable use and generation of these checksums, be sure to set up the `INTEGRITY_CHECK` option in `makepkg.conf`.
|
||||||
|
|
||||||
|
## Packaging Functions
|
||||||
|
In addition to the above directives, `PKGBUILDs` require a set of functions that provide instructions to build and install the package. As a minimum, the `PKGBUILD` must contain a `package()` function which installs all the package’s files into the packaging directory, with optional `prepare()`, `build()`, and `check()` functions being used to create those files from source.
|
||||||
|
|
||||||
|
This is directly sourced and executed by `makepkg`, so anything that Bash or the system has available is available for use here. Be sure any exotic commands used are covered by the `makedepends` array.
|
||||||
|
|
||||||
|
If you create any variables of your own in any of these functions, it is recommended to use the Bash `local` keyword to scope the variable to inside the function.
|
||||||
|
|
||||||
|
### `package()` Function
|
||||||
|
The `package()` function is used to install files into the directory that will become the root directory of the built package and is run after all the optional functions listed below. The packaging stage is run using `fakeroot` to ensure correct file permissions in the resulting package. All other functions will be run as the user calling `makepkg`. This function is run inside `$srcdir`.
|
||||||
|
|
||||||
|
### `verify()` Function
|
||||||
|
An optional `verify()` function can be specified to implement arbitrary source authentication. The function should return a non-zero exit code when verification fails. This function is run before sources are extracted. This function is run inside `$startdir`.
|
||||||
|
|
||||||
|
### `prepare()` Function
|
||||||
|
An optional `prepare()` function can be specified in which operations to prepare the sources for building, such as patching, are performed. This function is run after the source extraction and before the `build()` function. The `prepare()` function is skipped when source extraction is skipped. This function is run inside `$srcdir`.
|
||||||
|
|
||||||
|
### `build()` Function
|
||||||
|
The optional `build()` function is used to compile and/or adjust the source files in preparation to be installed by the `package()` function. This function is run inside `$srcdir`.
|
||||||
|
|
||||||
|
### `check()` Function
|
||||||
|
An optional `check()` function can be specified in which a package’s test-suite may be run. This function is run between the `build()` and `package()` functions. Be sure any exotic commands used are covered by the `checkdepends` array. This function is run inside `$srcdir`.
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
---
|
---
|
||||||
obj: application
|
obj: application
|
||||||
|
arch-wiki: https://wiki.archlinux.org/title/Pacman
|
||||||
|
rev: 2024-12-19
|
||||||
---
|
---
|
||||||
|
|
||||||
# Pacman
|
# Pacman
|
||||||
Pacman is the default [Arch Linux](../../../linux/Arch%20Linux.md) Package Manager
|
Pacman is the default [Arch Linux](../../../linux/Arch%20Linux.md) Package Manager
|
||||||
|
|
||||||
|
@ -56,6 +59,363 @@ pacman -Q
|
||||||
```
|
```
|
||||||
|
|
||||||
Empty the entire pacman cache:
|
Empty the entire pacman cache:
|
||||||
```shell
|
```shel
|
||||||
pacman -Scc
|
pacman -Scc
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Read changelog of package:
|
||||||
|
```shell
|
||||||
|
pacman -Qc pkgname
|
||||||
|
```
|
||||||
|
|
||||||
|
### File Conflicts
|
||||||
|
When pacman removes a package that has a configuration file, it normally creates a backup copy of that configuration file and appends `.pacsave` to the name of the file. Likewise, when pacman upgrades a package which includes a new configuration file created by the maintainer differing from the currently installed file, it saves a `.pacnew` file with the new configuration. pacman provides notice when these files are written.
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
Pacman, using libalpm, will attempt to read `pacman.conf` each time it is invoked. This configuration file is divided into sections or repositories. Each section defines a package repository that pacman can use when searching for packages in `--sync` mode. The exception to this is the `[options]` section, which defines global options.
|
||||||
|
|
||||||
|
```ini
|
||||||
|
# /etc/pacman.conf
|
||||||
|
|
||||||
|
[options]
|
||||||
|
# Set the default root directory for pacman to install to.
|
||||||
|
# This option is used if you want to install a package on a temporary mounted partition which is "owned" by another system, or for a chroot install.
|
||||||
|
# NOTE: If database path or log file are not specified on either the command line or in pacman.conf(5), their default location will be inside this root path.
|
||||||
|
RootDir = /path/to/root/dir
|
||||||
|
|
||||||
|
# Overrides the default location of the toplevel database directory.
|
||||||
|
# The default is /var/lib/pacman/.
|
||||||
|
# Most users will not need to set this option.
|
||||||
|
# NOTE: if specified, this is an absolute path and the root path is not automatically prepended.
|
||||||
|
DBPath = /path/to/db/dir
|
||||||
|
|
||||||
|
# Overrides the default location of the package cache directory.
|
||||||
|
# The default is /var/cache/pacman/pkg/.
|
||||||
|
# Multiple cache directories can be specified, and they are tried in the order they are listed in the config file.
|
||||||
|
# If a file is not found in any cache directory, it will be downloaded to the first cache directory with write access.
|
||||||
|
# NOTE: this is an absolute path, the root path is not automatically prepended.
|
||||||
|
CacheDir = /path/to/cache/dir
|
||||||
|
|
||||||
|
# Add directories to search for alpm hooks in addition to the system hook directory (/usr/share/libalpm/hooks/).
|
||||||
|
# The default is /etc/pacman.d/hooks.
|
||||||
|
# Multiple directories can be specified with hooks in later directories taking precedence over hooks in earlier directories.
|
||||||
|
# NOTE: this is an absolute path, the root path is not automatically prepended. For more information on the alpm hooks, see alpm-hooks(5).
|
||||||
|
HookDir = /path/to/hook/dir
|
||||||
|
|
||||||
|
# Overrides the default location of the directory containing configuration files for GnuPG.
|
||||||
|
# The default is /etc/pacman.d/gnupg/.
|
||||||
|
# This directory should contain two files: pubring.gpg and trustdb.gpg.
|
||||||
|
# pubring.gpg holds the public keys of all packagers. trustdb.gpg contains a so-called trust database, which specifies that the keys are authentic and trusted.
|
||||||
|
# NOTE: this is an absolute path, the root path is not automatically prepended.
|
||||||
|
GPGDir = /path/to/gpg/dir
|
||||||
|
|
||||||
|
# Overrides the default location of the pacman log file.
|
||||||
|
# The default is /var/log/pacman.log.
|
||||||
|
# This is an absolute path and the root directory is not prepended.
|
||||||
|
LogFile = /path/to/log/file
|
||||||
|
|
||||||
|
# If a user tries to --remove a package that’s listed in HoldPkg, pacman will ask for confirmation before proceeding. Shell-style glob patterns are allowed.
|
||||||
|
HoldPkg = package ...
|
||||||
|
|
||||||
|
# Instructs pacman to ignore any upgrades for this package when performing a --sysupgrade. Shell-style glob patterns are allowed.
|
||||||
|
IgnorePkg = package ...
|
||||||
|
|
||||||
|
# Instructs pacman to ignore any upgrades for all packages in this group when performing a --sysupgrade. Shell-style glob patterns are allowed.
|
||||||
|
IgnoreGroup = group ...
|
||||||
|
|
||||||
|
# Include another configuration file.
|
||||||
|
# This file can include repositories or general configuration options.
|
||||||
|
# Wildcards in the specified paths will get expanded based on glob rules.
|
||||||
|
Include = /path/to/config/file
|
||||||
|
|
||||||
|
# If set, pacman will only allow installation of packages with the given architectures (e.g. i686, x86_64, etc).
|
||||||
|
# The special value auto will use the system architecture, provided via “uname -m”.
|
||||||
|
# If unset, no architecture checks are made.
|
||||||
|
# NOTE: Packages with the special architecture any can always be installed, as they are meant to be architecture independent.
|
||||||
|
Architecture = auto &| i686 &| x86_64 | ...
|
||||||
|
|
||||||
|
# If set, an external program will be used to download all remote files.
|
||||||
|
# All instances of %u will be replaced with the download URL.
|
||||||
|
# If present, instances of %o will be replaced with the local filename, plus a “.part” extension, which allows programs like wget to do file resumes properly.
|
||||||
|
XferCommand = /path/to/command %u [%o]
|
||||||
|
|
||||||
|
# All files listed with a NoUpgrade directive will never be touched during a package install/upgrade, and the new files will be installed with a .pacnew extension.
|
||||||
|
# These files refer to files in the package archive, so do not include the leading slash (the RootDir) when specifying them.
|
||||||
|
# Shell-style glob patterns are allowed. It is possible to invert matches by prepending a file with an exclamation mark.
|
||||||
|
# Inverted files will result in previously blacklisted files being whitelisted again. Subsequent matches will override previous ones.
|
||||||
|
# A leading literal exclamation mark or backslash needs to be escaped.
|
||||||
|
NoUpgrade = file ...
|
||||||
|
|
||||||
|
# All files listed with a NoExtract directive will never be extracted from a package into the filesystem.
|
||||||
|
# This can be useful when you don’t want part of a package to be installed.
|
||||||
|
# For example, if your httpd root uses an index.php, then you would not want the index.html file to be extracted from the apache package.
|
||||||
|
# These files refer to files in the package archive, so do not include the leading slash (the RootDir) when specifying them.
|
||||||
|
# Shell-style glob patterns are allowed. It is possible to invert matches by prepending a file with an exclamation mark.
|
||||||
|
# Inverted files will result in previously blacklisted files being whitelisted again. Subsequent matches will override previous ones.
|
||||||
|
# A leading literal exclamation mark or backslash needs to be escaped.
|
||||||
|
NoExtract = file ...
|
||||||
|
|
||||||
|
# If set to KeepInstalled (the default), the -Sc operation will clean packages that are no longer installed (not present in the local database).
|
||||||
|
# If set to KeepCurrent, -Sc will clean outdated packages (not present in any sync database).
|
||||||
|
# The second behavior is useful when the package cache is shared among multiple machines, where the local databases are usually different, but the sync databases in use could be the same.
|
||||||
|
# If both values are specified, packages are only cleaned if not installed locally and not present in any known sync database.
|
||||||
|
CleanMethod = KeepInstalled &| KeepCurrent
|
||||||
|
|
||||||
|
# Set the default signature verification level. For more information, see Package and Database Signature Checking below.
|
||||||
|
SigLevel = ...
|
||||||
|
|
||||||
|
# Set the signature verification level for installing packages using the "-U" operation on a local file. Uses the value from SigLevel as the default.
|
||||||
|
LocalFileSigLevel = ...
|
||||||
|
|
||||||
|
# Set the signature verification level for installing packages using the "-U" operation on a remote file URL. Uses the value from SigLevel as the default.
|
||||||
|
RemoteFileSigLevel = ...
|
||||||
|
|
||||||
|
# Log action messages through syslog().
|
||||||
|
# This will insert log entries into /var/log/messages or equivalent.
|
||||||
|
UseSyslog
|
||||||
|
|
||||||
|
# Automatically enable colors only when pacman’s output is on a tty.
|
||||||
|
Color
|
||||||
|
|
||||||
|
# Disables progress bars. This is useful for terminals which do not support escape characters.
|
||||||
|
NoProgressBar
|
||||||
|
|
||||||
|
# Performs an approximate check for adequate available disk space before installing packages.
|
||||||
|
CheckSpace
|
||||||
|
|
||||||
|
# Displays name, version and size of target packages formatted as a table for upgrade, sync and remove operations.
|
||||||
|
VerbosePkgLists
|
||||||
|
|
||||||
|
# Disable defaults for low speed limit and timeout on downloads.
|
||||||
|
# Use this if you have issues downloading files with proxy and/or security gateway.
|
||||||
|
DisableDownloadTimeout
|
||||||
|
|
||||||
|
# Specifies number of concurrent download streams.
|
||||||
|
# The value needs to be a positive integer.
|
||||||
|
# If this config option is not set then only one download stream is used (i.e. downloads happen sequentially).
|
||||||
|
ParallelDownloads = ...
|
||||||
|
|
||||||
|
# Specifies the user to switch to for downloading files.
|
||||||
|
# If this config option is not set then the downloads are done as the user running pacman.
|
||||||
|
DownloadUser = username
|
||||||
|
|
||||||
|
# Disable the default sandbox applied to the process downloading files on Linux systems.
|
||||||
|
# Useful if experiencing landlock related failures while downloading files when running a Linux kernel that does not support this feature.
|
||||||
|
DisableSandbox
|
||||||
|
```
|
||||||
|
|
||||||
|
### Repository Sections
|
||||||
|
Each repository section defines a section name and at least one location where the packages can be found. The section name is defined by the string within square brackets (the two above are core and custom). Repository names must be unique and the name local is reserved for the database of installed packages. Locations are defined with the Server directive and follow a URL naming structure. If you want to use a local directory, you can specify the full path with a `file://` prefix, as shown above.
|
||||||
|
|
||||||
|
A common way to define DB locations utilizes the Include directive. For each repository defined in the configuration file, a single Include directive can contain a file that lists the servers for that repository.
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[core]
|
||||||
|
# use this server first
|
||||||
|
Server = ftp://ftp.archlinux.org/$repo/os/$arch
|
||||||
|
# next use servers as defined in the mirrorlist below
|
||||||
|
Include = {sysconfdir}/pacman.d/mirrorlist
|
||||||
|
|
||||||
|
# Include another config file.
|
||||||
|
Include = path
|
||||||
|
|
||||||
|
# A full URL to a location where the packages, and signatures (if available) for this repository can be found.
|
||||||
|
# Cache servers will be tried before any non-cache servers, will not be removed from the server pool for 404 download errors, and will not be used for database files.
|
||||||
|
CacheServer = url
|
||||||
|
|
||||||
|
# A full URL to a location where the database, packages, and signatures (if available) for this repository can be found.
|
||||||
|
Server = url
|
||||||
|
|
||||||
|
# Set the signature verification level for this repository. For more information, see Package and Database Signature Checking below.
|
||||||
|
SigLevel = ...
|
||||||
|
|
||||||
|
# Set the usage level for this repository. This option takes a list of tokens which must be at least one of the following:
|
||||||
|
# Sync : Enables refreshes for this repository.
|
||||||
|
# Search : Enables searching for this repository.
|
||||||
|
# Install : Enables installation of packages from this repository during a --sync operation.
|
||||||
|
# Upgrade : Allows this repository to be a valid source of packages when performing a --sysupgrade.
|
||||||
|
# All : Enables all of the above features for the repository. This is the default if not specified.
|
||||||
|
# Note that an enabled repository can be operated on explicitly, regardless of the Usage level set.
|
||||||
|
Usage = ...
|
||||||
|
```
|
||||||
|
|
||||||
|
### Signature Checking
|
||||||
|
The `SigLevel` directive is valid in both the `[options]` and repository sections. If used in `[options]`, it sets a default value for any repository that does not provide the setting.
|
||||||
|
- If set to `Never`, no signature checking will take place.
|
||||||
|
- If set to `Optional` , signatures will be checked when present, but unsigned databases and packages will also be accepted.
|
||||||
|
- If set to `Required`, signatures will be required on all packages and databases.
|
||||||
|
|
||||||
|
### Hooks
|
||||||
|
libalpm provides the ability to specify hooks to run before or after transactions based on the packages and/or files being modified. Hooks consist of a single `[Action]` section describing the action to be run and one or more `[Trigger]` section describing which transactions it should be run for.
|
||||||
|
|
||||||
|
Hooks are read from files located in the system hook directory `/usr/share/libalpm/hooks`, and additional custom directories specified in pacman.conf (the default is `/etc/pacman.d/hooks`). The file names are required to have the suffix `.hook`. Hooks are run in alphabetical order of their file name, where the ordering ignores the suffix.
|
||||||
|
|
||||||
|
Hooks may be overridden by placing a file with the same name in a higher priority hook directory. Hooks may be disabled by overriding them with a symlink to `/dev/null`.
|
||||||
|
|
||||||
|
Hooks must contain at least one `[Trigger]` section that determines which transactions will cause the hook to run. If multiple trigger sections are defined the hook will run if the transaction matches any of the triggers.
|
||||||
|
|
||||||
|
```ini
|
||||||
|
# Example: Force disks to sync to reduce the risk of data corruption
|
||||||
|
|
||||||
|
[Trigger]
|
||||||
|
# Select the type of operation to match targets against.
|
||||||
|
# May be specified multiple times.
|
||||||
|
# Installations are considered an upgrade if the package or file is already present on the system regardless of whether the new package version is actually greater than the currently installed version. For Path triggers, this is true even if the file changes ownership from one package to another.
|
||||||
|
# Operation = Install | Upgrade | Remove
|
||||||
|
Operation = Install
|
||||||
|
Operation = Upgrade
|
||||||
|
Operation = Remove
|
||||||
|
|
||||||
|
# Select whether targets are matched against transaction packages or files.
|
||||||
|
# Type = Path|Package
|
||||||
|
Type = Package
|
||||||
|
|
||||||
|
# The path or package name to match against the active transaction.
|
||||||
|
# Paths refer to the files in the package archive; the installation root should not be included in the path.
|
||||||
|
# Shell-style glob patterns are allowed. It is possible to invert matches by prepending a target with an exclamation mark. May be specified multiple times.
|
||||||
|
# Target = <path|package>
|
||||||
|
Target = *
|
||||||
|
|
||||||
|
[Action]
|
||||||
|
# An optional description that describes the action being taken by the hook for use in front-end output.
|
||||||
|
# Description = ...
|
||||||
|
|
||||||
|
# Packages that must be installed for the hook to run. May be specified multiple times.
|
||||||
|
# Depends = <package>
|
||||||
|
Depends = coreutils
|
||||||
|
|
||||||
|
# When to run the hook. Required.
|
||||||
|
# When = PreTransaction | PostTransaction
|
||||||
|
When = PostTransaction
|
||||||
|
|
||||||
|
# Command to run.
|
||||||
|
# Command arguments are split on whitespace. Values containing whitespace should be enclosed in quotes.
|
||||||
|
# Exec = <command>
|
||||||
|
Exec = /usr/bin/sync
|
||||||
|
|
||||||
|
# Causes the transaction to be aborted if the hook exits non-zero. Only applies to PreTransaction hooks.
|
||||||
|
# AbortOnFail
|
||||||
|
|
||||||
|
# Causes the list of matched trigger targets to be passed to the running hook on stdin.
|
||||||
|
# NeedsTargets
|
||||||
|
```
|
||||||
|
|
||||||
|
## Repositories
|
||||||
|
You can create your own package repository.
|
||||||
|
|
||||||
|
A repository essentially consists of:
|
||||||
|
- the packages (`.tar.zst`) and their signatures (`.tar.zst.sig`)
|
||||||
|
- a package index (`.db.tar.gz`)
|
||||||
|
|
||||||
|
### Adding a repo
|
||||||
|
To use a repo, add it to your `pacman.conf`:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
|
||||||
|
# Local Repository
|
||||||
|
[myrepo]
|
||||||
|
SigLevel = Optional TrustAll
|
||||||
|
Server = file:///path/to/myrepo
|
||||||
|
|
||||||
|
# Remote Repository
|
||||||
|
[myrepo]
|
||||||
|
SigLevel = Optional
|
||||||
|
Server = http://yourserver.com/myrepo
|
||||||
|
```
|
||||||
|
|
||||||
|
### Package Database
|
||||||
|
To manage the package data (index) use the `repo-add` and `repo-remove` commands.
|
||||||
|
|
||||||
|
`repo-add` will update a package database by reading a built package file. Multiple packages to add can be specified on the command line.
|
||||||
|
If a matching `.sig` file is found alongside a package file, the signature will automatically be embedded into the database.
|
||||||
|
|
||||||
|
`repo-remove` will update a package database by removing the package name specified on the command line. Multiple packages to remove can be specified on the command line.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
repo-add [options] <path-to-db> <package> [<package> ...]
|
||||||
|
repo-remove [options] <path-to-db> <packagename> [<packagename> ...]
|
||||||
|
```
|
||||||
|
|
||||||
|
| Option | Description |
|
||||||
|
| ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
|
| `-q, --quiet` | Force this program to keep quiet and run silently except for warning and error messages. |
|
||||||
|
| `-s, --sign` | Generate a PGP signature file using GnuPG. This will execute `gpg --detach-sign` on the generated database to generate a detached signature file, using the GPG agent if it is available. |
|
||||||
|
| `-k, --key <key>` | Specify a key to use when signing packages. Can also be specified using the `GPGKEY` environment variable. If not specified in either location, the default key from the keyring will be used. |
|
||||||
|
| `-v, --verify` | Verify the PGP signature of the database before updating the database. If the signature is invalid, an error is produced and the update does not proceed. |
|
||||||
|
| `--nocolor` | Remove color from repo-add and repo-remove output. |
|
||||||
|
| **`repo-add` ONLY OPTIONS:** | - |
|
||||||
|
| `-n, --new` | Only add packages that are not already in the database. Warnings will be printed upon detection of existing packages, but they will not be re-added. |
|
||||||
|
| `-R, --remove` | Remove old package files from the disk when updating their entry in the database. |
|
||||||
|
| `--include-sigs` | Include package PGP signatures in the repository database (if available) |
|
||||||
|
|
||||||
|
## Package Signing
|
||||||
|
To determine if packages are authentic, pacman uses OpenPGP keys in a web of trust model. Each user also has a unique OpenPGP key, which is generated when you configure `pacman-key`.
|
||||||
|
|
||||||
|
Examples of webs of trust:
|
||||||
|
- Custom packages: Packages made and signed with a local key.
|
||||||
|
- Unofficial packages: Packages made and signed by a developer. Then, a local key was used to sign the developer's key.
|
||||||
|
- Official packages: Packages made and signed by a developer. The developer's key was signed by the Arch Linux master keys. You used your key to sign the master keys, and you trust them to vouch for developers.
|
||||||
|
|
||||||
|
### Setup
|
||||||
|
The `SigLevel` option in `/etc/pacman.conf` determines the level of trust required to install a package with `pacman -S`. One can set signature checking globally, or per repository. If `SigLevel` is set globally in the `[options]` section, all packages installed with `pacman -S` will require signing. With the `LocalFileSigLevel` setting from the default `pacman.conf`, any packages you build, and install with `pacman -U`, will not need to be signed using `makepkg`.
|
||||||
|
|
||||||
|
For remote packages, the default configuration will only support the installation of packages signed by trusted keys:
|
||||||
|
|
||||||
|
```
|
||||||
|
# /etc/pacman.conf
|
||||||
|
SigLevel = Required DatabaseOptional TrustedOnly
|
||||||
|
```
|
||||||
|
|
||||||
|
To initialize the pacman keyring run:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pacman-key --init
|
||||||
|
```
|
||||||
|
|
||||||
|
### Keyring Management
|
||||||
|
#### Verifying the master keys
|
||||||
|
The initial setup of keys is achieved using:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pacman-key --populate
|
||||||
|
```
|
||||||
|
|
||||||
|
OpenPGP keys are too large (2048 bits or more) for humans to work with, so they are usually hashed to create a 40-hex-digit fingerprint which can be used to check by hand that two keys are the same. The last eight digits of the fingerprint serve as a name for the key known as the '(short) key ID' (the last sixteen digits of the fingerprint would be the 'long key ID').
|
||||||
|
|
||||||
|
#### Adding developer keys
|
||||||
|
The official Developers' and Package Maintainers' keys are signed by the master keys, so you do not need to use `pacman-key` to sign them yourself. Whenever pacman encounters a key it does not recognize, it will prompt you to download it from a keyserver configured in `/etc/pacman.d/gnupg/gpg.conf` (or by using the `--keyserver` option on the command line).
|
||||||
|
|
||||||
|
Once you have downloaded a developer key, you will not have to download it again, and it can be used to verify any other packages signed by that developer.
|
||||||
|
|
||||||
|
> **Note**: The `archlinux-keyring` package, which is a dependency of base, contains the latest keys. However keys can also be updated manually using `pacman-key --refresh-keys` (as root). While doing `--refresh-keys`, your local key will also be looked up on the remote keyserver, and you will receive a message about it not being found. This is nothing to be concerned about.
|
||||||
|
|
||||||
|
#### Adding unofficial keys
|
||||||
|
This method can be utilized to add a key to the pacman keyring, or to enable signed unofficial user repositories.
|
||||||
|
|
||||||
|
First, get the key ID (keyid) from its owner. Then add it to the keyring using one of the two methods:
|
||||||
|
|
||||||
|
If the key is found on a keyserver, import it with:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pacman-key --recv-keys keyid
|
||||||
|
```
|
||||||
|
|
||||||
|
If otherwise a link to a keyfile is provided, download it and then run:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pacman-key --add /path/to/downloaded/keyfile
|
||||||
|
```
|
||||||
|
|
||||||
|
It is recommended to verify the fingerprint, as with any master key or any other key you are going to sign:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pacman-key --finger keyid
|
||||||
|
```
|
||||||
|
|
||||||
|
Finally, you must locally sign the imported key:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pacman-key --lsign-key keyid
|
||||||
|
```
|
||||||
|
|
||||||
|
You now trust this key to sign packages.
|
||||||
|
|
|
@ -1,11 +1,190 @@
|
||||||
---
|
---
|
||||||
arch-wiki: https://wiki.archlinux.org/title/Makepkg
|
arch-wiki: https://wiki.archlinux.org/title/Makepkg
|
||||||
obj: application
|
obj: application
|
||||||
|
rev: 2024-12-19
|
||||||
---
|
---
|
||||||
|
|
||||||
# makepkg
|
# makepkg
|
||||||
makepkg is a tool for creating [pacman](Pacman.md) packages based on [PKGBUILD](PKGBUILD.md) files.
|
makepkg is a tool for creating [pacman](Pacman.md) packages based on [PKGBUILD](PKGBUILD.md) files.
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
The system configuration is available in `/etc/makepkg.conf`, but user-specific changes can be made in `$XDG_CONFIG_HOME/pacman/makepkg.conf` or `~/.makepkg.conf`. Also, system wide changes can be made with a drop-in file `/etc/makepkg.conf.d/makepkg.conf`. It is recommended to review the configuration prior to building packages.
|
||||||
|
|
||||||
|
> **Tip**: devtools helper scripts for building packages in a clean chroot use the `/usr/share/devtools/makepkg.conf.d/arch.conf` configuration file instead.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
#!/hint/bash
|
||||||
|
# shellcheck disable=2034
|
||||||
|
|
||||||
|
#
|
||||||
|
# /etc/makepkg.conf
|
||||||
|
#
|
||||||
|
|
||||||
|
#########################################################################
|
||||||
|
# SOURCE ACQUISITION
|
||||||
|
#########################################################################
|
||||||
|
#
|
||||||
|
#-- The download utilities that makepkg should use to acquire sources
|
||||||
|
# Format: 'protocol::agent'
|
||||||
|
DLAGENTS=('file::/usr/bin/curl -qgC - -o %o %u'
|
||||||
|
'ftp::/usr/bin/curl -qgfC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u'
|
||||||
|
'http::/usr/bin/curl -qgb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
|
||||||
|
'https::/usr/bin/curl -qgb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
|
||||||
|
'rsync::/usr/bin/rsync --no-motd -z %u %o'
|
||||||
|
'scp::/usr/bin/scp -C %u %o')
|
||||||
|
|
||||||
|
# Other common tools:
|
||||||
|
# /usr/bin/snarf
|
||||||
|
# /usr/bin/lftpget -c
|
||||||
|
# /usr/bin/wget
|
||||||
|
|
||||||
|
#-- The package required by makepkg to download VCS sources
|
||||||
|
# Format: 'protocol::package'
|
||||||
|
VCSCLIENTS=('bzr::breezy'
|
||||||
|
'fossil::fossil'
|
||||||
|
'git::git'
|
||||||
|
'hg::mercurial'
|
||||||
|
'svn::subversion')
|
||||||
|
|
||||||
|
#########################################################################
|
||||||
|
# ARCHITECTURE, COMPILE FLAGS
|
||||||
|
#########################################################################
|
||||||
|
#
|
||||||
|
CARCH="x86_64"
|
||||||
|
CHOST="x86_64-pc-linux-gnu"
|
||||||
|
|
||||||
|
#-- Compiler and Linker Flags
|
||||||
|
#CPPFLAGS=""
|
||||||
|
CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions \
|
||||||
|
-Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security \
|
||||||
|
-fstack-clash-protection -fcf-protection \
|
||||||
|
-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"
|
||||||
|
CXXFLAGS="$CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS"
|
||||||
|
LDFLAGS="-Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now \
|
||||||
|
-Wl,-z,pack-relative-relocs"
|
||||||
|
LTOFLAGS="-flto=auto"
|
||||||
|
#-- Make Flags: change this for DistCC/SMP systems
|
||||||
|
MAKEFLAGS="-j8"
|
||||||
|
#-- Debugging flags
|
||||||
|
DEBUG_CFLAGS="-g"
|
||||||
|
DEBUG_CXXFLAGS="$DEBUG_CFLAGS"
|
||||||
|
|
||||||
|
#########################################################################
|
||||||
|
# BUILD ENVIRONMENT
|
||||||
|
#########################################################################
|
||||||
|
#
|
||||||
|
# Makepkg defaults: BUILDENV=(!distcc !color !ccache check !sign)
|
||||||
|
# A negated environment option will do the opposite of the comments below.
|
||||||
|
#
|
||||||
|
#-- distcc: Use the Distributed C/C++/ObjC compiler
|
||||||
|
#-- color: Colorize output messages
|
||||||
|
#-- ccache: Use ccache to cache compilation
|
||||||
|
#-- check: Run the check() function if present in the PKGBUILD
|
||||||
|
#-- sign: Generate PGP signature file
|
||||||
|
#
|
||||||
|
BUILDENV=(!distcc color !ccache check !sign)
|
||||||
|
|
||||||
|
#
|
||||||
|
#-- If using DistCC, your MAKEFLAGS will also need modification. In addition,
|
||||||
|
#-- specify a space-delimited list of hosts running in the DistCC cluster.
|
||||||
|
#DISTCC_HOSTS=""
|
||||||
|
|
||||||
|
#-- Specify a directory for package building.
|
||||||
|
BUILDDIR=/tmp/makepkg
|
||||||
|
|
||||||
|
#########################################################################
|
||||||
|
# GLOBAL PACKAGE OPTIONS
|
||||||
|
# These are default values for the options=() settings
|
||||||
|
#########################################################################
|
||||||
|
#
|
||||||
|
# Makepkg defaults: OPTIONS=(!strip docs libtool staticlibs emptydirs !zipman !purge !debug !lto !autodeps)
|
||||||
|
# A negated option will do the opposite of the comments below.
|
||||||
|
#
|
||||||
|
#-- strip: Strip symbols from binaries/libraries
|
||||||
|
#-- docs: Save doc directories specified by DOC_DIRS
|
||||||
|
#-- libtool: Leave libtool (.la) files in packages
|
||||||
|
#-- staticlibs: Leave static library (.a) files in packages
|
||||||
|
#-- emptydirs: Leave empty directories in packages
|
||||||
|
#-- zipman: Compress manual (man and info) pages in MAN_DIRS with gzip
|
||||||
|
#-- purge: Remove files specified by PURGE_TARGETS
|
||||||
|
#-- debug: Add debugging flags as specified in DEBUG_* variables
|
||||||
|
#-- lto: Add compile flags for building with link time optimization
|
||||||
|
#-- autodeps: Automatically add depends/provides
|
||||||
|
#
|
||||||
|
OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !debug lto)
|
||||||
|
|
||||||
|
#-- File integrity checks to use. Valid: md5, sha1, sha224, sha256, sha384, sha512, b2
|
||||||
|
INTEGRITY_CHECK=(sha256)
|
||||||
|
#-- Options to be used when stripping binaries. See `man strip' for details.
|
||||||
|
STRIP_BINARIES="--strip-all"
|
||||||
|
#-- Options to be used when stripping shared libraries. See `man strip' for details.
|
||||||
|
STRIP_SHARED="--strip-unneeded"
|
||||||
|
#-- Options to be used when stripping static libraries. See `man strip' for details.
|
||||||
|
STRIP_STATIC="--strip-debug"
|
||||||
|
#-- Manual (man and info) directories to compress (if zipman is specified)
|
||||||
|
MAN_DIRS=({usr{,/local}{,/share},opt/*}/{man,info})
|
||||||
|
#-- Doc directories to remove (if !docs is specified)
|
||||||
|
DOC_DIRS=(usr/{,local/}{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc})
|
||||||
|
#-- Files to be removed from all packages (if purge is specified)
|
||||||
|
PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod)
|
||||||
|
#-- Directory to store source code in for debug packages
|
||||||
|
DBGSRCDIR="/usr/src/debug"
|
||||||
|
#-- Prefix and directories for library autodeps
|
||||||
|
LIB_DIRS=('lib:usr/lib' 'lib32:usr/lib32')
|
||||||
|
|
||||||
|
#########################################################################
|
||||||
|
# PACKAGE OUTPUT
|
||||||
|
#########################################################################
|
||||||
|
#
|
||||||
|
# Default: put built package and cached source in build directory
|
||||||
|
#
|
||||||
|
#-- Destination: specify a fixed directory where all packages will be placed
|
||||||
|
PKGDEST=/home/packages
|
||||||
|
|
||||||
|
#-- Source cache: specify a fixed directory where source files will be cached
|
||||||
|
SRCDEST=/home/sources
|
||||||
|
|
||||||
|
#-- Source packages: specify a fixed directory where all src packages will be placed
|
||||||
|
SRCPKGDEST=/home/srcpackages
|
||||||
|
|
||||||
|
#-- Log files: specify a fixed directory where all log files will be placed
|
||||||
|
#LOGDEST=/home/makepkglogs
|
||||||
|
|
||||||
|
#-- Packager: name/email of the person or organization building packages
|
||||||
|
PACKAGER="John Doe <john@doe.com>"
|
||||||
|
#-- Specify a key to use for package signing
|
||||||
|
GPGKEY=""
|
||||||
|
|
||||||
|
#########################################################################
|
||||||
|
# COMPRESSION DEFAULTS
|
||||||
|
#########################################################################
|
||||||
|
#
|
||||||
|
COMPRESSGZ=(gzip -c -f -n)
|
||||||
|
COMPRESSBZ2=(bzip2 -c -f)
|
||||||
|
COMPRESSXZ=(xz -c -z -)
|
||||||
|
COMPRESSZST=(zstd -c -T0 -)
|
||||||
|
COMPRESSLRZ=(lrzip -q)
|
||||||
|
COMPRESSLZO=(lzop -q)
|
||||||
|
COMPRESSZ=(compress -c -f)
|
||||||
|
COMPRESSLZ4=(lz4 -q)
|
||||||
|
COMPRESSLZ=(lzip -c -f)
|
||||||
|
|
||||||
|
#########################################################################
|
||||||
|
# EXTENSION DEFAULTS
|
||||||
|
#########################################################################
|
||||||
|
#
|
||||||
|
PKGEXT='.pkg.tar.zst'
|
||||||
|
SRCEXT='.src.tar.gz'
|
||||||
|
|
||||||
|
#########################################################################
|
||||||
|
# OTHER
|
||||||
|
#########################################################################
|
||||||
|
#
|
||||||
|
#-- Command used to run pacman as root, instead of trying sudo and su
|
||||||
|
#PACMAN_AUTH=()
|
||||||
|
# vim: set ft=sh ts=2 sw=2 et:
|
||||||
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
Make a package:
|
Make a package:
|
||||||
```shell
|
```shell
|
||||||
|
@ -38,22 +217,102 @@ makepkg --verifysource
|
||||||
```
|
```
|
||||||
|
|
||||||
## Options
|
## Options
|
||||||
| Option | Description |
|
| Option | Description |
|
||||||
| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `-A, --ignorearch` | Ignore a missing or incomplete arch field in the build script |
|
| `-A, --ignorearch` | Ignore a missing or incomplete arch field in the build script |
|
||||||
| `-c, --clean` | Clean up leftover work files and directories after a successful build |
|
| `-c, --clean` | Clean up leftover work files and directories after a successful build |
|
||||||
| `-d, --nodeps` | Do not perform any dependency checks. This will let you override and ignore any dependencies required. There is a good chance this option will break the build process if all of the dependencies are not installed |
|
| `-d, --nodeps` | Do not perform any dependency checks. This will let you override and ignore any dependencies required. There is a good chance this option will break the build process if all of the dependencies are not installed |
|
||||||
| `-e, --noextract` | Do not extract source files or run the prepare() function (if present); use whatever source already exists in the $srcdir/ directory. This is handy if you want to go into $srcdir/ and manually patch or tweak code, then make a package out of the result. Keep in mind that creating a patch may be a better solution to allow others to use your [PKGBUILD](PKGBUILD.md). |
|
| `-e, --noextract` | Do not extract source files or run the prepare() function (if present); use whatever source already exists in the $srcdir/ directory. This is handy if you want to go into $srcdir/ and manually patch or tweak code, then make a package out of the result. Keep in mind that creating a patch may be a better solution to allow others to use your [PKGBUILD](PKGBUILD.md). |
|
||||||
| `--skipinteg` | Do not perform any integrity checks (checksum and [PGP](../../../cryptography/GPG.md)) on source files |
|
| `--skipinteg` | Do not perform any integrity checks (checksum and [PGP](../../../cryptography/GPG.md)) on source files |
|
||||||
| `--skipchecksums` | Do not verify checksums of source files |
|
| `--skipchecksums` | Do not verify checksums of source files |
|
||||||
| `--skippgpcheck` | Do not verify [PGP](../../../cryptography/GPG.md) signatures of source files |
|
| `--skippgpcheck` | Do not verify [PGP](../../../cryptography/GPG.md) signatures of source files |
|
||||||
| `-i, --install` | Install or upgrade the package after a successful build using [pacman](Pacman.md) |
|
| `-i, --install` | Install or upgrade the package after a successful build using [pacman](Pacman.md) |
|
||||||
| `-o, --nobuild` | Download and extract files, run the prepare() function, but do not build them. Useful with the `--noextract` option if you wish to tweak the files in $srcdir/ before building |
|
| `-o, --nobuild` | Download and extract files, run the prepare() function, but do not build them. Useful with the `--noextract` option if you wish to tweak the files in $srcdir/ before building |
|
||||||
| `-r, --rmdeps` | Upon successful build, remove any dependencies installed by makepkg during dependency auto-resolution and installation |
|
| `-r, --rmdeps` | Upon successful build, remove any dependencies installed by makepkg during dependency auto-resolution and installation |
|
||||||
| `-s, --syncdeps` | Install missing dependencies using [pacman](Pacman.md). When build-time or run-time dependencies are not found, [pacman](Pacman.md) will try to resolve them. If successful, the missing packages will be downloaded and installed |
|
| `-s, --syncdeps` | Install missing dependencies using [pacman](Pacman.md). When build-time or run-time dependencies are not found, [pacman](Pacman.md) will try to resolve them. If successful, the missing packages will be downloaded and installed |
|
||||||
| `-C, --cleanbuild` | Remove the $srcdir before building the package |
|
| `-C, --cleanbuild` | Remove the $srcdir before building the package |
|
||||||
| `--noarchive` | Do not create the archive at the end of the build process. This can be useful to test the package() function or if your target distribution does not use [pacman](Pacman.md) |
|
| `-f, --force` | Overwrite package if it already exists |
|
||||||
| `--sign` | Sign the resulting package with [gpg](../../../cryptography/GPG.md) |
|
| `--noarchive` | Do not create the archive at the end of the build process. This can be useful to test the package() function or if your target distribution does not use [pacman](Pacman.md) |
|
||||||
| `--nosign` | Do not create a signature for the built package |
|
| `--sign` | Sign the resulting package with [gpg](../../../cryptography/GPG.md) |
|
||||||
| `--key <key>` | Specify a key to use when signing packages |
|
| `--nosign` | Do not create a signature for the built package |
|
||||||
| `--noconfirm` | (Passed to [pacman](Pacman.md)) Prevent [pacman](Pacman.md) from waiting for user input before proceeding with operations |
|
| `--key <key>` | Specify a key to use when signing packages |
|
||||||
|
| `--noconfirm` | (Passed to [pacman](Pacman.md)) Prevent [pacman](Pacman.md) from waiting for user input before proceeding with operations |
|
||||||
|
|
||||||
|
## Misc
|
||||||
|
### Using mold linker
|
||||||
|
[mold](../../development/mold.md) is a drop-in replacement for ld/lld linkers, which claims to be significantly faster.
|
||||||
|
|
||||||
|
To use mold, append `-fuse-ld=mold` to `LDFLAGS`. For example:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# /etc/makepkg.conf
|
||||||
|
|
||||||
|
LDFLAGS="... -fuse-ld=mold"
|
||||||
|
```
|
||||||
|
|
||||||
|
To pass extra options to mold, additionally add those to `LDFLAGS`. For example:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# /etc/makepkg.conf
|
||||||
|
|
||||||
|
LDFLAGS="... -fuse-ld=mold -Wl,--separate-debug-file"
|
||||||
|
```
|
||||||
|
|
||||||
|
To use mold for Rust packages, append `-C link-arg=-fuse-ld=mold` to `RUSTFLAGS`. For example:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# /etc/makepkg.conf.d/rust.conf
|
||||||
|
|
||||||
|
RUSTFLAGS="... -C link-arg=-fuse-ld=mold"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parallel compilation
|
||||||
|
The make build system uses the `MAKEFLAGS` environment variable to specify additional options for make. The variable can also be set in the `makepkg.conf` file.
|
||||||
|
|
||||||
|
Users with multi-core/multi-processor systems can specify the number of jobs to run simultaneously. This can be accomplished with the use of `nproc` to determine the number of available processors, e.g.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
MAKEFLAGS="--jobs=$(nproc)".
|
||||||
|
```
|
||||||
|
|
||||||
|
Some `PKGBUILDs` specifically override this with `-j1`, because of race conditions in certain versions or simply because it is not supported in the first place.
|
||||||
|
|
||||||
|
### Building from files in memory
|
||||||
|
As compiling requires many I/O operations and handling of small files, moving the working directory to a [tmpfs](../../../linux/filesystems/tmpFS.md) may bring improvements in build times.
|
||||||
|
|
||||||
|
The `BUILDDIR` variable can be temporarily exported to makepkg to set the build directory to an existing tmpfs. For example:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
BUILDDIR=/tmp/makepkg makepkg
|
||||||
|
```
|
||||||
|
|
||||||
|
Persistent configuration can be done in `makepkg.conf` by uncommenting the `BUILDDIR` option, which is found at the end of the BUILD ENVIRONMENT section in the default `/etc/makepkg.conf` file. Setting its value to e.g. `BUILDDIR=/tmp/makepkg` will make use of the Arch's default `/tmp` temporary file system.
|
||||||
|
|
||||||
|
> **Note:**
|
||||||
|
> - Avoid compiling larger packages in tmpfs to prevent running out of memory.
|
||||||
|
> - The tmpfs directory must be mounted without the `noexec` option, otherwise it will prevent built binaries from being executed.
|
||||||
|
> - Keep in mind that packages compiled in tmpfs will not persist across reboot. Consider setting the `PKGDEST` option appropriately to move the built package automatically to a persistent directory.
|
||||||
|
|
||||||
|
### Generate new checksums
|
||||||
|
Install `pacman-contrib` and run the following command in the same directory as the [PKGBUILD](./PKGBUILD.md) file to generate new checksums:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
updpkgsums
|
||||||
|
```
|
||||||
|
|
||||||
|
`updpkgsums` uses `makepkg --geninteg` to generate the checksums.
|
||||||
|
|
||||||
|
The checksums can also be obtained with e.g `sha256sum` and added to the `sha256sums` array by hand.
|
||||||
|
|
||||||
|
### Build from local source files
|
||||||
|
If you want to make changes to the source code you can download the source code without building the package by using the `-o, --nobuild` Download and extract files only option.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
makepkg -o
|
||||||
|
```
|
||||||
|
|
||||||
|
You can now make changes to the sources and then build the package by using the `-e, --noextract` Do not extract source files (use existing `$srcdir/` dir) option. Use the `-f` option to overwrite already built and existing packages.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
makepkg -ef
|
||||||
|
```
|
||||||
|
|
Loading…
Add table
Reference in a new issue