FS#14208 - Add a "--list" option or something similar for use with scripts.
Attached to Project:
Pacman
Opened by Xyne (Xyne) - Monday, 13 April 2009, 04:09 GMT
Last edited by Allan McRae (Allan) - Monday, 17 May 2010, 03:43 GMT
Opened by Xyne (Xyne) - Monday, 13 April 2009, 04:09 GMT
Last edited by Allan McRae (Allan) - Monday, 17 May 2010, 03:43 GMT
|
Details
It would be useful to have an option in pacman (that doesn't
require root) to display a complete list of packages to
download for a given sync operation (with deps resolved
unless --nodeps is given, etc), e.g.
pacman -Syu foo bar --list would then print out a list of files to download, e.g. kernel26 2.6.29.1-3 aria2 1.3.0-1 foo 3.5-3 bar 1.4-2 baz 3.5-1 Adding "--quiet" would remove the version from each line. This shouldn't be difficult to implement considering that the "--print-uris" option already exists. "--print-uris" is not useful because it requires both root (why?*) and considerable parsing to extract the relevant info. "--list" could be useful for remove operations as well as it could show all the packages that would be removed (cascades, etc). I know that I would make ample use of this and I believe that others who develop tools for pacman would find it very useful as well. I also know the standard response is likely to be "submit a patch" but I still don't know C and this should be much easier for someone who's already familiar with the code (it should just be a tweak to "--print-uris"). Also, before someone says "just use alpm", well, I don't know C but beyond that, from what I've seen, the documentation for alpm is somewhere between chaos and limbo. I've even seen one of the devs say that it's still mostly a mystery to him, so it's hardly practical. Anyway, this would be really useful. I really hope that one of the pacman devs agrees (please?). * I've written a partial implementation of pacman in perl which does not require root to determine package downloads, so I don't understand why pacman needs it. |
This task depends upon
Closed by Allan McRae (Allan)
Monday, 17 May 2010, 03:43 GMT
Reason for closing: Implemented
Additional comments about closing: git commit d39b1dbe
Monday, 17 May 2010, 03:43 GMT
Reason for closing: Implemented
Additional comments about closing: git commit d39b1dbe
> "--print-uris" is not useful because it requires both root (why?*) and considerable parsing to extract the relevant info.
The code for --print-uris is ugly, it is just a hack on top of the code for -S, which is why root is needed (because -S needs root).
So you are proposing to make this hack even bigger and uglier to also support --list.
And adding yet another hack on top of everything to remove root check in these cases.
Doesn't alpm have basic functions for resolving the package list that can be used directly? Considering how quick and easy it was to write them from scratch in Perl (see Pacman.pm in perl-xyne-arch) I would find it hard to believe that the main package management library of Arch doesn't have them after having been around for years.
I really wish I had the time to learn C right now... everything I've heard indicates that the pacman/alpm code either needs to a good clean up or complete refactoring and the current attitude seems to be "well, it's a mess, let's not touch it unless we really have to". I'm really not complaining about the devs so please don't take it that way. I understand that a cleanup/refactoring along with documentation would entail a shitload of work, possibly introduce new bugs, take a lot of time, etc and that if it currently works then there's no real motivation to do this. It's just unfortunate.
I don't see what is the problem with creating a transaction. We want to simulate a transaction, don't we? Why should we create ~4-5 new public functions for doing that? And nobody can implement a better simulation than a real transaction. (It's the front-end task to deal with questions or alpm messages.)
IMHO the only problem is that "-S" locks the database, that's why we need root. As I suggested in irc, my preferred solution is to create a new transaction flag: PM_TRANS_FLAG_NOLOCK == PM_TRANS_FLAG_SIMULATE == PM_TRANS_FLAG_NOCOMMIT. With this flag alpm would not lock the database and would not allow to call trans_commit. (Or if we choose FLAG_SIMULATE, trans_commit would turn into "return(0);")
PM_TRANS_FLAG_NOLOCK is probably one hack more, but it's not too bad, and it removes the root usage.
Now it looks easier to add a tweak to "--print-uris". The most difficult part now seems to find good switches :P
Note that -S --list is already used (see pacman -Sh).
We could have -Sp to print package names and versions (common default output)
-Spq to print only package names (common quiet output)
and -Spp to print uris ?
Otherwise maybe "--itemize" (without "-q- it would include version info of packages, with "-q" only the names) or "-n" & "--dry-run" (although printing out a list isn't really a "dry-run").
-S --print : print package name and version
-S --print -q : print package name
Xyne, would that suit you?
Yeah, that looks good. Thanks.
Would it be difficult to implement "--print" for "-R" as well?
This is hopefully the final patch.
http://mailman.archlinux.org/pipermail/pacman-dev/2009-September/009340.html