1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@gnu.org>
4 ;;; This file is part of GNU Guix.
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20 ;; This file contains machinery to build HTML and PDF copies of the manual
21 ;; that can be readily published on the web site. To do that, run:
23 ;; guix build -f build.scm
25 ;; The result is a directory hierarchy that can be used as the manual/
26 ;; sub-directory of the web site.
36 (gnu packages gettext)
38 (gnu packages guile-xyz)
39 (gnu packages iso-codes)
40 (gnu packages texinfo)
46 (@@ (guix self) file-append*))
48 (define translated-texi-manuals
49 (@@ (guix self) translate-texi-manuals))
52 (@@ (guix self) info-manual))
55 ;; The manual to build--i.e., the base name of a .texi file, such as "guix"
56 ;; or "guix-cookbook".
57 (or (getenv "GUIX_MANUAL")
61 '("de" "en" "es" "fr" "ru" "zh_CN"))
63 (define (texinfo-manual-images source)
64 "Return a directory containing all the images used by the user manual, taken
65 from SOURCE, the root of the source tree."
67 (module-ref (resolve-interface '(gnu packages graphviz))
71 (file-append* source "doc/images"))
74 (with-imported-modules '((guix build utils))
76 (use-modules (guix build utils)
79 (define (dot->image dot-file format)
80 (invoke #+(file-append graphviz "/bin/dot")
81 "-T" format "-Gratio=.9" "-Gnodesep=.005"
82 "-Granksep=.00005" "-Nfontsize=9"
83 "-Nheight=.1" "-Nwidth=.1"
84 "-o" (string-append #$output "/"
85 (basename dot-file ".dot")
91 (for-each (lambda (dot-file)
92 (for-each (cut dot->image dot-file <>)
94 (find-files #$images "\\.dot$"))
97 (for-each (lambda (png-file)
98 (install-file png-file #$output))
99 (find-files #$images "\\.png$")))))
101 (computed-file "texinfo-manual-images" build))
103 (define* (texinfo-manual-source source #:key
105 (languages %languages)
107 "Gather all the source files of the Texinfo manuals from SOURCE--.texi file
108 as well as images, OS examples, and translations."
109 (define documentation
110 (file-append* source "doc"))
113 (file-append* source "gnu/system/examples"))
116 (with-imported-modules '((guix build utils))
118 (use-modules (guix build utils)
121 (define (make-version-texi language)
122 ;; Create the 'version.texi' file for LANGUAGE.
123 (let ((file (if (string=? language "en")
125 (string-append "version-" language ".texi"))))
126 (call-with-output-file (string-append #$output "/" file)
128 (let* ((version #$version)
129 (time (make-time time-utc 0 #$date))
130 (date (time-utc->date time)))
133 @set UPDATED-MONTH ~a
136 (date->string date "~e ~B ~Y")
137 (date->string date "~B ~Y")
138 version version))))))
140 (install-file #$(file-append* documentation "/htmlxref.cnf")
143 (for-each (lambda (texi)
144 (install-file texi #$output))
145 (append (find-files #$documentation "\\.(texi|scm)$")
146 (find-files #$(translated-texi-manuals source)
149 ;; Create 'version.texi'.
150 (for-each make-version-texi '#$languages)
152 ;; Copy configuration templates that the manual includes.
153 (for-each (lambda (template)
156 #$output "/os-config-"
157 (basename template ".tmpl")
159 (find-files #$examples "\\.tmpl$"))
161 (symlink #$(texinfo-manual-images source)
162 (string-append #$output "/images")))))
164 (computed-file "texinfo-manual-source" build))
166 (define %web-site-url
167 ;; URL of the web site home page.
168 (or (getenv "GUIX_WEB_SITE_URL")
171 (define %makeinfo-html-options
172 ;; Options passed to 'makeinfo --html'.
173 '("--css-ref=https://www.gnu.org/software/gnulib/manual.css"
174 "-c" "EXTRA_HEAD=<meta name=\"viewport\" \
175 content=\"width=device-width, initial-scale=1\" />"))
177 (define guile-lib/htmlprag-fixed
178 ;; Guile-Lib with a hotfix for (htmlprag).
182 (inherit (package-source guile-lib))
183 (modules '(( guix build utils)))
187 ;; "<body><blockquote><p>foo</p>\n</blockquote></body>",
188 ;; 'html->shtml' would mistakenly close 'blockquote' right
189 ;; before <p>. This patch removes 'p' from the
190 ;; 'parent-constraints' alist to fix that.
191 (substitute* "src/htmlprag.scm"
192 (("^[[:blank:]]*\\(p[[:blank:]]+\\. \\(body td th\\)\\).*")
196 (substitute-keyword-arguments (package-arguments guile-lib)
197 ((#:phases phases '%standard-phases)
198 `(modify-phases ,phases
199 (add-before 'check 'skip-known-failure
201 ;; XXX: The above change causes one test failure among
202 ;; the htmlprag tests.
203 (setenv "XFAIL_TESTS" "htmlprag.scm")
206 (define* (syntax-highlighted-html input
208 (name "highlighted-syntax")
210 "/static/base/css/code.css"))
211 "Return a derivation called NAME that processes all the HTML files in INPUT
212 to (1) add them a link to SYNTAX-CSS-URL, and (2) highlight the syntax of all
213 its <pre class=\"lisp\"> blocks (as produced by 'makeinfo --html')."
215 (with-extensions (list guile-lib/htmlprag-fixed guile-syntax-highlight)
216 (with-imported-modules '((guix build utils))
218 (use-modules (htmlprag)
220 (syntax-highlight scheme)
221 (syntax-highlight lexers)
228 (define (pair-open/close lst)
229 ;; Pair 'open' and 'close' tags produced by 'highlights' and
230 ;; produce nested 'paren' tags instead.
235 ((('open open) rest ...)
238 (loop rest (+ 1 level) '()))
239 (lambda (inner close rest)
241 (cons `(paren ,level ,open ,inner ,close)
243 ((('close str) rest ...)
245 (values (reverse result) str rest)
247 (format (current-error-port)
248 "warning: extra closing paren; context:~% ~y~%"
250 (loop rest 0 (cons `(close ,str) result)))))
252 (loop rest level (cons item result)))
255 (format (current-error-port)
256 "warning: missing ~a closing parens; context:~% ~y%"
257 level (reverse result)))
258 (values (reverse result) "" '())))))
260 (define (highlights->sxml* highlights anchors)
261 ;; Like 'highlights->sxml', but handle nested 'paren tags. This
262 ;; allows for paren matching highlights via appropriate CSS
263 ;; "hover" properties. When a symbol is encountered, look it up
264 ;; in ANCHORS, a vhash, and emit the corresponding href, if any.
265 (define (tag->class tag)
266 (string-append "syntax-" (symbol->string tag)))
269 ((? string? str) str)
270 (('paren level open (body ...) close)
271 `(span (@ (class ,(string-append "syntax-paren"
272 (number->string level))))
274 (span (@ (class "syntax-symbol"))
275 ,@(highlights->sxml* body anchors))
278 ;; Check whether we can emit a hyperlink for TEXT.
279 (match (vhash-assoc text anchors)
281 `(span (@ (class ,(tag->class 'symbol))) ,text))
283 `(a (@ (class ,(tag->class 'symbol)) (href ,target))
286 `(span (@ (class ,(tag->class tag))) ,text)))
289 (define entity->string
295 (e (pk 'unknown-entity e) (primitive-exit 2))))
297 (define (concatenate-snippets pieces)
298 ;; Concatenate PIECES, which contains strings and entities,
299 ;; replacing entities with their corresponding string.
300 (let loop ((pieces pieces)
304 (string-concatenate-reverse strings))
305 (((? string? str) . rest)
306 (loop rest (cons str strings)))
307 ((('*ENTITY* "additional" entity) . rest)
308 (loop rest (cons (entity->string entity) strings)))
309 ((('span _ lst ...) . rest) ;for <span class="roman">
310 (loop (append lst rest) strings))
312 (pk 'unsupported-code-snippet something)
313 (primitive-exit 1)))))
315 (define (syntax-highlight sxml anchors)
316 ;; Recurse over SXML and syntax-highlight code snippets.
317 (let loop ((sxml sxml))
319 (('*TOP* decl body ...)
320 `(*TOP* ,decl ,@(map loop body)))
323 (link (@ (rel "stylesheet")
325 (href #$syntax-css-url)))))
326 (('pre ('@ ('class "lisp")) code-snippet ...)
327 `(pre (@ (class "lisp"))
330 (highlight lex-scheme
331 (concatenate-snippets code-snippet)))
333 ((tag ('@ attributes ...) body ...)
334 `(,tag (@ ,@attributes) ,@(map loop body)))
336 `(,tag ,@(map loop body)))
340 (define (underscore-decode str)
341 ;; Decode STR, an "underscore-encoded" string as produced by
342 ;; makeinfo for indexes, such as "_0025base_002dservices" for
346 (match (string-index str #\_)
348 (string-concatenate-reverse (cons str result)))
350 (let ((char (string->number
351 (substring str (+ index 1) (+ index 5))
353 (loop (string-drop str (+ index 5))
354 (append (list (string (integer->char char))
355 (string-take str index))
358 (define (anchor-id->key id)
359 ;; Convert ID, an anchor ID such as
360 ;; "index-pam_002dlimits_002dservice" to the corresponding key,
361 ;; "pam-limits-service" in this example.
363 (string-drop id (string-length "index-"))))
365 (define* (collect-anchors file #:optional (vhash vlist-null))
366 ;; Collect the anchors that appear in FILE, a makeinfo-generated
367 ;; file. Grab those from <dt> tags, which corresponds to
368 ;; Texinfo @deftp, @defvr, etc. Return VHASH augmented with
369 ;; more name/reference pairs.
370 (define string-or-entity?
373 (('*ENTITY* _ ...) #t)
376 (define (worthy-entry? lst)
378 ;; Scheme Variable: <strong>x</strong>
380 ;; <code>cups-configuration</code> parameter: …
381 (let loop ((lst lst))
383 (((? string-or-entity?) rest ...)
385 ((('strong _ ...) _ ...)
389 (let ((shtml (call-with-input-file file html->shtml)))
390 (let loop ((shtml shtml)
393 (('dt ('@ ('id id)) rest ...)
394 (if (and (string-prefix? "index-" id)
395 (worthy-entry? rest))
396 (vhash-cons (anchor-id->key id)
397 (string-append (basename file)
401 ((tag ('@ _ ...) body ...)
402 (fold loop vhash body))
404 (fold loop vhash body))
407 (define (process-html file anchors)
408 ;; Parse FILE and perform syntax highlighting for its Scheme
409 ;; snippets. Install the result to #$output.
410 (format (current-error-port) "processing ~a...~%" file)
411 (let* ((shtml (call-with-input-file file html->shtml))
412 (highlighted (syntax-highlight shtml anchors))
413 (base (string-drop file (string-length #$input)))
414 (target (string-append #$output base)))
415 (mkdir-p (dirname target))
416 (call-with-output-file target
418 (write-shtml-as-html highlighted port)))))
420 (define (copy-as-is file)
421 ;; Copy FILE as is to #$output.
422 (let* ((base (string-drop file (string-length #$input)))
423 (target (string-append #$output base)))
424 (mkdir-p (dirname target))
427 (if (eq? 'symlink (stat:type (lstat file)))
428 (symlink (readlink file) target)
431 (let ((errno (system-error-errno args)))
432 (pk 'error-link file target (strerror errno))
433 (primitive-exit 3))))))
435 (define (html? file stat)
436 (string-suffix? ".html" file))
438 ;; Install a UTF-8 locale so we can process UTF-8 files.
439 (setenv "GUIX_LOCPATH"
440 #+(file-append glibc-utf8-locales "/lib/locale"))
441 (setlocale LC_ALL "en_US.utf8")
443 ;; First process the mono-node 'guix.html' files.
444 (n-par-for-each (parallel-job-count)
446 (let ((anchors (collect-anchors mono)))
447 (process-html mono anchors)))
448 (find-files #$input "^guix(\\.[a-zA-Z_-]+)?\\.html$"))
450 ;; Next process the multi-node HTML files in two phases: (1)
451 ;; collect the list of anchors, and (2) perform
452 ;; syntax-highlighting.
453 (let* ((multi (find-files #$input "^html_node$"
455 (anchors (n-par-map (parallel-job-count)
458 (fold collect-anchors vlist-null
459 (find-files multi html?))))
461 (n-par-for-each (parallel-job-count)
463 (let ((anchors (assoc-ref anchors (dirname file))))
464 (process-html file anchors)))
465 (append-map (lambda (multi)
466 (find-files multi html?))
469 ;; Last, copy non-HTML files as is.
471 (find-files #$input (negate html?)))))))
473 (computed-file name build))
475 (define* (html-manual source #:key (languages %languages)
479 (options %makeinfo-html-options))
480 "Return the HTML manuals built from SOURCE for all LANGUAGES, with the given
482 (define manual-source
483 (texinfo-manual-source source
485 #:languages languages
489 (texinfo-manual-images source))
492 (with-imported-modules '((guix build utils))
494 (use-modules (guix build utils)
497 (define (normalize language)
498 ;; Normalize LANGUAGE. For instance, "zh_CN" becomes "zh-cn".
499 (string-map (match-lambda
502 (string-downcase language)))
504 (define (language->texi-file-name language)
505 (if (string=? language "en")
506 (string-append #$manual-source "/"
508 (string-append #$manual-source "/"
509 #$manual "." language ".texi")))
511 ;; Install a UTF-8 locale so that 'makeinfo' is at ease.
512 (setenv "GUIX_LOCPATH"
513 #+(file-append glibc-utf8-locales "/lib/locale"))
514 (setenv "LC_ALL" "en_US.utf8")
516 (setvbuf (current-output-port) 'line)
517 (setvbuf (current-error-port) 'line)
519 ;; 'makeinfo' looks for "htmlxref.cnf" in the current directory, so
520 ;; copy it right here.
521 (copy-file (string-append #$manual-source "/htmlxref.cnf")
524 (for-each (lambda (language)
525 (let* ((texi (language->texi-file-name language))
527 "-c" ,(string-append "TOP_NODE_UP_URL=/manual/"
531 (format #t "building HTML manual for language '~a'...~%"
533 (mkdir-p (string-append #$output "/"
534 (normalize language)))
535 (setenv "LANGUAGE" language)
536 (apply invoke #$(file-append texinfo "/bin/makeinfo")
537 "-o" (string-append #$output "/"
541 (apply invoke #$(file-append texinfo "/bin/makeinfo")
544 (string-append #$output "/"
547 (if (string=? language "en")
549 (string-append "." language))
553 ;; Make sure images are available.
555 (string-append #$output "/" (normalize language)
558 (string-append #$output "/" (normalize language)
559 "/html_node/images"))))
560 (filter (compose file-exists? language->texi-file-name)
563 (let* ((name (string-append manual "-html-manual"))
564 (manual (computed-file name build)))
565 (syntax-highlighted-html manual
566 #:name (string-append name "-highlighted"))))
568 (define* (pdf-manual source #:key (languages %languages)
573 "Return the HTML manuals built from SOURCE for all LANGUAGES, with the given
575 (define manual-source
576 (texinfo-manual-source source
578 #:languages languages
581 ;; FIXME: This union works, except for the table of contents of non-English
582 ;; manuals, which contains escape sequences like "^^ca^^fe" instead of
586 ;; (texlive-union (list texlive-tex-texinfo
587 ;; texlive-generic-epsf
588 ;; texlive-fonts-ec)))
591 (with-imported-modules '((guix build utils))
593 (use-modules (guix build utils)
597 (define (normalize language) ;XXX: deduplicate
598 ;; Normalize LANGUAGE. For instance, "zh_CN" becomes "zh-cn".
599 (string-map (match-lambda
602 (string-downcase language)))
604 ;; Install a UTF-8 locale so that 'makeinfo' is at ease.
605 (setenv "GUIX_LOCPATH"
606 #+(file-append glibc-utf8-locales "/lib/locale"))
607 (setenv "LC_ALL" "en_US.utf8")
609 (string-append #+(file-append texlive "/bin") ":"
610 #+(file-append texinfo "/bin") ":"
612 ;; Below are command-line tools needed by
613 ;; 'texi2dvi' and friends.
614 #+(file-append sed "/bin") ":"
615 #+(file-append grep "/bin") ":"
616 #+(file-append coreutils "/bin") ":"
617 #+(file-append gawk "/bin") ":"
618 #+(file-append tar "/bin") ":"
619 #+(file-append diffutils "/bin")))
621 (setvbuf (current-output-port) 'line)
622 (setvbuf (current-error-port) 'line)
624 (setenv "HOME" (getcwd)) ;for kpathsea/mktextfm
626 ;; 'SOURCE_DATE_EPOCH' is honored by pdftex.
627 (setenv "SOURCE_DATE_EPOCH" "1")
629 (for-each (lambda (language)
630 (let ((opts `("--pdf"
633 ,(if (string=? language "en")
634 (string-append #$manual-source "/"
636 (string-append #$manual-source "/"
637 #$manual "." language ".texi")))))
638 (format #t "building PDF manual for language '~a'...~%"
640 (mkdir-p (string-append #$output "/"
641 (normalize language)))
642 (setenv "LANGUAGE" language)
645 ;; FIXME: Unfortunately building PDFs for non-Latin
646 ;; alphabets doesn't work:
647 ;; <https://lists.gnu.org/archive/html/help-texinfo/2012-01/msg00014.html>.
648 (guard (c ((invoke-error? c)
649 (format (current-error-port)
650 "~%~%Failed to produce \
651 PDF for language '~a'!~%~%"
653 (apply invoke #$(file-append texinfo "/bin/makeinfo")
655 (string-append #$output "/"
658 (if (string=? language "en")
666 (computed-file (string-append manual "-pdf-manual") build))
668 (define (guix-manual-text-domain source languages)
669 "Return the PO files for LANGUAGES of the 'guix-manual' text domain taken
672 (file-append* source "/po/doc"))
675 (with-imported-modules '((guix build utils))
677 (use-modules (guix build utils))
680 (for-each (lambda (language)
682 (string-append #$output "/" language
686 (invoke #+(file-append gnu-gettext "/bin/msgfmt")
688 (string-append directory "/guix-manual.mo")
689 (string-append #$po-directory "/guix-manual."
691 '#$(delete "en" languages)))))
693 (computed-file "guix-manual-po" build))
695 (define* (html-manual-indexes source
696 #:key (languages %languages)
699 (title (if (string=? "guix" manual)
700 "GNU Guix Reference Manual"
701 "GNU Guix Cookbook"))
704 (with-extensions (list guile-json-3)
705 (with-imported-modules '((guix build utils))
707 (use-modules (guix build utils)
715 (define (normalize language) ;XXX: deduplicate
716 ;; Normalize LANGUAGE. For instance, "zh_CN" becomes "zh-cn".
717 (string-map (match-lambda
720 (string-downcase language)))
722 (define-syntax-rule (with-language language exp ...)
723 (let ((lang (getenv "LANGUAGE")))
726 (setenv "LANGUAGE" language)
727 (setlocale LC_MESSAGES))
731 (setenv "LANGUAGE" lang)
732 (unsetenv "LANGUAGE"))
733 (setlocale LC_MESSAGES)))))
735 ;; (put 'with-language 'scheme-indent-function 1)
736 (define* (translate str language
737 #:key (domain "guix-manual"))
740 (bindtextdomain "guix-manual"
741 #+(guix-manual-text-domain
744 (bindtextdomain "iso_639-3" ;language names
745 #+(file-append iso-codes
747 (write (gettext ,str ,domain))))
749 (with-language language
750 ;; Since the 'gettext' function caches msgid translations,
751 ;; regardless of $LANGUAGE, we have to spawn a new process each
752 ;; time we want to translate to a different language. Bah!
753 (let* ((pipe (open-pipe* OPEN_READ
754 #+(file-append guile-2.2
756 "-c" (object->string exp)))
761 (define (seconds->string seconds language)
762 (let* ((time (make-time time-utc 0 seconds))
763 (date (time-utc->date time)))
764 (with-language language (date->string date "~e ~B ~Y"))))
766 (define (guix-url path)
767 (string-append #$%web-site-url path))
769 (define (sxml-index language title body)
770 ;; FIXME: Avoid duplicating styling info from guix-artwork.git.
771 `(html (@ (lang ,language))
773 (title ,(string-append title " — GNU Guix"))
774 (meta (@ (charset "UTF-8")))
775 (meta (@ (name "viewport") (content "width=device-width, initial-scale=1.0")))
777 (link (@ (rel "prefetch") (href ,(guix-url "menu/index.html"))))
779 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/elements.css"))))
780 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/common.css"))))
781 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/messages.css"))))
782 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/navbar.css"))))
783 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/breadcrumbs.css"))))
784 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/buttons.css"))))
785 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/footer.css"))))
787 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/page.css"))))
788 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/post.css")))))
790 (header (@ (class "navbar"))
791 (h1 (a (@ (class "branding")
792 (href #$%web-site-url)))
793 (span (@ (class "a11y-offset"))
795 (nav (@ (class "menu"))))
796 (nav (@ (class "breadcrumbs"))
797 (a (@ (class "crumb")
798 (href #$%web-site-url))
803 (define (language-index language)
805 (translate #$title language))
811 (@ (class "page centered-block limit-width"))
813 (p (@ (class "post-metadata centered-text"))
815 ,(seconds->string #$date language))
819 (li (a (@ (href "html_node"))
820 "HTML, with one page per node"))
824 (if (string=? language
830 "HTML, entirely on one page"))
831 ,@(if (member language '("ru" "zh_CN"))
833 `((li (a (@ (href ,(string-append
835 (if (string=? language "en")
842 (define %iso639-languages
844 (assoc-ref (call-with-input-file
845 #+(file-append iso-codes
846 "/share/iso-codes/json/iso_639-3.json")
850 (define (language-code->name code)
851 "Return the full name of a language from its ISO-639-3 code."
852 (let ((code (match (string-index code #\_)
854 (index (string-take code index)))))
855 (any (lambda (language)
856 (and (string=? (or (assoc-ref language "alpha_2")
857 (assoc-ref language "alpha_3"))
859 (assoc-ref language "name")))
862 (define (top-level-index languages)
863 (define title #$title)
868 (@ (class "page centered-block limit-width"))
871 "This document is available in the following
874 ,@(map (lambda (language)
875 `(li (a (@ (href ,(normalize language)))
877 (language-code->name language)
879 #:domain "iso_639-3"))))
882 (define (write-html file sxml)
883 (call-with-output-file file
885 (display "<!DOCTYPE html>\n" port)
886 (sxml->xml sxml port))))
888 (setenv "GUIX_LOCPATH"
889 #+(file-append glibc-utf8-locales "/lib/locale"))
890 (setenv "LC_ALL" "en_US.utf8")
891 (setlocale LC_ALL "en_US.utf8")
893 (for-each (lambda (language)
895 (string-append #$output "/"
896 (normalize language)))
899 (write-html (string-append directory "/index.html")
900 (language-index language)))
903 (write-html (string-append #$output "/index.html")
904 (top-level-index '#$languages))))))
906 (computed-file "html-indexes" build))
908 (define* (pdf+html-manual source
909 #:key (languages %languages)
911 (date (time-second (current-time time-utc)))
913 "Return the union of the HTML and PDF manuals, as well as the indexes."
914 (directory-union (string-append manual "-manual")
918 #:languages languages
921 (list html-manual-indexes
922 html-manual pdf-manual))
925 (define (latest-commit+date directory)
926 "Return two values: the last commit ID (a hex string) for DIRECTORY, and its
927 commit date (an integer)."
928 (let* ((repository (repository-open directory))
929 (head (repository-head repository))
930 (oid (reference-target head))
931 (commit (commit-lookup repository oid)))
932 ;; TODO: Use (git describe) when it's widely available.
933 (values (oid->string oid) (commit-time commit))))
936 (let* ((root (canonicalize-path
937 (string-append (current-source-directory) "/..")))
938 (commit date (latest-commit+date root)))
939 (format (current-error-port)
940 "building manual from work tree around commit ~a, ~a~%"
942 (let* ((time (make-time time-utc 0 date))
943 (date (time-utc->date time)))
944 (date->string date "~e ~B ~Y")))
945 (pdf+html-manual (local-file root "guix" #:recursive? #t
946 #:select? (git-predicate root))
947 #:version (or (getenv "GUIX_MANUAL_VERSION")
948 (string-take commit 7))