5 Utility Libraries
The planet collection provides configuration and utilities for using PLaneT.
5.1 Resolver
(require planet/resolver) | package: base |
The primary purpose of this library to for require to find PLaneT packages. It also, however, provides some utilities for manipulating the resolvers behavior.
procedure
(planet-module-name-resolver r-m-p) → void?
r-m-p : resolved-module-path?
(planet-module-name-resolver spec module-path stx load orig-paramz) → resolved-module-path? spec : (or/c module-path? path?) module-path : (or/c #f resolved-module-path?) stx : (or/c #f syntax?) load : boolean? orig-paramz : parameterization?
procedure
(get-planet-module-path/pkg spec module-path stx) →
path? pkg? spec : (or/c module-path? path?) module-path : (or/c #f resolved-module-path?) stx : (or/c #f syntax?)
procedure
(resolve-planet-path planet-path) → path?
planet-path : any/c
If the PLaneT package is not actually installed, then this function expects to be called with a very powerful security guard, one that is available to the built-in module name resolver, but not generally available to user code. So probably this function will fail (possibly deadlock).
This is the same function as the one with the same name, exported by planet/util.
5.1.1 Resolver file locking
When PLaneT is asked to resolve a module path for loading the file (e.g., when the last argument to the (current-module-name-resolver) is #t and that resolver triggers a call to the PLaneT resolver), it finds the directory where the files are installed, say in this directory, which corresponds to version 1.2 of dyoo’s closure-compile.plt package:
"(CACHE-DIR)/dyoo/closure-compile.plt/1/2/"
If the file
"(CACHE-DIR)/dyoo/closure-compile.plt/1/2.SUCCESS"
is there, it assumes that there is no installation needed and it just continues, using the path to the file inside that directory.
If the "2.SUCCESS" file is not there, then it attempts to grab an 'exclusive filesystem lock on this file (via port-try-file-lock?)
"(CACHE-DIR)/dyoo/closure-compile.plt/1/2.LOCK"
If it gets the lock, it then proceeds with the installation, calling raco setup to do the unpacking, compilation, and docs building. After the unpacking has finished, but before beginning compilation and docs building, it creates the "2.UNPACKED" file:
"(CACHE-DIR)/dyoo/closure-compile.plt/1/2.UNPACKED"
When compilation and docs build are complete, it creates the "2.SUCCESS" file:
"(CACHE-DIR)/dyoo/closure-compile.plt/1/2.SUCCESS"
and releases the lock on the "2.LOCK" file.
If it fails to get the lock on "2.LOCK" and it does not already hold the lock (due to a re-entrant call to the resolver (the resolver knows about locks it holds via an internal parameter that gets created when the planet/resolver module is instantiated) then it goes into a loop that polls for the existence of the "2.SUCCESS" file; when it that file appears, it just continues, without installing anything (since that means someone else installed it).
In some situations (e.g., when a new namespace is created and a fresh instantiation of planet/resolver is created), PLaneT can be fooled into thinking that it does not hold the lock on some installation. In order to cope with these situations somewhat, PLaneT takes an easier path when the resolver is only looking for information about package files (i.e., when the last argument to the resolver is #f, or when get-planet-module-path/pkg is called directly (as opposed to being called via module resolution). In those cases, PLaneT will look only for the "2.UNPACKED" file instead of the "2.SUCCESS" file.
5.2 Client Configuration
(require planet/config) | package: base |
The planet/config library provides several parameters useful for configuring how PLaneT works.
Note that while these parameters can be useful to modify programmatically, PLaneT code runs at module-expansion time, so most user programs cannot set them until PLaneT has already run. Therefore, to meaningfully change these settings, it is best to manually edit the "config.rkt" file.
parameter
(PLANET-BASE-DIR dir) → void? dir : path-string?
(let ([plt-planet-dir-env-var (getenv "PLTPLANETDIR")]) (if plt-planet-dir-env-var (string->path plt-planet-dir-env-var) (build-path (find-system-path 'addon-dir) "planet" (PLANET-CODE-VERSION))))
parameter
(PLANET-DIR dir) → void? dir : path-string?
parameter
(CACHE-DIR dir) → void? dir : path-string?
parameter
(UNINSTALLED-PACKAGE-CACHE dir) → void? dir : path-string?
parameter
(LINKAGE-FILE file) → void? file : path-string?
parameter
(LOG-FILE) → (or/c path-string? false?)
(LOG-FILE file) → void? file : (or/c path-string? false?)
parameter
(USE-HTTP-DOWNLOADS? bool) → void? bool : any/c
parameter
(HTTP-DOWNLOAD-SERVLET-URL url) → void? url : string?
parameter
(PLANET-SERVER-NAME host) → void? host : string?
parameter
(PLANET-SERVER-PORT) → natural-number?
(PLANET-SERVER-PORT port) → void? port : natural-number?
parameter
(HARD-LINK-FILE) → path?
(HARD-LINK-FILE file) → void? file : path?
parameter
(PLANET-ARCHIVE-FILTER) → (or/c #f string? regexp?)
(PLANET-ARCHIVE-FILTER regexp-filter) → void? regexp-filter : (or/c #f string? regexp?)
parameter
(PLANET-CODE-VERSION vers) → void? vers : string?
parameter
(DEFAULT-PACKAGE-LANGUAGE vers) → void? vers : string?
Defaults to (version).
5.3 Package Archives
(require planet/planet-archives) | package: base |
procedure
→
(listof (list/c (and/c path? absolute-path?) string? string? (listof string?) exact-nonnegative-integer? exact-nonnegative-integer?))
procedure
→
(listof (list/c (and/c path? absolute-path?) string? string? (listof string?) exact-nonnegative-integer? exact-nonnegative-integer?))
procedure
→
(listof (list/c (and/c path? absolute-path?) string? string? (listof string?) exact-nonnegative-integer? exact-nonnegative-integer?))
5.4 Package Utils
(require planet/util) | package: planet-lib |
The planet/util library supports examination of the pieces of PLaneT. It is meant primarily to support debugging and to allow easier development of higher-level package-management tools. The functionality exposed by the raco planet command-line tool is also available programmatically through this library.
procedure
(download/install-pkg owner pkg maj min) → (or/c pkg? #f)
owner : string? pkg : (and/c string? #rx"[.]plt$") maj : natural-number/c min : natural-number/c
The pkg argument must end with ".plt".
procedure
(install-pkg pkg-spec file maj min) → (or/c pkg-spec? #f)
pkg-spec : pkg-spec? file : path-string? maj : natural-number/c min : natural-number/c
See get-package-spec to build a pkg-spec argument.
Returns a new pkg-spec? corresponding to the package that was actually installed.
procedure
(get-package-spec owner pkg [maj min]) → pkg-spec?
owner : string? pkg : (and/c string? #rx"[.]plt$") maj : (or/c #f natural-number/c) = #f min : (or/c #f natural-number/c) = #f
The pkg argument must end with the string ".plt".
parameter
→
(listof (list/c string? (listof (list/c string? (cons/c natural-number/c (listof natural-number/c)))))) (current-cache-contents contents) → void?
contents :
(listof (list/c string? (listof (list/c string? (cons/c natural-number/c (listof natural-number/c))))))
procedure
→
(listof (list/c path-string? (list/c string? (list/c string?) natural-number/c natural-number/c)))
The linkage table is an association between file locations (encoded as path strings) and concrete planet package versions. If a require line in the associated file requests a package, this table is consulted to determine a particular concrete package to satisfy the request.
procedure
(make-planet-archive directory [output-file]) → path-string?
directory : path-string?
output-file : (or/c path? path-string?) = (string-append (path->string name) ".plt")
See also build-scribble-docs? and force-package-building?
parameter
(build-scribble-docs? b) → void? b : boolean?
parameter
(force-package-building? b) → void? b : boolean?
Defaults to #t, and thus packaging will signal errors.
procedure
(download-package pkg-spec)
→
(or/c (list/c #true path? natural-number/c natural-number/c) string? (list/c #false string?)) pkg-spec : pkg-spec?
The other two possible results indicate errors. If the result is a list, then the server is saying that there is no matching package; otherwise the error is some lower-level problem (perhaps no networking, etc.)
procedure
(pkg->download-url pkg) → url?
pkg : pkg?
procedure
(get-package-from-cache pkg-spec) → (or/c #false path?)
pkg-spec : pkg-spec?
procedure
(lookup-package-by-keys owner name major minor-lo minor-hi)
→
(or/c (list/c path? string? string? (listof string?) exact-nonnegative-integer? exact-nonnegative-integer?) #false) owner : string? name : string? major : exact-nonnegative-integer? minor-lo : exact-nonnegative-integer? minor-hi : exact-nonnegative-integer?
procedure
(unpack-planet-archive plt-file output-dir) → any
plt-file : (or/c path? path-string?) output-dir : (or/c path? path-string?)
procedure
(remove-pkg owner pkg maj min) → any
owner : string? pkg : (and/c string? #rx"[.]plt$") maj : natural-number/c min : natural-number/c
procedure
(erase-pkg owner pkg maj min) → any
owner : string? pkg : (and/c string? #rx"[.]plt$") maj : natural-number/c min : natural-number/c
procedure
(display-plt-file-structure plt-file) → any
plt-file : (or/c path-string? path?)
procedure
(display-plt-archived-file plt-file file-to-print) → any plt-file : (or/c path-string? path?) file-to-print : string?
procedure
(unlink-all) → any
procedure
(add-hard-link owner pkg maj min dir) → any
owner : string? pkg : (and/c string? #rx"[.]plt$") maj : natural-number/c min : natural-number/c dir : path?
If the specified package already has a development link, this function first removes the old link and then adds the new one.
The pkg argument must end with the string ".plt".
procedure
(remove-hard-link owner pkg maj min [ #:quiet? quiet?]) → any owner : string? pkg : (and/c string? #rx"[.]plt$") maj : natural-number/c min : natural-number/c quiet? : boolean? = #false
The pkg argument must end with the string ".plt". The maj and min arguments must be integers. This procedure signals an error if no such link exists, unless #:quiet? is #true.
procedure
(resolve-planet-path spec) → path?
spec : quoted-planet-require-spec?
struct
(struct exn:fail:planet exn:fail (message continuation-marks) #:extra-constructor-name make-exn:fail:planet) message : string? continuation-marks : continuation-mark-set?
5.5 Package Version
Provides bindings for PLaneT developers that automatically produce references to the name and version of the containing PLaneT package so the same code may be reused across releases without accidentally referring to a different version of the same package.
(require planet/version) | package: planet-lib |
syntax
syntax
(this-package-version-symbol suffix-id)
syntax
syntax
syntax
syntax
this-package-version-symbol produces a symbol suitable for use in planet module paths. For instance, in version 1:0 of the package package.plt owned by author, (this-package-version-symbol dir/file) produces 'author/package:1:0/dir/file. In the same package, (this-package-version-symbol) produces 'author/package:1:0.
syntax
(this-package-in suffix-id ...)
Note: Use this-package-in when documenting PLaneT packages with Scribble to associate each documented binding with the appropriate package.
procedure
(make-planet-symbol stx [suffix]) → (or/c #false symbol?)
stx : syntax? suffix : (or/c #false string?) = #false
procedure
(package-version->symbol ver [suffix]) → (or/c #false symbol?)
ver :
(or/c (list/c string? string? exact-nonnegative-integer? exact-nonnegative-integer?) #false) suffix : (or/c #false string?) = #false
5.6 Macros and Syntax Objects
(require planet/syntax) | package: planet-lib |
Provides bindings useful for PLaneT-based macros.
procedure
(syntax-source-planet-package stx) → (or/c list? #f)
stx : syntax?
procedure
(syntax-source-planet-package-owner stx) → (or/c string? #f)
stx : syntax?
procedure
(syntax-source-planet-package-name stx) → (or/c string? #f)
stx : syntax?
procedure
(syntax-source-planet-package-major stx) → (or/c integer? #f)
stx : syntax?
procedure
(syntax-source-planet-package-minor stx) → (or/c integer? #f)
stx : syntax?
procedure
(syntax-source-planet-package-symbol stx [ suffix]) → (or/c symbol? #f) stx : syntax? suffix : (or/c symbol? #f) = #f
procedure
(make-planet-require-spec stx [suffix]) → syntax?
stx : syntax? suffix : (or/c symbol? #f) = #f
5.7 Scribble Documentation
(require planet/scribble) | package: planet-doc |
Provides bindings for documenting PLaneT packages.
syntax
(this-package-in suffix-id ...)
syntax
(racketmod/this-package maybe-file suffix-id datum ...)
syntax
(racketmodname/this-package suffix-id)
(racketmodname/this-package (unsyntax suffix-expr))
syntax
(racketmodlink/this-package suffix-id pre-content-expr ...)
syntax
(defmodule/this-package maybe-req suffix-id maybe-sources pre-flow ...)
syntax
(defmodulelang/this-package suffix-id maybe-sources pre-flow ...)
(defmodulelang/this-package suffix-id #:module-paths (mod-suffix-id ...) maybe-sources pre-flow ...)
syntax
(defmodulereader/this-package suffix-id maybe-sources pre-flow ...)
syntax
(defmodule*/this-package maybe-req (suffix-id ...+) maybe-sources pre-flow ...)
syntax
(defmodulelang*/this-package (suffix-id ...+) maybe-sources pre-flow ...)
(defmodulelang*/this-package (suffix-id ...+) #:module-paths (mod-suffix-id ...) maybe-sources pre-flow ...)
syntax
(defmodulereader*/this-package (suffix-id ...+) maybe-sources pre-flow ...)
syntax
(defmodule*/no-declare/this-package maybe-req (suffix-id ...+) maybe-sources pre-flow ...)
syntax
(defmodulelang*/no-declare/this-package (suffix-id ...+) maybe-sources pre-flow ...)
(defmodulelang*/no-declare/this-package (suffix-id ...+) #:module-paths (mod-suffix-id ...) maybe-sources pre-flow ...)
syntax
(defmodulereader*/no-declare/this-package (suffix-id ...+) maybe-sources pre-flow ...)
syntax
(declare-exporting/this-package suffix-id ... maybe-sources)
The full module name passed to defmodule, etc is formed by appending the suffix-id or mod-suffix-id to the symbol returned by (this-package-version-symbol), separated by a / character, and tagging the resulting symbol as a planet module path. As a special case, if suffix-id is main, the suffix is omitted.
(defmodule/this-package dir/file) = (defmodule (planet author/package:1:0/dir/file))
(defmodule/this-package main) = (defmodule (planet author/package:1:0))
5.8 Terse Status Updates
(require planet/terse-info) | package: base |
This module provides access to some PLaneT status information. This module is first loaded by PLaneT in the initial namespace (when PLaneT’s resolver is loaded), but PLaneT uses dynamic-require to load this module each time it wants to announce information. Similarly, the state of which procedures are registered (via planet-terse-register) is saved in the namespace, making the listening and information producing namespace-specific.
procedure
(planet-terse-register proc) → void?
proc :
(-> (or/c 'download 'install 'docs-build 'finish) string? any/c)
Note that proc is called asynchronously (ie, on some thread other than the one calling planet-terse-register).
procedure
(planet-terse-set-key key) → void?
key : any/c
The table holding the key uses ephemerons and a weak hash table to ensure that when the key is unreachable, then the procedures passed to planet-terse-log cannot be reached through the table.
5.9 The Cache File’s Path
(require planet/cachepath) | package: base |
procedure
(get-planet-cache-path) → (and/c path? absolute-path?)