diff mbox series

[bug#61750,2/2] WIP failing attempt to get the man page while cross-compiling

Message ID 20230224140740.16494-2-attila@lendvai.name
State New
Headers show
Series [bug#61750,1/2] gnu: shepherd: Build Shepherd from git. | expand

Commit Message

Attila Lendvai Feb. 24, 2023, 2:07 p.m. UTC
---
 gnu/packages/admin.scm | 48 +++++++++++++++++++++++++++++++++---------
 1 file changed, 38 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index 91f98bf48e..6e5082e612 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -343,7 +343,7 @@  (define-public shepherd-0.9
               (sha256
                (base32 "1pvdpx2mfki8wvhcac54p8fn5idqszicww60ikswszz2cv5d0s11"))))
     (arguments
-     (list #:configure-flags #~'("--localstatedir=/var")
+     (list #:configure-flags #~'("HELP2MAN=true --localstatedir=/var")
            #:make-flags #~'("GUILE_AUTO_COMPILE=0")
            #:phases (if (%current-target-system)
                         #~(modify-phases %standard-phases
@@ -359,17 +359,45 @@  (define-public shepherd-0.9
                                   (("%FIBERS_OBJECT_DIRECTORY%")
                                    #$(file-append
                                       (this-package-input "guile-fibers")
-                                      "/lib/guile/3.0/site-ccache"))))))
+                                      "/lib/guile/3.0/site-ccache")))))
+                            (add-after 'configure 'copy-man-pages
+                              (lambda* (#:key outputs native-inputs #:allow-other-keys)
+                                ;; Cannot run help2man when cross-compiling,
+                                ;; so let's copy the man pages from the native
+                                ;; build.
+                                (let ((gzip (search-input-file native-inputs
+                                                               "bin/gzip")))
+                                  ;; TODO
+                                  (pk #$(file-append
+                                         (this-package-input this-package)
+                                         "/man/shepherd.1.gz"))
+                                  (invoke gzip "--decompress" "--stdout"
+                                          #$(file-append
+                                             (this-package-input this-package)
+                                             "/man/shepherd.1.gz")
+                                          ">doc/shepherd.1"))
+                                #;(copy-file #$(file-append
+                                              (this-package-input this-package)
+                                              "/man/shepherd.1")
+                                           (string-append
+                                            (assoc-ref outputs "out")
+                                            "/man/shepherd.1"))
+                                #f)))
                         #~%standard-phases)))
     (native-inputs
-     (list autoconf
-           automake
-           gettext-minimal
-           guile-3.0
-           guile-fibers-1.1             ; for cross-compilation
-           help2man
-           pkg-config
-           texinfo))
+     (cons* autoconf
+            automake
+            gettext-minimal
+            guile-3.0
+            guile-fibers-1.1            ; for cross-compilation
+            help2man
+            pkg-config
+            texinfo
+            ;; for the help2man man page when cross-compiling
+            (if (%current-target-system)
+                (list gzip
+                      this-package)
+                '())))
     (inputs (list guile-3.0
                   guile-fibers-1.1))))