From: Yuri D'Elia <wavexx@thregr.org>
To: emacs-devel@gnu.org, 27822@debbugs.gnu.org,
Subject: bug#27822: [PATCH] do not auto-remove external packages (fixes #27822)
Date: Tue, 17 Jul 2018 13:16:04 +0200 [thread overview]
Message-ID: <877elugljf.fsf__15853.5521397882$1531826116$gmane$org@wavexx.thregr.org> (raw)
In-Reply-To: <87y3rc8thp.fsf@wavexx.thregr.org>
[-- Attachment #1: Type: text/plain, Size: 589 bytes --]
User-agent: mu4e 1.1.0; emacs 27.0.50
The package-autoremove machinery assumes all packages which are not
user-selected are removable (see https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27822)
However this is blatantly untrue. For example, in debian unstable, emacs
packages can be installed system-wide via apt as well (see all the elpa-*
packages).
Such packages _cannot_ and shouldn't be auto-removed.
The following patch checks whether a package has been _directly_ installed
into `package-user-dir' before marking it eligible for auto-removal.
[copyright assignment already done]
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Do-not-consider-external-packages-to-be-removable.patch --]
[-- Type: text/x-diff, Size: 1911 bytes --]
From 5a4234b3c1289960fd760256aa6399efbd04bfc3 Mon Sep 17 00:00:00 2001
From: Yuri D'Elia <wavexx@thregr.org>
Date: Tue, 17 Jul 2018 12:59:35 +0200
Subject: [PATCH] Do not consider external packages to be removable
Packages which are not directly user-installed shouldn't be autoremoved,
since they can be setup through a different path (via
`package-directory-list') where we have no authority over.
---
lisp/emacs-lisp/package.el | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 36233522..534f155c 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -1754,6 +1754,15 @@ if it is still empty."
(indirect indirect-deps)
(t (delete-dups (append direct-deps indirect-deps))))))
+(defun package--user-installed-p (pkg)
+ "Check if the package is a user-installed package.
+PKG is a package name.
+Checks whether the package was installed into `package-user-dir' where
+we assume to have control over."
+ (let* ((pkg-desc (cadr (assq pkg package-alist)))
+ (dir (package-desc-dir pkg-desc)))
+ (file-in-directory-p dir package-user-dir)))
+
(defun package--removable-packages ()
"Return a list of names of packages no longer needed.
These are packages which are neither contained in
@@ -1763,7 +1772,9 @@ These are packages which are neither contained in
;; `p' and its dependencies are needed.
append (cons p (package--get-deps p)))))
(cl-loop for p in (mapcar #'car package-alist)
- unless (memq p needed)
+ unless (or (memq p needed)
+ ;; do not auto-remove external packages
+ (not (package--user-installed-p p)))
collect p)))
(defun package--used-elsewhere-p (pkg-desc &optional pkg-list all)
--
2.18.0
prev parent reply other threads:[~2018-07-17 11:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-25 14:46 bug#27822: 26.0.50; package-autoremove and 'package-directory-list Yuri D'Elia
2018-07-17 11:16 ` [PATCH] do not auto-remove external packages (fixes #27822) Yuri D'Elia
2018-07-17 12:40 ` bug#27822: " Stefan Monnier
2018-07-17 12:50 ` Yuri D'Elia
2018-08-07 11:12 ` package.el fix (was Re: [PATCH] do not auto-remove external packages (fixes #27822)) Yuri D'Elia
2018-08-09 1:19 ` bug#27822: [PATCH] do not auto-remove external packages (fixes #27822) Noam Postavsky
2018-08-09 11:16 ` Yuri D'Elia
2018-08-09 15:24 ` Eli Zaretskii
2018-08-12 1:08 ` Noam Postavsky
2018-07-17 11:16 ` Yuri D'Elia [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='877elugljf.fsf__15853.5521397882$1531826116$gmane$org@wavexx.thregr.org' \
--to=wavexx@thregr.org \
--cc=27822@debbugs.gnu.org \
--cc=emacs-devel@gnu.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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.