6.5 Package Catalog Database
The functions provided by pkg/db do not actually manage packages; they do not change or consult the local database of installed modules in any package scope. The functions provided by pkg/db simply reflect a local copy of the information that a package catalog and individual package might provide (but with no guarantee of being in sync with an actual package catalog or package).
The database is implemented as an SQLite database with its own locking, so no additional locks are needed for database access, but beware of concurrent database changes that could break your program logic.
struct
(struct pkg (name catalog author source checksum desc) #:extra-constructor-name make-pkg #:transparent) name : string? catalog : string? author : string? source : string? checksum : string? desc : string?
parameter
(current-pkg-catalog-file file) → void? file : path-string?
procedure
(get-catalogs) → (listof string?)
procedure
(set-catalogs! catalogs) → void?
catalogs : (listof string?)
The set-catalogs! function removes information for any other package catalogs from the database.
The result list is ordered by precedence of the package catalog.
procedure
(set-pkgs! catalog pkgs #:clear-other-checksums? clear-other-checksums?) → void? catalog : string? pkgs : (listof (or/c string? pkg?)) clear-other-checksums? : #t
Information about any other package for catalog is removed from the database. If a string is provided for pkgs, it is treated as a package name; if additional information is already recorded in the database for the package name, then the additional information is preserved.
If clear-other-checksums? is true, then for each element of pkgs that has a given checksum other than "", any information in the database specific to another checksum (such as a list of module paths) is removed from the database.
procedure
(set-pkg! name catalog author source checksum desc #:clear-other-checksums? clear-other-checksums?) → void? name : string? catalog : string? author : string? source : string? checksum : string? desc : string? clear-other-checksums? : (not (equal? checksum ""))
If clear-other-checksums? is true, then information (such as a list of module paths) is removed from the database when it is specific to a checksum other than checksum.
procedure
(get-pkg-tags name catalog) → (listof string?)
name : string? catalog : string?
procedure
(set-pkg-tags! name catalog module-paths) → void?
name : string? catalog : string? module-paths : (listof string?)
procedure
(get-pkg-dependencies name catalog checksum) → (listof list?)
name : string? catalog : string? checksum : string?
procedure
(set-pkg-dependencies! name catalog checksum dependencies) → void? name : string? catalog : string? checksum : string? dependencies : (listof any/c)
The list of dependencies must have the shape described for a deps "info.rkt" field as described in Package Metadata. The result from get-pkg-dependencies is normalized: each dependency is represented by a list, a version in a dependency is always preceded by '#:version, and if both version and platform specification are included, '#:version appears before '#:platform.
procedure
(get-pkg-modules name catalog checksum) → (listof module-path?)
name : string? catalog : string? checksum : string?
procedure
(set-pkg-modules! name catalog checksum module-paths) → void? name : string? catalog : string? checksum : string? module-paths : (listof module-path?)
procedure
(get-module-pkgs module-path) → (listof pkg?)
module-path : module-path?
procedure
(get-pkgs-without-modules [#:catalog catalog]) → (listof pkg?)
catalog : (or/c #f string?) = #f
Each resulting pkg has its name, catalog, and checksum field set, but other fields may be "".