From: Michael Albinus via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Sean Devlin <spd@toadstyle.org>
Cc: 69085@debbugs.gnu.org
Subject: bug#69085: 29.2; Tramp: Extend tramp-make-copy-program-file-name via tramp-methods
Date: Fri, 16 Feb 2024 15:54:53 +0100 [thread overview]
Message-ID: <87eddctq6a.fsf@gmx.de> (raw)
In-Reply-To: <70162BD1-DC02-4838-9197-37249010B192@toadstyle.org> (Sean Devlin's message of "Wed, 14 Feb 2024 19:57:13 -0500")
[-- Attachment #1: Type: text/plain, Size: 2291 bytes --]
Sean Devlin <spd@toadstyle.org> writes:
> Hi Michael,
Hi Sean,
> Suppose we want to add OOB copying to the Docker method. Docker
> has a copy command with usage like this:
>
> Usage: docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|-
> docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH
>
> We could try to add support to the Docker method for OOB copying by
> starting Emacs -Q and evaluating these forms:
>
> (add-to-list 'tramp-methods
> `(,tramp-docker-method
> (tramp-login-program ,tramp-docker-program)
> (tramp-login-args (("exec")
> ("-it")
> ("-u" "%u")
> ("%h")
> ("%l")))
> (tramp-direct-async (,tramp-default-remote-shell "-c"))
> (tramp-remote-shell ,tramp-default-remote-shell)
> (tramp-remote-shell-login ("-l"))
> (tramp-remote-shell-args ("-i" "-c"))
>
> (tramp-copy-program ,tramp-docker-program)
> (tramp-copy-args (("cp")))
> ))
Well, if "docker cp" doesn't need the user, why do we use the user at
all? Couldn't we get rid of it in this case? That is, don't use the
("-u" "%u") in tramp-login-args.
> I think what is needed is some way for the tramp-docker method to
> specify the format for remote paths in the OOB copy command, since
> tramp-make-copy-program-file-name will include the user if it is
> specified in the connection.
>
> One method might be to add a key to tramp-methods that lets you
> specify the format similar to tramp-login-args and tramp-copy-args:
I've tried another approach. In Tramp 2.7, I've added a new method
"dockercp" which doesn't use the user at all, and which adds
tramp-copy-program and tramp-copy-args.
Do you have a chance to install Tramp from its repository like
--8<---------------cut here---------------start------------->8---
# git clone https://git.savannah.gnu.org/git/tramp.git
--8<---------------cut here---------------end--------------->8---
Then pls modify tramp-container.el with the appended patch. After that,
you should be able to access your docker container like
/dockercp:CONTAINER:/path/to/file. And if you copy large files, "docker
cp" will be applied.
Best regards, Michael.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 2688 bytes --]
diff --git a/lisp/tramp-container.el b/lisp/tramp-container.el
index 1f578949..caea6b47 100644
--- a/lisp/tramp-container.el
+++ b/lisp/tramp-container.el
@@ -31,6 +31,7 @@
;; Open a file on a running Docker container:
;;
;; C-x C-f /docker:USER@CONTAINER:/path/to/file
+;; C-x C-f /dockercp:CONTAINER:/path/to/file
;;
;; or Podman:
;;
@@ -141,6 +142,11 @@ If it is nil, the default context will be used."
(defconst tramp-docker-method "docker"
"Tramp method name to use to connect to Docker containers.")
+;;;###tramp-autoload
+(defconst tramp-dockercp-method "dockercp"
+ "Tramp method name to use to connect to Docker containers.
+This is for out-of-band connections.")
+
;;;###tramp-autoload
(defconst tramp-podman-method "podman"
"Tramp method name to use to connect to Podman containers.")
@@ -183,7 +189,7 @@ BODY is the backend specific code."
(defun tramp-container--completion-function (method)
"List running containers available for connection.
METHOD is the Tramp method to be used for \"ps\", either
-`tramp-docker-method' or `tramp-podman-method'.
+`tramp-docker-method', `tramp-dockercp-method' or `tramp-podman-method'.
This function is used by `tramp-set-completion-function', please
see its function help for a description of the format."
@@ -375,6 +381,20 @@ see its function help for a description of the format."
(tramp-remote-shell-login ("-l"))
(tramp-remote-shell-args ("-i" "-c"))))
+ (add-to-list 'tramp-methods
+ `(,tramp-dockercp-method
+ (tramp-login-program ,tramp-docker-program)
+ (tramp-login-args (("exec")
+ ("-it")
+ ("%h")
+ ("%l")))
+ (tramp-direct-async (,tramp-default-remote-shell "-c"))
+ (tramp-remote-shell ,tramp-default-remote-shell)
+ (tramp-remote-shell-login ("-l"))
+ (tramp-remote-shell-args ("-i" "-c"))
+ (tramp-copy-program ,tramp-docker-program)
+ (tramp-copy-args (("cp")))))
+
(add-to-list 'tramp-methods
`(,tramp-podman-method
(tramp-login-program ,tramp-podman-program)
@@ -431,6 +451,10 @@ see its function help for a description of the format."
tramp-docker-method
`((tramp-container--completion-function ,tramp-docker-method)))
+ (tramp-set-completion-function
+ tramp-dockercp-method
+ `((tramp-container--completion-function ,tramp-dockercp-method)))
+
(tramp-set-completion-function
tramp-podman-method
`((tramp-container--completion-function ,tramp-podman-method)))
next prev parent reply other threads:[~2024-02-16 14:54 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-12 20:08 bug#69085: 29.2; Tramp: Extend tramp-make-copy-program-file-name via tramp-methods Sean Devlin
[not found] ` <handler.69085.B.17077686248331.ack@debbugs.gnu.org>
2024-02-12 20:14 ` bug#69085: Acknowledgement (29.2; Tramp: Extend tramp-make-copy-program-file-name via tramp-methods) Sean Devlin
2024-02-12 21:16 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-12 21:14 ` bug#69085: 29.2; Tramp: Extend tramp-make-copy-program-file-name via tramp-methods Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-12 21:51 ` Sean Devlin
2024-02-13 12:18 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-13 20:18 ` Sean Devlin
2024-02-14 6:59 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-15 0:57 ` Sean Devlin
2024-02-16 14:54 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-02-16 17:51 ` Sean Devlin
2024-02-17 17:57 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-19 19:19 ` Sean Devlin
2024-02-20 12:04 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-20 16:15 ` Sean Devlin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87eddctq6a.fsf@gmx.de \
--to=bug-gnu-emacs@gnu.org \
--cc=69085@debbugs.gnu.org \
--cc=michael.albinus@gmx.de \
--cc=spd@toadstyle.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).