Name

PGXN Meta Spec - The PGXN distribution metadata specification

Version

1.0.0

Synopsis

{
   "name": "pgTAP",
   "abstract": "Unit testing for PostgreSQL",
   "description": "pgTAP is a suite of database functions that make it easy to write TAP-emitting unit tests in psql scripts or xUnit-style test functions.",
   "version": "0.2.5",
   "maintainer": [
      "David E. Wheeler <theory@pgxn.org>",
      "pgTAP List <pgtap-users@pgfoundry.org>"
   ],
   "license": {
      "PostgreSQL": "http://www.postgresql.org/about/licence"
   },
   "prereqs": {
      "runtime": {
         "requires": {
            "plpgsql": 0,
            "PostgreSQL": "8.0.0"
         },
         "recommends": {
            "PostgreSQL": "8.4.0"
         }
      }
   },
   "provides": {
     "pgtap": {
       "file": "sql/pgtap.sql",
       "docfile": "doc/pgtap.mmd",
       "version": "0.2.4",
       "abstract": "Unit testing assertions for PostgreSQL"
     },
     "schematap": {
       "file": "sql/schematap.sql",
       "docfile": "doc/schematap.mmd",
       "version": "0.2.4",
       "abstract": "Schema testing assertions for PostgreSQL"
     }
   },
   "resources": {
      "homepage": "http://pgtap.org/",
      "bugtracker": {
         "web": "http://github.com/theory/pgtap/issues"
      },
      "repository": {
        "url":  "https://github.com/theory/pgtap.git",
        "web":  "https://github.com/theory/pgtap",
        "type": "git"
      }
   },
   "generated_by": "David E. Wheeler",
   "meta-spec": {
      "version": "1.0.0",
      "url": "http://pgxn.org/meta/spec.txt"
   },
   "tags": [
      "testing",
      "unit testing",
      "tap",
      "tddd",
      "test driven database development"
   ]
}

Description

This document describes version 1.0.0 of the PGXN distribution metadata specification, also known as the “PGXN Meta Spec.” It is formatted using the MultiMarkdown variant of Markdown, and the canonical copy may always be found at master.pgxn.org/meta/spec.txt. A generated HTML-formatted copy found at pgxn.org/spec/ may also be considered canonical.

This document is stable. Any revisions to this specification for typo corrections and prose clarifications may be issued as “PGXN Meta Spec 1.0.x”. These revisions will never change semantics or add or remove specified behavior.

Distribution metadata describe important properties of PGXN distributions. Distribution building tools should create a metadata file in accordance with this specification and include it with the distribution for use by automated tools that index, examine, package, or install PGXN distributions.

Terminology

distribution
The primary object described by the metadata. In the context of this document it usually refers to a collection of extensions, source code, utilities, tests, and/or documents that are distributed together for other developers to use. Examples of distributions are semver, pair, and pgTAP.
extension
A reusable library of code contained in a single file or within files referenced by the CREATE EXTENSION statement. Extensions usually contain one or more PostgreSQL objects — such as data types, functions, and operators — and are often referred to by the name of a primary object that can be mapped to the file name. For example, one might refer to pgTAP instead of sql/pgtap.sql.
consumer
Code that reads a metadata file, deserializes it into a data structure in memory, or interprets a data structure of metadata elements.
producer
Code that constructs a metadata data structure, serializes into a bytestream and/or writes it to disk.
must, should, may, etc.
These terms are interpreted as described in IETF RFC 2119.

Data Types

Fields in the Structure section describe data elements, each of which has an associated data type as described herein. There are four primitive types: Boolean, String, List, and Map. Other types are subtypes of primitives and define compound data structures or define constraints on the values of a data element.

Boolean

A Boolean is used to provide a true or false value. It must be represented as a defined (not null) value.

String

A String is data element containing a non-zero length sequence of Unicode characters.

List

A List is an ordered collection of zero or more data elements. Elements of a List may be of mixed types.

Producers must represent List elements using a data structure which unambiguously indicates that multiple values are possible, such as a JavaScript array.

Consumers expecting a List must consider a String as equivalent to a List of length 1.

Map

A Map is an unordered collection of zero or more data elements (“values”), indexed by associated String elements (“keys”). The Map’s value elements may be of mixed types.

