summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2013-08-23 15:51:36 +0200
committerLudovic Courtès <ludo@gnu.org>2013-08-23 15:51:36 +0200
commit7db3ff4a29415ccc4f781c3e2450deb97d51a26f (patch)
tree459549425e83a80457a5261da57545c8e32f0455
parentbaed8816fcd6665319c342a1d4c117198af33dc2 (diff)
downloadpatches-7db3ff4a29415ccc4f781c3e2450deb97d51a26f.tar
patches-7db3ff4a29415ccc4f781c3e2450deb97d51a26f.tar.gz
utils: Add `guile-version>?', and use it.
This fixes Guile version comparisons when (version) has a vendor-specific suffix. Reported by Andreas Enge <andreas@enge.fr>. * guix/utils.scm (guile-version>?): New procedure. * tests/utils.scm ("guile-version>? 1.8", "guile-version>? 10.5"): New tests. * guix/scripts/substitute-binary.scm (fetch, progress-report-port): Use `guile-version>?' instead of `version>?'. * guix/http-client.scm (when-guile<=2.0.5, http-fetch): Likewise.
-rw-r--r--guix/http-client.scm4
-rwxr-xr-xguix/scripts/substitute-binary.scm4
-rw-r--r--guix/utils.scm10
-rw-r--r--tests/utils.scm6
4 files changed, 20 insertions, 4 deletions
diff --git a/guix/http-client.scm b/guix/http-client.scm
index 898b1669e5..11231cbc1e 100644
--- a/guix/http-client.scm
+++ b/guix/http-client.scm
@@ -133,7 +133,7 @@ closed it will also close PORT, unless the KEEP-ALIVE? is true."
(get-bytevector-all (response-port r))))))
;; Install this patch only on Guile 2.0.5.
- (when (version>? "2.0.6" (version))
+ (unless (guile-version>? "2.0.5")
(module-set! (resolve-module '(web response))
'read-response-body read-response-body*)))
@@ -163,7 +163,7 @@ unbuffered port, suitable for use in `filtered-port'."
;; Try hard to use the API du jour to get an input port.
;; On Guile 2.0.5 and before, we can only get a string or
;; bytevector, and not an input port. Work around that.
- (if (version>? (version) "2.0.7")
+ (if (guile-version>? "2.0.7")
(http-get uri #:streaming? #t #:port port) ; 2.0.9+
(if (defined? 'http-get*)
(http-get* uri #:decode-body? text?
diff --git a/guix/scripts/substitute-binary.scm b/guix/scripts/substitute-binary.scm
index 4a013fe277..97bbfcbce8 100755
--- a/guix/scripts/substitute-binary.scm
+++ b/guix/scripts/substitute-binary.scm
@@ -155,7 +155,7 @@ provide."
;; and then cancel with:
;; sudo tc qdisc del dev eth0 root
(let ((port #f))
- (with-timeout (if (or timeout? (version>? (version) "2.0.5"))
+ (with-timeout (if (or timeout? (guile-version>? "2.0.5"))
%fetch-timeout
0)
(begin
@@ -417,7 +417,7 @@ PORT. REPORT-PROGRESS is a two-argument procedure such as that returned by
;; Since `http-fetch' in Guile 2.0.5 returns all the data once it's done,
;; don't pretend to report any progress in that case.
- (if (version>? (version) "2.0.5")
+ (if (guile-version>? "2.0.5")
(make-custom-binary-input-port "progress-port-proc"
read! #f #f
(cut close-port port))
diff --git a/guix/utils.scm b/guix/utils.scm
index 4187efde41..733319a0b4 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -59,6 +59,7 @@
%current-target-system
version-compare
version>?
+ guile-version>?
package-name->name+version
string-tokenize*
file-extension
@@ -316,6 +317,15 @@ or '= when they denote equal versions."
"Return #t when A denotes a newer version than B."
(eq? '> (version-compare a b)))
+(define (guile-version>? str)
+ "Return #t if the running Guile version is greater than STR."
+ ;; Note: Using (version>? (version) "2.0.5") or similar doesn't work,
+ ;; because the result of (version) can have a prefix, like "2.0.5-deb1".
+ (version>? (string-append (major-version) "."
+ (minor-version) "."
+ (micro-version))
+ str))
+
(define (package-name->name+version name)
"Given NAME, a package name like \"foo-0.9.1b\", return two values:
\"foo\" and \"0.9.1b\". When the version part is unavailable, NAME and
diff --git a/tests/utils.scm b/tests/utils.scm
index 3be60e443d..4f6ecc514d 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -66,6 +66,12 @@
("nixpkgs" "1.0pre22125_a28fe19")
("gtk2" "2.38.0"))))
+(test-assert "guile-version>? 1.8"
+ (guile-version>? "1.8"))
+
+(test-assert "guile-version>? 10.5"
+ (not (guile-version>? "10.5")))
+
(test-equal "string-tokenize*"
'(("foo")
("foo" "bar" "baz")