Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'pkgin rm *' behaves unexpectedly #125

Open
0-wiz-0 opened this issue Jul 24, 2022 · 6 comments
Open

'pkgin rm *' behaves unexpectedly #125

0-wiz-0 opened this issue Jul 24, 2022 · 6 comments
Assignees

Comments

@0-wiz-0
Copy link

0-wiz-0 commented Jul 24, 2022

I wanted to uninstall all packages, so I tried pkgin rm \*, backslash to avoid expansion from the shell, and got:

# pkgin rm \*     
reading local summary...
processing local summary...
77 packages to delete: 
... a list of 77 packages, I guess, haven't counted ...

proceed ? [Y/n] n

but there are many more packages installed:

# pkg_info | wc -l
    1117
@0-wiz-0
Copy link
Author

0-wiz-0 commented Jul 24, 2022

When I ran it, it did indeed delete 77 packages.
The next call to pkgin rm \* only offers deleting of two packages, libreoffice and zxing-cpp.
The next one says it will remove 51, some leaf packages, but also (most? all? of) qt5.
The next run offered only zsh-autosuggestions; I tried pkgin ar at that point and it offered to delete 281 packages.
I don't see the pattern.

@0-wiz-0
Copy link
Author

0-wiz-0 commented Jul 24, 2022

After the pkgin ar, pkgin rm still offered only to delete zsh-autosuggestion; after that, zsh, then 1-6 packages each time I started it.

@sskras
Copy link

sskras commented Oct 21, 2022

Wow.

@jperkin
Copy link
Contributor

jperkin commented Jul 26, 2023

Firstly, what's happening here is that pkgin operates on package matches, not globs. If you ask to install or remove *, it will try to find the best package match for your pattern, there's no concept of expanding globs. The package it chooses will be dependent on the ordering in the local package repository but likely reverse alphabetical (hence picking z* in your case), and the numbering will be based on how many dependent packages it will have to remove along with the one that matched.

I think that fundamentally we can't support globs like this, due to the way pkgsrc pattern matching works. Consider patterns like vim{,-xaw}: in pkgsrc context that means either vim or vim-xaw, but not both. While we could add hacky hardcoding of * to mean all packages, I'm not sure it makes for a orthogonal user experience, and I'm leaning more towards adding a clear paragraph or two about this in the man page.

Finally, trying to perform a hypothetical pkgin rm '*' wouldn't necessarily work anyway, or be desirable, as there will be packages such pkg_install that cannot be removed, as well as preserve packages that will not be auto-removed. Plus, you'd end up with removing pkgin itself and being unable to recover without resorting to pkg_add (along with potential for issues on platforms where the binary has been removed from out underneath you), and if you are a user who is comfortable doing that then you're probably going to be using pkg_delete -f '*' or similar instead anyway.

I'll leave this open though until the docs are clearer, and if there are a lot of strong opinions that * should work, along with clarity on what should be expected if used for e.g. pkgin install, then I'm happy to reevaluate.

@jperkin jperkin self-assigned this Jul 26, 2023
@0-wiz-0
Copy link
Author

0-wiz-0 commented Jul 27, 2023

Thanks for the explanation. That makes it a bit clearer what happens, though I'm still baffled by the amount of packages deleted each time - if it chooses the 'best match' as you say, why doesn't it always just delete one?
I think documenting this in more detail is probably enough to close this issue, otherwise.

Just to give some bigger view: My use case was reinstalling all packages after an OS upgrade, using a pre-existing package list (that can be used to pkgin import), to make sure only the wanted packages are installed (and not other packages that were installed for testing and forgotten), and they are at the newest version and for the right operating system version, while leaving the changed configuration files alone.

Now that the pkgdb is inside PREFIX, the best method I have for this is to move the old PREFIX aside and install in a new one, but then I have to copy the configuration files manually.

If you have a better suggestion, please let me know. Thanks.

@jperkin
Copy link
Contributor

jperkin commented Jul 27, 2023

Thanks for the explanation. That makes it a bit clearer what happens, though I'm still baffled by the amount of packages deleted each time - if it chooses the 'best match' as you say, why doesn't it always just delete one?

It only chooses one, but the list of packages will also include any packages that are reverse dependencies of that package, and will also be removed to ensure consistency.

I'm hoping to make this clearer in future releases by separating out packages and dependencies.

If you have a better suggestion, please let me know. Thanks.

pkgin list | awk '{print $1}' | xargs pkgin rm or so should work for now. In the future it might be interesting to have a similar command to import but one that ensures that only the listed packages and their dependencies are installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants