From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Albinus via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs 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 Message-ID: <87eddctq6a.fsf@gmx.de> References: <327CF2FD-F00D-402B-B273-12066DDEB0E5@toadstyle.org> <875xytjsfw.fsf@gmx.de> <76B2D222-939F-4096-AFA5-2B0AA92A9A03@toadstyle.org> <8734twimm3.fsf@gmx.de> <87r0hfh6p1.fsf@gmx.de> <70162BD1-DC02-4838-9197-37249010B192@toadstyle.org> Reply-To: Michael Albinus Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25097"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 69085@debbugs.gnu.org To: Sean Devlin Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Feb 16 15:56:15 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1razdP-0006JF-8D for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 16 Feb 2024 15:56:15 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1razcv-0004ZZ-Ef; Fri, 16 Feb 2024 09:55:45 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1razct-0004Z5-BF for bug-gnu-emacs@gnu.org; Fri, 16 Feb 2024 09:55:43 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1razcs-0007IC-Oj for bug-gnu-emacs@gnu.org; Fri, 16 Feb 2024 09:55:42 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1razdB-0003ml-OD for bug-gnu-emacs@gnu.org; Fri, 16 Feb 2024 09:56:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Michael Albinus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 16 Feb 2024 14:56:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69085 X-GNU-PR-Package: emacs Original-Received: via spool by 69085-submit@debbugs.gnu.org id=B69085.170809532513300 (code B ref 69085); Fri, 16 Feb 2024 14:56:01 +0000 Original-Received: (at 69085) by debbugs.gnu.org; 16 Feb 2024 14:55:25 +0000 Original-Received: from localhost ([127.0.0.1]:58590 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1razcb-0003Ro-2T for submit@debbugs.gnu.org; Fri, 16 Feb 2024 09:55:25 -0500 Original-Received: from mout.gmx.net ([212.227.17.22]:38043) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1razcW-0003Lg-Nl for 69085@debbugs.gnu.org; Fri, 16 Feb 2024 09:55:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1708095294; x=1708700094; i=michael.albinus@gmx.de; bh=AHgswbEPXnGMUMOMni01w/TW4kIOiO6VIFmH+lOBFpE=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References: Date; b=Ij6emn1vB4IGKLMf+G7wsGoVN1N7bThBpn4+cv3FrHm4dmA88PdnTYMT3cI/iJH9 NDMeBXNe27t20POiUPFa9uKf0wQ50gxK0zxTvQXcDVyynP2tvhqEmQQafh7BiH52t 198K9PhLJr1ewKuvm1DeDrtUj2hFwbpy9SYmK++9WM73qCzPVQb46aXMVEK5bFkDh YaeqfZlIMXjmPPreGFvQ36xuTYIfZvGl/j0cPOrIkauqPYdL2m5Jr9eONRGGHyY+b JefR+1g4ZTGdG7rx+mEnQdooVQNRUvEpA6H76EHxqDAAvBgtloiKw6hJ/+NNT21B7 0/4MNkRp7etsGLSbrA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from gandalf.gmx.de ([185.89.39.16]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mirng-1r5DA20y6m-00exY6; Fri, 16 Feb 2024 15:54:54 +0100 In-Reply-To: <70162BD1-DC02-4838-9197-37249010B192@toadstyle.org> (Sean Devlin's message of "Wed, 14 Feb 2024 19:57:13 -0500") X-Provags-ID: V03:K1:bvBMOpIPbZ0LqwWCMyMUnYZn6jfmp08tWLUfe6qhAkE17816ip9 64pG3o56b3CbnIDltuMmw+83qhKCEfSAGbxJQW4rCBpZVK6BvYIbX69fWJPiR4QNXgVRc7X CpJzqyeEWkTysarkbBQUrriy4nWZOGWTQpLeWFvjFNWcRkzKuzMHt/Cp5uBwiQiEIRN4A+C Zja1PqWWWymzCeJIXPDng== UI-OutboundReport: notjunk:1;M01:P0:2AboKLITOJ4=;j9IMS85TwMHsfw9SHrDuhXDIKkQ bvxuzxacvOyclPzzRSSJ4yR3030k/wR7WxhqN1izgvbhkAcC8UVAQW5IqPq3OrDU3aGMdu+KU 1sw0+ZygejArEz6yOARgOwoCpPfFMfQFpIokePx0c2eQ95yMfpkFX2Oiyk+KSCMC0FHYrRj3f UXeUydAH9WvLo8Zs4JuUL1Jw8BTBgPTDj3TGX+Q0s8sSSEVYKmS9dpXO1KgdhABxAJURjyt6s mJunfeqfOBIcQdFI1j/lpUAZ1Ni32UclMvKAHpyUIzoF6EW+5VIygampGw8sNvEeScPd3vxSd XDVYdlRDnc5GGuA21tqhEf6bIabT/Ew8qt0BzlsICCHNh2EuO10AfGS9FaCL33gB9iAj6yXwR mWK5+OpGaJF7f3Tagoy57EZZSGzASTM+EQJC7G1SSRKBoTtO1zWn5ZNIQmfzK3QTMQK7ishQs /Kr4yiQs9ZqooJz0yOyd3hx8min7GBv9h1bTksW7SY8h/HEfS2q2Xh27eLWczIa1YVU+9cdQ9 /FGe0voor8bpHjgEB6sn1hQEE/thxNrtG8sXcKZJPhPVj/P79m5zaA55UacG9qfNF0aq+n4gx QLEwsrhj6EHD1P9g9WzbVK8bSGorFIrt2/ynPxMjvDU1jHcmnWGh5nFvcHCLfCfNhIq0Ov7mN DlDftuBItJnLH1vVKCvUd7cmxvHyEMXbyv49Td7VJDSfwqK9Q/6JIxNYZCV23YItWOHEhWl4D dz34nS2EYueHCTScUkmEL6kr/rPnoe5MdKzuv5bLiMkru6b2Fge8xByRb+VoGgtz2Z9CqRJw X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:280102 Archived-At: --=-=-= Content-Type: text/plain Sean Devlin 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. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment Content-Transfer-Encoding: quoted-printable diff --git a/lisp/tramp-container.el b/lisp/tramp-container.el index 1f578949..caea6b47 100644 =2D-- 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))) --=-=-=--