Update filters are simple post-processing hooks. They're run after any input files have been collected, and before the target package is built.
|-u man||Compresses man pages.|
|-u appdata|| Creates
|-u desktop|| Adds a stub
||Update a `composer.json` for phar target.|
|-u fixperms|| Limit file permissions (
|-u strip||Strip debugging symbols from binaries.|
|-u deps||Resolve library/dependency names across distros.|
|-u unprefix||Converting system package filenames to local paths.|
|-u lcase||Lowercase filenames and directories.|
|-u preprocess||Expand preprocessing macros in source files.|
|-u packfile||Customize via external/packaged-in Packfile make script.|
You'd usually run them with:
xpm -s dir -u man,appdata,desktop -t deb ...
They're intended for simple tasks.
- Can supplant build/make steps that rather belong into the packaging process.
- They're partly resembling debian-helpers.
- Can either be specified as comma-separated lists, or with multiple -u or --filter flags.
- Some plugins take options separated by
=from plugin name, as in -u deps=fedora or -u lcase=*:php:rb
Note that filters are applied just once on the input, not on each output package in a multi-target build.
The "man" filter simply compresses manpages found in the staging path.
- It looks for a man/ directory.
- Searches for files ending in .1 or .2 or other numeric suffixes.
It's intended to avoid that step in Makefiles. (As this is clearly a packaging thing.)
The "appdata" filter crafts a plain PKG.appdata.xml file. Those are used by the application managers/centers in most distributions. It's an agreed format between DEB and RPM-based distros, Listaller, etc.
A few things missing here:
- We likely need a
--screenshotflag. Those are the primary purpose of AppData/AppStream.
- This filter will overwrite existing appdata.xml files. So don't use it, if you're already providing one.
- We likely need a
State: very crude.
With -u desktop an application icon file
appname.desktopwill be generated.
- Don't use this update filter if you're already providing one.
- It will be prefixed with
fpm:appnameto avoid collisions.
When using the -t phar module, you may wish to combine it with an implicit -u composer update.
- Writes current version etc. to
Creates a stub composer.json otherwise, containing:
- type: Library
- extra: [ Maintainer, Epoch, Releases (stub) ]
- autoload (shared.phar)
No dependency translation is handled whatsoever currently. (This plugin is primarily meant for -s src to -t phar conversion. The php plugin meta data fields are somewhat broader than composer bundle specs; and the dependencies specifically more localized application/api-targeted. Besides there's no agreed mapping yet between composer and system packages.)
Note that there's a distinct -s composer source package plugin. The two have orthogonal use cases.
- Writes current version etc. to
Converts directory and filenames to lowercase.
- Directories are always lowercased.
- File extensions can be specified with -u lcase=* for all, or lcase=php:cpp for specific groups to lowercase.
This is meant just for the -t phar target. It's probably less suitable for system packages.
The deps filter is supposed to convert distro-specific package names. It utilizes
distromatch. Since the latter is discontinued, it might make sense to just bundle a few package maps with
xpm/fpmdirectly, and perform the lookup (for major distros) internally. (Would also be faster, really.)
For extracing system package contents back into relative/local path structures you can use:
xpm -s deb -u unprefix=/usr/share/appfiles/ -t zip pkgname.deb
This will slice out just the files given below the base path as filter= argument.
Applies umask 0755 to files. Which is somewhat redundant since both deb and rpm plugins already implement a variation thereof.
Strips debugging symbols from binaries.
- Is just applied to binaries.
- Skips shared libraries currently.
Pipes source files through
preprocess.pyto expand macros. This is meant for scripting languages, not as C/C++ build hook.
The recognized comment syntax is based on the source language / file extensions.
/* #include "file.ph" */
<!-- #include "file.ph" -->
It doesn't process literal C-macros.
- In-code substitutions of defined constants are enabled per default (preprocess -s flag).
- Expects a file extension list, such as -u preprocess=pl:php:rb.
preprocessto be available, which is packaged for Debian distros at least.
To make packaging hooks even more flexible, there's now a thing called Packfiles. They're basically make scripts, get run within the
/tmp/pack-xyz-staging/directory, after all "source" files have been collected.
Packfilegets picked up from where fpm/xpm was invoked from. Any Packfiles that somehow end up in the staging path along with "source" files will be run too, but be removed afterwards. Both types run only within the staging dir, so can use relative paths all along:
all: touch etc/defaults/mypkg.conf
A few environment variables are predefined (
PACK_ARCH) for even more cusomizations. But of course shouldn't be used habitually. The purpose of Packfiles is to untangle the real build steps from mere/minor packaging and file arrangement tasks.