Package description files are used to store metadata about a package. This includes information on how to retrieve/build the package and what files are used by the package. Package description go through various phases until they are ready to be used:

Recipe
In this stage the package description is all there is. It is an instruction as to where to get the files and how to build a binary from the source code. Attributes are used to specify various flexible characteristics of the build environment. Recipies usually exist in /var/upm/avail and its subdirectories. A single files contains all the build instructions.
Build
In the build stage B records have been added and the variable nature of the attributes has become fixed by commitments to a certain style of build. The binary package is bound to a CPU architecture and the features are fixed now. A binary package might be stored as a .tgz tarball somewhere or just be a temporary stage in a directory generated by uPM. Builds might exist as tarballs in /var/upm/binary/ARCH/.
Installed
In the installed stage the package description contains records of files, directories and symlinks installed and exact records on the metainformation of all packages so that the current state of the package can be verified. The package descriptions of installed packages are to be found in /usr/upm/installed.

Package description files are simple lines of text with fields separated by blanks. The last parameter might be a string containing blanks. No quoting is necessary.

Some records can contain references to variables implemented by String Expansion which might refer to the attribute definition in /etc/upm.conf and the package description.. String expansion is done when content is contained in { }. The following expansions are supported:

exp ? e1 : e2
Conditional. If exp is true/defined then e1 is used as a value otherwise e2
e1 & e2
Boolean logic & and | are supported.
e2 = e2
Comparisions. All typical forms of comparision in C are supported.
VARIABLE
Reference to a variable. Looked up in B records A records and attribute section of upm.conf
"string"
String literal
123.xx.44
String literal
( e )
Subexpression
! e
NOT expression
The following fixed variables are available during the build process:

  1. B The target directory where the install should place the binaries
  2. S The source directory where the build process takes place
  3. V The version number of the package
  4. P The name of the package
  5. UPM_VERSION The version of UPM runnig

Filesystem Entities Definition records

These lines are used to track the files owned by a package. The lines are only allowed to exist if the package is installed. Upon installation these lines are derived from the contents of the source tree.
Directories
D <FN> <PERM> <OWNER> <GROUP>
Files
F <FN> <PERM> <OWNER> <GROUP> <MD5SUM> <SIZE>
Links
L <FN> <TARGET>
Nodes (special devices, pipes and such)
N <FN> <PERM> <OWNER> <GROUP> <DEV>
Entities commandered by other packages
Z <FN> <Package>

Z records will be generated when another package has replaced files of the package. They are a memory of file that have been there and a record of who the villian was.

Header Records

Description of the Package
W <descriptive text>

This contains the text displayed when an overview of packages is requested.

Options
O <option>

Is used to set up special behavior of the packaging system. Supported are

OVERWRITE
Allows other packages to overwrite files in this package. Files will vanish as other files provide them. This is used for busybox to gradually relinguish its commands to the "real" thing. A package with the OVERWRITE package will not install files that are already provided by other packages.
Source specification
S <url> <md5sum>

Retrieve and unpack source code from the indicated location. Contents retrieved are checked against the (optional) md5sum. All the classic tar compressed formats are supported.

Patch Specifications
P <patch-url> <md5sum>

Patch-Hinting allows hinting to UPM how the patch has to be applied. Without a hint UPM will try to do patch-magic by trying various way of applying the patch until it fits. Patch hinting is done by appending @ to the end of the patch. If a number follows then that is the -p parmeter value usually given to patch. If some text follows then that is the directory to CD to before doing a patch -p0.

Binary specification
C <arch< <binary-url> <md5sum>

C lines specifiy where binaries with default configuration are available. The arch specifies the basic architecture. Binaries are not as flexible as recipes. The binary will not install if there is a basic incompatibility of attribute settings.

Homepage specification
H <homepage-url>
Relationship specification
R <relationship> <package> <condition>

How does a package relate to other packages. Relationships allowed are DEPEND, CONFLICT, RDEPEND, REPLACES, PROVIDE. In the case of PROVIDE the condition is the version of the virtual package and not a condition. REPLACE means that the package referred to is completely removed on installation of this package. A BUILD reference causes version information from the depended on package to be imported into the B records.

Event specifications
E <Event> line of shell command

Shell commands are run at specific events. All shell commands undergo string expansion first. It is possible to have these shell commands customized by the attributes of the package or of the system. It is strongly suggested NOT to use these event scripts but rather to rely on the attributes controlling the build engine, triggers, Blacklists and system wide scriptsi as much as possible. Package descriptions containing *MERGE events might be considered unsafe at some point. Do not write maintainer scripts that are package specific If you need some functionality then please generalize it and put it into some kind of utility package. The event handlers can then invoke those scripts. Maintainer scripts tend to rot since no one bothers with them. Tools that can be useful for multiple packages will usually be maitained well.

