From 4a542969c767cb0ebcd45c0d1ff513b3535d5118 Mon Sep 17 00:00:00 2001 From: Sam Tobin-Hochstadt Date: Thu, 26 Sep 2013 17:37:25 -0400 Subject: [PATCH] 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. --- Makefile | 2 +- .../pkg/scribblings/getting-started.scrbl | 5 ++--- .../racket-doc/pkg/scribblings/pkg.scrbl | 6 ++++++ racket/collects/pkg/main.rkt | 15 +++++++++++++-- racket/collects/racket/HISTORY.txt | 3 ++- 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 46c40bcfeb..bff2e70cd0 100644 --- a/Makefile +++ b/Makefile @@ -199,7 +199,7 @@ RACKET = racket/bin/racket $(USER_CONFIG) RACO = racket/bin/racket $(USER_CONFIG) -N raco -l- raco WIN32_RACKET = racket\racket $(USER_CONFIG) 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) LOCAL_USER_AUTO = --catalog build/local/catalog $(USER_AUTO_OPTIONS) SOURCE_USER_AUTO_q = --catalog "$(SRC_CATALOG)" $(USER_AUTO_OPTIONS) diff --git a/pkgs/racket-pkgs/racket-doc/pkg/scribblings/getting-started.scrbl b/pkgs/racket-pkgs/racket-doc/pkg/scribblings/getting-started.scrbl index 80a9a85808..6e8ce1ce44 100644 --- a/pkgs/racket-pkgs/racket-doc/pkg/scribblings/getting-started.scrbl +++ b/pkgs/racket-pkgs/racket-doc/pkg/scribblings/getting-started.scrbl @@ -300,10 +300,9 @@ get started. Whether creating a @tech{single-collection package} or a @tech{multi-collection package}, the next step is to link your development directory as a locally installed package. Use -@command-ref{install} in the directory where you created the -@nonterm{pkg-name} directory: +@command-ref{install} in the @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 @nonterm{pkg-name}. The ``Source'' column will show that it's a diff --git a/pkgs/racket-pkgs/racket-doc/pkg/scribblings/pkg.scrbl b/pkgs/racket-pkgs/racket-doc/pkg/scribblings/pkg.scrbl index c7b3d0e1fc..03aa4b36f8 100644 --- a/pkgs/racket-pkgs/racket-doc/pkg/scribblings/pkg.scrbl +++ b/pkgs/racket-pkgs/racket-doc/pkg/scribblings/pkg.scrbl @@ -322,6 +322,9 @@ sub-commands. If a given @nonterm{pkg-source} is ``auto-installed'' (to satisfy some other package's 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 following @nonterm{option}s: @@ -377,6 +380,9 @@ sub-commands. of the given directory will not change for each given directory that implements a @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, and instead treats them like other sources: package content is copied to install.} diff --git a/racket/collects/pkg/main.rkt b/racket/collects/pkg/main.rkt index 17ea5d0a31..0f12d77465 100644 --- a/racket/collects/pkg/main.rkt +++ b/racket/collects/pkg/main.rkt @@ -151,6 +151,7 @@ #:once-each catalog-flags ... [#:bool skip-installed () ("Skip a if already installed")] + [#:bool pkgs () ("Install only the specified packages, even when none are provided")] install-force-flags ... job-flags ... #:args pkg-source @@ -159,8 +160,18 @@ 'install scope scope-dir installation user #f a-type (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)) ((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 (with-pkg-lock (parameterize ([current-pkg-catalogs (and catalog @@ -173,8 +184,8 @@ #:update-deps? update-deps #:strip (or (and source 'source) (and binary 'binary)) #:link-dirs? link-dirs? - (for/list ([p (in-list pkg-source)]) - (pkg-desc p a-type name checksum #f)))))) + (for/list ([p (in-list sources)]) + (pkg-desc p a-type* name checksum #f)))))) (setup no-setup setup-collects jobs)))] ;; ---------------------------------------- [update diff --git a/racket/collects/racket/HISTORY.txt b/racket/collects/racket/HISTORY.txt index dce90bc1ab..e7d0c4a745 100644 --- a/racket/collects/racket/HISTORY.txt +++ b/racket/collects/racket/HISTORY.txt @@ -1,8 +1,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! setup/collection-name: added syntax/unsafe/for-transform: added +raco pkg install with no arguments installs the current directory. Version 5.90.0.6 Added path