emacs-helm / helm-system-packages

A Helm interface to the package manager of your operating system
GNU General Public License v3.0
105 stars 11 forks source link

Tramp support [Testing] #15

Closed Ambrevar closed 6 years ago

Ambrevar commented 6 years ago

This is a follow up on #12.

This makes it possible to run helm-system-packages remotely, even on systems running a different package manager.

I've tested pacman over TRAMP. Seems to work like a charm. I have made some breaking changes so I'm not sure if dpkg and portage still work.

Let me know if there is anything broken. I'll merge in a week or so.

@dvzubarev, @thierryvolpiatto?

thierryvolpiatto commented 6 years ago

Pierre Neidhardt notifications@github.com writes:

This is a follow up on #12.

This makes it possible to run helm-system-packages remotely, even on systems running a different package manager.

I've tested pacman over TRAMP. Seems to work like a charm. I have made some breaking changes so I'm not sure if dpkg and portage still work.

Let me know if there is anything broken. I'll merge in a week or so.

@dvzubarev, @thierryvolpiatto?

In toplevel form: helm-system-packages-pacman.el:246:1:Warning: Unused lexical variable ‘eshell-buffer-name’

In end of data: helm-system-packages-pacman.el:382:1:Warning: the function ‘eshell-interactive-process’ is not known to be defined.

In toplevel form: helm-system-packages-xbps.el:223:1:Warning: Unused lexical variable ‘eshell-buffer-name’

In helm-system-packages-prefix-remote: helm-system-packages.el:387:10:Warning: tramp-make-tramp-file-name called with 7 arguments, but accepts only 4-5

In helm-system-packages-files: helm-system-packages.el:436:15:Warning: ‘helm-system-packages-run’ is an obsolete function (as of 1.9.0); use ‘helm-system-packages-call’ instead.

In end of data: helm-system-packages.el:574:1:Warning: the following functions are not known to be defined: helm-system-packages-refresh, tramp-find-executable

-- Thierry

Ambrevar commented 6 years ago

Thank you Thierry.

In toplevel form: helm-system-packages-pacman.el:246:1:Warning: Unused lexical variable ‘eshell-buffer-name’

This is on purpose but I don't know how to silence the compiler.

In helm-system-packages-prefix-remote: helm-system-packages.el:387:10:Warning: tramp-make-tramp-file-name called with 7 arguments, but accepts only 4-5

Ugh! That's because I am on Emacs 26 while you've compiled on Emacs 25. Any recommendation here for backward compatibility?

In helm-system-packages-files: helm-system-packages.el:436:15:Warning: ‘helm-system-packages-run’ is an obsolete function (as of 1.9.0); use ‘helm-system-packages-call’ instead.

This is a friendly reminder that -portage has got to be updated. I don't have any Gentoo running right now.

Is it working fine beside that? (show info, (un)install, browse url, find files and show deps)

thierryvolpiatto commented 6 years ago

Pierre Neidhardt notifications@github.com writes:

Thank you Thierry.

In toplevel form: helm-system-packages-pacman.el:246:1:Warning: Unused lexical variable ‘eshell-buffer-name’

This is on purpose but I don't know how to silence the compiler.

Declare the variable.

In helm-system-packages-prefix-remote: helm-system-packages.el:387:10:Warning: tramp-make-tramp-file-name called with 7 arguments, but accepts only 4-5

Ugh! That's because I am on Emacs 26 while you've compiled on Emacs 25. Any recommendation here for backward compatibility?

See helm-ff--create-tramp-name.

In helm-system-packages-files: helm-system-packages.el:436:15:Warning: ‘helm-system-packages-run’ is an obsolete function (as of 1.9.0); use ‘helm-system-packages-call’ instead.

This is a friendly reminder that -portage has got to be updated. I don't have any Gentoo running right now.

Is it working fine beside that? (show info, (un)install, browse url, find files and show deps)

Didn't have the time to try for now, I will tell you as soon as possible.

-- Thierry

dvzubarev commented 6 years ago

Sorry for late response. I've tested on Ubuntu 16.04 and Debian 8 as remote host. The default action results in the following error.

Debugger entered--Lisp error: (wrong-type-argument stringp ((mapcar (lambda (pkg) (cons pkg (helm-system-packages-call "apt-cache" nil "show" pkg))) (helm-marked-candidates))))
  string-match("^* " ((mapcar (lambda (pkg) (cons pkg (helm-system-packages-call "apt-cache" nil "show" pkg))) (helm-marked-candidates))) 0)
  replace-regexp-in-string("^* " "- " ((mapcar (lambda (pkg) (cons pkg (helm-system-packages-call "apt-cache" nil "show" pkg))) (helm-marked-candidates))))
  helm-system-packages-show-information(((uninstalled (\, (mapcar (lambda (pkg) (cons pkg (helm-system-packages-call "apt-cache" nil "show" pkg))) (helm-marked-candidates))))))
  helm-system-packages-dpkg-info("sl")

"Show (reverse) dependencies" lead to a similar error (also there are two action "show dependencies" F6 and F8).

