knowledge/technology/applications/package managers/arch-linux/PKGBUILD.md

51 lines
1.3 KiB
Markdown
Raw Normal View History

2023-12-04 10:02:23 +00:00
---
arch-wiki: https://wiki.archlinux.org/title/PKGBUILD
obj: concept
---
2023-12-19 01:53:37 +00:00
# PKGBUILD
2024-01-17 08:00:45 +00:00
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)
2023-12-04 10:02:23 +00:00
2024-01-17 08:00:45 +00:00
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).
2023-12-04 10:02:23 +00:00
2023-12-19 01:39:56 +00:00
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.
2023-12-04 10:02:23 +00:00
# Example
PKGBUILD:
```sh
# Maintainer: User <mail>
pkgname=NAME
pkgver=VERSION
pkgrel=1
pkgdesc="DESCRIPTION"
arch=('x86_64')
url=URL
license=("MIT")
depends=("git")
makedepends=("git")
source=("FILE_NAME::FILE_URL")
sha256sums=("SKIP")
prepare() {
}
pkver() {
}
build() {
cd "$pkgname"
make
}
check() {
}
package() {
cd "$pkgname"
install -Dm755 ./app "$pkgdir/usr/bin/app"
}
```