License String

A License String is a subtype of String with a restricted set of values. Valid values are described in detail in the description of the license field.

Term

A Term is a subtype of String that must be at least two characters long contain no slash (/), backslash (\), control, or space characters.

Tag

A Tag is a subtype of String that must be fewer than 256 characters long contain no slash (/), backslash (\), control, or space characters.

URI

URI is a subtype of String containing a Uniform Resource Identifier or Locator.

Version

A Version is a subtype of String containing a value that describes the version number of extensions or distributions. Restrictions on format are described in detail in the Version Format section.

Version Range

The Version Range type is a subtype of String. It describes a range of Versions that may be present or installed to fulfill prerequisites. It is specified in detail in the Version Ranges section.

Structure

The metadata structure is a data element of type Map. This section describes valid keys within the Map.

Any keys not described in this specification document (whether top-level or within compound data structures described herein) are considered custom keys and must begin with an “x” or “X” and be followed by an underscore; i.e. they must match the pattern: /\Ax_/i. If a custom key refers to a compound data structure, subkeys within it do not need an “x_” or “X_” prefix.

Consumers of metadata may ignore any or all custom keys. All other keys not described herein are invalid and should be ignored by consumers. Producers must not generate or output invalid keys.

For each key, an example is provided followed by a description. The description begins with the version of spec in which the key was added or in which the definition was modified, whether the key is required or optional, and the data type of the corresponding data element. These items are in parentheses, brackets, and braces, respectively.

If a data type is a Map or Map subtype, valid subkeys will be described as well. All examples are represented as JSON.

Required Fields

abstract

Example:

"abstract": "Unit testing for PostgreSQL"

(Spec 1) [required] {String}

This is a short description of the purpose of the distribution.

maintainer

Examples:

"maintainer": "David E. Wheeler <theory@pgxn.org>"

"maintainer": [
  "David E. Wheeler <theory@pgxn.org>",
  "Josh Berkus <jberkus@pgxn.org>"
]

(Spec 1) [required] {List of one or more Strings}

This List indicates the person(s) to contact concerning the distribution. The preferred form of the contact string is:

contact-name <email-address>

This field provides a general contact list independent of other structured fields provided within the resources field, such as bugtracker. The addressee(s) can be contacted for any purpose including but not limited to: (security) problems with the distribution, questions about the distribution, or bugs in the distribution.

A distribution’s original author is usually the contact listed within this field. Co-maintainers, successor maintainers, or mailing lists devoted to the distribution may also be listed in addition to or instead of the original author.

license

Examples:

"license": {
  "PostgreSQL": "http://www.postgresql.org/about/licence"
}

"license": {
  "Perl 5": "http://dev.perl.org/licenses/",
  "BSD": "http://www.opensource.org/licenses/bsd-license.html"
}

"license": "perl_5"

"license": [ "apache_2", "mozilla_1_0" ]

(Spec 1) [required] {Map or List of one or more License Strings}

One or more licenses that apply to some or all of the files in the distribution. If multiple licenses are listed, the distribution documentation should be consulted to clarify the interpretation of multiple licenses.

The Map type describes the license or licenses. Each subkey may be any string naming a license. All values must be URIs that link to the appropriate license.

The List type may be used as a shortcut to identify one or more well-known licenses. The following list of License Strings are valid in the List representation:

string description
agpl_3 GNU Affero General Public License, Version 3
apache_1_1 Apache Software License, Version 1.1
apache_2_0 Apache License, Version 2.0
artistic_1 Artistic License, (Version 1)
artistic_2 Artistic License, Version 2.0
bsd BSD License (three-clause)
freebsd FreeBSD License (two-clause)
gfdl_1_2 GNU Free Documentation License, Version 1.2
gfdl_1_3 GNU Free Documentation License, Version 1.3
gpl_1 GNU General Public License, Version 1
gpl_2 GNU General Public License, Version 2
gpl_3 GNU General Public License, Version 3
lgpl_2_1 GNU Lesser General Public License, Version 2.1
lgpl_3_0 GNU Lesser General Public License, Version 3.0
mit MIT (aka X11) License
mozilla_1_0 Mozilla Public License, Version 1.0
mozilla_1_1 Mozilla Public License, Version 1.1
openssl OpenSSL License
perl_5 The Perl 5 License (Artistic 1 & GPL 1 or later)
postgresql The PostgreSQL License
qpl_1_0 Q Public License, Version 1.0
ssleay Original SSLeay License
sun Sun Internet Standards Source License (SISSL)
zlib zlib License

