You are not logged in.
Sick of sed? Annoyed at awk? Gagging on grep? expac is for you!
expac formats package data the way you want it to. No more need for parsing the output of pacman -Qi. Want to know the depends of a package in a neat list with your own delimiter? Done!
$ expac %D -l'\n' pacman
bash
libarchive>=2.7.1
libfetch>=2.25
pacman-mirrorlist
This is great! ...but falc! I don't want those versions in there! Won't I have to go get some sort of parsing tool to get rid of them? Nope! expac can do that too! Just slide in the %E in place of %D. It's got everything!
The local database is the default, but you can access the sync databases too! Just use the familiar -S option, and you're on your way! expac also searches with regex, and it'll accept repo/pkg style arguments as well.
Ok, but seriously. I thought this would be nice for folks who want to interface with alpm from a script but who don't want the overhead of having to parse pacman's less flexible output. This is meant to be light, and provide raw output for use in conjunction with other utilities.
But there are, of course, other uses. Maybe you want custom formatted pacman searches. Ever wanted to see install or download sizes in search results? Easy!
expac '%r/%n %v [%k|%m]\n %d' -Ss foo
Now you've got both! The format string is capable of handling all the common backslashed escape codes, which also means that adding color is a breeze.
I think I've only touched the tip of the iceberg as far as what you could do this with programmatically with tremendous ease. Just an example...
$ declare -A deps
$ eval $(expac 'deps[%n]="%D"' -Qs 'x.*git')
$ echo ${deps[x264-git]}
libxcomposite libxdamage libxrender
The focus here is to make the output as flexible as possible. Build and install dates are allowed custom format strings, so you can very easily get them in epoch times for easy sorting and manipulation elsewhere. The end-of-package delimiter can be changed from the default newline to whatever you want.
I've released this into the AUR, and there's of course a github repo for it. Below you'll find, from the man page, a list of all the supported tokens:
%B backup files
%C conflicts with
%D depends on
%E depends on (no version strings)
%F files (only with -Q)
%G groups
%L licenses
%N required by
%O optional deps
%P provides
%R replaces
%S provides (no version strings)
%a architecture
%b build date
%d description
%f filename (only with -S)
%i has install scriptlet
%k download size
%l install date (only with -Q)
%m install size
%n package name
%p packager name
%r repo
%s md5sum
%u project URL
%v version
%w install reason
%% literal %
Bugs? There's no bugs. But if I happen to be wrong, drop a note here, email me, yell at me on IRC, or open a github issue.
Thanks to Keenerd for breaking this, telling me my code sucks, and putting up with my not-so-internal monologue while writing this.
Last edited by falconindy (2010-12-01 22:06:16)
Offline
This is awesome. I like seeing more and more software being built around libalpm rather than scraping pacman's output or the db directly.
Offline
Nifty! I like your style, falconindy.
This silver ladybug at line 28...
Offline
This is awesome. I like seeing more and more software being built around libalpm rather than scraping pacman's output or the db directly.
Ain't that the truth.
Offline
very interesting. bump for awareness and this question:
is there a way to specify the date format?
currently "Wed Dec 8 10:00:50 2013" which makes sorting hard.
P.S.: Nvm, it's even in the manual: --timefmt
Cheers
Last edited by demian (2014-01-21 17:02:56)
no place like /home
github
Offline
You can use e.g. '--timefmt=%s':
-t, --timefmt <format>
Output time described by the specified format. This string is passed directly to strftime(3). The default format is %c.
Offline
Wow, karol ninja'd
Offline
Question Regarding the build date flag
%b build date
When I run
expac --timefmt=%s '%b\t%n' | sort -n
I should see the the sorted packages installed by pacman by their original installation date
oldest to newest but i see latest updated/upgraded dates packages as well in the sort.
Is that the correct and expected output of that flag?
from man page
List the oldest 10 installed packages (by build date):
$ expac --timefmt=%s '%b\t%n' | sort -n | head -10
I want to use expac to view oldest and newest packages by their original install date not upgrades or updates, if possible.
EDIT:
the %l flag also includes latest upgrades in the results.
Last edited by glyons (2017-06-25 12:06:52)
Offline
Install date is %l. But if by "original installation date" you mean the install date of the first version of the package that you ever installed, I think you should resort to parsing pacman.log.
Offline