mirror of
git://git.savannah.gnu.org/guix.git
synced 2023-12-14 03:33:07 +01:00
gnu: python-trezor-agent: Fix key generation with trezor-gpg init
* gnu/packages/finance.scm (trezor-agent): Add comment on why the undoing of the wrapping is done, and also delete the irrelevant sideffect of the now undone wrapping. (python-trezor-agent): Add a patch that changes the python code to handle the argv[0] changed by the wrapping. * gnu/packages/patches/trezor-agent-fix-argv0.patch: New file. * gnu/local.mk (dist_patch_DATA): Reference patch. Signed-off-by: Nicolas Goaziou <mail@nicolasgoaziou.fr>
This commit is contained in:
parent
032d1c03b6
commit
25cb5bad5e
3 changed files with 39 additions and 2 deletions
|
@ -1680,6 +1680,7 @@ dist_patch_DATA = \
|
|||
%D%/packages/patches/python-pytorch-system-libraries.patch \
|
||||
%D%/packages/patches/python-robotframework-source-date-epoch.patch \
|
||||
%D%/packages/patches/python-seaborn-kde-test.patch \
|
||||
%D%/packages/patches/python-trezor-agent-fix-argv0.patch \
|
||||
%D%/packages/patches/python2-subprocess32-disable-input-test.patch \
|
||||
%D%/packages/patches/python-unittest2-python3-compat.patch \
|
||||
%D%/packages/patches/python-unittest2-remove-argparse.patch \
|
||||
|
|
|
@ -844,7 +844,8 @@ the Monero GUI client.")
|
|||
(commit (string-append "v" version))))
|
||||
(file-name (git-file-name name version))
|
||||
(sha256
|
||||
(base32 "0q99vbfd3h85s8rnjipnmldixabqmmlk5w9karv6f0rhyi54f4zv"))))
|
||||
(base32 "0q99vbfd3h85s8rnjipnmldixabqmmlk5w9karv6f0rhyi54f4zv"))
|
||||
(patches (search-patches "python-trezor-agent-fix-argv0.patch"))))
|
||||
(build-system python-build-system)
|
||||
(arguments
|
||||
`(#:phases
|
||||
|
@ -1091,7 +1092,15 @@ the KeepKey Hardware Wallet.")
|
|||
(add-after 'wrap 'fixup-agent-py
|
||||
(lambda* (#:key inputs outputs #:allow-other-keys)
|
||||
(let* ((out (assoc-ref outputs "out")))
|
||||
;; overwrite the wrapper with the real thing.
|
||||
;; The wrap phase also wraps trezor_agent.py (besides the
|
||||
;; public facing executable called trezor-agent). We need to
|
||||
;; undo that wrapping. The reason this is needed is that the
|
||||
;; python easy install generates a toplevel script (?) that
|
||||
;; messes with argv[0] and then re-opens the python
|
||||
;; module. This fails when the wrapped file is actually a shell
|
||||
;; script, not a python file.
|
||||
(delete-file (string-append out "/bin/.trezor_agent.py-real"))
|
||||
;; Overwrite the wrapped one with the real thing.
|
||||
(install-file "./trezor_agent.py"
|
||||
(string-append out "/bin"))
|
||||
#t))))))
|
||||
|
|
27
gnu/packages/patches/python-trezor-agent-fix-argv0.patch
Normal file
27
gnu/packages/patches/python-trezor-agent-fix-argv0.patch
Normal file
|
@ -0,0 +1,27 @@
|
|||
diff --git a/libagent/gpg/__init__.py b/libagent/gpg/__init__.py
|
||||
index 3711bc8..67085de 100644
|
||||
--- a/libagent/gpg/__init__.py
|
||||
+++ b/libagent/gpg/__init__.py
|
||||
@@ -122,15 +122,19 @@ def run_init(device_type, args):
|
||||
verify_gpg_version()
|
||||
|
||||
# Prepare new GPG home directory for hardware-based identity
|
||||
- device_name = os.path.basename(sys.argv[0]).rsplit('-', 1)[0]
|
||||
- log.info('device name: %s', device_name)
|
||||
+ exe_name = os.path.basename(sys.argv[0])
|
||||
+ # drop the Guix wrapper's dot prefix from the name
|
||||
+ if exe_name[0] == '.' and exe_name.endswith('-real'):
|
||||
+ exe_name = exe_name[1:-5:]
|
||||
+ device_name = exe_name.rsplit('-', 1)[0]
|
||||
+ log.info('exe name: %s, device name: %s', exe_name, device_name)
|
||||
homedir = args.homedir
|
||||
if not homedir:
|
||||
homedir = os.path.expanduser('~/.gnupg/{}'.format(device_name))
|
||||
|
||||
log.info('GPG home directory: %s', homedir)
|
||||
|
||||
- if os.path.exists(homedir):
|
||||
+ if os.path.exists(homedir) and not args.subkey:
|
||||
log.error('GPG home directory %s exists, '
|
||||
'remove it manually if required', homedir)
|
||||
sys.exit(1)
|
Loading…
Reference in a new issue