The following License Strings are also valid and indicate other licensing not described above:

string description
open_source Other Open Source Initiative (OSI) approved license
restricted Requires special permission from copyright holder
unrestricted Not an OSI approved license, but not restricted
unknown License not provided in metadata

All other strings are invalid in the license List.

provides

Example:

"provides": {
  "pgtap": {
    "file": "sql/pgtap.sql",
    "docfile": "doc/pgtap.mmd",
    "version": "0.2.4",
    "abstract": "Unit testing assertions for PostgreSQL"
  },
  "schematap": {
    "file": "sql/schematap.sql",
    "docfile": "doc/schematap.mmd",
    "version": "0.2.4",
    "abstract": "Schema testing assertions for PostgreSQL"
  }
}

(Spec 1) [required] {Map of Terms}

This describes all extensions provided by this distribution. This information is used by PGXN to build indexes identifying in which distributions various extensions can be found.

The keys of provides are Terms that name the extensions found within the distribution. The values are Maps with the following subkeys:

file
The value must contain a relative file path from the root of the distribution to the file containing the extension. The path must be specified with unix conventions. Required.
version
This field contains a Version for the extension. All extensions must have versions. Required.
abstract
A short String value describing the extension. Optional.
docfile
The value must contain a relative file path from the root of the distribution to the file containing documentation for the extension. The path must be specified with unix conventions. Optional.

meta-spec

Example:

"meta-spec": {
  "version": "1.0.0",
  "url": "http://pgxn.org/meta/spec.txt"
}

(Spec 1) [required] {Map}

This field indicates the Version of the PGXN Meta Spec that should be used to interpret the metadata. Consumers must check this key as soon as possible and abort further metadata processing if the meta-spec Version is not supported by the consumer.

The following keys are valid, but only version is required.

version
This subkey gives the integer Version of the PGXN Meta Spec against which the document was generated.
url
This is a URI of the metadata specification document corresponding to the given version. This is strictly for human-consumption and should not impact the interpretation of the document.

name

Example:

"name": "pgTAP"

(Spec 1) [required] {Term}

This field is the name of the distribution. This is usually the same as the name of the “main extension” in the distribution, but may be completely unrelated to the extensions within the distribution. This value will be used in the distribution file name on PGXN.

version

Example:

"version": "1.3.6"

(Spec 1) [required] {Version}

This field gives the version of the distribution to which the metadata structure refers. Its value must be a Version.

Optional Fields

description

Example:

"description": "pgTAP is a suite of database functions that make it easy to write TAP-emitting unit tests in psql scripts or xUnit-style test functions."

(Spec 1) [optional] {String}

A longer, more complete description of the purpose or intended use of the distribution than the one provided by the abstract key.

generated_by

Example:

"generated_by": "Module::Build::PGXN version 0.42"

(Spec 1) [optional] {String}

This field indicates the tool that was used to create this metadata. There are no defined semantics for this field, but it is traditional to use a string in the form “Software package version 1.23” or the maintainer’s name, if the file was generated by hand.

tags

Example:

"tags": [ "testing", "unit testing", "tap" ]

(Spec 1) [optional] {List of Tags}

A List of keywords that describe this distribution.

no_index

Example:

"no_index": {
  "file":      [ "src/file.sql" ],
  "directory": [ "src/private" ],
}

(Spec 1) [optional] {Map}

This Map describes any files or directories that are private to the packaging or implementation of the distribution and should be ignored by indexing or search tools.

Valid subkeys are as follows:

file
A List of relative paths to files. Paths must be specified with unix conventions.
directory
A List of relative paths to directories. Paths must be specified with unix conventions.

prereqs

Example:

