PKGBUILD is a script in which one can specify source of package, checksum, version info, dependencies and build instructions to install a package. This script is then build using makepkg program which runs the script and build the package according to the instructions. PKGBUILD is an efficient way to install packages which are not available in the repository or patched versions of the actual package as this will install package using the same package manager that is used in the system (Pacman) and so installing, upgrading and removing will be natively supported.



For the package you want to install, read the documentation and instruction to install it. Check if there is a install script or Makefile that package include and what are the dependencies of the package.

Specify the information in PKGBUILD script using the following format.

# Maintainer NAME <EMAIL>

pkgname= # name of the package
pkgver=  # upstream version of package
pkgrel=  # current version of the PKGBUILD
pkgdesc= '' # One-line description about package
arch=('')   # Architecture of the package, generally x86_64
url=('')    # website or other upstream url
depends=('')  # Dependencies
optdepends=('')  # optional dependencies
makedepends=('') # Build dependencies
license=('')     # License of package
source=('')      # List of url from where source files are to be fetched

# Things to do before installation

# Build instruction

Add checksums

When fetching something over the internet, its essential to check the integrity of the the package. So, we need to add checksum of the source files. The following command will fetch the source files and add the checksum of those at the bottom of the PKGBUILD which you can later place after source section.

$ makepkg -g >> PKGBUILD

Build PKGBUILD and test

Now its time to build the package using PKGBUILD that you just wrote. The following command will automatically build the package and then prompt to install the package on your system.

$ makepkg -i

After installation is complete test the package to see if its properly installed and that it is working fine.

Generate .SRCINFO

This is specially important if you want to push PKGBUILD on to Arch User Repository a.k.a. AUR because AUR uses this file to generate and show information about the PKGBUILD on the web-interface.

$ makepkg --printsrcinfo > .SRCINFO


Now, the PKGBUILD is ready to be pushed on AUR. Remember to not add source or build package in the git commit and also not to forget the hidden but essential .SRCINFO file.