Possible events are:

POSTINST
Execute after the package has been installed into the temporary binary tree NOT into the / tree. Executed as the root user in a fakeroot environment. The current directory is the binary directory. This is typically used to clean up the binary tree and provide other finishing touches. Note that the base husk (directory and links from the base package) is removed automatically before the POSTINST is run. It is rare that this event hander would be needed.
PREINST
Execute before the package files are moved into the temporary binary tree NOT into the / tre. Executed as the root user in a fakeroot environment. Current directory is the binary directory. This is typically used to setup directories that the configure or build stages expect. Note that the husk (directories and symlinks) of the base package is always provided in temporary binary trees. Only in extraordinary circumstances is it necessary to run an event handler here.
PREMERGE
Executed before the package files are moved into the / tree. {B} is the directory of the binary tree to be merged in. This can be used to simulate Debian preinst scripts. Simply invoke a script from the {B} tree... maybe {B}/var/lib/dpkg/info/mypackage.preinst ?? I would recommend not to use such a script since this script has to run as real root.
POSTMERGE
Execute after all the package files have been moved into the / tree as real root. Current directory is the / directory.
PRERM
Run as root before the package is removed.
POSTRM
Run as root after the package is removed.
PRECONFIGURE
Run as fakeroot user. Directory is sourcedirectory. Before configure
POSTCONFIGURE
Run as fakeroot user. Directory is sourcedirectory. After configure.
PREBUILD
Run as fakeroot user. Directory is sourcedirectory. Before build.
POSTBUILD
Run as fakeroot user. Directory is sourcedirectory. After build.
Attribute specification
A <Attribute> <contents>

Attributes allow to specify various information that might be used by dependency conditions and to control and track the build process. Two important attributes are VERSION which is the version of the package installed. VERSION is generated from the version provided at install time. DELTA is used to track revisions to the package description if necessary. It is optional and should only be set if there is a need to track multiple package descriptions for a single VERSION.

Build Attributes
B <Attribute> <contents>

Build records are generated during the building of binaries from source. They track the values attributes had when the binary was build. Build records are also used to track the versions of all packages mentioned in build depends. This enables a forced rebuild of all packages that have been generated with a broken version. If dependency checks are being done and references to attributes of packages are made then the build attributes are the significant values..

Installation Attributes
I <Attribute> <contents>

Installation attributes track what happened during the merging of the package into the real tree. Currently that info includes only version of packages replaced.

Environment Variables
V <type> <variable> <value>

Environment variables allow the control of paths such as MANPATH, PATH and the paths used for ld.so as well as default settings in /etc/profile. The V records are processed in order of priority. The packages with the most depth of dependencies are processed first and the packages depending on them later. Therefore packages depending on others can override settings as needed.

Types of variables:

PATH
Multiple specifications of the variable result in concatenation of the strings specified by :.
ENV
Simply set environment variables. Multiple occurences cause an override.
SET
Multiple occurrences are not allowed. Fail if multiple settings exist.
The following files are generated from the V settings:
/usr/upm/env/environment
Raw list of the variables and their effective settings
/usr/upm/env/profile.env
File with a suitable format to be sourced by bash and others.
/usr/upm/env/csh.evn
File with a suitable format to be sourced by csh and others.
/usr/upom/env/ld.so.conf
Configuration file for ld.so suitable to generate a list of all directories to be processed by ld.so
Priority Links
Y <FN> <TARGET> <Priority>

Priority Links are used to manage multiple programs providing the same functionality. For example there are multiple ways to provide a vi editor. Packages can define a priority and the system will point the link to the lowest priority link. The user can display priorities and fix these pointers to a favorite implementation.

Blacklist
X <File> ABORT/WARN/IGNORE

Blacklisting is used to prevent packages from installing files. Typically there are files that are dirctories of information such as /usr/info/dir. Many packages provide these files. uPM enforces that no packages should overwrite other packages files and therefore those installs will fail. Blacklisting the file will make it possible for uPM to handle the situation intelligently. ABORT means that packages providing that packages providing that file will not install. WARN means allow the installation but warn about the situation. IGNORE means to simply silently ignore the garbage.

Blacklisting can also be used for Directories. Some major directories can be taken offline. The base package does that extensively to prohibit accidents.

Trigger
T <Dir> <Shell-code<

Execute the script when a package writes new contents to the directory or removes files from the directory. {N} contains a list of new files. {R} contains the list of removed files.

A simple example for the use of a trigger is the invocation of ldconfig:

T lib ldconfig
T usr/lib ldconfig
will insure that ldconfig is run whenever there is a new file in those directories.