diff options
author | Ludovic Courtès <ludo@gnu.org> | 2013-02-15 22:04:51 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2013-02-15 22:04:51 +0100 |
commit | 3665b4dc60cd1f7867c179806427c792f99dbf2b (patch) | |
tree | 9245aa0870230015419f6f22fd631ab9b683f67c /gnu | |
parent | e04f30e02307fb7660e3fb36ada8d5bcd53977f1 (diff) | |
download | guix-3665b4dc60cd1f7867c179806427c792f99dbf2b.tar guix-3665b4dc60cd1f7867c179806427c792f99dbf2b.tar.gz |
gnu: samba: Augment the RUNPATH of executables to point to $out/lib.
* gnu/packages/samba.scm (samba): Add `add-lib-to-runpath' phase, and
PatchELF as an input.
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/packages/samba.scm | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/gnu/packages/samba.scm b/gnu/packages/samba.scm index d414c285f8..93c9f70a50 100644 --- a/gnu/packages/samba.scm +++ b/gnu/packages/samba.scm @@ -27,6 +27,7 @@ #:use-module (gnu packages readline) #:use-module (gnu packages libunwind) #:use-module (gnu packages linux) + #:use-module (gnu packages patchelf) #:use-module (gnu packages perl) #:use-module (gnu packages python)) @@ -103,10 +104,45 @@ anywhere.") "1phl6mmrc72jyvbyrw6cv6b92cxq3v2pbn1fh97nnb4hild1fnjg")))) (build-system gnu-build-system) (arguments - '(#:phases (alist-cons-before 'configure 'chdir - (lambda _ - (chdir "source3")) - %standard-phases) + '(#:phases (alist-cons-before + 'configure 'chdir + (lambda _ + (chdir "source3")) + (alist-cons-after + 'strip 'add-lib-to-runpath + (lambda* (#:key outputs #:allow-other-keys) + (define (file-rpath file) + ;; Return the RPATH of FILE. + (let* ((p (open-pipe* OPEN_READ "patchelf" + "--print-rpath" file)) + (l (read-line p))) + (and (zero? (close-pipe p)) l))) + + (define (augment-rpath file dir) + ;; Add DIR to the RPATH of FILE. + (let* ((rpath (file-rpath file)) + (rpath* (if rpath + (string-append dir ":" rpath) + dir))) + (format #t "~a: changing RPATH from `~a' to `~a'~%" + file (or rpath "") rpath*) + (zero? (system* "patchelf" "--set-rpath" + rpath* file)))) + + (let* ((out (assoc-ref outputs "out")) + (lib (string-append out "/lib"))) + ;; Add LIB to the RUNPATH of all the executables. + (with-directory-excursion out + (for-each (cut augment-rpath <> lib) + (append (find-files "bin" ".*") + (find-files "sbin" ".*")))))) + %standard-phases)) + + #:modules ((guix build gnu-build-system) + (guix build utils) + (ice-9 popen) + (ice-9 rdelim) + (srfi srfi-26)) ;; This flag is required to allow for "make test". #:configure-flags '("--enable-socket-wrapper") @@ -126,7 +162,8 @@ anywhere.") ("popt" ,popt) ("openldap" ,openldap) ("linux-pam" ,linux-pam) - ("readline" ,readline))) + ("readline" ,readline) + ("patchelf" ,patchelf))) (native-inputs ; for the test suite `(("perl" ,perl) ("python" ,python))) |