Pacman PKGINFO
Contents
Issues
It seems that although Pacman is quite well documented in its usage for managing or building packages, the package format is completely undocumented.
Of course it says that a package file is a simple tar compressed with LZMA (xz), and that it must contain the files below, but their format is not clearly defined, at most hinted (in the case of .PKGINFO) or given templates and short explanation (in case of the other), see Creating packages:
.PKGINFO containing the package's meta-data;
.INSTALL giving hooks for various situations like pre- / post- install, upgrade or remove;
all the other files and directories with their full path (like etc/somepackage/someconf);
all the files are not rooted in /, i.e. they are relative;
Analysis
The empirical approach
To obtain some examples we could run the following command inside the packages cache (/var/cache/pacman/pkg):
find . -type f -name '*.pkg.tar.xz' -print -exec tar -xJf {} -O .PKGINFO \; -printf '\n\n' >/tmp/PKGINFO.txt
To see which options are present we could run:
grep -E -o -e '^[^ ]+\s*=' /tmp/PKGINFO.txt | sort -u
arch = backup = builddate = conflict = depend = group = license = makepkgopt = optdepend = packager = pkgbase = pkgdesc = pkgname = pkgver = provides = replaces = size = url =
It seems that the general file syntax is the following:
lines starting with # which are ignored;
lines of the format property = value;
- the same property could appear multiple times and it constitutes a list;
It seems that the following properties are not lists but singleton values: arch, builddate, packager, pkgbase, pkgdesc, pkgname, pkgver, size, url. All the others could have multiple values.
Their semantic and syntax seem to follow that provided in PKGBUILD (5).
The reverse engineering approach
We can shovel through the source code available at pacman.git:
makepkg write_pkginfo function;
pmpkg.py makepkg function;
libalpm parse_descfile function -- the definitive source;
Examples
Bash
# Generated by makepkg 4.0.3 # using fakeroot version 1.18.3 # Thu May 31 11:46:35 UTC 2012 pkgname = bash pkgver = 4.2.029-1 pkgdesc = The GNU Bourne Again shell url = http://www.gnu.org/software/bash/bash.html builddate = 1338464794 packager = Allan McRae <allan@archlinux.org> size = 3747840 arch = i686 license = GPL group = base backup = etc/bash.bashrc backup = etc/bash.bash_logout backup = etc/skel/.bashrc backup = etc/skel/.bash_profile backup = etc/skel/.bash_logout depend = readline>=6.1 depend = glibc provides = sh makepkgopt = strip makepkgopt = docs makepkgopt = libtool makepkgopt = emptydirs makepkgopt = zipman makepkgopt = purge makepkgopt = !upx
GCC
# Generated by makepkg 4.0.3 # using fakeroot version 1.18.4 # Sat Jun 16 11:09:24 UTC 2012 pkgname = gcc pkgbase = gcc pkgver = 4.7.1-1 pkgdesc = The GNU Compiler Collection - C and C++ frontends url = http://gcc.gnu.org builddate = 1339844963 packager = Allan McRae <allan@archlinux.org> size = 72290304 arch = i686 license = GPL license = LGPL license = FDL license = custom group = base-devel depend = gcc-libs=4.7.1-1 depend = binutils>=2.22 depend = libmpc depend = cloog depend = ppl makepkgopt = strip makepkgopt = docs makepkgopt = !libtool makepkgopt = !emptydirs makepkgopt = zipman makepkgopt = purge makepkgopt = !upx
GhostScript
# Generated by makepkg 4.0.1 # using fakeroot version 1.18.2 # Thu Feb 9 20:20:37 UTC 2012 pkgname = ghostscript pkgver = 9.05-1 pkgdesc = An interpreter for the PostScript language url = http://www.ghostscript.com/ builddate = 1328818837 packager = Andreas Radke <andyrtr@archlinux.org> size = 46666752 arch = i686 license = GPL3 license = custom optdepend = texlive-core: needed for dvipdf optdepend = gtk2: needed for gsx depend = libxt depend = libcups depend = fontconfig depend = jasper depend = zlib depend = libpng>=1.5.7 depend = libjpeg depend = libtiff>=4.0.0 depend = lcms makepkgopt = strip makepkgopt = docs makepkgopt = !libtool makepkgopt = emptydirs makepkgopt = zipman makepkgopt = purge makepkgopt = !upx