Tutorials  /  Linux Basics

Arch Linux makepkg Guide: Build Packages, Optimize Performance & Manage Dependencies

Ccentron Redaktion · May 2025 ·5 min read ·Linux Basics, Tutorial

Direct usage of makepkg can clutter your system setup. It's essential to have the base-devel package group installed. By default, makepkg keeps build-time dependencies installed, even if they’re not needed to run the package. This behavior can be changed, but doing so may unnecessarily modify your system logs at /var/log/pacman.log.

This document focuses solely on using makepkg as a method for compiling software packages.

Step-by-Step: Using makepkg for Compilation

Begin by ensuring that the base-devel package group is installed. If it’s missing, makepkg will presume it's present, and fail when a missing tool is required. Note that makepkg is included with the pacman package, which is already installed on your system.

Install base-devel

Console
# pacman -S base-devel

Run makepkg from within the directory containing the PKGBUILD, typically the directory cloned from AUR using git. By default, makepkg fetches the source, compiles it, and creates the package file.

Common makepkg Options

  • -s, --syncdeps: Installs all required dependencies for both building and using the software. For AUR-specific dependencies, pre-install them or ensure they exist in a local repo.
  • -r, --rmdeps: Removes unneeded dependencies after a successful build, particularly:
    • Build-time only dependencies.
    • If used without --install, also removes runtime dependencies.
  • -i, --install: Installs or upgrades the package post-build.
  • -c, --clean: Deletes temporary build files—useful during build troubleshooting.

Install the Package Automatically and Clean Up

This command installs the built package, retains runtime dependencies, and removes build-time ones:

Console
# makepkg -sri

Keep Dependencies for Future Upgrades

If you prefer not to install the package right away and want to retain all dependencies for a possible future rebuild or upgrade:

Console
# makepkg -s

After building, you can either set up a local repository (explained elsewhere) or install the package file directly using:

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

Matching infrastructure at centron

No hardware needed to follow along: ccloud³ VMs with full root access start at €3.12 per month, billed by the hour and ready in seconds. Rent a cloud server →

Speed Up Package Creation with makepkg

By default, makepkg compresses packages into a .tar.xz archive using just a single thread for the xz compression process.

Enable Multi-Threading on Multi-Core Systems

If your system has multiple CPU cores, you can enable xz to use several threads by modifying the /etc/makepkg.conf file. Look for the line:

Code
COMPRESSXZ=(xz -c -z -)

To use all available virtual CPU cores, change it to:

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

If you’d like to limit resource usage to specific cores and reduce system load, set a fixed number of threads like this:

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

Note: Setting more threads than your CPU has virtual cores will actually reduce performance.

Disable Compression to Build Faster

If storage space isn't a concern and you want to speed up packaging, you can disable compression entirely. To do so, locate this line in /etc/makepkg.conf:

Code
PKGEXT='.pkg.tar.xz'

And change it to:

Code
PKGEXT='.pkg.tar'

It's best practice to verify and import all PGP signatures as outlined in the section titled “PGP Signature Error.”

Still, if you choose to run makepkg directly and want to skip PGP verification, you can use the --skippgpcheck option:

Code
makepkg --skippgpcheck

Conclusion: Efficiently Building Packages with makepkg

Compiling packages with makepkg gives you complete control over the build process on Arch Linux. By installing base-devel, configuring multi-threaded compression, and selectively handling dependencies, you can optimize both performance and system cleanliness.

While options like skipping PGP checks exist, it's best to adhere to recommended security practices unless you're fully aware of the implications. With the right adjustments, makepkg becomes a powerful and efficient tool for managing custom package.

Jetzt 200 € Guthaben sichern

Testen Sie Ihr Setup auf ccloud³

Registrieren Sie sich in der ccloud³ und erhalten Sie 200 € Startguthaben für Ihr Projekt – z. B. für eine PostgreSQL-VM mit automatischen Backups.

centron Redaktion Technische Redaktion

Das Redaktionsteam von centron schreibt Anleitungen aus dem Betriebsalltag: getestet auf unserer eigenen Plattform, betrieben im Rechenzentrum in Hallstadt bei Bamberg.

Kategorie Linux Basics
Teilen
Noch offene Fragen?

Our team will help you with your specific setup - in German or English, by people who run the platform themselves.

War dieses Tutorial hilfreich?

Your answer is stored anonymously and helps us improve our tutorials.

Kommentare

No comments yet - be the first to ask a question about this tutorial.

Sign in to comment

Comments are open to centron customers. Sign in to your account to ask a question about this tutorial.

Weiterlesen

Das könnte Sie auch interessieren

Jetzt kostenlos anfangen

Melden Sie sich an und erhalten Sie in den ersten 60 Tagen ein Guthaben von 200 € bei centron.

Dieses Werbeangebot gilt nur für neue Konten. Angebot ausschließlich für Gewerbetreibende.

Jetzt loslegen Sales kontaktieren