emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 9ea40b3ddf: Fix tmpdir handling in Tramp for Android sshd


From: Michael Albinus
Subject: master 9ea40b3ddf: Fix tmpdir handling in Tramp for Android sshd
Date: Mon, 15 Aug 2022 13:35:56 -0400 (EDT)

branch: master
commit 9ea40b3ddfba1104d02ff61e3d20482287d3caca
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>

    Fix tmpdir handling in Tramp for Android sshd
    
    * doc/misc/tramp.texi (Android shell setup): Rework.
    
    * lisp/net/tramp.el (tramp-get-remote-tmpdir): Cache result in
    temporary connection property.
---
 doc/misc/tramp.texi | 39 ++++++++++++++++++++++++++++++++-------
 lisp/net/tramp.el   |  2 +-
 2 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index 924aa66d44..96ffb5c880 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -2975,14 +2975,31 @@ where @samp{192.168.0.26} is the Android device's IP 
address.
 (@pxref{Predefined connection information}).
 
 @item
-@value{tramp} requires preserving @env{PATH} environment variable from
-user settings.  Android devices prefer @file{/system/xbin} path over
-@file{/system/bin}.  Both of these are set as follows:
+On the Android device the directory names are prefixed with an
+application specific prefix, which is
+@file{/data/data/com.termux/files/usr/bin} instead of @file{/usr/bin}
+in the @code{Termux} case.  You must adapt the file names in
+@code{tramp-remote-path}, for example via connection-local
+@ifinfo
+settings (@pxref{Connection Variables, , , emacs}):
+@end ifinfo
+@ifnotinfo
+settings:
+@end ifnotinfo
 
 @lisp
 @group
-(add-to-list 'tramp-remote-path 'tramp-own-remote-path)
-(add-to-list 'tramp-remote-path "/system/xbin")
+(connection-local-set-profile-variables
+ 'tramp-connection-local-termux-profile
+ `((tramp-remote-path
+    . ,(mapcar
+       (lambda (x)
+         (if (stringp x) (concat "/data/data/com.termux/files" x) x))
+       (copy-tree tramp-remote-path)))))
+
+(connection-local-set-profiles
+ '(:application tramp :machine "192.168.0.26")
+ 'tramp-connection-local-termux-profile)
 @end group
 @end lisp
 
@@ -2991,7 +3008,9 @@ When the Android device is not @samp{rooted}, specify a 
writable
 directory for temporary files:
 
 @lisp
-(add-to-list 'tramp-remote-process-environment "TMPDIR=$HOME")
+(add-to-list 'tramp-connection-properties
+             (list (regexp-quote "192.168.0.26")
+                  "tmpdir" "/data/data/com.termux/files/home/tmp"))
 @end lisp
 
 @item
@@ -3019,11 +3038,17 @@ the previous example, fix the connection properties as 
follows:
 @group
 (add-to-list 'tramp-connection-properties
              (list (regexp-quote "android") "remote-shell" "sh"))
+(add-to-list 'tramp-connection-properties
+             (list (regexp-quote "android")
+                  "tmpdir" "/data/data/com.termux/files/home/tmp"))
+(connection-local-set-profiles
+ '(:application tramp :machine "android")
+ 'tramp-connection-local-termux-profile)
 @end group
 @end lisp
 
 @noindent
-Open a remote connection with a more concise command @kbd{C-x C-f
+Open a remote connection with the more concise command @kbd{C-x C-f
 @trampfn{ssh,android,} @key{RET}}.
 @end itemize
 
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 4cc4ee0722..5ffc4f1b88 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -6011,7 +6011,7 @@ This handles also chrooted environments, which are not 
regarded as local."
 
 (defun tramp-get-remote-tmpdir (vec)
   "Return directory for temporary files on the remote host identified by VEC."
-  (with-tramp-connection-property vec "tmpdir"
+  (with-tramp-connection-property (tramp-get-process vec) "remote-tmpdir"
     (let ((dir
           (tramp-make-tramp-file-name
            vec (or (tramp-get-method-parameter vec 'tramp-tmpdir) "/tmp"))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]