diff mbox series

[bug#54266] samba: wrap scripts with GUIX_PYTHONPATH

Message ID f407fb7d-c411-7696-19a8-ae99eba69eab@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, 7:26 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 | 46 ++++++++++++++++++++++++++++++++++--------
  1 file changed, 38 insertions(+), 8 deletions(-)

Comments

M March 8, 2022, 8:39 p.m. UTC | #1
fesoj000 schreef op di 08-03-2022 om 20:26 [+0100]:
> -     (list
> -      #:make-flags #~(list "TEST_OPTIONS=--quick") ;some tests are very long
> -      #:phases
> -      #~(modify-phases %standard-phases
> +     `(#:make-flags '("TEST_OPTIONS=--quick") ;some tests are very long

What's the reason for turning things from G-exps into S-exps?
M March 8, 2022, 8:44 p.m. UTC | #2
fesoj000 schreef op di 08-03-2022 om 20:26 [+0100]:
> +                            (wrap-program (string-append out file)
> +                              `("GUIX_PYTHONPATH" =
> +                                (,(guix-pythonpath
> +                                   (site-package-path
> +                                    (assoc-ref inputs "python")))))))

I would expect that python always puts its own site-packages in front
of the path, though I could be mistaken, so is this necessary?

Also, it looks like some of the python stuf uses 'ldb', so 'ldb' might
need to be included as well.

Greetings,
Maxime.
M March 8, 2022, 10:28 p.m. UTC | #3
[Please keep 54266@debbugs.gnu.org in CC]

fesoj000 schreef op di 08-03-2022 om 23:14 [+0100]:
> packages. If you talk about the samba package output then we can do this like
> the new diff below.

Looking at some of the python scripts, it seems that they
add samba's python libraries to the path by theirselves,
so I don't think this is necessary.

> > Also, it looks like some of the python stuf uses 'ldb', so 'ldb' might
> > need to be included as well.
> 'ldb' is included, you can look at the guix-pythonpath function which builds
> the pythonpath. In fact not only 'ldb' is need but further 'tdb' and 'talloc'.

Looking a little closer, it indeed seems fine (untested)!

Greetings,
Maxime.
diff mbox series

Patch

diff --git a/gnu/packages/samba.scm b/gnu/packages/samba.scm
index b775ad905c..2bdf89163e 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)
@@ -193,10 +194,13 @@  (define-public samba
          (base32 "0zyid2np45kl8hzp9fjqwvn5lxj766a4f0mya58vldqrhcrmw4b9"))))
      (build-system gnu-build-system)
      (arguments
-     (list
-      #:make-flags #~(list "TEST_OPTIONS=--quick") ;some tests are very long
-      #:phases
-      #~(modify-phases %standard-phases
+     `(#:make-flags '("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
              (lambda* (#:key inputs #:allow-other-keys)
                ;; Append Samba's own DTDs to XML_CATALOG_FILES
@@ -212,12 +216,13 @@  (define-public samba
                   (string-append all " $XML_CATALOG_FILES")))))
            (replace 'configure
              ;; Samba uses a custom configuration script that runs WAF.
-            (lambda* (#:key inputs #:allow-other-keys)
-              (let* ((libdir (string-append #$output "/lib")))
+            (lambda* (#:key inputs outputs #:allow-other-keys)
+              (let* ((out (assoc-ref outputs "out"))
+                     (libdir (string-append out "/lib")))
                  (invoke "./configure"
                          "--enable-selftest"
                          "--enable-fhs"
-                        (string-append "--prefix=" #$output)
+                        (string-append "--prefix=" out)
                          "--sysconfdir=/etc"
                          "--localstatedir=/var"
                          ;; Install public and private libraries into
@@ -231,12 +236,37 @@  (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 outputs #:allow-other-keys)
+              (let ((out (assoc-ref outputs "out")))
+                (define (site-package-path python)
+                  (string-append "/lib/python" (python-version python)
+                                 "/site-packages"))
+                (define (guix-pythonpath site-package-path)
+                  (string-join
+                   (append (map (lambda (input)
+                                  (string-append (assoc-ref inputs input)
+                                                 site-package-path))
+                                '("tdb" "ldb" "talloc"))
+                           (list (string-append out site-package-path)))
+                   ":"))
+                (for-each (lambda (file)
+                            (wrap-program (string-append out 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