diff mbox

[4/10] argon2: Install pkg-config file.

Message ID 87d1k0sx3s.fsf@openmailbox.org
State New
Headers show

Commit Message

Lukas Gradl Sept. 18, 2016, 9:43 p.m. UTC
Danny Milosavljevic <dannym@scratchpost.org> writes:

>> +       (snippet
>> +        '(let ((p (open-file "argon2.pc" "a")))
> ...                                          ^ why?

Sorry, I took this without thinking from another place where I did
similar things.  This should be "w".  The attached patch fixes that.

Thank you!
Best,
Lukas

Comments

Danny Milosavljevic Sept. 19, 2016, 7:15 p.m. UTC | #1
Hi Lukas,

I thought about it some more.

On Sun, 18 Sep 2016 16:43:03 -0500
Lukas Gradl <lgradl@openmailbox.org> wrote:
> +               (and
> +                (install-file "argon2" (string-append out "/bin"))
> +                (install-file "libargon2.a" (string-append out "/lib"))
> +                (install-file "libargon2.so" (string-append out "/lib"))
> +                (install-file "argon2.pc"
> +                              (string-append out "/lib/pkgconfig"))

Hmm. I looked at the implementation of "install-file" and its return value seems to be the one of "copy-file". And the Guile manual specifies that the return value of "copy-file" is unspecified. (Instead it does dynamic unwinding on error)

So I'd do the "install-file" and "copy-recursively" calls outside the "(and ...)".

> +                (copy-recursively "include"
> +                                  (string-append out "/include"))
> +                (zero? (system* "ln" "-s"
> +                                (string-append out "/lib/libargon2.so")
> +                                (string-append out "/lib/libargon2.so.0")))

I think that there's a "symlink" function in Guile for that (which has unspecified return value). Would probably be marginally faster, too.

> +                (zero? (system* ; Fix compatability for libtool based builds.
> +                        "ln" "-s"
> +                        (string-append out "/lib/libargon2.so")
> +                        (string-append out "/lib/libargon2.so.0.0.0"))))))))))

Likewise.

About the part of the toolchain that sets the soname, either libtool mode=link does it ("-version-info") or it's an option "-soname" to ld (or gcc with "-Wl," prefix). 

The official soname used is set in argon2 Makefile:

        SO_LDFLAGS := -Wl,-soname,libargon2.so.0
                                  ^^^^^^^^^

But I'd say it's fine to manually symlink - since it works. Please still check how the client of argon2 in this case (libring ?) loads the shared object.
diff mbox

Patch

From eea1626e7ca44674d7430356a900665edefeb4ae Mon Sep 17 00:00:00 2001
From: Lukas Gradl <lgradl@openmailbox.org>
Date: Tue, 9 Aug 2016 16:49:19 -0500
Subject: [PATCH 04/10] gnu: argon2: Install pkg-config file.

* gnu/packages/password-utils.scm (argon2)[source]: Create pkg-config file.
[arguments]: Install it.
---
 gnu/packages/password-utils.scm | 40 +++++++++++++++++++++++++++++++++++-----
 1 file changed, 35 insertions(+), 5 deletions(-)

diff --git a/gnu/packages/password-utils.scm b/gnu/packages/password-utils.scm
index 7288da6..30e1206 100644
--- a/gnu/packages/password-utils.scm
+++ b/gnu/packages/password-utils.scm
@@ -311,6 +311,21 @@  through the pass command.")
          "https://codeload.github.com/P-H-C/phc-winner-"
          name "/tar.gz/" version))
        (file-name (string-append name "-" version ".tar.gz"))
+       (snippet
+        '(let ((p (open-file "argon2.pc" "w")))
+           (begin
+             (display
+              (string-append "prefix=/usr/local\n"
+                             "exec_prefix=${prefix}\n"
+                             "includedir=${prefix}/include\n"
+                             "libdir=${prefix}/lib\n\n"
+                             "Name: Argon2\n"
+                             "Description: "
+                             "The Argon2 password hashing algorithm\n"
+                             "Version: 1.0.0\n"
+                             "Cflags: -I${includedir}/\n"
+                             "Libs: -L${libdir} -largon2\n") p)
+             (close-output-port p))))
        (sha256
         (base32
          "0g6wa94sh639xl1qc8z21q43r1mp8y77r1zf8nwx5pfsxd8fmyzv"))))
@@ -321,14 +336,29 @@  through the pass command.")
        #:phases
        (modify-phases %standard-phases
          (delete 'configure)
+         (add-after 'unpack 'fix-pkg-config
+           (lambda _
+             (substitute* "argon2.pc"
+               (("/usr/local")
+                (assoc-ref %outputs "out")))))
          (replace 'install
            (lambda _
              (let ((out (assoc-ref %outputs "out")))
-               (install-file "argon2" (string-append out "/bin"))
-               (install-file "libargon2.a" (string-append out "/lib"))
-               (install-file "libargon2.so" (string-append out "/lib"))
-               (copy-recursively "include"
-                                 (string-append out "/include"))))))))
+               (and
+                (install-file "argon2" (string-append out "/bin"))
+                (install-file "libargon2.a" (string-append out "/lib"))
+                (install-file "libargon2.so" (string-append out "/lib"))
+                (install-file "argon2.pc"
+                              (string-append out "/lib/pkgconfig"))
+                (copy-recursively "include"
+                                  (string-append out "/include"))
+                (zero? (system* "ln" "-s"
+                                (string-append out "/lib/libargon2.so")
+                                (string-append out "/lib/libargon2.so.0")))
+                (zero? (system* ; Fix compatability for libtool based builds.
+                        "ln" "-s"
+                        (string-append out "/lib/libargon2.so")
+                        (string-append out "/lib/libargon2.so.0.0.0"))))))))))
     (home-page "https://www.argon2.com/")
     (synopsis "Password hashing library")
     (description "Argon2 provides a key derivation function that was declared
-- 
2.9.0