"prereqs": {
  "runtime": {
    "requires": {
      "PostgreSQL": "8.0.0",
      "PostGIS": "1.5.0"
    },
    "recommends": {
      "PostgreSQL": "8.4.0"
    },
    "suggests": {
      "sha1": 0
    }
  },
  "build": {
    "requires": {
      "prefix": 0
    }
  },
  "test": {
    "recommends": {
      "pgTAP": 0
    }
  }
}

(Spec 1) [optional] {Map}

This is a Map that describes all the prerequisites of the distribution. The keys are phases of activity, such as configure, build, test, or runtime. Values are Maps in which the keys name the type of prerequisite relationship such as requires, recommends, suggests, or "conflicts", and the values provide sets of prerequisite relations. The sets of relations must be specified as a Map of extension names to Version Ranges.

The full definition for this field is given in the Prereq Spec section.

release_status

Example:

"release_status": "stable"

(Spec 1) [optional] {String}

This field specifies the release status of this distribution. It must have one of the following values:

stable
Indicates an ordinary, “final” release that should be indexed by PGXN.
testing
Indicates a “beta” release that is substantially complete, but has an elevated risk of bugs and requires additional testing. The distribution should not be installed over a stable release without an explicit request or other confirmation from a user. This release status may also be used for “release candidate” versions of a distribution.
unstable
Indicates an “alpha” release that is under active development, but has been released for early feedback or testing and may be missing features or may have serious bugs. The distribution should not be installed over a stable release without an explicit request or other confirmation from a user.

Consumers may use this field to determine how to index the distribution for PGXN or other repositories. If this field is not present, consumers may assume that the distribution status is “stable.”

resources

Example:

"resources": {
  "homepage": "http://pgxn.org/",
  "bugtracker": {
    "web": "http://github.com/theory/pgtap/issues",
    "mailto": "pgxn-bugs@example.com"
  },
  "repository": {
    "url": "git://github.com/theory/pgtap.git",
    "web": "http://github.com/theory/pgtap/",
    "type": "git"
  },
  "x_twitter": "http://twitter.com/pgtap/"
}

(Spec 1) [optional] {Map}

This field describes resources related to this distribution.

Valid subkeys include:

homepage
A URI for the official home of this project on the web.
bugtracker
This entry describes the bug tracking system for this distribution. It is a Map with the following valid keys:
web

a URI pointing to a web front-end for the bug tracker

mailto

an email address to which bug reports can be sent

repository
This entry describes the source control repository for this distribution. It is a Map with the following valid keys:
url

a URI pointing to the repository itself

web

a URI pointing to a web front-end for the repository

type

a lowercase string indicating the VCS used

Because a URI like http://myrepo.example.com/ is ambiguous as to type, producers should provide a type whenever a url key is given. The type field should be the name of the most common program used to work with the repository, e.g. git, svn, cvs, darcs, bzr or hg.

Version Numbers

Version Format

This section defines the Version type, used by several fields in the PGXN Meta Spec.

Version numbers must be treated as strings, and adhere to the Semantic Versioning Specification. Semantic versions take a dotted-integer format consisting of three positive integers separated by full stop characters (i.e. “dots”, “periods” or “decimal points”). A “special version” may be denoted by appending an arbitrary ASCII string immediately following the patch version. Please see the specification for all details on the format.

Version Ranges

Some fields (prereqs) indicate the particular version(s) of some other extension that may be required as a prerequisite. This section details the Version Range type used to provide this information.

The simplest format for a Version Range is just the version number itself, e.g. 2.4.0. This means that at leastversion 2.4.0 must be present. To indicate that any version of a prerequisite is okay, even if the prerequisite doesn’t define a version at all, use the version 0.

Alternatively, a version range may use the operators < (less than), <= (less than or equal), > (greater than), >= (greater than or equal), == (equal), and != (not equal). For example, the specification < 2.0.0 means that any version of the prerequisite less than 2.0.0 is suitable.

For more complicated situations, version specifications may be AND-ed together using commas. The specification >= 1.2.0, != 1.5.0, < 2.0.0 indicates a version that must be at least 1.2.0, less than 2.0.0, and not equal to 1.5.0.

Prerequisites

Prereq Spec

The prereqs key defines the relationship between a distribution and other extensions. The prereq spec structure is a hierarchical data structure which divides prerequisites into Phases of activity in the installation process and Relationships that indicate how prerequisites should be resolved.

