From a0079cf1bd8ef707ab9e15a0e249cbd34f157ae4 Mon Sep 17 00:00:00 2001 From: Attila Lendvai Date: Fri, 29 Apr 2022 15:14:34 +0200 Subject: nonguix: Extend patchelf-plan syntax with optional path. Makes it possible to define entries like the following in the patchelf-plan: ("the-binary" ("glibc" ("nss" "/lib/nss"))) * nonguix/build/binary-build-system.scm (maybe-make-rpath, make-rpath): New functions and use them. Signed-off-by: Jonathan Brielmaier --- nonguix/build/binary-build-system.scm | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/nonguix/build/binary-build-system.scm b/nonguix/build/binary-build-system.scm index 6a676ae..0738558 100644 --- a/nonguix/build/binary-build-system.scm +++ b/nonguix/build/binary-build-system.scm @@ -97,6 +97,19 @@ The PATCHELF-PLAN elements are lists of: Both executables and dynamic libraries are accepted. The inputs are optional when the file is an executable." (define (binary-patch binary interpreter runpath) + + (define* (maybe-make-rpath entries name #:optional (extra-path "/lib")) + (let ((entry (assoc-ref entries name))) + (if entry + (string-append entry extra-path) + #f))) + + (define* (make-rpath name #:optional (extra-path "/lib")) + (or (maybe-make-rpath outputs name extra-path) + (maybe-make-rpath inputs name extra-path) + (error (format #f "`~a' not found among the inputs nor the outputs." + input-or-output)))) + (unless (string-contains binary ".so") ;; Use `system*' and not `invoke' since this may raise an error if ;; library does not end with .so. @@ -104,13 +117,11 @@ The inputs are optional when the file is an executable." (when runpath (let ((rpath (string-join (map - (lambda (input-or-output) - (cond - ((assoc-ref outputs input-or-output) - (string-append (assoc-ref outputs input-or-output) "/lib")) - ((assoc-ref inputs input-or-output) - (string-append (assoc-ref inputs input-or-output) "/lib")) - (else (error (format #f "`~a' not found among the inputs nor the outputs." input-or-output))))) + (match-lambda + ((name extra-path) + (make-rpath name extra-path)) + (name + (make-rpath name))) runpath) ":"))) (invoke "patchelf" "--set-rpath" rpath binary))) -- cgit v1.2.3