guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

02/02: guix: scripts: Parse $GUIX_BUILD_OPTIONS separately.


From: Ludovic Courtès
Subject: 02/02: guix: scripts: Parse $GUIX_BUILD_OPTIONS separately.
Date: Sat, 06 Dec 2014 15:03:55 +0000

civodul pushed a commit to branch master
in repository guix.

commit 847391fe6229bc9b989939470b4a84bd82c75088
Author: nebuli <address@hidden>
Date:   Fri Dec 5 01:28:12 2014 +0100

    guix: scripts: Parse $GUIX_BUILD_OPTIONS separately.
    
    Appending to "raw" args broke optional parameters in 'guix package -I'
    and 'guix package -A', and possibly other places.  Therefore, switch to
    parsing each set of options on its own and append resulting alists
    together afterwards.
    
    * guix/scripts/archive.scm (parse-options-from): Rename from
      (parse-options) and add explicit argument.  New form of (parse-options)
      using its old algorithm via -from function.
    * guix/scripts/build.scm: Ditto.
    * guix/scripts/environment.scm: Ditto.
    * guix/scripts/package.scm: Ditto.
    * guix/scripts/system.scm: Ditto.
    * tests/guix-package.sh: Add test.
    * doc/guix.texi (Invoking guix build): Make it clear that the options
      are parsed independently.
    
    Co-authored-by: Ludovic Courtès <address@hidden>
---
 doc/guix.texi                |    3 ++-
 guix/scripts/archive.scm     |    8 ++++++--
 guix/scripts/build.scm       |    8 ++++++--
 guix/scripts/environment.scm |    9 +++++++--
 guix/scripts/package.scm     |    8 ++++++--
 guix/scripts/system.scm      |    8 ++++++--
 tests/guix-package.sh        |   13 +++++++++++++
 7 files changed, 46 insertions(+), 11 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index e804d79..1d4a012 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -2802,7 +2802,8 @@ below:
 $ export GUIX_BUILD_OPTIONS="--no-substitutes -c 2 -L /foo/bar"
 @end example
 
-These options are appended to the ones passed on the command line.
+These options are parsed independently, and the result is appended to
+the parsed command-line options.
 @end defvr
 
 
diff --git a/guix/scripts/archive.scm b/guix/scripts/archive.scm
index 29a3ad1..781ffc5 100644
--- a/guix/scripts/archive.scm
+++ b/guix/scripts/archive.scm
@@ -293,8 +293,12 @@ the input port."
 (define (guix-archive . args)
   (define (parse-options)
     ;; Return the alist of option values.
-    (args-fold* (append args (environment-build-options))
-                %options
+    (append (parse-options-from args)
+            (parse-options-from (environment-build-options))))
+
+  (define (parse-options-from args)
+    ;; Actual parsing takes place here.
+    (args-fold* args %options
                 (lambda (opt name arg result)
                   (leave (_ "~A: unrecognized option~%") name))
                 (lambda (arg result)
diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm
index 76a743f..26e9f42 100644
--- a/guix/scripts/build.scm
+++ b/guix/scripts/build.scm
@@ -401,8 +401,12 @@ arguments with packages that use the specified source."
 (define (guix-build . args)
   (define (parse-options)
     ;; Return the alist of option values.
-    (args-fold* (append args (environment-build-options))
-                %options
+    (append (parse-options-from args)
+            (parse-options-from (environment-build-options))))
+
+  (define (parse-options-from args)
+    ;; Actual parsing takes place here.
+    (args-fold* args %options
                 (lambda (opt name arg result)
                   (leave (_ "~A: unrecognized option~%") name))
                 (lambda (arg result)
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index a309dfa..c388b0c 100644
--- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -213,8 +213,13 @@ packages."
 ;; Entry point.
 (define (guix-environment . args)
   (define (parse-options)
-    (args-fold* (append args (environment-build-options))
-                %options
+    ;; Return the alist of option values.
+    (append (parse-options-from args)
+            (parse-options-from (environment-build-options))))
+
+  (define (parse-options-from args)
+    ;; Actual parsing takes place here.
+    (args-fold* args %options
                 (lambda (opt name arg result)
                   (leave (_ "~A: unrecognized option~%") name))
                 (lambda (arg result)
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index 9ff4d17..21dc66c 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -668,8 +668,12 @@ removed from MANIFEST."
 (define (guix-package . args)
   (define (parse-options)
     ;; Return the alist of option values.
-    (args-fold* (append args (environment-build-options))
-                %options
+    (append (parse-options-from args)
+            (parse-options-from (environment-build-options))))
+
+  (define (parse-options-from args)
+    ;; Actual parsing takes place here.
+    (args-fold* args %options
                 (lambda (opt name arg result arg-handler)
                   (leave (_ "~A: unrecognized option~%") name))
                 (lambda (arg result arg-handler)
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index f2a25dd..5622860 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -477,8 +477,12 @@ Build the operating system declared in FILE according to 
ACTION.\n"))
 (define (guix-system . args)
   (define (parse-options)
     ;; Return the alist of option values.
-    (args-fold* (append args (environment-build-options))
-                %options
+    (append (parse-options-from args)
+            (parse-options-from (environment-build-options))))
+
+  (define (parse-options-from args)
+    ;; Actual parsing takes place here.
+    (args-fold* args %options
                 (lambda (opt name arg result)
                   (leave (_ "~A: unrecognized option~%") name))
                 (lambda (arg result)
diff --git a/tests/guix-package.sh b/tests/guix-package.sh
index 3e0e36f..f4e091a 100644
--- a/tests/guix-package.sh
+++ b/tests/guix-package.sh
@@ -289,3 +289,16 @@ GUIX_PACKAGE_PATH="$module_dir"
 export GUIX_PACKAGE_PATH
 guix package -A emacs-foo-bar | grep 42
 guix package -i emacs-foo-bar-42 -n
+unset GUIX_PACKAGE_PATH
+
+# Using 'GUIX_BUILD_OPTIONS'.
+
+available="`guix package -A | sort`"
+GUIX_BUILD_OPTIONS="--dry-run"
+export GUIX_BUILD_OPTIONS
+
+# Make sure $GUIX_BUILD_OPTIONS is not simply appended to the command-line,
+# which would break 'guix package -A' and similar.
+available2="`guix package -A | sort`"
+test "$available2" = "$available"
+guix package -I



reply via email to

[Prev in Thread] Current Thread [Next in Thread]