aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2017-06-25 19:49:53 +0200
committerMichael Albinus2017-06-25 19:49:53 +0200
commit68e03d1eb40e8766b9bb51d9519188d8a21db0c3 (patch)
tree875fce932b183fac02ed32f44d06f1b3e5626436
parent51e8e77d0f21356ebb1651bddc6f5f9291269f98 (diff)
downloademacs-68e03d1eb40e8766b9bb51d9519188d8a21db0c3.tar.gz
emacs-68e03d1eb40e8766b9bb51d9519188d8a21db0c3.zip
Fix Android 6/7 problems in Tramp
* lisp/net/tramp-adb.el (tramp-adb-ls-toolbox-regexp): Fix link part. (tramp-adb-handle-directory-files-and-attributes) (tramp-adb-handle-file-name-all-completions): Insert "." and ".." only when needed. (tramp-adb-get-ls-command): Force one column output for toybox.
-rw-r--r--lisp/net/tramp-adb.el49
1 files changed, 28 insertions, 21 deletions
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index 23aa90186a6..346979000f5 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -72,7 +72,7 @@ It is used for TCP/IP devices."
72(defconst tramp-adb-ls-toolbox-regexp 72(defconst tramp-adb-ls-toolbox-regexp
73 (concat 73 (concat
74 "^[[:space:]]*\\([-[:alpha:]]+\\)" ; \1 permissions 74 "^[[:space:]]*\\([-[:alpha:]]+\\)" ; \1 permissions
75 "\\(?:[[:space:]][[:digit:]]+\\)?" ; links (Android 7/ToolBox) 75 "\\(?:[[:space:]]+[[:digit:]]+\\)?" ; links (Android 7/toybox)
76 "[[:space:]]*\\([^[:space:]]+\\)" ; \2 username 76 "[[:space:]]*\\([^[:space:]]+\\)" ; \2 username
77 "[[:space:]]+\\([^[:space:]]+\\)" ; \3 group 77 "[[:space:]]+\\([^[:space:]]+\\)" ; \3 group
78 "[[:space:]]+\\([[:digit:]]+\\)" ; \4 size 78 "[[:space:]]+\\([[:digit:]]+\\)" ; \4 size
@@ -411,15 +411,17 @@ pass to the OPERATION."
411 (tramp-adb-get-ls-command v) 411 (tramp-adb-get-ls-command v)
412 (tramp-shell-quote-argument localname))) 412 (tramp-shell-quote-argument localname)))
413 ;; We insert also filename/. and filename/.., because "ls" doesn't. 413 ;; We insert also filename/. and filename/.., because "ls" doesn't.
414 (narrow-to-region (point) (point)) 414 ;; Looks like it does include them in toybox, since Android 6.
415 (tramp-adb-send-command 415 (unless (re-search-backward "\\.$" nil t)
416 v (format "%s -d -a -l %s %s" 416 (narrow-to-region (point-max) (point-max))
417 (tramp-adb-get-ls-command v) 417 (tramp-adb-send-command
418 (tramp-shell-quote-argument 418 v (format "%s -d -a -l %s %s"
419 (concat (file-name-as-directory localname) ".")) 419 (tramp-adb-get-ls-command v)
420 (tramp-shell-quote-argument 420 (tramp-shell-quote-argument
421 (concat (file-name-as-directory localname) "..")))) 421 (concat (file-name-as-directory localname) "."))
422 (widen)) 422 (tramp-shell-quote-argument
423 (concat (file-name-as-directory localname) ".."))))
424 (widen)))
423 (tramp-adb-sh-fix-ls-output) 425 (tramp-adb-sh-fix-ls-output)
424 (let ((result (tramp-do-parse-file-attributes-with-ls 426 (let ((result (tramp-do-parse-file-attributes-with-ls
425 v (or id-format 'integer)))) 427 v (or id-format 'integer))))
@@ -443,11 +445,12 @@ pass to the OPERATION."
443 (with-tramp-connection-property vec "ls" 445 (with-tramp-connection-property vec "ls"
444 (tramp-message vec 5 "Finding a suitable `ls' command") 446 (tramp-message vec 5 "Finding a suitable `ls' command")
445 (cond 447 (cond
446 ;; Can't disable coloring explicitly for toybox ls command 448 ;; Can't disable coloring explicitly for toybox ls command. We
447 ((tramp-adb-send-command-and-check vec "toybox") "ls") 449 ;; must force "ls" to print just one column.
450 ((tramp-adb-send-command-and-check vec "toybox") "env COLUMNS=1 ls")
448 ;; On CyanogenMod based system BusyBox is used and "ls" output 451 ;; On CyanogenMod based system BusyBox is used and "ls" output
449 ;; coloring is enabled by default. So we try to disable it 452 ;; coloring is enabled by default. So we try to disable it when
450 ;; when possible. 453 ;; possible.
451 ((tramp-adb-send-command-and-check vec "ls --color=never -al /dev/null") 454 ((tramp-adb-send-command-and-check vec "ls --color=never -al /dev/null")
452 "ls --color=never") 455 "ls --color=never")
453 (t "ls")))) 456 (t "ls"))))
@@ -569,13 +572,17 @@ Emacs dired can't find files."
569 (file-name-as-directory f) 572 (file-name-as-directory f)
570 f)) 573 f))
571 (with-current-buffer (tramp-get-buffer v) 574 (with-current-buffer (tramp-get-buffer v)
572 (append 575 (delete-dups
573 '("." "..") 576 (append
574 (delq 577 ;; In older Android versions, "." and ".." are not
575 nil 578 ;; included. In newer versions (toybox, since Android
576 (mapcar 579 ;; 6) they are. We fix this by `delete-dups'.
577 (lambda (l) (and (not (string-match "^[[:space:]]*$" l)) l)) 580 '("." "..")
578 (split-string (buffer-string) "\n"))))))))))) 581 (delq
582 nil
583 (mapcar
584 (lambda (l) (and (not (string-match "^[[:space:]]*$" l)) l))
585 (split-string (buffer-string) "\n"))))))))))))
579 586
580(defun tramp-adb-handle-file-local-copy (filename) 587(defun tramp-adb-handle-file-local-copy (filename)
581 "Like `file-local-copy' for Tramp files." 588 "Like `file-local-copy' for Tramp files."