7.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
(call-with-pkgs-transaction proc) → any
proc : (-> any)
Added in version 6.1.1.5 of package base.
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-ring name catalog)
→ (or/c #f exact-nonnegative-integer?) name : string? catalog : string?
procedure
(set-pkg-ring! name catalog ring) → void?
name : string? catalog : string? ring : (or/c #f exact-nonnegative-integer?)
The PLT-supported package catalog reports a curated ring number to reflect advice on package preference and conflicts, where the set of ring-0 and ring-1 packages are expected to have no conflicts (that is, no multiply defined modules, document names, etc.). The raco pkg tool does not pay attention to a package’s ring number, but other uses of a catalog may consult ring numbers.
Added in version 6.10.0.3 of package base.
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 "".