diff mbox series

[bug#54266] samba: wrap scripts with GUIX_PYTHONPATH

Message ID ded52caa-b6c4-cee2-0d33-43ec5e436630@gmail.com
State New
Headers show
Series [bug#54266] samba: wrap scripts with GUIX_PYTHONPATH | expand

Checks

Context Check Description
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

fesoj000 March 8, 2022, 11:10 p.m. UTC
Tools like samba-tool need the python libraries installed by samba and some of
sambas inputs.

* gnu/packages/samba.scm: new buildstep
(samba)[wrap-scripts]: Add build step.
---
  gnu/packages/samba.scm | 30 +++++++++++++++++++++++++++++-
  1 file changed, 29 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/gnu/packages/samba.scm b/gnu/packages/samba.scm
index b775ad905c..cb34fd8c2c 100644
--- a/gnu/packages/samba.scm
+++ b/gnu/packages/samba.scm
@@ -40,6 +40,7 @@  (define-module (gnu packages samba)
    #:use-module (gnu packages autotools)
    #:use-module (gnu packages backup)
    #:use-module (gnu packages base)
+  #:use-module (gnu packages bash)
    #:use-module (gnu packages check)
    #:use-module (gnu packages crypto)
    #:use-module (gnu packages cups)
@@ -195,6 +196,10 @@  (define-public samba
      (arguments
       (list
        #:make-flags #~(list "TEST_OPTIONS=--quick") ;some tests are very long
+      #:imported-modules `((guix build python-build-system)
+                           ,@%gnu-build-system-modules)
+      #:modules `(((guix build python-build-system) #:select (python-version))
+                  ,@%gnu-build-system-modules)
        #:phases
        #~(modify-phases %standard-phases
            (add-before 'configure 'setup-docbook-stylesheets
@@ -231,12 +236,35 @@  (define-public samba
            (add-before 'install 'disable-etc,var-samba-directories-setup
              (lambda _
                (substitute* "dynconfig/wscript"
-                (("bld\\.INSTALL_DIR.*") "")))))
+                (("bld\\.INSTALL_DIR.*") ""))))
+          (add-after 'install 'wrap-scripts
+            (lambda* (#:key inputs #:allow-other-keys)
+              (define (site-package-path python)
+                (string-append "/lib/python" (python-version python)
+                               "/site-packages"))
+              (define (guix-pythonpath site-package-path)
+                (string-join
+                 (map (lambda (input)
+                        (string-append (assoc-ref inputs input)
+                                       site-package-path))
+                      '("tdb" "ldb" "talloc"))
+                 ":"))
+              (for-each (lambda (file)
+                          (wrap-program (string-append #$output file)
+                            `("GUIX_PYTHONPATH" =
+                              (,(guix-pythonpath
+                                 (site-package-path
+                                  (assoc-ref inputs "python")))))))
+                        '("/bin/samba-tool" "/sbin/samba_dnsupdate"
+                          "/sbin/samba_downgrade_db" "/sbin/samba-gpupdate"
+                          "/sbin/samba_kcc" "/sbin/samba_spnupdate"
+                          "/sbin/samba_upgradedns")))))
        ;; FIXME: The test suite seemingly hangs after failing to provision the
        ;; test environment.
        #:tests? #f))
      (inputs
       (list acl
+           bash-minimal
             cmocka
             cups
             gamin