Replies: 6 comments 30 replies
-
Other IdeasSome other ideas for the format, in either the short or long term:
|
Beta Was this translation helpful? Give feedback.
-
I think you also need to take into account different glibc versions and different standard C library implementations. So you probably also need a libc implementation field and a libc version number field also. In some distros one can even choose between MUSL and GlibC on many source-based distros for example. And there are binary MUSL-based distros also. |
Beta Was this translation helpful? Give feedback.
-
I suspect that restriction makes this very restrictive for higher-performance versions of extensions that depend on modern CPUs, like pgvector: The list contains only archetypes ( |
Beta Was this translation helpful? Give feedback.
-
I'm not so sure about these requirements. I don't have Python on my system, nor Ruby, and Perl is only installed because PostgreSQL requires it for development. Would Python/Perl/Ruby be an installation requirement for Trunk to work with this? That sounds like a rather large set of dependencies. |
Beta Was this translation helpful? Give feedback.
-
For extensions that use external dependencies (simples ones like pgsql-http depending on libcurl, complex ones like postgis depending on geos/gdal/proj/etc) what is the expectation for how those dependencies should be bundled? Static linking only? Is there some way to place dynamic dependencies in the pgsql tree such that the deps in the tree are picked up preferentially over deps already on the system? |
Beta Was this translation helpful? Give feedback.
-
NOTE: Moved to a pull request for the RFCs Book. |
Beta Was this translation helpful? Give feedback.
-
RFC: Binary Distribution Format
This RFC specifies the binary distribution format for PGXN packages, also called the trunk format.1
A trunk is a ZIP-format archive with a specially formatted file name and the
.trunk
extension. It contains a single distribution nearly as it would be installed by PGXS. Although a specialized installer is recommended, a trunk file may be installed by simply copying directories of files to destinations defined by pg_config.File Format
File name convention
The trunk filename is:
Definition of variables:
package
: Package name, e.g.vector
,postgis
,pgAdmin
.version
: Distribution version in SemVer format without build metadata, e.g.,0.8.6
or1.0.0-beta
.pg
: Major version of Postgres the binary was built against, e.g.,pg15
,pg16
.platform
: The platform the binary was built for. Will be made up of one to three hyphen-delimited2 values for the OS, version information3, and CPU architecture. Examples:any
,gnulinux-amd64
,darwin-23.5.0.arm64
,musllinux-1.2-amd64v3
. The allowed values will be defined one or more separate RFCs.Examples:
pgtap-1.0.1+pg15-any.trunk
packagespgtap
version 1.9.1, compatible with Postgres 15 (any minor release) on any platform.pair-0.32.1+pg16-gnulinux-amd64.trunk
packagespair
version 0.32.1,compatible with Postgres 16 (any minor release) on GNU libc-based Linux for amd64 CPUs.
pair-0.32.1+pg16-darwin-23.5.0-arm64.trunk
packagespair
version 0.32.1, compatible with Postgres 16 (any minor release) on Darwin version 23.5.0 (macOS) for arm64 CPUs.Escaping and Unicode
The
+
in the file name indicates the division between the package name and version and the package metadata. The package name and version must not include a+
. This allows the file name, without the.trunk
extension, to also function as a valid SemVer.Tools producing trunks should verify that the filename components do not contain
+
, as the resulting file may not be processed correctly if it does.The package name should be lowercase.
The file name components should all be UTF-8.
The filenames inside the archive are encoded as UTF-8. Although some ZIP clients in common use do not properly display UTF-8 filenames, the encoding is supported by the ZIP specification.
Parsing
Parsing of the file name takes place in four parts:
For the file name, remove the
.trunk
extension. If working with the directory name (prefix) extracted from the archive, there will be no.trunk
extension.Split the name into two parts at the
+
sign. The left part is the package name and SemVer. The right part is the platform specification.For the left part, split on the right-most dash. If the string to the right of the dash is a valid SemVer, then the left part is the package name. If the right string is not a valid SemVer, try again at the second right-most dash and check again. Continue until a valid SemVer is produced or else fail.
Split the right string on dashes. There will be between two and four values as follows:
pg16
) andany
.pg16
), the OS (gnulinux
,darwin
, etc.), and the architecture (amd64
,arm64
, etc.)pg16
), the OS (gnulinux
,darwin
, etc.), the OS version (23.5.0
) and the architecture (amd64
,arm64
, etc.)Examples:
pgtap-1.0.1+pg15-any
pgtap
1.0.1
pg15
any
pair-0.32.1-beta1+pg16-gnulinux-amd64
pair
0.32.1-beta1
pg16
gnulinux
amd64
pair-0.32.1+pg16-darwin-23.5.0-arm64
pair
0.32.1
pg16
darin
23.5.0
arm64
File contents
The contents of a wheel file should unpack into a directory with the same name as the file, but without the
.trunk
extension. The contents of the directory are:trunk.json
contains metadata necessary to install the extension. The format wil be subject to a future RFC, but at a minimum will include the trunk format version, package version, dependencies, license, language and runtime (e.g., libc implementation and version), platform metadata, and Postgres version and build configuration. Trunk installers should warn if the trunk version is greater than the version it supports, and must fail if the Trunk version has a greater major version than the version it supports.digests
contains a list of (almost) all the files in the trunk and their secure hashes. Each line lists a single file and its checksum in the BSD digest format:{algorithm} ({filename}) = {checksum}
. Every file exceptdigests
--- which cannot contain a hash of itself --- must be listed in this file. The cryptographic hash algorithm must be SHA-256 or better; specifically, MD5 and SHA-1 are not permitted, as signed trunk files rely on the strong hashes indigests
to validate the integrity of the archive.pgsql
directory contains one or more subdirectories named forpg_config
directory configurations:bin
,doc
,html
,include
,pkginclude
,lib
,pkglib
,locale
,man
,share
, andsysconf
. Each contains the files to be installed in the correspondingpg_config
directory.pgsql/bin
and begin with exactly'#!{cmd}
, wherecmd
is the name of the interpreter, in order to enjoy script wrapper generation and shebang rewriting at install time. They must have no extension. The list of supported interpreters will depend on the features of the installer, but one can reasonably expect support for Perl, Python, and Ruby. If no appropriate instance of the given interpreter is present, the installer may abort the installation.README
,LICENSE
, andCHANGELOG
may optionally be in the directory. Each must be plain text or Markdown-formatted. In the latter case, they may use the extension.md
.Makefile
,configure
file or any other tool for building the package contents.During extraction, trunk installers verify all the hashes in
digests
against the file contents. Apart fromdigests
and its signatures, installation will fail if any file in the archive is not both mentioned and correctly hashed indigests
.Details
Installing a Trunk
The following descriptions will use a trunk file named
pair-0.32.1+pg16-gnulinux-amd64.trunk
. Trunk installation notionally consists of two phases:digests
itself, is listed indigest
along with it valid hash digest. If any file is missing or has an invalid digest, installation should fail. If a file listed indigests
is not present, installation should fail.trunk.json
file. Check that the distribution is compatible with:any
is allowed for any platform#!{cmd}
to point to the correct interpreter. Fail if no such interpreter is present.pgsql
directory.References
Footnotes
With much inspiration and from and gratitude to the Python Binary distribution format. ↩
Why hyphens? They allow the entire file name, between the package name and the
.trunk
extension, to be a valid SemVer. ↩See for example PEP 600 defining Python wheel tags for different versions of GNU libc and PEP 656 defining tags for different versions of musl libc. See also how Homebrew uses macOS version names in file names for its packages. ↩
Beta Was this translation helpful? Give feedback.
All reactions