Installing/Uninstalling works fine on the local and remote machines. Find files works fine on the local machine, but on the remote one the current directory is prepending to the paths e.g. /ssh:user@host:/home/user//usr/bin/etc. Ideally we need to strip /home/user from the path.

Ambrevar commented 6 years ago

@dvzubarev Thanks for the report. I think I've fixed Show info, let me know if it works. I can't see what's wrong in Show dependencies. Could you post the backtrace?

As for the "Find files" issue, I know that it comes from the compatibility change with helm-ff--create-tramp-name for Emacs<26, but I'm not sure what's the ideal way to fix it.

@@ -383,15 +383,7 @@ Otherwise display in `helm-system-packages-buffer'."
   "Prefix FILE with path to remote connection.
 If local, return FILE unmodified."
   (if (tramp-tramp-file-p default-directory)
-      (let ((v (tramp-dissect-file-name default-directory)))
-        (tramp-make-tramp-file-name
-         (tramp-file-name-method v)
-         (tramp-file-name-user v)
-         (tramp-file-name-domain v)
-         (tramp-file-name-host v)
-         (tramp-file-name-port v)
-         file
-         (tramp-file-name-hop v)))
+      (helm-ff--create-tramp-name (concat default-directory file))
     file))

Before the patch, it used to work for Emacs 26 but not on Emacs<=25. With the patch, the default-directory file path is now used in the result, while we only want the default-directory protocol + user + host + etc., which we prepent to the file. @thierryvolpiatto?

dvzubarev commented 6 years ago

Show info works, thanks. Backtrace for Show dependencies:

Debugger entered--Lisp error: (wrong-type-argument stringp ("clang-5.0"))
  call-process("apt-cache" nil t nil "depends" ("clang-5.0"))
  apply(call-process "apt-cache" nil t nil ("depends" ("clang-5.0")))
  process-file("apt-cache" nil t nil "depends" ("clang-5.0"))
  apply(process-file "apt-cache" nil t nil ("depends" ("clang-5.0")))
  helm-system-packages-call("apt-cache" nil "depends" ("clang-5.0"))
  helm-system-packages-dpkg-show-dependencies("clang-5.0")
  helm-execute-selection-action-1()
  helm-execute-selection-action()
  helm-internal(((name . "dpkg") (init . helm-system-packages-init) (candidates . helm-candidates-in-buffer) (keymap keymap (29 . helm-system-packages-toggle-descriptions) (27 keymap (82 . helm-system-packages-dpkg-toggle-residuals) (68 . helm-system-packages-dpkg-toggle-dependencies) (78 . helm-system-packages-dpkg-toggle-uninstalled) (73 . helm-system-packages-dpkg-toggle-explicit)) keymap (tab . helm-execute-persistent-action) (33554440 . describe-key) (17 . ace-jump-helm-line) (normal-state keymap (26 . helm-select-action) (14 . helm-next-line) "Auxiliary keymap for Normal state" (16 . helm-previous-line)) (insert-state keymap (26 . helm-select-action) (14 . helm-next-line) "Auxiliary keymap for Insert state" (16 . helm-previous-line)) (f13 lambda nil (interactive) (helm-select-nth-action 12)) (f12 lambda nil (interactive) (helm-select-nth-action 11)) (f11 lambda nil (interactive) (helm-select-nth-action 10)) (f10 lambda nil (interactive) (helm-select-nth-action 9)) (f9 lambda nil (interactive) (helm-select-nth-action 8)) (f8 lambda nil (interactive) (helm-select-nth-action 7)) (f7 lambda nil (interactive) (helm-select-nth-action 6)) (f6 lambda nil (interactive) (helm-select-nth-action 5)) (f5 lambda nil (interactive) (helm-select-nth-action 4)) (f4 lambda nil (interactive) (helm-select-nth-action 3)) (f3 lambda nil (interactive) (helm-select-nth-action 2)) (f2 lambda nil (interactive) (helm-select-nth-action 1)) (menu-bar keymap (help-menu keymap (describe keymap (describe-mode . helm-help)))) (help keymap (109 . helm-help)) (23 . #[0 "\306\307\310\311\312\305!\313\"\314$\216\315\302!\210\316\304!\317\211\211\301=\203'

Also backtrace for Browse homepage URL:

Debugger entered--Lisp error: (wrong-type-argument stringp ("clang-5.0"))
  call-process("apt-cache" nil t nil "show" ("clang-5.0"))
  apply(call-process "apt-cache" nil t nil ("show" ("clang-5.0")))
  process-file("apt-cache" nil t nil "show" ("clang-5.0"))
  apply(process-file "apt-cache" nil t nil ("show" ("clang-5.0")))
  helm-system-packages-call("apt-cache" nil "show" ("clang-5.0"))
  helm-system-packages-dpkg-browse-url("clang-5.0")
  helm-execute-selection-action-1()
  helm-execute-selection-action()
Ambrevar commented 6 years ago

Browse-url and show-deps should be fixed. Thank you very much for testing and thanks for submitting the idea.

I'll fix the find-files issue later.