make installation name configurable via `raco pkg config'

This commit is contained in:
Matthew Flatt 2013-07-26 07:35:55 -06:00
parent 68f4d297f7
commit 9f14fe3f6d
3 changed files with 23 additions and 5 deletions

View File

@ -326,7 +326,9 @@ sub-sub-commands:
@item{@exec{user} --- Install packages for the current user and current installation's name/version.}
]
The default package scope is normally @exec{user}, but it can be configured with
@command-ref{config}@exec{ --set default-scope @nonterm{scope}}.}
@command-ref{config}@exec{ --set default-scope @nonterm{scope}}.
The default installation name is normally the Racket version, but it can be configured with
@command-ref{config}@exec{ --set name @nonterm{name}}.}
@item{@Flag{i} or @DFlag{installation} --- Shorthand for @exec{--scope installation}.}
@item{@Flag{u} or @DFlag{user} --- Shorthand for @exec{--scope user}.}
@item{@DFlag{scope-dir} @nonterm{dir} --- Select @nonterm{dir} as the @tech{package scope}.}
@ -468,6 +470,8 @@ View and modify configuration of the package manager itself, with the following
@exec{installation} scope) is
the default @tech{package scope} for all @exec{raco pkg} commands
(even @command{config}, which is consistent but potentially confusing).}
@item{@exec{name} --- A string for the installation's name, which is used by @exec{user}
@tech{package scope} and defaults to the Racket version.}
]
}

View File

@ -86,15 +86,20 @@ directory:
with version and search-tag queries to form a remote
documentation reference.}
@item{@racket['catalogs] --- a list of URL strings used as the search
path for resolving package names; an @racket[#f] in the list
is replaced with the default search path.}
@item{@racket['installation-name] --- a string for the installation
name, which is used for packages in @exec{user}
@tech[#:doc '(lib "pkg/scribblings/pkg.scrbl")]{package
scope}; the default is @racket[(version)].}
@item{@racket['catalogs] --- a list of URL strings used as the search
path for resolving package names; an @racket[#f] in the list
is replaced with the default search path.}
@item{@racket['default-scope] --- either @racket["user"] or
@racket["installation"], determining the default @tech[#:doc
'(lib "pkg/scribblings/pkg.scrbl")]{package scope} for
package-management operations.}
@item{@racket['absolute-installation?] --- a boolean that is
@racket[#t] if the installation uses absolute path names,
@racket[#f] otherwise.}

View File

@ -489,6 +489,7 @@
(list "https://pkg.racket-lang.org"
"https://planet-compat.racket-lang.org")]
['default-scope "user"]
['installation-name (version)]
[_ #f]))
(define c (read-pkg-file-hash (pkg-config-file)))
(define v (hash-ref c k 'none))
@ -1631,6 +1632,12 @@
key
val))
(update-pkg-cfg! 'default-scope val)]
[(list (and key "name") val)
(unless (eq? 'installation (current-pkg-scope))
(pkg-error (~a "setting `name' makes sense only in `installation' scope\n"
" current package scope: ~a")
(current-pkg-scope)))
(update-pkg-cfg! 'installation-name val)]
[(list key)
(pkg-error "unsupported config key\n key: ~e" key)]
[(list)
@ -1644,6 +1651,8 @@
(printf "~a\n" s))]
["default-scope"
(printf "~a\n" (read-pkg-cfg/def 'default-scope))]
["name"
(printf "~a\n" (read-pkg-cfg/def 'installation-name))]
[_
(pkg-error "unsupported config key\n key: ~e" key)])]
[(list)