[pacman-dev] [PATCH 6/7] pacsearch: using pacman color theme

Pierre Neidhardt ambrevar at gmail.com
Thu Jan 23 10:23:31 EST 2014


On 14-01-23 10:03:57, Andrew Gregory wrote:
> On 01/23/14 at 02:58pm, Pierre Neidhardt wrote:
> > On 14-01-23 08:38:22, Andrew Gregory wrote:
> > > On 01/23/14 at 12:07am, Pierre Neidhardt wrote:
> > > > No more per-repo coloring: this was not Arch-agnostic, and there is no
> > > > reasonable, simple way to color repos in a consistant manner with only 6 colors.
> > > > 
> > > > 'local' is in red: this way we benefit from the pacman -Ss && pacman -Qs combo.
> > > > 
> > > > to_color subroutine: it takes an array instead of a string, this is faster and
> > > > simpler.
> > > > 
> > > > Signed-off-by: Pierre Neidhardt <ambrevar at gmail.com>
> > > > ---
> > > >  contrib/pacsearch.in | 32 ++++++++++++++------------------
> > > >  1 file changed, 14 insertions(+), 18 deletions(-)
> > > 
> > > If we use pacman's color theme and remove per-repo coloring does this script
> > > still do anything worth keeping it around and fixing its bugs (try `pacsearch
> > > pacman mirrorlist`)?  All that's left is searching both -Ss and -Qs, recoloring
> > > "local/" red, adding "[installed]" to -Qs entries, and hiding -Qs entries that
> > > are also in -Ss.  All but the last can be accomplished in a few lines of bash
> > > using sed.
> >
> > ...
> > 
> > This script is tiny, right, but not enough to be a one-liner (the "duplicate
> > entry removal" needs a hash table and some parsing). Besides when you do it with
> > sed/awk, you lose the coloring. And with sed/awk it's hard to sort without
> > another call to 'sort', which does not save time. All these reasons are good
> > enough to have this script.
> 
> pacsearch does not sort its results and you can still have color with sed/awk
> with --color=always.

I'm not sure that's a good solution, since the parsing gets tricky with all the
colors into the strings. Try this:

    $ pacman -Ss pacman --color=always | awk '/core\/pacman/'
    <no result>
    $ pacman -Ss pacman | awk '/core\/pacman/'
    core/pacman 4.1.2-5 (base base-devel) [installerad]
    core/pacman-mirrorlist 20140107-1 [installerad]

> > If I understood you correctly, `pacsearch pacman mirrorlist` is not a
> > bug. pacsearch's argument is a pattern, not package names. See pacsearch -h.
> 
> pacman mirrorlist is not the name of a package, those are two separate search
> terms that pacsearch needlessly combines into a single term when it passes them
> to pacman.
> 
> apg

Actually I was thinking this behaviour is a feature, for instance to find two
words in a description. But pacman does not behave this way.

    $ pacman -Ss 'based package'
    core/pacman 4.1.2-5 (base base-devel) [installerad]
         A library-based package manager with dependency support

    $ pacman -Ss based package
    core/pacman 4.1.2-5 (base base-devel) [installerad]
         A library-based package manager with dependency support
    community/qcad 3.4.5.0-2
        A 2D CAD package based upon Qt

    $ pacsearch based package
    core/pacman 4.1.2-5 (base base-devel) [installerad] 
        A library-based package manager with dependency support

I've just fixed it, it's a trivial bug. Thanks for pointing this out.

-- 
Pierre Neidhardt

The District of Columbia has a law forbidding you to exert pressure on
a balloon and thereby cause a whistling sound on the streets.


More information about the pacman-dev mailing list