emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: package.el dependencies


From: Artur Malabarba
Subject: Re: package.el dependencies
Date: Mon, 26 Jan 2015 10:53:22 -0200

2015-01-25 13:48 GMT-02:00 Thierry Volpiatto <address@hidden>:
>
> Stefan Monnier <address@hidden> writes:
>
>>>>> 1) Prevent (or warn) deleting a package if it is already used by another
>>>>> package as dependency.
>>>> That'd be nice.
>>> Fixed,
>>
>> Thanks Thierry.
>>
>>> assuming that when upgrading a package, deletion of old version
>>> is made AFTER installing new version.
>>
>> Good,
>
> Here the patch:
>
> --8<---------------cut here---------------start------------->8---
> 20c8e5d05f8e8e8996cf80f03f35335b328fdd94 HEAD package_autoremove
> Author: Thierry Volpiatto <address@hidden>
> Date:   Sun Jan 25 10:13:28 2015 +0100
>
>     Prevent deleting a package needed as dependency by another package.
>
>     * lisp/emacs-lisp/package.el (package-used-elsewhere-p): New.
>     (package-delete): Use it.
>
> 1 file changed, 30 insertions(+), 18 deletions(-)
> +(defun package-used-elsewhere-p (pkg)
> +  "Check if PKG is used elsewhere as dependency.
> +Argument PKG is a symbol."
> +  (cl-loop with alist = (remove (assoc pkg package-alist) package-alist)
> +           for p in alist thereis
> +           (member pkg (mapcar 'car (package-desc-reqs (cadr p))))))
> [...]
> +
> +          ((package-used-elsewhere-p (elt pkg-desc 1))
> +           ;; Don't delete packages used as dependency elsewhere.
> +           (error "Package `%s' is used elsewhere as dependency, not 
> deleting"
> +                  (package-desc-full-name pkg-desc)))

I was reading this again now and I have a question. How does this work
if `package-used-elsequere-p' only takes the function name? For
instance, let's say I upgrade `dash', which is a dependency to some
other packages. Here's what I think would happen:
1. Emacs installs the new version.
2. Emacs tries to delete the old version.
3. `package-delete' calls `(package-used-elsewhere-p 'dash)', which
returns non-nil.
4. `package-delete' throws an error, because `dash' is used as
dependency, even though Emacs was just trying to delete the old
version.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]