Knowledgebase

Using Makepkg on Arch Linux Print

  • 0

If you use makepkg directly, it somewhat pollutes your system. The base-devel package group must be installed. This way, by default, dependencies needed only to build the package, but not needed to use it, are left installed. This default behavior can be changed, but this involves installing and uninstalling packages and polluting your /var/log/pacman.log.

Refer to this article for understanding and using the AUR in general, including obtaining the PKGBUILD. This doc only shows the steps specific to makepkg, if it is the method you choose to compile a package.

Compiling Using Makepkg

If the base-devel package group is not already installed, you need to install it. If you don't, makepkg will assume it's already installed, and if a package in it is required but not installed, it will simply fail rather than install it for you. makepkg itself is part of the pacman package, already installed.

# pacman -S base-devel

You need to run makepkg in the directory with the PKGBUILD, the directory made by git clone. By default, it will download the actual source code, compile the package, and package it.

There are many options for makepkg, including these commonly used ones:

  • -s, --syncdeps : Automatically install missing dependencies required for building and using the package.
  • Note if the PKGBUILD has dependencies on AUR packages, you need to install those first, or have them available in a local repository of your own so it can find them.
  • -r, --rmdeps : If it builds successfully, automatically uninstall dependencies that are no longer needed, including the following:
  • Ones required for building but not using the package.
  • If used without the --install option, ones required for using the package.
  • -i, --install : If it builds successfully, automatically install/upgrade the package.
  • -c, --clean : Automatically delete temporary build files, usually only needed when debugging a build that has gone wrong.

To automatically install/upgrade the package, leave dependencies installed for using the package, and remove dependencies only needed during building, run:

# makepkg -sri

Alternatively, you can choose not to automatically install it, and leave all dependencies installed, so if you package an upgrade someday, they are already installed:

# makepkg -s

You can then either use a Local Repository as explained here, or install the file directly:

# pacman -U <PKGNAME>-<PKGVER>-<PKGREL>-<ARCH>.pkg.tar.xz

Package Faster

By default, makepkg combines an entire package into an archive format; making a .tar.xz file using a single thread for the xz compression.

On multi CPU systems, you can allow xz to use multiple threads by editing /etc/makepkg.conf, and change the following line:

COMPRESSXZ=(xz -c -z -)

You can allow as many threads as you have virtual cores:

COMPRESSXZ=(xz -c -z - --threads=0)

To allow using multiple virtual cores, but not all of them, such as to reduce impact to overall system performance, add a specific number, such as the following:

COMPRESSXZ=(xz -c -z - --threads=21)

Note: Specifying more threads than the number of virtual cores you have will decrease performance.

If you don't mind the package file being (potentially much) larger, disable compression by editing /etc/makepkg.conf, and change the following line:

PKGEXT='.pkg.tar.xz'

It should look like the following:

PKGEXT='.pkg.tar'

Skip Verifying PGP Signature

It's recommended to properly verify and add any PGP signaturesused , as explained here in the section "PGP Signature Error".

However, if you are running makepkg directly, you can give it the --skippgpcheck option to skip verifying the PGP Signature.

If you use makepkg directly, it somewhat pollutes your system. The base-devel package group must be installed. This way, by default, dependencies needed only to build the package, but not needed to use it, are left installed. This default behavior can be changed, but this involves installing and uninstalling packages and polluting your /var/log/pacman.log. Refer to this article for understanding and using the AUR in general, including obtaining the PKGBUILD. This doc only shows the steps specific to makepkg, if it is the method you choose to compile a package. Compiling Using Makepkg If the base-devel package group is not already installed, you need to install it. If you don't, makepkg will assume it's already installed, and if a package in it is required but not installed, it will simply fail rather than install it for you. makepkg itself is part of the pacman package, already installed. # pacman -S base-devel You need to run makepkg in the directory with the PKGBUILD, the directory made by git clone. By default, it will download the actual source code, compile the package, and package it. There are many options for makepkg, including these commonly used ones: -s, --syncdeps : Automatically install missing dependencies required for building and using the package. Note if the PKGBUILD has dependencies on AUR packages, you need to install those first, or have them available in a local repository of your own so it can find them. -r, --rmdeps : If it builds successfully, automatically uninstall dependencies that are no longer needed, including the following: Ones required for building but not using the package. If used without the --install option, ones required for using the package. -i, --install : If it builds successfully, automatically install/upgrade the package. -c, --clean : Automatically delete temporary build files, usually only needed when debugging a build that has gone wrong. To automatically install/upgrade the package, leave dependencies installed for using the package, and remove dependencies only needed during building, run: # makepkg -sri Alternatively, you can choose not to automatically install it, and leave all dependencies installed, so if you package an upgrade someday, they are already installed: # makepkg -s You can then either use a Local Repository as explained here, or install the file directly: # pacman -U ---.pkg.tar.xz Package Faster By default, makepkg combines an entire package into an archive format; making a .tar.xz file using a single thread for the xz compression. On multi CPU systems, you can allow xz to use multiple threads by editing /etc/makepkg.conf, and change the following line: COMPRESSXZ=(xz -c -z -) You can allow as many threads as you have virtual cores: COMPRESSXZ=(xz -c -z - --threads=0) To allow using multiple virtual cores, but not all of them, such as to reduce impact to overall system performance, add a specific number, such as the following: COMPRESSXZ=(xz -c -z - --threads=21) Note: Specifying more threads than the number of virtual cores you have will decrease performance. If you don't mind the package file being (potentially much) larger, disable compression by editing /etc/makepkg.conf, and change the following line: PKGEXT='.pkg.tar.xz' It should look like the following: PKGEXT='.pkg.tar' Skip Verifying PGP Signature It's recommended to properly verify and add any PGP signaturesused , as explained here in the section "PGP Signature Error". However, if you are running makepkg directly, you can give it the --skippgpcheck option to skip verifying the PGP Signature.

Was this answer helpful?
Back

Powered by WHMCompleteSolution