一键导入
aur-makepkg
Comprehensive guide for building Arch Linux packages using makepkg, covering the build process, configuration, debugging, and optimization.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Comprehensive guide for building Arch Linux packages using makepkg, covering the build process, configuration, debugging, and optimization.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Master skill for AUR (Arch User Repository) package development, serving as a comprehensive guide and dispatcher for creating, auditing, and submitting Arch Linux packages.
Comprehensive guide for auditing and validating Arch Linux packages and PKGBUILDs using automated tools and manual verification.
Comprehensive guide for using AUR helper tools like yay, paru, pikaur, and aura for automating package management.
Comprehensive guide to Arch Linux package guidelines and standards for consistency, quality, and interoperability across the Arch Linux ecosystem.
Comprehensive guide for using pacman, the Arch Linux package manager, covering installation, removal, queries, and troubleshooting.
Comprehensive guide for creating and editing PKGBUILD files - the core build scripts used by makepkg to create Arch Linux packages.
| name | aur-makepkg |
| description | Comprehensive guide for building Arch Linux packages using makepkg, covering the build process, configuration, debugging, and optimization. |
Comprehensive guide for building Arch Linux packages using makepkg. Covers the build process, configuration, environment variables, debugging, and optimization for creating packages from PKGBUILDs.
This skill should be used when:
makepkg is a script provided by the pacman package that automates building packages. It reads a PKGBUILD and performs these steps in order:
# Build package (requires dependencies)
makepkg -s
# Build and install automatically
makepkg -si
# Skip dependency installation
makepkg
# Clean up after build (default behavior)
makepkg -c
# Clean build directory BEFORE building (pristine environment)
makepkg -C
# Overwrite existing package in output directory
makepkg -f
# Output directories are configured in makepkg.conf
# Package output directory
PKGDEST=/home/packages
# Source download directory
SRCDEST=/home/sources
# Sign the package
makepkg --sign
Configuration hierarchy (later files override earlier ones):
/etc/makepkg.conf - Global/etc/makepkg.conf.d/*.conf - System-wide drops~/.makepkg.conf or $XDG_CONFIG_HOME/pacman/makepkg.conf - User-specificGlobal configuration for all users.
# Package output directory
PKGDEST=/home/packages
# Source download directory (recommended for VCS packages)
SRCDEST=/home/sources
# Log directory
LOGDEST=/home/buildlogs
# GPG key for signing
GPGKEY="your fingerprint"
# Parallel compilation
MAKEFLAGS="-j$(nproc)"
User-specific overrides.
# Disable signature verification (NOT RECOMMENDED)
# Use --skippgpcheck flag or add !sign to BUILDENV
# Use all CPU cores
MAKEFLAGS="-j$(nproc)"
# Color output
USE_COLOR=1
| Variable | Purpose |
|---|---|
| MAKEFLAGS | Compiler flags (e.g., -j4) |
| PKGDEST | Package output directory |
| SRCDEST | Source download directory |
| SRCPKGDEST | Source package directory |
| LOGDEST | Build log directory |
| PACKAGER | Package maintainer name (email obfuscated) |
| GPGKEY | GPG key for signing |
| BUILDENV | Build tools (ccache, distcc) |
# Build with specific settings
MAKEFLAGS="-j4" PKGDEST="/tmp/packages" makepkg -s
# Set maintainer info (email obfuscated per AUR guidelines)
PACKAGER="Your Name <you at example dot com>" makepkg
# Download sources and verify integrity (no extraction or building)
makepkg --verifysource
# Download and extract only (no build)
makepkg --nobuild
# Install missing dependencies and build
makepkg -s
# Default: sources are extracted automatically
# Skip extraction (if sources already present)
makepkg --noextract
# Build package (default behavior)
makepkg
# Parallel compilation is controlled via MAKEFLAGS, not a flag
MAKEFLAGS="-j$(nproc)" makepkg
# Create package (default, runs after build)
makepkg
# Package only (skip build if already done)
makepkg --pkg
# Sign package
makepkg --sign
# Default location: current directory (where PKGBUILD is)
less ./mypackage.log
# Or specify log location
LOGDEST=/tmp/logs makepkg
# Log all function output to files
makepkg --log
# Debug mode (shows commands as they run)
makepkg --debug
Missing Dependencies
# Install missing deps
makepkg -s
# Check what's missing
makepkg -o 2>&1 | grep "could not satisfy"
Permission Errors
# CRITICAL: Never build as root - PKGBUILDs can contain arbitrary commands
# If only root is available, use:
runuser -u nobody -- makepkg -s
# Fix ownership
chown -R $USER:$USER ./mypackage
Checksum Mismatch
# Update checksums
updpkgsums PKGBUILD
# Or manually generate
makepkg -g >> PKGBUILD
Network Issues
# Use proxy
export HTTP_PROXY=http://proxy:8080
export HTTPS_PROXY=http://proxy:8080
# Use specific downloader
DLAGENTS=("ftp::/usr/bin/curl -fC - -o %o %u")
Incompatible Flags If build succeeds manually but fails via makepkg, incompatible makepkg.conf settings may be the cause. Disable defaults in PKGBUILD:
options=('!makeflags' '!buildflags' '!debug')
gpg --full-gen-key
# Use RSA, 4096 bits, expires in 2 years
# Sign during build
makepkg --sign
# Sign existing package
gpg --detach-sign package.pkg.tar.zst
# Sign package and append
gpg --armor --detach-sign --yes
# Verify signature
gpg --verify package.pkg.tar.zst.sig
# Verify with pacman
pacman -U package.pkg.tar.zst
# In makepkg.conf
MAKEFLAGS="-j$(nproc)"
# Or on command line (note: -j is for makepkg's MAKEFLAGS, not a direct flag)
MAKEFLAGS="-j$(nproc)" makepkg
# makepkg assumes base-devel is installed
# Never list base-devel members in makedepends:
# WRONG: makedepends=('gcc' 'make')
# CORRECT: makedepends=() # base-devel provides these
For faster builds, use the mold linker:
# Install mold
pacman -S mold
# Add to LDFLAGS in makepkg.conf
LDFLAGS="-fuse-ld=mold"
# Install ccache
pacman -S ccache
# Enable in /etc/makepkg.conf or ~/.makepkg.conf:
BUILDENV=(!distcc color ccache !check)
# Install distcc
pacman -S distcc
# Enable in /etc/makepkg.conf or ~/.makepkg.conf:
BUILDENV=(distcc !color !ccache !check)
# Configure hosts in /etc/distcc/hosts or via environment
DISTCC_HOSTS="localhost host1 host2"
When a source URL doesn't include a useful filename, use :: to specify one:
source=("https://example.com/download.php?file=12345::https://example.com/file.tar.gz")
This renames the downloaded file to 12345 instead of the query-string filename.
For AUR submission, generate .SRCINFO:
makepkg --printsrcinfo > .SRCINFO
Mandatory for AUR: Regenerate .SRCINFO whenever metadata changes (pkgver, depends, etc.). The AUR web interface uses this file - if missing or outdated, the correct version won't display.
# In /etc/makepkg.conf or PKGBUILD
DLAGENTS=('http::/usr/bin/curl -LC - -b cookies.txt -c cookies.txt -o %o %u'
'https::/usr/bin/wget --passive-ftp -O %o %u'
'git::git clone %u %o')
# Download and verify sources (prepares for offline build)
makepkg --verifysource
# Then build offline (sources must already be in SRCDEST)
makepkg
# Download and extract only (no build)
makepkg --nobuild
# Skip prepare() function
makepkg --noprepare
# Debug specific function
bash -x PKGBUILD
# Default: .pkg.tar.zst (compressed)
makepkg
# Create source package (PKG.src.tar.zst)
makepkg --source
# Create source package with ALL sources (including downloaded during build)
makepkg --allsource
# Package only (skip build)
makepkg --pkg
The package name and version are defined in the PKGBUILD via pkgname and pkgver variables - they cannot be overridden via command-line flags.
| Command | Purpose |
|---|---|
makepkg -s | Syncdeps: Install missing dependencies |
makepkg -i | Install: Build and install with pacman |
makepkg -c | Clean: Remove work files after build |
makepkg -C | Cleanbuild: Remove $srcdir before build |
makepkg -f | Force: Overwrite existing package |
makepkg -g | Geninteg: Generate integrity checksums |
updpkgsums | Preferred tool to update checksums |
makepkg --allsource | Create source package with all sources |
makepkg --printsrcinfo | Generate .SRCINFO for AUR |
makepkg --sign | Sign the package |
makepkg --verifysource | Verify: Download and check integrity |
makepkg --skippgpcheck | Skip PGP signature verification |
updpkgsumsmakepkg --log for debuggingabsarchbuild or containersGPL-3.0-or-later, not GPL3"$pkgdir" and "$srcdir" to handle spaces# Install namcap
pacman -S namcap
# Audit PKGBUILD
namcap PKGBUILD
# Audit built package
namcap package.pkg.tar.zst
# Check for shell scripting errors
shellcheck --shell=bash --exclude=SC2034,SC2154,SC2164 PKGBUILD
.install scripts run chrooted in the target system's installation directory. They do NOT have access to build-time variables like $pkgdir or $srcdir. Only use actual system paths:
# WRONG - uses build-time variables
post_install() {
rm -rf "$pkgdir"/usr/share/cache
}
# CORRECT - uses system paths
post_install() {
rm -rf /usr/share/cache
}