► |  | Package Management in Racket

1 | Getting Started with Packages
2 | Package Concepts
3 | Using raco pkg
4 | Package Metadata
5 | Source, Binary, and Built Packages
6 | Package APIs
7 | Package Catalog Protocol
8 | PLane T Compatibility
9 | FAQ
10 | Future Plans

▼ | 6 | Package APIs

6.1 | Functions for raco pkg
6.2 | Package Management Functions
6.3 | Package Paths and Database
6.4 | Package Source Parsing
6.5 | Package Catalog Database

On this page:

pkg-info
sc-pkg-info
pkg-info/ alt
sc-pkg-info/ alt
path->pkg
path->pkg+ subpath
path->pkg+ subpath+ collect
get-pkgs-dir
read-pkgs-db
read-pkg-file-hash

5.92
top ← prev up next →

#### 6.3`` Package Paths and Database

(require pkg/path) | package: base

The pkg/path library provides utilities for working with package paths and installed-package databases.

> > struct
> > (struct |  | pkg-info (orig-pkg checksum auto?)
> > |  | #:prefab)
> | orig-pkg |  | : |  |
> (or/c (list/c 'catalog string?)
> (list/c 'url string?)
> (list/c 'link string?)
> (list/c 'static-link string?))
> checksum : (or/c #f string?)
> auto? : boolean?

A structure type that is used to report installed-package information.

> struct (struct sc-pkg-info pkg-info ())

A structure subtype that represents a package that is installed as single-collection.

> struct (struct pkg-info/alt pkg-info (dir-name))
> dir-name : string?
> struct (struct sc-pkg-info/alt sc-pkg-info (dir-name))
> dir-name : string?

Structure subtypes that are used when the installation directory for a package does not match the package name, but is instead dir-name. The directory name always includes a + (which is disallowed in a package name).

> procedure (path->pkg path #:cache cache) → (or/c string? #f)
> path : path-string?
> cache : (or/c #f (and/c hash? (not/c immutable?)))

Returns the installed package containing path, if any.

If cache is not #f, then it is consulted and modified to cache installed-package information across calls to path->pkg (with the assumption that the set of installed packages does not change across calls that receive the same cache).

> procedure (path->pkg+subpath path #:cache cache)
> | → |  |
> (or/c string? #f) |  | (or/c path? 'same #f)
> path : path-string?
> cache : (or/c #f (and/c hash? (not/c immutable?)))

Like path->pkg, but returns a second value that represents the remainder of path within the package’s directory.

> > procedure
> > (path->pkg+subpath+collect |  | path |
> > |  | #:cache cache) |
> | → |  |
> (or/c string? #f)
> (or/c path? 'same #f)
> (or/c string? #f)
> path : path-string?
> cache : (or/c #f (and/c hash? (not/c immutable?)))

Like path->pkg+subpath, but returns a third value for a collection name if the package is a single-collection package, #f otherwise.

> procedure (get-pkgs-dir scope [user-version]) → path?
> | scope |  | : |  |
> (or/c 'installation 'user 'shared
> (and/c path? complete-path?))
> user-version : string? = (version)

Returns the path of the directory that holds installed packages in the given scope. The user-version argument is used to generate the result for 'user scope.

> procedure (read-pkgs-db scope) → (hash/c string? pkg-info?)
> | scope |  | : |  |
> (or/c 'installation 'user 'shared
> (and/c path? complete-path?))

Returns a hash table representing the currently installed packages in the specified scope.

> procedure (read-pkg-file-hash path) → hash?
> path : path?

Reads a hash table from path, logging any errors and returning an empty hash table if path does not exist or if an error is encountered.
top ← prev up next →