For example, to specify that pgtap is required during the test phase, this entry would appear in the distribution metadata:

"prereqs": {
  "test": {
    "requires": {
      "pgtap": 0
    }
  }
}

Note that the prereqs key may not be used to specify prerequisites distributed outside PGXN or the PostgreSQL core and its contrib extensions.

Phases

Requirements for regular use must be listed in the runtime phase. Other requirements should be listed in the earliest stage in which they are required and consumers must accumulate and satisfy requirements across phases before executing the activity. For example, build requirements must also be available during the test phase.

before action requirements that must be met
./configure configure
make configure, runtime, build
make test configure, runtime, build, test

Consumers that install the distribution must ensure that runtime requirements are also installed and may install dependencies from other phases.

after action requirements that must be met
make install runtime
configure
The configure phase occurs before any dynamic configuration has been attempted. Extensions required by the configure phase must be available for use before the distribution building tool has been executed.
build
The build phase is when the distribution’s source code is compiled (if necessary) and otherwise made ready for installation.
test
The test phase is when the distribution’s automated test suite is run. Any extension needed only for testing and not for subsequent use should be listed here.
runtime
The runtime phase refers not only to when the distribution’s contents are installed, but also to its continued use. Any extension that is a prerequisite for regular use of this distribution should be indicated here.
develop
The develop phase’s prereqs are extensions needed to work on the distribution’s source code as its maintainer does. These tools might be needed to build a release tarball, to run maintainer-only tests, or to perform other tasks related to developing new versions of the distribution.

Relationships

requires
These dependencies must be installed for proper completion of the phase.
recommends
Recommended dependencies are strongly encouraged and should be satisfied except in resource constrained environments.
suggests
These dependencies are optional, but are suggested for enhanced operation of the described distribution.
conflicts
These dependencies cannot be installed when the phase is in operation. This is a very rare situation, and the conflicts relationship should be used with great caution, or not at all.

Merging and Resolving Prerequisites

Whenever metadata consumers merge prerequisites, they should be merged in a way that preserves the intended semantics of the prerequisite structure. Generally, this means concatenating the version specifications using commas, as described in the Version Ranges section.

A subtle error that can occur when resolving prerequisites comes from the way that extensions in prerequisites are indexed to distribution files on PGXN. When a extension is deleted from a distribution, prerequisites calling for that extension could indicate that an older distribution should installed, potentially overwriting files from a newer distribution.

For example, say the PGXN index contained these extension-distribution mappings:

Extension Version Distribution
pgtap 0.25.0 pgTAP-0.25.0.zip
schematap 0.25.0 pgTAP-0.25.0.zip
functap 0.18.1 pgTAP-0.18.1.zip

Note that functap was removed from the pgTAP distribution sometime after 0.18.1. Consider the case where pgTAP 0.25.0 is installed. If a distribution specified “functap” as a prerequisite, it could result in pgTAP-0.18.1.tar.gz being installed, overwriting any files from pgTAP-0.25.0.zip.

Consumers of metadata should test whether prerequisites would result in installed module files being “downgraded” to an older version and may warn users or ignore the prerequisite that would cause such a result.

Serialization

Distribution metadata should be serialized as JSON-encoded data and packaged with distributions as the file META.json.

Notes For Implementors

Comparing Version Numbers

Following the Semantic Versioning Spec, version numbers must be strictly compared by splitting the Version string on full stop characters (i.e. “dots”, “periods” or “decimal points”) and comparing each of the three parts as integers. If an ASCII string has been appended to the third number, it will be extracted and compared in ASCII-betical order, and in any event will be considered to be less than an un-encumbered third integer of the same value. Some examples:

0.12.1      < 0.12.2
1.42.0      > 1.41.99
2.0.0       > 1.999.999
2.0.0alpha3 < 2.0.0beta1
2.0.0beta   < 2.0.0

See Also

Contributors

The PGXN Meta Spec borrows heavily from the CPAN Meta Spec, which was originally written by Ken Williams in 2003 and has since been updated by Randy Sims, David Golden, and Ricardo Signes. Ported to PGXN by David E. Wheeler.