Linux makepkg Guide - ryzendew/Linux-Tips-and-Tricks GitHub Wiki
Linux makepkg Guide
Complete beginner-friendly guide to makepkg on Linux, covering Arch Linux, CachyOS, and other distributions including building packages from PKGBUILD files, creating custom packages, and package building best practices.
Table of Contents
- Understanding makepkg
- makepkg Installation
- Building Packages
- PKGBUILD Files
- Creating PKGBUILDs
- Troubleshooting
Understanding makepkg
What is makepkg?
makepkg builds packages from PKGBUILD files.
Uses:
- Build AUR packages: Build packages from AUR
- Create packages: Build custom packages
- Test packages: Test before installing
- Package development: Develop new packages
Why it matters:
- AUR packages: Required for AUR
- Custom packages: Create your own
- Package control: Full control over builds
makepkg Installation
Install makepkg
Arch/CachyOS:
# Install base-devel (includes makepkg)
sudo pacman -S base-devel
# Verify
makepkg --version
makepkg is included in base-devel group.
Building Packages
Build from PKGBUILD
Basic build:
# Download PKGBUILD
# Or create your own
# Build package
makepkg
# Install after build
makepkg -i
Build Options
Common options:
# Clean build
makepkg -c
# Skip checksums
makepkg --skipinteg
# Install after build
makepkg -i
# Source only
makepkg -S
PKGBUILD Files
PKGBUILD Structure
Basic PKGBUILD:
pkgname=my-package
pkgver=1.0
pkgrel=1
pkgdesc="My package description"
arch=('x86_64')
url="https://example.com"
license=('GPL')
depends=('dependency1' 'dependency2')
source=("https://example.com/$pkgname-$pkgver.tar.gz")
md5sums=('checksum')
build() {
cd "$srcdir/$pkgname-$pkgver"
./configure --prefix=/usr
make
}
package() {
cd "$srcdir/$pkgname-$pkgver"
make DESTDIR="$pkgdir" install
}
Creating PKGBUILDs
New PKGBUILD
Create PKGBUILD:
# Create directory
mkdir -p ~/pkgbuilds/my-package
cd ~/pkgbuilds/my-package
# Create PKGBUILD
vim PKGBUILD
Test PKGBUILD
Validate:
# Check syntax
makepkg --printsrcinfo
# Test build
makepkg -f
Troubleshooting
Build Errors
Check dependencies:
# Install dependencies
sudo pacman -S base-devel
# Check PKGBUILD
makepkg --printsrcinfo
Permission Errors
Fix permissions:
# Check user in wheel group
groups
# Or build as user (not root)
Summary
This guide covered makepkg usage, PKGBUILD creation, and package building for Arch Linux, CachyOS, and other distributions.
Next Steps
- Arch Build System - ABS guide
- Package Management - Package management
- makepkg Documentation:
man makepkg
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.