From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Yuri D'Elia Newsgroups: gmane.emacs.bugs Subject: bug#27822: [PATCH] do not auto-remove external packages (fixes #27822) Date: Tue, 17 Jul 2018 13:16:04 +0200 Message-ID: <877elugljf.fsf__15853.5521397882$1531826116$gmane$org@wavexx.thregr.org> References: <87y3rc8thp.fsf@wavexx.thregr.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1531826116 7705 195.159.176.226 (17 Jul 2018 11:15:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 17 Jul 2018 11:15:16 +0000 (UTC) To: emacs-devel@gnu.org, 27822@debbugs.gnu.org, Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jul 17 13:15:12 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ffNwm-0001w7-17 for geb-bug-gnu-emacs@m.gmane.org; Tue, 17 Jul 2018 13:15:12 +0200 Original-Received: from localhost ([::1]:58292 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffNyt-0004wO-1p for geb-bug-gnu-emacs@m.gmane.org; Tue, 17 Jul 2018 07:17:23 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41797) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffNye-0004ur-Me for bug-gnu-emacs@gnu.org; Tue, 17 Jul 2018 07:17:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffNya-0005q9-MK for bug-gnu-emacs@gnu.org; Tue, 17 Jul 2018 07:17:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:39471) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ffNya-0005pu-HS for bug-gnu-emacs@gnu.org; Tue, 17 Jul 2018 07:17:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ffNyY-00057X-CI for bug-gnu-emacs@gnu.org; Tue, 17 Jul 2018 07:17:04 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <87y3rc8thp.fsf@wavexx.thregr.org> Resent-From: Yuri D'Elia Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 17 Jul 2018 11:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27822 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 27822-submit@debbugs.gnu.org id=B27822.153182617017298 (code B ref 27822); Tue, 17 Jul 2018 11:17:02 +0000 Original-Received: (at 27822) by debbugs.gnu.org; 17 Jul 2018 11:16:10 +0000 Original-Received: from localhost ([127.0.0.1]:44489 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ffNxh-0004UW-To for submit@debbugs.gnu.org; Tue, 17 Jul 2018 07:16:10 -0400 Original-Received: from erc.thregr.org ([46.43.2.63]:60362) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ffNxf-0004R8-2y for 27822@debbugs.gnu.org; Tue, 17 Jul 2018 07:16:07 -0400 Original-Received: from [2a02:27e8:20:9049:4a2a:e3ff:fe02:7265] (helo=localhost) by erc.thregr.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) id 1ffNxd-0001Im-5f (envelope-from ); Tue, 17 Jul 2018 13:16:05 +0200 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:148605 Archived-At: --=-=-= Content-Type: text/plain 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] --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Do-not-consider-external-packages-to-be-removable.patch >From 5a4234b3c1289960fd760256aa6399efbd04bfc3 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia 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 --=-=-=--