From 5b0c648a7c5ac3d827bb6fc61b3b2037a2d4b62c Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 4 Jul 2018 10:52:59 +0200 Subject: profiles: 'info-dir-file' hook now produces 'dir.LANG' files. Previously, entries for 'guix.fr.info' would end up in 'dir', above the 'guix.info' entries; consequently, running 'info guix' would actually open 'guix.fr.info', which was confusing for non-French readers. * guix/profiles.scm (info-dir-file)[glibc-utf8-locales]: New variable. [build](info-file-language): New procedure. (install-info): Use it, to create 'dir.LANG' files. Set GUIX_LOCPATH. --- guix/profiles.scm | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'guix/profiles.scm') diff --git a/guix/profiles.scm b/guix/profiles.scm index ebd7da2a24..e6b77e8d38 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -703,6 +703,8 @@ MANIFEST." (module-ref (resolve-interface '(gnu packages texinfo)) 'texinfo)) (define gzip ;lazy reference (module-ref (resolve-interface '(gnu packages compression)) 'gzip)) + (define glibc-utf8-locales ;lazy reference + (module-ref (resolve-interface '(gnu packages base)) 'glibc-utf8-locales)) (define build (with-imported-modules '((guix build utils)) @@ -720,11 +722,31 @@ MANIFEST." (map (cut string-append infodir "/" <>) (or (scandir infodir info-file?) '())))) + (define (info-file-language file) + (let* ((base (if (string-suffix? ".gz" file) + (basename file ".info.gz") + (basename file ".info"))) + (dot (string-rindex base #\.))) + (if dot + (string-drop base (+ 1 dot)) + "en"))) + (define (install-info info) - (setenv "PATH" (string-append #+gzip "/bin")) ;for info.gz files - (zero? - (system* (string-append #+texinfo "/bin/install-info") "--silent" - info (string-append #$output "/share/info/dir")))) + (let ((language (info-file-language info))) + ;; We need to choose a valid locale for $LANGUAGE to be honored. + (setenv "LC_ALL" "en_US.utf8") + (setenv "LANGUAGE" language) + (zero? + (system* #+(file-append texinfo "/bin/install-info") + "--silent" info + (apply string-append #$output "/share/info/dir" + (if (string=? "en" language) + '("") + `("." ,language))))))) + + (setenv "PATH" (string-append #+gzip "/bin")) ;for info.gz files + (setenv "GUIX_LOCPATH" + #+(file-append glibc-utf8-locales "/lib/locale")) (mkdir-p (string-append #$output "/share/info")) (exit (every install-info -- cgit v1.2.3 From f03df3ee75d1209fb9782999bd04378c58e9f0f1 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 9 Jul 2018 10:44:36 +0200 Subject: profiles: Factorize 'manifest-search-paths'. * guix/profiles.scm (manifest-search-paths): New procedure. (profile-derivation)[builder]: Use it. * guix/build/profiles.scm (build-etc/profile): Remove $PATH. --- guix/build/profiles.scm | 2 +- guix/profiles.scm | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'guix/profiles.scm') diff --git a/guix/build/profiles.scm b/guix/build/profiles.scm index 819688a913..df785c85a7 100644 --- a/guix/build/profiles.scm +++ b/guix/build/profiles.scm @@ -89,7 +89,7 @@ definitions for all the SEARCH-PATHS." # When GUIX_PROFILE is undefined, the various environment variables refer # to this specific profile generation. \n" port) - (let ((variables (evaluate-search-paths (cons $PATH search-paths) + (let ((variables (evaluate-search-paths search-paths (list output)))) (for-each (write-environment-variable-definition port) (map (abstract-profile output) variables)))))) diff --git a/guix/profiles.scm b/guix/profiles.scm index e6b77e8d38..88228f1558 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -91,6 +91,7 @@ manifest-lookup manifest-installed? manifest-matching-entries + manifest-search-paths manifest-transaction manifest-transaction? @@ -545,6 +546,14 @@ no match.." (filter matches? (manifest-entries manifest))) +(define (manifest-search-paths manifest) + "Return the list of search path specifications that apply to MANIFEST, +including the search path specification for $PATH." + (delete-duplicates + (cons $PATH + (append-map manifest-entry-search-paths + (manifest-entries manifest))))) + ;;; ;;; Manifest transactions. @@ -1367,8 +1376,7 @@ are cross-built for TARGET." (map sexp->search-path-specification (delete-duplicates '#$(map search-path-specification->sexp - (append-map manifest-entry-search-paths - (manifest-entries manifest)))))) + (manifest-search-paths manifest))))) (build-profile #$output '#$inputs #:symlink #$(if relative-symlinks? -- cgit v1.2.3 From 78d55b703d155d36520e1c93dc08a6502c56bd55 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 9 Jul 2018 13:22:29 +0200 Subject: profiles: Introduce 'profile-search-paths' and use it. * guix/profiles.scm (profile-search-paths): New procedure. * guix/scripts/environment.scm (evaluate-search-paths): Remove. (create-environment): Replace 'paths' with 'manifest'. Use 'profile-search-paths' instead of 'evaluate-search-paths'. (show-search-paths): Likewise. (launch-environment): Replace 'paths' with 'manifest'. Make 'pure?' a keyword parameter. (launch-environment/fork, launch-environment/container): Likewise. (guix-environment): Remove 'paths' variable. Adjust callers of the above procedures accordingly. --- guix/profiles.scm | 14 ++++++++++++ guix/scripts/environment.scm | 54 ++++++++++++++++++++------------------------ 2 files changed, 39 insertions(+), 29 deletions(-) (limited to 'guix/profiles.scm') diff --git a/guix/profiles.scm b/guix/profiles.scm index 88228f1558..d2a794b187 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -110,6 +110,7 @@ ca-certificate-bundle %default-profile-hooks profile-derivation + profile-search-paths generation-number generation-numbers @@ -1400,6 +1401,19 @@ are cross-built for TARGET." ;; to have no substitute to offer. #:substitutable? #f))) +(define* (profile-search-paths profile + #:optional (manifest (profile-manifest profile)) + #:key (getenv (const #f))) + "Read the manifest of PROFILE and evaluate the values of search path +environment variables required by PROFILE; return a list of +specification/value pairs. If MANIFEST is not #f, it is assumed to be the +manifest of PROFILE, which avoids rereading it. + +Use GETENV to determine the current settings and report only settings not +already effective." + (evaluate-search-paths (manifest-search-paths manifest) + (list profile) getenv)) + (define (profile-regexp profile) "Return a regular expression that matches PROFILE's name and number." (make-regexp (string-append "^" (regexp-quote (basename profile)) diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm index 9a69e3b269..1c04800e42 100644 --- a/guix/scripts/environment.scm +++ b/guix/scripts/environment.scm @@ -49,11 +49,6 @@ #:use-module (srfi srfi-98) #:export (guix-environment)) -(define (evaluate-profile-search-paths profile search-paths) - "Evaluate SEARCH-PATHS, a list of search-path specifications, for the -directories in PROFILE, the store path of a profile." - (evaluate-search-paths search-paths (list profile))) - ;; Protect some env vars from purification. Borrowed from nix-shell. (define %precious-variables '("HOME" "USER" "LOGNAME" "DISPLAY" "TERM" "TZ" "PAGER")) @@ -70,8 +65,8 @@ as 'HOME' and 'USER' are left untouched." (((names . _) ...) names))))) -(define (create-environment profile paths pure?) - "Set the environment variables specified by PATHS for PROFILE. When PURE? +(define* (create-environment profile manifest #:key pure?) + "Set the environment variables specified by MANIFEST for PROFILE. When PURE? is #t, unset the variables in the current environment. Otherwise, augment existing environment variables with additional search paths." (when pure? (purify-environment)) @@ -84,23 +79,23 @@ existing environment variables with additional search paths." (string-append value separator current) value) value))))) - (evaluate-profile-search-paths profile paths)) + (profile-search-paths profile manifest)) ;; Give users a way to know that they're in 'guix environment', so they can ;; adjust 'PS1' accordingly, for instance. Set it to PROFILE so users can ;; conveniently access its contents. (setenv "GUIX_ENVIRONMENT" profile)) -(define (show-search-paths profile search-paths pure?) - "Display SEARCH-PATHS applied to PROFILE. When PURE? is #t, do not augment -existing environment variables with additional search paths." +(define* (show-search-paths profile manifest #:key pure?) + "Display the search paths of MANIFEST applied to PROFILE. When PURE? is #t, +do not augment existing environment variables with additional search paths." (for-each (match-lambda ((search-path . value) (display (search-path-definition search-path value #:kind (if pure? 'exact 'prefix))) (newline))) - (evaluate-profile-search-paths profile search-paths))) + (profile-search-paths profile manifest))) (define (input->manifest-entry input) "Return a manifest entry for INPUT, or #f if INPUT does not correspond to a @@ -379,32 +374,34 @@ and suitable for 'exit'." (define exit/status (compose exit status->exit-code)) (define primitive-exit/status (compose primitive-exit status->exit-code)) -(define (launch-environment command inputs paths pure?) +(define* (launch-environment command profile manifest + #:key pure?) "Run COMMAND in a new environment containing INPUTS, using the native search paths defined by the list PATHS. When PURE?, pre-existing environment variables are cleared before setting the new ones." ;; Properly handle SIGINT, so pressing C-c in an interactive terminal ;; application works. (sigaction SIGINT SIG_DFL) - (create-environment inputs paths pure?) + (create-environment profile manifest #:pure? pure?) (match command ((program . args) (apply execlp program program args)))) -(define (launch-environment/fork command inputs paths pure?) - "Run COMMAND in a new process with an environment containing INPUTS, using -the native search paths defined by the list PATHS. When PURE?, pre-existing -environment variables are cleared before setting the new ones." +(define* (launch-environment/fork command profile manifest #:key pure?) + "Run COMMAND in a new process with an environment containing PROFILE, with +the search paths specified by MANIFEST. When PURE?, pre-existing environment +variables are cleared before setting the new ones." (match (primitive-fork) - (0 (launch-environment command inputs paths pure?)) + (0 (launch-environment command profile manifest + #:pure? pure?)) (pid (match (waitpid pid) ((_ . status) status))))) (define* (launch-environment/container #:key command bash user user-mappings - profile paths link-profile? network?) + profile manifest link-profile? network?) "Run COMMAND within a container that features the software in PROFILE. -Environment variables are set according to PATHS, a list of native search -paths. The global shell is BASH, a file name for a GNU Bash binary in the +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 store. When NETWORK?, access to the host system network is permitted. 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 @@ -496,7 +493,7 @@ will be used for the passwd entry. LINK-PROFILE? creates a symbolic link from (primitive-exit/status ;; A container's environment is already purified, so no need to ;; request it be purified again. - (launch-environment command profile paths #f))) + (launch-environment command profile manifest #:pure? #f))) #:namespaces (if network? (delq 'net %namespaces) ; share host network %namespaces))))))) @@ -654,8 +651,7 @@ message if any test fails." '("/bin/sh") (list %default-shell)))) (manifest (options/resolve-packages opts)) - (mappings (pick-all opts 'file-system-mapping)) - (paths (manifest-search-paths manifest))) + (mappings (pick-all opts 'file-system-mapping))) (when container? (assert-container-features)) @@ -700,7 +696,7 @@ message if any test fails." ((assoc-ref opts 'dry-run?) (return #t)) ((assoc-ref opts 'search-paths) - (show-search-paths profile paths pure?) + (show-search-paths profile manifest #:pure? pure?) (return #t)) (container? (let ((bash-binary @@ -713,11 +709,11 @@ message if any test fails." #:user user #:user-mappings mappings #:profile profile - #:paths paths + #:manifest manifest #:link-profile? link-prof? #:network? network?))) (else (return (exit/status - (launch-environment/fork command profile - paths pure?))))))))))))) + (launch-environment/fork command profile manifest + #:pure? pure?))))))))))))) -- cgit v1.2.3 From bc6e291ef0b3c71c07e50d88d7764e5dd334e8b1 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 13 Jul 2018 14:33:11 +0200 Subject: guix package: Use relative symlinks to generations. Reported by Roel Janssen at . * guix/profiles.scm (switch-to-generation): Use (basename generation) as the symlink target. * guix/scripts/package.scm (build-and-use-profile): Likewise, use (basename name) as the symlink target. * tests/guix-package.sh: Adjust --roll-back test accordingly. Add explicitly test with '-p foo/prof'. --- guix/profiles.scm | 2 +- guix/scripts/package.scm | 2 +- tests/guix-package.sh | 12 +++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) (limited to 'guix/profiles.scm') diff --git a/guix/profiles.scm b/guix/profiles.scm index d2a794b187..f34f4fcff6 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -1521,7 +1521,7 @@ the generation that was current before switching." (profile profile) (generation number))))) (else - (switch-symlinks profile generation) + (switch-symlinks profile (basename generation)) current)))) (define (switch-to-previous-generation profile) diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index 29829f52c8..b38a55d01c 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -190,7 +190,7 @@ do not treat collisions in MANIFEST as an error." (let* ((entries (manifest-entries manifest)) (count (length entries))) (switch-symlinks name prof) - (switch-symlinks profile name) + (switch-symlinks profile (basename name)) (unless (string=? profile %current-profile) (register-gc-root store name)) (format #t (N_ "~a package in profile~%" diff --git a/tests/guix-package.sh b/tests/guix-package.sh index 3b3fa35cd8..cef3b3452e 100644 --- a/tests/guix-package.sh +++ b/tests/guix-package.sh @@ -185,6 +185,16 @@ grep -E 'emacs[[:blank:]]+42\.5\.9rc7[[:blank:]]+.*-emacs-42.5.9rc7' \ rm "$emacs_tarball" "$tmpfile" rmdir "$module_dir" +# Profiles with a relative file name. Make sure we don't create dangling +# symlinks--see bug report at +# . +mkdir -p "$module_dir/foo" +( cd "$module_dir" ; \ + guix package --bootstrap -i guile-bootstrap -p foo/prof ) +test -f "$module_dir/foo/prof/bin/guile" +rm "$module_dir/foo"/* +rmdir "$module_dir/foo" +rmdir "$module_dir" # # Try with the default profile. @@ -215,7 +225,7 @@ do guix package --bootstrap --roll-back ! test -f "$HOME/.guix-profile/bin" ! test -f "$HOME/.guix-profile/lib" - test "`readlink "$default_profile"`" = "$default_profile-0-link" + test "`readlink "$default_profile"`" = "`basename $default_profile-0-link`" done # Check whether '-p ~/.guix-profile' makes any difference. -- cgit v1.2.3