一键导入
aur-pkgbuild
Comprehensive guide for creating and editing PKGBUILD files - the core build scripts used by makepkg to create Arch Linux packages.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Comprehensive guide for creating and editing PKGBUILD files - the core build scripts used by makepkg to create Arch Linux packages.
用 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 for building Arch Linux packages using makepkg, covering the build process, configuration, debugging, and optimization.
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.
| name | aur-pkgbuild |
| description | Comprehensive guide for creating and editing PKGBUILD files - the core build scripts used by makepkg to create Arch Linux packages. |
Comprehensive guide for creating and editing PKGBUILD files - the core build scripts used by makepkg to create Arch Linux packages. This skill covers all PKGBUILD variables, functions, and best practices for building packages for Arch Linux and the AUR.
This skill should be used when:
pkgname=packagename # Package name (lowercase, alphanumeric + @._+-)
pkgver=1.0.0 # Upstream version (no hyphens, use _ instead)
pkgrel=1 # Release number (resets on new upstream version)
arch=('x86_64') # Target architecture(s)
pkgdesc="Description" # Max ~80 chars, no self-referencing
url="https://example.com" # Official project URL
license=('GPL-3.0-or-later') # SPDX license identifier
groups=() # Package groups (e.g., 'plasma')
@ . _ + --) or dot (.)-git, -svn, -hg, -bzr, -darcs for VCS packages-bin for prebuilt binaries (when source available)libfoo2)pkgname=firefox # Good: matches upstream
pkgname=gtk3 # Good: version suffix for compatibility
pkgname=screen-sidebar # Good: alternate version with patch
pkgname=code-git # Good: VCS package
pkgname=vim-bin # Good: prebuilt binary
pkgver() function for VCS packages# If upstream is "v1.0.0", use:
pkgver=1.0.0
# If upstream is "release-1_0", use:
pkgver=1_0
epoch=1 makes 1:1.0.0-1 newer than any 0:x.x.x-xRuntime dependencies required to build AND run the package.
depends=('glibc>=2.20' 'gtk3')
Dependencies only needed for building.
makedepends=('cmake' 'ninja')
Note: Do NOT include packages from base-devel (gcc, make, etc.)
Dependencies only needed for running test suites.
checkdepends=('python-pytest')
Optional features, not required for basic functionality.
optdepends=('cups: printing support'
'sane: scanner support')
depends_x86_64=('lib32-glibc')
ldd or readelf on binaries to find library depsnamcap to detect missing depsWhat the package provides (libraries, virtual packages).
provides=('libfoo.so' 'qt5')
provides=('qt=5.15.0') # With version
Note: Do NOT include $pkgname - it's implicit.
Packages that cannot be installed alongside this one.
conflicts=('old-package' 'another-package')
Obsolete packages replaced by this one.
replaces=('wireshark-qt') # For official repo packages
Note: Avoid in AUR - use conflicts and provides instead.
source=("${pkgname}-${pkgver}.tar.gz::https://example.com/download")
source=('localfile.patch')
source=('git+https://github.com/user/repo.git')
sha256sums=('abc123...') # Recommended
sha512sums=('def456...') # Stronger
b2sums=('ghi789...') # Strongest
md5sums=('xyz...') # Legacy, avoid
sha1sums=('old...') # Legacy, avoid
cksums=('crc...') # CRC32, minimal security
Generate with:
makepkg -g >> PKGBUILD # Generate new checksums
updpkgsums PKGBUILD # Update existing (preferred)
# Custom filename to avoid conflicts
source=('unique-name.tar.gz::https://example.com/download')
# PGP signature verification
source=('file.tar.gz'
'file.tar.gz.sig')
validpgpkeys=('KEYFINGERPRINT')
# Git sources
source=('name::git+https://repo.git#branch=main')
# Skip extraction (filename only, not full path)
noextract=('file.tar.gz')
SKIP only for VCS sourcesRun before build - apply patches, modify sources.
prepare() {
cd "$pkgname-$pkgver"
patch -p1 -i "$srcdir/fix.patch"
}
Compile the software.
build() {
cd "$pkgname-$pkgver"
./configure --prefix=/usr
make
}
Run test suite (optional).
check() {
cd "$pkgname-$pkgver"
make test
}
Install into fake root for packaging.
package() {
cd "$pkgname-$pkgver"
make DESTDIR="$pkgdir" install
}
pkgbase="project-name" # Used when multiple packages from one source
pkgname=(package1 package2)
package_package1() {
# Install files for package1
install -Dm644 file1 "$pkgdir/usr/bin/app1"
}
package_package2() {
# Install files for package2
install -Dm644 file2 "$pkgdir/usr/bin/app2"
}
Note: All packages required to build the entire set must be in the global makedepends array. makepkg does not check split package dependencies before the build begins.
CRITICAL: .install scripts do NOT have access to $pkgdir or $srcdir. These scripts run on the user's system during pacman operations, not during the build process. They reference the actual system paths, not build directories.
pre_install() {
echo "Running before installation"
}
post_install() {
echo "Package installed!"
}
pre_upgrade() {
echo "Before upgrade"
}
post_upgrade() {
echo "After upgrade"
}
pre_remove() {
echo "Before removal"
}
post_remove() {
echo "After removal"
}
post_install() {
# Show message to user - system paths only
echo "Please run systemctl daemon-reload"
}
Do NOT use $pkgdir or $srcdir in .install files.
options=('!emptydirs' # Remove empty directories (default: keep them)
'!libtool' # Remove .la libtool files (default: keep them)
'!ccache' # Don't use ccache
'!strip' # Don't strip binaries (default: strip them)
'upx' # Compress binaries
'zipman' # Compress man pages
)
| Path | Purpose |
|---|---|
/usr/bin | Executables |
/usr/lib | Libraries |
/usr/include | Headers |
/usr/share/doc | Documentation |
/usr/share/licenses | License files |
/usr/share/man | Man pages |
/etc | Configuration files |
/etc/package | Package config (recommended) |
/opt/package | Large self-contained apps |
/var/lib/package | Persistent data |
Do NOT include: /bin, /sbin, /dev, /home, /srv, /media, /mnt, /proc, /root, /selinux, /sys, /tmp, /var/tmp, /run
Always use SPDX license identifiers from the official SPDX License List.
license=('GPL-3.0-or-later') # Single license (SPDX)
license=('GPL-3.0-or-later' 'MIT') # Multiple licenses (SPDX)
license=('custom:NAME') # Custom license - requires license file
license=('BSD-3-Clause') # BSD variants need license file
For custom licenses or license families (MIT, BSD), you must provide the license text:
package() {
# ... build commands ...
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
The PKGBUILD and helper files in your AUR submission should be licensed under 0BSD:
# Maintainer: Your Name <you at example dot com>
pkgname=example
pkgver=1.0.0
pkgrel=1
pkgdesc="An example package"
arch=('x86_64')
url="https://example.com"
license=('MIT')
depends=('glibc' 'gtk3')
makedepends=() # Don't list base-devel packages (gcc, make, etc.)
source=("${pkgname}-${pkgver}.tar.gz::https://example.com/download")
sha256sums=('REPLACEME')
build() {
cd "$srcdir/${pkgname}-${pkgver}"
./configure --prefix=/usr
make
}
package() {
cd "$srcdir/${pkgname}-${pkgver}"
make DESTDIR="$pkgdir" install
}
makedepends=('cmake' 'ninja')
build() {
cmake -B build -S "$pkgname-$pkgver" \
-DCMAKE_INSTALL_PREFIX=/usr \
-DBUILD_SHARED_LIBS=ON
cmake --build build
}
package() {
DESTDIR="$pkgdir" cmake --install build
}
makedepends=('python-setuptools')
depends=('python')
build() {
cd "$srcdir/$pkgname-$pkgver"
python setup.py build
}
package() {
cd "$srcdir/$pkgname-$pkgver"
python setup.py install --root="$pkgdir" --optimize=1
}
namcap PKGBUILD # Check PKGBUILD
namcap package.pkg.tar.zst # Check built package
shellcheck --shell=bash --exclude=SC2034,SC2154,SC2164 PKGBUILD