From e9b497cbb8f04490b6c835c8b5ed9b92d2765781 Mon Sep 17 00:00:00 2001 From: Maxime Devos Date: Mon, 12 Jul 2021 17:52:39 +0200 Subject: [PATCH 1/2] gnu: python-pycryptodome: Unbundle libtomcrypt. * gnu/packages/python-crypto.scm (pycryptodome)[arguments]<#:phases>{replace-libtomcrypt}: New phase. (pycryptodome)[native-inputs]{tomcrypt-source}: Add source code of 'libtomcrypt'. --- gnu/packages/python-crypto.scm | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/gnu/packages/python-crypto.scm b/gnu/packages/python-crypto.scm index 733a87cd2f..5eb990b5ba 100644 --- a/gnu/packages/python-crypto.scm +++ b/gnu/packages/python-crypto.scm @@ -24,6 +24,7 @@ ;;; Copyright © 2020 Alexandros Theodotou ;;; Copyright © 2020 Justus Winter ;;; Copyright © 2020 Vinicius Monego +;;; Copyright © 2021 Maxime Devos ;;; ;;; This file is part of GNU Guix. ;;; @@ -43,6 +44,7 @@ (define-module (gnu packages python-crypto) #:use-module (guix packages) #:use-module (guix download) + #:use-module (guix gexp) #:use-module (guix git-download) #:use-module (guix build-system python) #:use-module (gnu packages) @@ -1001,6 +1003,39 @@ protocol (Javascript Object Signing and Encryption).") (base32 "1i4m74f88qj9ci8rpyzrbk2slmsdj5ipmwdkq6qk24byalm203li")))) (build-system python-build-system) + (arguments + `(#:modules ((srfi srfi-26) + (guix build python-build-system) + (guix build utils)) + #:phases + (modify-phases %standard-phases + (add-after 'unpack 'replace-libtomcrypt + (lambda* (#:key native-inputs inputs #:allow-other-keys) + (with-directory-excursion "src/libtom" + ;; Delete bundled code. + (for-each delete-file (find-files ".")) + ;; Extract tomcrypt source code into "untarred". + (mkdir "untarred") + (invoke "tar" "xf" + (assoc-ref (or native-inputs inputs) "tomcrypt-source") + "--strip-components=1" + "-Cuntarred") + ;; Use source code from "untarred". + (rename-file "untarred/src/ciphers/des.c" "tomcrypt_des.c") + (for-each (cut install-file <> ".") + (find-files "untarred/src/headers")) + (delete-file-recursively "untarred")))) + ;; The code bundled in pycryptdome has been modified + ;; to make some variables and functions 'static'. + (add-after 'replace-libtomcrypt 'make-des-static + (lambda _ + (substitute* (find-files "src/libtom") + (("^extern const struct") "static const struct") + (("^const struct") "static const struct") + (("^int des") "static int des") + (("^void des") "static void des"))))))) + (native-inputs + `(("tomcrypt-source" ,(package-source libtomcrypt)))) (home-page "https://www.pycryptodome.org") (synopsis "Low-level cryptographic Python library") (description -- 2.32.0