diff options
Diffstat (limited to 'guix/scripts')
-rw-r--r-- | guix/scripts/environment.scm | 19 | ||||
-rw-r--r-- | guix/scripts/import/crate.scm | 36 | ||||
-rw-r--r-- | guix/scripts/pull.scm | 2 |
3 files changed, 44 insertions, 13 deletions
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm index cfe0a37c42..d78ca0f303 100644 --- a/guix/scripts/environment.scm +++ b/guix/scripts/environment.scm @@ -453,7 +453,7 @@ regexps in WHITE-LIST." (define* (launch-environment/container #:key command bash user user-mappings profile manifest link-profile? network? - map-cwd?) + map-cwd? (white-list '())) "Run COMMAND within a container that features the software in PROFILE. Environment variables are set according to the search paths of MANIFEST. The global shell is BASH, a file name for a GNU Bash binary in the @@ -462,7 +462,10 @@ USER-MAPPINGS, a list of file system mappings, contains the user-specified host file systems to mount inside the container. If USER is not #f, each target of USER-MAPPINGS will be re-written relative to '/home/USER', and USER will be used for the passwd entry. LINK-PROFILE? creates a symbolic link from -~/.guix-profile to the environment profile." +~/.guix-profile to the environment profile. + +Preserve environment variables whose name matches the one of the regexps in +WHILE-LIST." (define (optional-mapping->fs mapping) (and (file-exists? (file-system-mapping-source mapping)) (file-system-mapping->bind-mount mapping))) @@ -488,6 +491,11 @@ will be used for the passwd entry. LINK-PROFILE? creates a symbolic link from (group-entry (gid 65534) ;the overflow GID (name "overflow")))) (home-dir (password-entry-directory passwd)) + (environ (filter (match-lambda + ((variable . value) + (find (cut regexp-exec <> variable) + white-list))) + (get-environment-variables))) ;; Bind-mount all requisite store items, user-specified mappings, ;; /bin/sh, the current working directory, and possibly networking ;; configuration files within the container. @@ -556,6 +564,12 @@ will be used for the passwd entry. LINK-PROFILE? creates a symbolic link from (override-user-dir user home cwd) home-dir)) + ;; Set environment variables that match WHITE-LIST. + (for-each (match-lambda + ((variable . value) + (setenv variable value))) + environ) + (primitive-exit/status ;; A container's environment is already purified, so no need to ;; request it be purified again. @@ -759,6 +773,7 @@ message if any test fails." #:user-mappings mappings #:profile profile #:manifest manifest + #:white-list white-list #:link-profile? link-prof? #:network? network? #:map-cwd? (not no-cwd?)))) diff --git a/guix/scripts/import/crate.scm b/guix/scripts/import/crate.scm index 7ae8638911..4690cceb4d 100644 --- a/guix/scripts/import/crate.scm +++ b/guix/scripts/import/crate.scm @@ -28,6 +28,7 @@ #:use-module (srfi srfi-1) #:use-module (srfi srfi-11) #:use-module (srfi srfi-37) + #:use-module (srfi srfi-41) #:use-module (ice-9 match) #:use-module (ice-9 format) #:export (guix-import-crate)) @@ -44,6 +45,9 @@ (display (G_ "Usage: guix import crate PACKAGE-NAME Import and convert the crate.io package for PACKAGE-NAME.\n")) (display (G_ " + -r, --recursive import packages recursively")) + (newline) + (display (G_ " -h, --help display this help and exit")) (display (G_ " -V, --version display version information and exit")) @@ -59,6 +63,9 @@ Import and convert the crate.io package for PACKAGE-NAME.\n")) (option '(#\V "version") #f #f (lambda args (show-version-and-exit "guix import crate"))) + (option '(#\r "recursive") #f #f + (lambda (opt name arg result) + (alist-cons 'recursive #t result))) %standard-import-options)) @@ -79,22 +86,31 @@ Import and convert the crate.io package for PACKAGE-NAME.\n")) (let* ((opts (parse-options)) (args (filter-map (match-lambda - (('argument . value) - value) - (_ #f)) + (('argument . value) + value) + (_ #f)) (reverse opts)))) (match args ((spec) (define-values (name version) (package-name->name+version spec)) - (let ((sexp (crate->guix-package name version))) - (unless sexp - (leave (G_ "failed to download meta-data for package '~a'~%") - (if version - (string-append name "@" version) - name))) - sexp)) + (if (assoc-ref opts 'recursive) + (map (match-lambda + ((and ('package ('name name) . rest) pkg) + `(define-public ,(string->symbol name) + ,pkg)) + (_ #f)) + (reverse + (stream->list + (crate-recursive-import name)))) + (let ((sexp (crate->guix-package name version))) + (unless sexp + (leave (G_ "failed to download meta-data for package '~a'~%") + (if version + (string-append name "@" version) + name))) + sexp))) (() (leave (G_ "too few arguments~%"))) ((many ...) diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm index e018985469..04970cf503 100644 --- a/guix/scripts/pull.scm +++ b/guix/scripts/pull.scm @@ -314,7 +314,7 @@ to display." (removed (let ((count (length removed))) (format (current-error-port) - (N_ " ~*One channel removed:~%" + (N_ " ~a channel removed:~%" " ~a channels removed:~%" count) count) (for-each display-channel removed)))) |