Paste number 342692: | Trying to generate manpages database |
Pasted by: | Apteryx |
When: | 5 years, 1 month ago |
Share: | Tweet this! | http://paste.lisp.org/+7CF8 |
Channel: | None |
Paste contents: |
From 726c48e8c431471c4b1c892293fd0c5ba58689a0 Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Date: Tue, 28 Mar 2017 09:25:21 -0700
Subject: [PATCH] Generate man database files
---
guix/profiles.scm | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)
diff --git a/guix/profiles.scm b/guix/profiles.scm
index a62a076f64..68539bddfc 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -916,11 +916,76 @@ files for the truetype fonts of the @var{manifest} entries."
(guix build union))
#:local-build? #t
#:substitutable? #f))
+
+(define (manual-database manifest)
+ (define man-db ;lazy reference
+ (module-ref (resolve-interface '(gnu packages man)) 'man-db))
+
+ (define build
+ #~(begin
+ (use-modules (guix build utils)
+ (guix gexp)
+ (srfi srfi-1))
+
+ (define entries
+ (filter-map (lambda (directory)
+ (let ((man (string-append directory "/share/man")))
+ (and (directory-exists? man)
+ man)))
+ '#$(manifest-inputs manifest)))
+
+ (define man-directory
+ (string-append #$output "/share/man"))
+
+ (define man-db-config-orig
+ (string-append #+man-db "/etc/man_db.conf"))
+
+ (define man-db-config
+ (string-append (getenv "PWD") "/man_db.conf"))
+
+ (define (create-mandb-map-entries manpaths catpath)
+ (string-join (map (lambda (manpath)
+ (string-append "MANDB_MAP " manpath " " catpath))
+ manpaths)
+ "\n"))
+
+ ;; Create a mandb config file which contains all manpaths of the
+ ;; entries found... This is so that we can create a manpath -->
+ ;; catpath mapping to control where the database files get created.
+
+ (copy-file man-db-config-orig man-db-config)
+
+ ;; Doesn't work; error is: " no code for module (guix store)"
+ ;; I'll have to use Guile directly?
+ (file-append man-db-config
+ (create-mandb-map-entries entries man-directory))
+
+ ;; Replace default MANDB_MAP entries by our own.
+;; (substitute* man-db-config
+;; (("^MANDB_MAP.*$")
+;; ""))
+;; (substitute* man-db-config
+;; (("# \\*MANPATH\\* -> \\*CATPATH\\*\\n#")
+;; (string-append "# *MANPATH* -> *CATPATH*
+;; #"
+;; (create-mandb-map-entries entries man-directory))))
+
+
+ (mkdir-p man-directory)
+ (setenv "MANPATH" (string-join entries ":"))
+ (zero? (system* (string-append #+man-db "/bin/mandb") "--debug"
+ "-c" "-C" man-db-config))))
+
+ (gexp->derivation "manual-database" build
+ #:modules '((guix build utils)
+ (guix gexp))
+ #:local-build? #t))
(define %default-profile-hooks
;; This is the list of derivation-returning procedures that are called by
;; default when making a non-empty profile.
(list info-dir-file
+ manual-database
fonts-dir-file
ghc-package-cache-file
ca-certificate-bundle
--
2.12.0
This paste has no annotations.