Subject: [bug#66952] [PATCH] gnu: libarchive: Replace add--L-in-libarchive-pc by configure-flags.

From: Nicolas Graves <[email-masked]>
Date: Sun, 5 Nov 2023 16:21:25 +0100

* gnu/packages/backup.scm (libarchive): Replace add--L-in-libarchive-pc by configure-flags.
[arguments](phases): Remove phase add--L-in-libarchive-pc.
(configuration-flags): Adapt configuration LIBS to avoid propagation.

Change-Id: I85f623043e98b82e46b9afe18c0be53cc7961d4b
---
 gnu/packages/backup.scm | 39 +++++++++++----------------------------
 1 file changed, 11 insertions(+), 28 deletions(-)

diff --git a/gnu/packages/backup.scm b/gnu/packages/backup.scm
index 12c4a45b9d..b5e4112c4b 100644
--- a/gnu/packages/backup.scm
+++ b/gnu/packages/backup.scm
@@ -24,6 +24,7 @@
 ;;; Copyright © 2022 Maxim Cournoyer <[email-masked]>
 ;;; Copyright © 2022 Feng Shu <[email-masked]>
 ;;; Copyright © 2023 Timo Wilken <[email-masked]>
+;;; Copyright © 2023 Nicolas Graves <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -41,7 +42,6 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu packages backup)
-  #:use-module (guix gexp)
   #:use-module (guix packages)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix gexp)
@@ -262,7 +262,15 @@ (define-public libarchive
            `(,zstd "lib")))
     (arguments
      (list
-      #:configure-flags #~'("--disable-static")
+      ;; Embed absolute references to inputs to avoid propagation.
+      #:configure-flags
+      #~(list "--disable-static"
+              (string-append
+               "LIBS= -L"
+               (string-join
+                (list #$@(map (lambda (in) (this-package-input (car in)))
+                              (package-inputs this-package)))
+                "/lib -L")))
       #:phases
       #~(modify-phases %standard-phases
           (add-before 'build 'patch-pwd
@@ -288,32 +296,7 @@ (define-public libarchive
 		    (invoke "./bsdcpio_test" "^test_owner_parse")
 		    (invoke "./bsdtar_test"))
                   ;; Tests may be disabled if cross-compiling.
-                  (format #t "Test suite not run.~%"))))
-          (add-after 'install 'add--L-in-libarchive-pc
-            (lambda* (#:key inputs outputs #:allow-other-keys)
-              (let* ((out     #$output)
-                     (lib     (string-append out "/lib"))
-                     (nettle  (assoc-ref inputs "nettle"))
-                     (libxml2 (assoc-ref inputs "libxml2"))
-                     (xz      (assoc-ref inputs "xz"))
-                     (zlib    (assoc-ref inputs "zlib"))
-                     (zstd    (assoc-ref inputs "zstd"))
-                     (bzip2   (assoc-ref inputs "bzip2")))
-                ;; Embed absolute references to these inputs to avoid propagation.
-                (substitute* (list (string-append lib "/pkgconfig/libarchive.pc")
-                                   (string-append lib "/libarchive.la"))
-                  (("-lnettle")
-                   (string-append "-L" nettle "/lib -lnettle"))
-                  (("-lxml2")
-                   (string-append "-L" libxml2 "/lib -lxml2"))
-                  (("-llzma")
-                   (string-append "-L" xz "/lib -llzma"))
-                  (("-lz")
-                   (string-append "-L" zlib "/lib -lz"))
-                  (("-lzstd")
-                   (string-append "-L" zstd "/lib -lzstd"))
-                  (("-lbz2")
-                   (string-append "-L" bzip2 "/lib -lbz2")))))))))
+                  (format #t "Test suite not run.~%")))))))
     (home-page "https://libarchive.org/")
     (synopsis "Multi-format archive and compression library")
     (description
-- 
2.41.0