Subject: [bug#65037] [PATCH 6/7] gnu: trezor-agent: Fix build, update versioning, and the git tag.

From: Attila Lendvai <[email-masked]>
Date: Thu, 3 Aug 2023 15:11:34 +0200

Fix it by adding missing native-inputs, so that the tests finish (and thus the
build succeeds).

Also clarify the versioning of the package in a comment, so that later updates
will not pick the wrong version number.

* gnu/packages/finance.scm (trezor-agent): Update version from 0.14.4 to
0.12.0 (!). Move the git tag from v0.14.4 to v0.14.6.
---
 gnu/packages/finance.scm | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/gnu/packages/finance.scm b/gnu/packages/finance.scm
index 0656d72e64..807241ab8c 100644
--- a/gnu/packages/finance.scm
+++ b/gnu/packages/finance.scm
@@ -1212,7 +1212,9 @@ (define-public ledger-agent
 (define-public trezor-agent
   (package
     (name "trezor-agent")
-    (version "0.14.4")
+    ;; The version of trezor-agent can be found in ./agents/trezor/setup.py.
+    ;; See next comment for details.
+    (version "0.12.0")
     (source
      (origin
        (method git-fetch)
@@ -1221,12 +1223,16 @@ (define-public trezor-agent
              ;; The version mismatch is not a mistake.  Multiple Python
              ;; apps/packages are in the same git repo, and they have
              ;; different versions.  The git tag seems to track libagent,
-             ;; i.e. python-trezor-agent in the Guix namespace.  See
-             ;; e.g. ./agents/trezor/setup.py.
-             (commit "v0.14.4")))
+             ;; which is python-trezor-agent in the Guix namespace.  See
+             ;; ./agents/trezor/setup.py for the version of trezor-agent.
+             ;;
+             ;; Here we pick the latest tag in the git repo that bumps the
+             ;; version of trezor-agent in ./agents/trezor/setup.py to the
+             ;; version we specified above.
+             (commit "v0.14.6")))
        (file-name (git-file-name name version))
        (sha256
-        (base32 "1ksv494xpga27ifrjyn1bkqaya5h769lqb9rx1ng0n4kvmnrqr3l"))
+        (base32 "0pjlsig2gd4m10xkfpa01fr9jswqn0s3qa7l7wgfv5714x33dimm"))
        (modules
         '((guix build utils)
           (ice-9 ftw)
@@ -1245,7 +1251,10 @@ (define-public trezor-agent
                                     (string-append "./" file-name)))
                      (scandir "./agents/trezor/"
                               (negate (cut member <> '("." "..") string=))))
-           (delete-file-recursively "./agents")))))
+           (delete-file-recursively "./agents")
+           ;; Without deleting libagent setuptools complains as follows:
+           ;; "error: Multiple top-level packages discovered in a flat-layout: ['contrib', 'libagent']."
+           (delete-file-recursively "./libagent")))))
     (arguments
      `(#:phases
        (modify-phases %standard-phases
@@ -1274,8 +1283,10 @@ (define-public trezor-agent
     (build-system python-build-system)
     (inputs
      (list python-trezor python-trezor-agent))
-    (native-inputs
-     (list python-attrs))
+    (native-inputs ; Only needed for running the tests
+     (list python-attrs
+           python-bech32
+           python-simple-rlp))
     (home-page "https://github.com/romanz/trezor-agent")
     (synopsis "Using Trezor as hardware SSH/GPG agent")
     (description "This package allows using Trezor as a hardware SSH/GPG
-- 
2.40.1