* doc/misc/tramp.texi (Android shell setup): Rework.
(Frequently Asked Questions): Improve recommendations for speeding up.
* doc/misc/trampver.texi:
* lisp/net/trampver.el: Change version to "2.5.4-pre".
* lisp/net/tramp-adb.el (tramp-methods): Use "%d".
(tramp-adb-handle-directory-files-and-attributes): Fix "." and
".." in listing.
(tramp-adb-handle-file-attributes)
(tramp-adb-handle-directory-files-and-attributes)
(tramp-adb-handle-file-name-all-completions): Pipe "ls" output
through "cat", in order to avoid quoting special characters.
(tramp-adb-maybe-open-connection): Compute args from `tramp-login-args'.
* lisp/net/tramp-compat.el (tramp-compat-replace-regexp-in-region):
New defalias.
* lisp/net/tramp-gvfs.el (tramp-gvfs-do-copy-or-rename-file):
Adapt check for proper remote command.
* lisp/net/tramp.el (tramp-methods): Adapt docstring.
(tramp-handle-make-process): Check for adb device if indicated.
(tramp-get-remote-tmpdir): Cache result in temporary connection
property.
* test/lisp/net/tramp-tests.el (tramp-test17-insert-directory)
(tramp-test22-file-times, tramp--test-utf8): Adapt tests.
(tramp--test-shell-file-name): Do not depend on `tramp--test-adb-p'.
(tramp-test46-unload): Ignore autoload functions in
`tramp-file-name' structure tests, since `tramp-file-name-handler'
is also autoloaded in Emacs 29.
(@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
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
@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
responsiveness slows down. Some suggestions within the scope of
@value{tramp}'s settings include:
+@itemize @minus
+@item
Use an external method, such as @option{scp}, which are faster than
-internal methods.
+internal methods for large files.
+@item
Keep the file @code{tramp-persistency-file-name}, which is where
@value{tramp} caches remote information about hosts and files. Caching
is enabled by default. Don't disable it.
That cache cleanup will be necessary if the remote directories or
files are updated independent of @value{tramp}.
+@item
Disable version control to avoid delays:
@lisp
(setq vc-handled-backends '(SVN Git))
@end lisp
+@item
+@vindex remote-file-name-inhibit-locks
+Disable file locks. Set @code{remote-file-name-inhibit-locks} to
+@code{t} if you know that different Emacs sessions are not modifying
+the same remote file.
+
+@item
Disable excessive traces. Set @code{tramp-verbose} to 3 or lower,
default being 3. Increase trace levels temporarily when hunting for
bugs.
+@end itemize
@item
@c In the Tramp GIT, the version numbers are auto-frobbed from
@c tramp.el, and the bug report address is auto-frobbed from
@c configure.ac.
-@set trampver 2.5.3.28.2
+@set trampver 2.5.4-pre
@set trampurl https://www.gnu.org/software/tramp/
@set tramp-bug-report-address tramp-devel@@gnu.org
@set emacsver 25.1
(add-to-list 'tramp-methods
`(,tramp-adb-method
(tramp-login-program ,tramp-adb-program)
- (tramp-login-args (("shell")))
+ (tramp-login-args (("-s" "%d") ("shell")))
(tramp-direct-async t)
(tramp-tmpdir "/data/local/tmp")
(tramp-default-port 5555)))
v localname (format "file-attributes-%s" id-format)
(and
(tramp-adb-send-command-and-check
- v (format "%s -d -l %s"
+ v (format "%s -d -l %s | cat"
(tramp-adb-get-ls-command v)
(tramp-shell-quote-argument localname)))
(with-current-buffer (tramp-get-buffer v)
full match id-format nosort count)
(with-current-buffer (tramp-get-buffer v)
(when (tramp-adb-send-command-and-check
- v (format "%s -a -l %s"
+ v (format "%s -a -l %s | cat"
(tramp-adb-get-ls-command v)
(tramp-shell-quote-argument localname)))
- ;; We insert also filename/. and filename/.., because "ls" doesn't.
- ;; Looks like it does include them in toybox, since Android 6.
+ ;; We insert also filename/. and filename/.., because
+ ;; "ls" doesn't on some file systems, like "sdcard".
(unless (re-search-backward "\\.$" nil t)
(narrow-to-region (point-max) (point-max))
(tramp-adb-send-command
- v (format "%s -d -a -l %s %s"
+ v (format "%s -d -a -l %s %s | cat"
(tramp-adb-get-ls-command v)
(tramp-shell-quote-argument
(tramp-compat-file-name-concat localname "."))
(tramp-shell-quote-argument
(tramp-compat-file-name-concat localname ".."))))
+ (tramp-compat-replace-regexp-in-region
+ (regexp-quote
+ (tramp-compat-file-name-unquote
+ (file-name-as-directory localname)))
+ "" (point-min))
(widen)))
(tramp-adb-sh-fix-ls-output)
(let ((result (tramp-do-parse-file-attributes-with-ls
(with-parsed-tramp-file-name (expand-file-name directory) nil
(with-tramp-file-property v localname "file-name-all-completions"
(tramp-adb-send-command
- v (format "%s -a %s"
+ v (format "%s -a %s | cat"
(tramp-adb-get-ls-command v)
(tramp-shell-quote-argument localname)))
(mapcar
(with-current-buffer (tramp-get-buffer v)
(delete-dups
(append
- ;; In older Android versions, "." and ".." are not
- ;; included. In newer versions (toybox, since Android 6)
- ;; they are. We fix this by `delete-dups'.
+ ;; On some file systems like "sdcard", "." and ".." are
+ ;; not included. We fix this by `delete-dups'.
'("." "..")
(delq
nil
(with-tramp-progress-reporter vec 3 "Opening adb shell connection"
(let* ((coding-system-for-read 'utf-8-dos) ; Is this correct?
(process-connection-type tramp-process-connection-type)
- (args (if (> (length host) 0)
- (list "-s" device "shell")
- (list "shell")))
+ (args (tramp-expand-args
+ vec 'tramp-login-args ?d (or device "")))
(p (let ((default-directory
tramp-compat-temporary-file-directory))
(apply #'start-process (tramp-get-connection-name vec) buf
(car components))
(cdr components)))))))
+;; Function `replace-regexp-in-region' is new in Emacs 28.1.
+(defalias 'tramp-compat-replace-regexp-in-region
+ (if (fboundp 'replace-regexp-in-region)
+ #'replace-regexp-in-region
+ (lambda (regexp replacement &optional start end)
+ (if start
+ (when (< start (point-min))
+ (error "Start before start of buffer"))
+ (setq start (point)))
+ (if end
+ (when (> end (point-max))
+ (error "End after end of buffer"))
+ (setq end (point-max)))
+ (save-excursion
+ (let ((matches 0)
+ (case-fold-search nil))
+ (goto-char start)
+ (while (re-search-forward regexp end t)
+ (replace-match replacement t)
+ (setq matches (1+ matches)))
+ (and (not (zerop matches))
+ matches))))))
+
(dolist (elt (all-completions "tramp-compat-" obarray 'functionp))
(put (intern elt) 'tramp-suppress-trace t))
;; code in case of direct copy/move. Apply
;; sanity checks.
(or (not equal-remote)
- (tramp-gvfs-send-command
- v "gvfs-info" (tramp-gvfs-url-file-name newname))
- (eq op 'copy)
- (not (tramp-gvfs-send-command
- v "gvfs-info"
- (tramp-gvfs-url-file-name filename)))))
+ (and
+ (tramp-gvfs-send-command
+ v "gvfs-info"
+ (tramp-gvfs-url-file-name newname))
+ (or (eq op 'copy)
+ (not (tramp-gvfs-send-command
+ v "gvfs-info"
+ (tramp-gvfs-url-file-name filename)))))))
(if (or (not equal-remote)
(and equal-remote
argument if it is supported.
- \"%y\" is replaced by the `tramp-scp-force-scp-protocol'
argument if it is supported.
+ - \"%d\" is replaced by the device detected by `tramp-adb-get-device'.
The existence of `tramp-login-args', combined with the
absence of `tramp-copy-args', is an indication that the
;; is different between tramp-sh.el, and tramp-adb.el or
;; tramp-sshfs.el.
(let* ((sh-file-name-handler-p (tramp-sh-file-name-handler-p v))
+ (adb-file-name-handler-p
+ (tramp-adb-file-name-p (tramp-make-tramp-file-name v)))
(login-program
(tramp-get-method-parameter v 'tramp-login-program))
;; We don't create the temporary file. In fact, it
(when sh-file-name-handler-p
(tramp-compat-funcall
'tramp-ssh-controlmaster-options v)))
+ (device
+ (when adb-file-name-handler-p
+ (tramp-compat-funcall
+ 'tramp-adb-get-device v)))
login-args p)
;; Replace `login-args' place holders. Split
v 'tramp-login-args
?h (or host "") ?u (or user "") ?p (or port "")
?c (format-spec (or options "") (format-spec-make ?t tmpfile))
- ?l ""))))
+ ?d (or device "") ?l ""))))
p (make-process
:name name :buffer buffer
:command (append `(,login-program) login-args command)
(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"))))
;; Maintainer: Michael Albinus <michael.albinus@gmx.de>
;; Keywords: comm, processes
;; Package: tramp
-;; Version: 2.5.3.28.2
+;; Version: 2.5.4-pre
;; Package-Requires: ((emacs "25.1"))
;; Package-Type: multi
;; URL: https://www.gnu.org/software/tramp/
;; ./configure" to change them.
;;;###tramp-autoload
-(defconst tramp-version "2.5.3.28.2"
+(defconst tramp-version "2.5.4-pre"
"This version of Tramp.")
;;;###tramp-autoload
;; Check for Emacs version.
(let ((x (if (not (string-lessp emacs-version "25.1"))
"ok"
- (format "Tramp 2.5.3.28.2 is not fit for %s"
+ (format "Tramp 2.5.4-pre is not fit for %s"
(replace-regexp-in-string "\n" "" (emacs-version))))))
(unless (string-equal "ok" x) (error "%s" x)))
(goto-char (point-min))
(should
(looking-at-p (format "^.+ %s/$" (regexp-quote tmp-name1)))))
- (with-temp-buffer
- (insert-directory
- (file-name-as-directory tmp-name1) "-al" nil 'full-directory-p)
- (goto-char (point-min))
- (should
- (looking-at-p
- (concat
- ;; There might be a summary line.
- "\\(total.+[[:digit:]]+ ?[kKMGTPEZY]?i?B?\n\\)?"
- ;; We don't know in which order ".", ".." and "foo" appear.
- (format
- "\\(.+ %s\\( ->.+\\)?\n\\)\\{%d\\}"
- (regexp-opt (directory-files tmp-name1))
- (length (directory-files tmp-name1)))))))
+ (let ((directory-files (directory-files tmp-name1)))
+ (with-temp-buffer
+ (insert-directory
+ (file-name-as-directory tmp-name1) "-al" nil 'full-directory-p)
+ (goto-char (point-min))
+ (should
+ (looking-at-p
+ (concat
+ ;; There might be a summary line.
+ "\\(total.+[[:digit:]]+ ?[kKMGTPEZY]?i?B?\n\\)?"
+ ;; We don't know in which order ".", ".." and "foo" appear.
+ (format
+ "\\(.+ %s\\( ->.+\\)?\n\\)\\{%d\\}"
+ (regexp-opt directory-files)
+ (length directory-files)))))))
;; Check error cases.
(when (and (tramp--test-supports-set-file-modes-p)
(file-attributes tmp-name1))))
;; Skip the test, if the remote handler is not able to set
;; the correct time.
- (skip-unless (set-file-times tmp-name1 (seconds-to-time 1)))
+ ;; Some remote machines cannot resolve seconds. So we use a minute.
+ (skip-unless (set-file-times tmp-name1 (seconds-to-time 60)))
;; Dumb remote shells without perl(1) or stat(1) are not
;; able to return the date correctly. They say "don't know".
(unless (tramp-compat-time-equal-p
(tramp-compat-time-equal-p
(tramp-compat-file-attribute-modification-time
(file-attributes tmp-name1))
- (seconds-to-time 1)))
+ (seconds-to-time 60)))
(write-region "bla" nil tmp-name2)
(should (file-exists-p tmp-name2))
(should (file-newer-than-file-p tmp-name2 tmp-name1))
;; regular files, there shouldn't be a difference.
(when (tramp--test-emacs28-p)
(with-no-warnings
- (set-file-times tmp-name1 (seconds-to-time 1) 'nofollow)
+ (set-file-times tmp-name1 (seconds-to-time 60) 'nofollow)
(should
(tramp-compat-time-equal-p
(tramp-compat-file-attribute-modification-time
(file-attributes tmp-name1))
- (seconds-to-time 1)))))))
+ (seconds-to-time 60)))))))
;; Cleanup.
(ignore-errors
(defun tramp--test-shell-file-name ()
"Return default remote shell."
- (if (tramp--test-adb-p) "/system/bin/sh" "/bin/sh"))
+ (if (file-exists-p
+ (concat
+ (file-remote-p tramp-test-temporary-file-directory) "/system/bin/sh"))
+ "/system/bin/sh" "/bin/sh"))
(ert-deftest tramp-test28-process-file ()
"Check `process-file'."
"银河系漫游指南系列"
"Автостопом по гала́ктике"
;; Use codepoints without a name. See Bug#31272.
- "\99\9b\9abung"
+ ;; Works on some Android systems only.
+ (unless (tramp--test-adb-p) "\99\9b\9abung")
;; Use codepoints from Supplementary Multilingual Plane (U+10000
;; to U+1FFFF).
"🌈🍒👋")
(should-not (cl--find-class 'tramp-file-name))
(mapatoms
(lambda (x)
- (and (functionp x)
+ (and (functionp x) (null (autoloadp (symbol-function x)))
(string-match-p "tramp-file-name" (symbol-name x))
(ert-fail (format "Structure function `%s' still exists" x)))))