diff options
author | Attila Lendvai <attila@lendvai.name> | 2022-04-29 15:14:34 +0200 |
---|---|---|
committer | Jonathan Brielmaier <jonathan.brielmaier@web.de> | 2022-05-05 23:14:30 +0200 |
commit | a0079cf1bd8ef707ab9e15a0e249cbd34f157ae4 (patch) | |
tree | d082f47f9fb5f19290cb5712cb551f037fc87efb | |
parent | 8f8bdc8ec6e03c6453e2e4c43a8b5c0f37a0d401 (diff) |
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 <jonathan.brielmaier@web.de>
-rw-r--r-- | nonguix/build/binary-build-system.scm | 25 |
1 files 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))) |