* guix/channels.scm (latest-channel-instance): Write nearest tag into .version of the checkout. * guix/self.scm (info-manual): Use nearest tag from .version as the version string while generating documentation. --- guix/channels.scm | 15 ++++++++++++++- guix/self.scm | 11 +++++++---- 2 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/guix/channels.scm b/guix/channels.scm index bbabf654a9..d35cbc42cf 100644 --- a/guix/channels.scm +++ b/guix/channels.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2018, 2019, 2020 Ludovic Courtès <l...@gnu.org> ;;; Copyright © 2018 Ricardo Wurmus <rek...@elephly.net> ;;; Copyright © 2019 Jan (janneke) Nieuwenhuizen <jann...@gnu.org> +;;; Copyright © 2020 Arun Isaac <arunis...@systemreboot.net> ;;; ;;; This file is part of GNU Guix. ;;; @@ -40,6 +41,7 @@ #:use-module (guix sets) #:use-module (guix store) #:use-module (guix i18n) + #:use-module (guix build utils) #:use-module ((guix utils) #:select (source-properties->location &error-location @@ -56,9 +58,11 @@ #:autoload (guix quirks) (%quirks %patches applicable-patch? apply-patch) #:use-module (ice-9 format) #:use-module (ice-9 match) + #:use-module (ice-9 popen) #:use-module (ice-9 vlist) #:use-module ((ice-9 rdelim) #:select (read-string)) #:use-module ((rnrs bytevectors) #:select (bytevector=?)) + #:use-module (rnrs io ports) #:export (channel channel? channel-name @@ -397,7 +401,16 @@ thus potentially malicious code."))))))) (when (guix-channel? channel) ;; Apply the relevant subset of PATCHES directly in CHECKOUT. This is ;; safe to do because 'switch-to-ref' eventually does a hard reset. - (apply-patches checkout commit patches)) + (apply-patches checkout commit patches) + + ;; Write nearest tag into .version. + (with-directory-excursion checkout + (let ((version + (call-with-port + (open-pipe* OPEN_READ "./build-aux/git-version-gen" ".tarball-version") + get-string-all))) + (call-with-output-file ".version" + (cut put-string <> version))))) (let* ((name (url+commit->name (channel-url channel) commit)) (checkout (add-to-store store name #t "sha256" checkout diff --git a/guix/self.scm b/guix/self.scm index f70b1ecdd8..8c94efa7de 100644 --- a/guix/self.scm +++ b/guix/self.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017, 2018, 2019, 2020 Ludovic Courtès <l...@gnu.org> +;;; Copyright © 2020 Arun Isaac <arunis...@systemreboot.net> ;;; ;;; This file is part of GNU Guix. ;;; @@ -459,16 +460,18 @@ a list of extra files, such as '(\"contributing\")." (with-imported-modules '((guix build utils)) #~(begin (use-modules (guix build utils) + (rnrs io ports) (ice-9 match)) (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'. Use nearest tag written in .version as the + ;; version string. (call-with-output-file "version.texi" (lambda (port) - (let ((version "0.0-git")) + (let* ((tag (call-with-input-file (string-append #$source "/.version") + get-string-all)) + (version (substring tag 0 (string-index-right tag #\.)))) (format port " @set UPDATED 1 January 1970 @set UPDATED-MONTH January 1970 -- 2.26.2