Make 'raco pkg install' with no arguments install the current directory.

This is useful for telling people how to install a new pkg, from
GitHub or elsewhere: just get the files, and then do
`raco pkg install` in the relevant directory.

Also, both cabal (the Haskell package manager) and npm (the node.js
package manager) behave this way.

To explicitly get the old behavior, specify the sources as
`--pkgs pkg-srcs ...`.  This is useful in scripts, when `pkg-srcs`
might be empty.
This commit is contained in:
Sam Tobin-Hochstadt 2013-09-26 17:37:25 -04:00
parent eca9e16b96
commit 4a542969c7
5 changed files with 24 additions and 7 deletions

View File

@ -199,7 +199,7 @@ RACKET = racket/bin/racket $(USER_CONFIG)
RACO = racket/bin/racket $(USER_CONFIG) -N raco -l- raco RACO = racket/bin/racket $(USER_CONFIG) -N raco -l- raco
WIN32_RACKET = racket\racket $(USER_CONFIG) WIN32_RACKET = racket\racket $(USER_CONFIG)
WIN32_RACO = racket\racket $(USER_CONFIG) -N raco -l- raco WIN32_RACO = racket\racket $(USER_CONFIG) -N raco -l- raco
X_AUTO_OPTIONS = --skip-installed --deps search-auto $(JOB_OPTIONS) X_AUTO_OPTIONS = --skip-installed --deps search-auto --pkgs $(JOB_OPTIONS)
USER_AUTO_OPTIONS = --scope user $(X_AUTO_OPTIONS) USER_AUTO_OPTIONS = --scope user $(X_AUTO_OPTIONS)
LOCAL_USER_AUTO = --catalog build/local/catalog $(USER_AUTO_OPTIONS) LOCAL_USER_AUTO = --catalog build/local/catalog $(USER_AUTO_OPTIONS)
SOURCE_USER_AUTO_q = --catalog "$(SRC_CATALOG)" $(USER_AUTO_OPTIONS) SOURCE_USER_AUTO_q = --catalog "$(SRC_CATALOG)" $(USER_AUTO_OPTIONS)

View File

@ -300,10 +300,9 @@ get started.
Whether creating a @tech{single-collection package} or a Whether creating a @tech{single-collection package} or a
@tech{multi-collection package}, the next step is to link your @tech{multi-collection package}, the next step is to link your
development directory as a locally installed package. Use development directory as a locally installed package. Use
@command-ref{install} in the directory where you created the @command-ref{install} in the @nonterm{pkg-name} directory:
@nonterm{pkg-name} directory:
@commandline{raco pkg install --link @nonterm{pkg-name}} @commandline{raco pkg install}
If you use @command-ref{show} at this point, you'll see a line for If you use @command-ref{show} at this point, you'll see a line for
@nonterm{pkg-name}. The ``Source'' column will show that it's a @nonterm{pkg-name}. The ``Source'' column will show that it's a

View File

@ -322,6 +322,9 @@ sub-commands.
If a given @nonterm{pkg-source} is ``auto-installed'' (to satisfy some other package's If a given @nonterm{pkg-source} is ``auto-installed'' (to satisfy some other package's
dependency), then it is promoted to explicitly installed. dependency), then it is promoted to explicitly installed.
If no @nonterm{pkg-source}s are supplied, the current directory is
installed as a link. See the @DFlag{link} flag below for more details.
The @exec{install} sub-command accepts The @exec{install} sub-command accepts
the following @nonterm{option}s: the following @nonterm{option}s:
@ -377,6 +380,9 @@ sub-commands.
of the given directory will not change for each given directory that implements a of the given directory will not change for each given directory that implements a
@tech{multi-collection package}.} @tech{multi-collection package}.}
@item{@DFlag{pkgs} --- Disables default installation of the current directory when no @nonterm{pkg-source}s
are supplied.}
@item{@DFlag{copy} --- Disables default handling of directory @tech{package sources} as links, @item{@DFlag{copy} --- Disables default handling of directory @tech{package sources} as links,
and instead treats them like other sources: package content is copied to install.} and instead treats them like other sources: package content is copied to install.}

View File

@ -151,6 +151,7 @@
#:once-each #:once-each
catalog-flags ... catalog-flags ...
[#:bool skip-installed () ("Skip a <pkg-source> if already installed")] [#:bool skip-installed () ("Skip a <pkg-source> if already installed")]
[#:bool pkgs () ("Install only the specified packages, even when none are provided")]
install-force-flags ... install-force-flags ...
job-flags ... job-flags ...
#:args pkg-source #:args pkg-source
@ -159,8 +160,18 @@
'install 'install
scope scope-dir installation user #f a-type scope scope-dir installation user #f a-type
(lambda () (lambda ()
(when (and name (> (length pkg-source) 1))
((current-pkg-error) (format "the --name flag only makes sense with a single package source")))
(unless (or (not name) (package-source->name name)) (unless (or (not name) (package-source->name name))
((current-pkg-error) (format "~e is an invalid package name" name))) ((current-pkg-error) (format "~e is an invalid package name" name)))
;; if no sources were supplied, and `--pkgs` was not
;; explicitly specified, install the current directory
;; as a linked directory
(define-values (sources a-type*)
(if (and (not pkgs) (null? pkg-source))
(values (list (path->string (current-directory)))
'link)
(values pkg-source a-type)))
(define setup-collects (define setup-collects
(with-pkg-lock (with-pkg-lock
(parameterize ([current-pkg-catalogs (and catalog (parameterize ([current-pkg-catalogs (and catalog
@ -173,8 +184,8 @@
#:update-deps? update-deps #:update-deps? update-deps
#:strip (or (and source 'source) (and binary 'binary)) #:strip (or (and source 'source) (and binary 'binary))
#:link-dirs? link-dirs? #:link-dirs? link-dirs?
(for/list ([p (in-list pkg-source)]) (for/list ([p (in-list sources)])
(pkg-desc p a-type name checksum #f)))))) (pkg-desc p a-type* name checksum #f))))))
(setup no-setup setup-collects jobs)))] (setup no-setup setup-collects jobs)))]
;; ---------------------------------------- ;; ----------------------------------------
[update [update

View File

@ -1,8 +1,9 @@
Version 5.90.0.9 Version 5.90.0.9
Allow hash table chaperones and impersonators to Support efficient Allow hash table chaperones and impersonators to support efficient
hash-clear and hash-clear! hash-clear and hash-clear!
setup/collection-name: added setup/collection-name: added
syntax/unsafe/for-transform: added syntax/unsafe/for-transform: added
raco pkg install with no arguments installs the current directory.
Version 5.90.0.6 Version 5.90.0.6
Added path<?, symbol<? Added path<?, symbol<?