mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-11 21:59:08 -05:00
guix system: Protect against changes to $PATH when activating the system.
Partly fixes <http://bugs.gnu.org/18082>. Reported by Mark H Weaver <mhw@netris.org>. * guix/scripts/system.scm (save-environment-excursion): New macro. (switch-to-system): Wrap 'primitive-load' call in it.
This commit is contained in:
parent
b6debdaa22
commit
720ee245da
1 changed files with 15 additions and 1 deletions
|
@ -172,6 +172,16 @@ (define %system-profile
|
|||
;; The system profile.
|
||||
(string-append %state-directory "/profiles/system"))
|
||||
|
||||
(define-syntax-rule (save-environment-excursion body ...)
|
||||
"Save the current environment variables, run BODY..., and restore them."
|
||||
(let ((env (environ)))
|
||||
(dynamic-wind
|
||||
(const #t)
|
||||
(lambda ()
|
||||
body ...)
|
||||
(lambda ()
|
||||
(environ env)))))
|
||||
|
||||
(define* (switch-to-system os
|
||||
#:optional (profile %system-profile))
|
||||
"Make a new generation of PROFILE pointing to the directory of OS, switch to
|
||||
|
@ -185,7 +195,11 @@ (define* (switch-to-system os
|
|||
(switch-symlinks profile generation)
|
||||
|
||||
(format #t (_ "activating system...~%"))
|
||||
(return (primitive-load (derivation->output-path script)))
|
||||
|
||||
;; The activation script may change $PATH, among others, so protect
|
||||
;; against that.
|
||||
(return (save-environment-excursion
|
||||
(primitive-load (derivation->output-path script))))
|
||||
|
||||
;; TODO: Run 'deco reload ...'.
|
||||
)))
|
||||
|
|
Loading…
Reference in a new issue