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
Task Type Feature Request
Category Output
Status Closed
Assigned To Xavier (shining)
Architecture All
Severity Low
Priority Normal
Reported Version 3.2.2
Due in Version 3.4.0
Due Date Undecided
Percent Complete 100%
Votes 3
Private No

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
Comment by Xavier (shining) - Tuesday, 14 April 2009, 17:18 GMT
> 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.

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.
Comment by Xyne (Xyne) - Wednesday, 15 April 2009, 19:22 GMT
I didn't know that "--print-uris" was a hack, I haven't looked at the code. Maybe this would be an opportunity to fix that. :)

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.
Comment by Nagy Gabor (combo) - Thursday, 16 April 2009, 19:09 GMT
IMHO --list cannot make things worse. :-) After commit baf58525553db8f1e680de16793b147c88df59e2, there is no PM_TRANS_FLAG_PRINTURIS flag, so there is no PRINTURI hack in alpm code at all. [Next task: kill PM_TRANS_FLAG_DOWNLOADONLY.]

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);")
Comment by Xyne (Xyne) - Wednesday, 20 May 2009, 12:26 GMT
  • Field changed: Percent Complete (100% → 0%)
This is not a duplicate of the other feature request. The other request only applies to listing packages on the system along with upgrades (-Qu). This option would provide the full list of packages for a download operation, including packages specified on the command line and their dependencies.
Comment by Xavier (shining) - Wednesday, 20 May 2009, 12:44 GMT
Hm it's true, Nagy made the -Sp operation much better by moving it to the frontend, so that's one hack less.

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 ?
Comment by Xyne (Xyne) - Wednesday, 20 May 2009, 22:59 GMT
I like the idea of "-Spq". It's actually quite intuitive. Perhaps it could print out a list with the version numbers (similar to "-Q" without any arguments) and then "-Spqq" would print out a list without the version numbers.

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").
Comment by Xavier (shining) - Monday, 20 July 2009, 08:27 GMT
a patch is here : http://www.archlinux.org/pipermail/pacman-dev/2009-July/008949.html
-S --print : print package name and version
-S --print -q : print package name

Xyne, would that suit you?
Comment by Xyne (Xyne) - Monday, 20 July 2009, 15:19 GMT
@Xavier

Yeah, that looks good. Thanks.

Would it be difficult to implement "--print" for "-R" as well?
Comment by Xavier (shining) - Wednesday, 22 July 2009, 12:07 GMT
It's not difficult, so Nagy and I implemented it for -U and -R too even if it seems less useful.

This is hopefully the final patch.
Comment by Xavier (shining) - Saturday, 12 September 2009, 11:21 GMT

Loading...