Subject: bug#25787: [PATCH 3/6] gnu: Add cryptopp.

From: Marius Bakke <[email-masked]>
Date: Wed, 22 Feb 2017 16:53:19 +0100

Pierre Langlois <[email-masked]> writes:

> * gnu/packages/crypto.scm (cryptopp): New variable.

I've actually been sitting on this package for a while, hoping they
would release a version with this fix:

https://github.com/weidai11/cryptopp/pull/347

Can you try to extract out the commit and add it as a patch?

> diff --git a/gnu/packages/crypto.scm b/gnu/packages/crypto.scm
> index fd2b5a36b..a8756e2ab 100644
> --- a/gnu/packages/crypto.scm
> +++ b/gnu/packages/crypto.scm
> @@ -6,6 +6,7 @@
>  ;;; Copyright © 2016 Tobias Geerinckx-Rice <[email-masked]>
>  ;;; Copyright © 2016 ng0 <[email-masked]>
>  ;;; Copyright © 2016 Eric Bavier <[email-masked]>
> +;;; Copyright © 2017 Pierre Langlois <[email-masked]>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -414,3 +415,46 @@ utility as a demonstration of the @code{scrypt} key derivation function.
>  @code{Scrypt} is designed to be far more resistant against hardware brute-force
>  attacks than alternative functions such as @code{PBKDF2} or @code{bcrypt}.")
>      (license license:bsd-2)))
> +
> +(define-public cryptopp
> +  (let ((version "5.6.5"))

I don't think it's necessary to bind the "version" variable outside the
package scope.

> +    (package
> +      (name "cryptopp")

I would call this "crypto++" both here and in the variable name. It
matches the upstream project name more closely, and is also how it is
known in the Common Platform Enumerations (CPE) database.[0]

https://lists.gnu.org/archive/html/guix-devel/2017-02/msg00587.html

> +      (version version)
> +      (source (origin
> +                (method url-fetch)
> +                (uri (string-append
> +                       "https://github.com/weidai11/cryptopp/archive/CRYPTOPP_"
> +                       (string-join (string-split version #\.) "_") ".tar.gz"))

Please download from the home page when possible:

https://cryptopp.com/cryptopp565.zip

> +                (file-name (string-append name "-" version ".tar.gz"))
> +                (sha256
> +                 (base32
> +                   "11p6mak784mx8hjasg9alwk4g3q5bsfrik9lv73a34dinca5bzbr"))))
> +      (build-system cmake-build-system)
> +      (arguments
> +        '(#:phases
> +           (modify-phases %standard-phases
> +             ;; A libcrypto++.pc file is not included, create it.

Nice!

> +             (add-after 'install 'install-pkg-config
> +               (lambda* (#:key outputs #:allow-other-keys)
> +                 (let* ((out (assoc-ref outputs "out"))
> +                        (pkgconfig-path (string-append out "/lib/pkgconfig")))
> +                   (mkdir-p pkgconfig-path)
> +                   (with-output-to-file
> +                     (string-append pkgconfig-path "/libcrypto++.pc")
> +                     (lambda _
> +                       (format #t
> +                         "prefix=~@*~a~@
> +                          libdir=${prefix}/lib~@
> +                          includedir=${prefix}/include~@
> +                          Name: libcrypto++-~1@*~a~@
> +                          Description: Class library of cryptographic schemes~@
> +                          Version: ~1@*~a~@
> +                          Libs: -L${libdir} -lcryptopp~@
> +                          Cflags: -I${includedir}~%"
> +                         out version)))))))))

Ahh.. This is why it was let-bound. You can "unquote" version here to
make it be evaluated without binding it at the top level. Note: You
probably also have to "quasiquote" the arguments with ` instead of ' (on
the line that contains #:phases).

> +      (home-page "https://cryptopp.com/")
> +      (synopsis "C++ class library of cryptographic schemes")
> +      (description "Crypto++ is a free C++ class library of cryptographic
> +schemes.")
> +      (license (list license:boost1.0 license:public-domain)))))

This needs a comment explaining what is covered by which license.

Can you send an updated patch? :)