@@ -172,7 +172,7 @@ (define (boot-guile-uri arch)
(define-public guix
;; Latest version of Guix, which may or may not correspond to a release.
;; Note: the 'update-guix-package.scm' script expects this definition to
- ;; start precisely like this.
+ ;; start precisely like this. Also match the regexps in (guix self)!
(let ((version "1.4.0")
(commit "4dfdd822102690b5687acf28365ab707b68d9476")
(revision 10))
@@ -418,23 +418,57 @@ (define (info-manual source)
(define examples
(file-append* source "gnu/system/examples"))
+ ;; Sniff the latest public Guix release version number from this file.
+ (define guix-package-module
+ (file-append* source "gnu/packages/package-management.scm"))
+
(define build
(with-imported-modules '((guix build utils))
#~(begin
(use-modules (guix build utils)
- (ice-9 match))
+ (ice-9 match)
+ (ice-9 rdelim)
+ (ice-9 regex))
+
+ ;; Use regular expressions rather than READ to ‘parse’ the guix
+ ;; package, in an attempt not to limit any future reader extensions.
+ (define guix-package-regexp
+ (make-regexp
+ "^\\(define[-[:alnum:]]*[[:blank:]]+guix([^[:alnum:]]|$)"))
+
+ (define guix-package-version-regexp
+ (make-regexp "\\(version[[:blank:]]*\"([^\"]*)\"\\)"))
+
+ (define (get-guix-package-version port)
+ (let loop ()
+ (let ((line (read-line port)))
+ (unless (or (eof-object? line)
+ (regexp-exec guix-package-regexp line))
+ (loop))))
+ (let loop ()
+ (let ((line (read-line port)))
+ (if (eof-object? line)
+ #f
+ (let ((rx (regexp-exec guix-package-version-regexp line)))
+ (if (eq? 2 (and=> rx match:count))
+ (match:substring rx 1)
+ (loop)))))))
(mkdir #$output)
- ;; Create 'version.texi'.
- ;; XXX: Can we use a more meaningful version string yet one that
- ;; doesn't change at each commit?
+ ;; Create 'version.texi'. We could sniff the git commit from the
+ ;; SOURCE file name, but don't: not only is the manual expensive to
+ ;; rebuild, VERSION is used almost exclusively to construct release
+ ;; URLs and the like.
(call-with-output-file "version.texi"
- (lambda (port)
- (let ((version "0.0-git"))
- (pk (find-files #$source "."))
- (punt)
- (format port "
+ (lambda (output)
+ (let* ((input (open-file #$guix-package-module "r"))
+ (version (if input
+ (let ((v (get-guix-package-version input)))
+ (close-port input)
+ v)
+ "0.0-git")))
+ (format output "\
@set UPDATED 1 January 1970
@set UPDATED-MONTH January 1970
@set EDITION ~a