First Last Prev Next    No search results available      Search page      Enter new bug
Bug#: 171374
Alias:
Product:
Component:
Status: RESOLVED
Resolution: FIXED
Assigned To: portage-utils <portage-utils@gentoo.org>
Hardware:
OS:
Version:
Priority:
Severity:
Reporter: TGL <tom.gl@free.fr>
Add CC:
CC:
Remove selected CCs
URL:
Summary:
Status Whiteboard:
Keywords:

Filename Description Type Creator Created Size Actions
qgrep-01_regexp_compilation_speedup.patch qgrep-01_regexp_compilation_speedup.patch patch TGL 2007-03-18 19:54 0000 1.54 KB Details | Diff
qgrep-02_add_-l_and_-L_options.patch qgrep-02_add_-l_and_-L_options.patch patch TGL 2007-03-18 19:55 0000 2.57 KB Details | Diff
qgrep-03_add_a_--skip_option.patch qgrep-03_add_a_--skip_option.patch patch TGL 2007-03-18 19:55 0000 2.41 KB Details | Diff
qgrep-04_add_a_--with-name_option.patch qgrep-04_add_a_--with-name_option.patch patch TGL 2007-03-18 19:56 0000 3.40 KB Details | Diff
qgrep-05_add_a_--extended_option.patch qgrep-05_add_a_--extended_option.patch patch TGL 2007-03-18 19:57 0000 1.30 KB Details | Diff
qgrep-06_take_additional_args_as_a_search_restriction.patch qgrep-06_take_additional_args_as_a_search_restriction.patch patch TGL 2007-03-18 19:58 0000 3.83 KB Details | Diff
qgrep-all_in_one.patch qgrep-all_in_one.patch patch TGL 2007-03-18 19:59 0000 8.09 KB Details | Diff
qgrep-07_misc_options_warnings_and_-lvv_support.patch qgrep-07_misc_options_warnings_and_-lvv_support.patch patch TGL 2007-03-24 11:22 0000 1.62 KB Details | Diff
qgrep-all_in_one.patch qgrep-all_in_one.patch patch TGL 2007-03-24 11:23 0000 8.52 KB Details | Diff
qgrep-07_misc_options_warnings_and_-lvv_support.patch qgrep-07_misc_options_warnings_and_-lvv_support.patch patch TGL 2007-03-24 19:18 0000 2.42 KB Details | Diff
qgrep-all_in_one.patch qgrep-all_in_one.patch patch TGL 2007-03-24 19:18 0000 8.68 KB Details | Diff
strstr_in_qgrep_name_match.patch strstr_in_qgrep_name_match.patch patch samLT 2007-03-30 11:53 0000 798 bytes Details | Diff
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 171374 depends on: Show dependency tree
Show dependency graph
Bug 171374 blocks: 172240
Votes: 0    Show votes for this bug    Vote for this bug

Additional Comments: (this is where you put emerge --info)







View Bug Activity   |   Format For Printing   |   XML   |   Clone This Bug


Description:   Opened: 2007-03-18 19:53 0000
Here is a serie of 6 patches for "qgrep", which adds a few new features.
Details about what each patch does follow, in the attachment comments.

The first one is for CVS revision 1.17, and then they are incremental.
Also, I will attach an equivalent all-in-one patch at the end.

(I've thought that opening 6 bugs for that would have been spam, my
apologies if you disagree...)

------- Comment #1 From TGL 2007-03-18 19:54:26 0000 -------
Created an attachment (id=113690) [edit]
qgrep-01_regexp_compilation_speedup.patch

Reduces CPU usage of "-e/--regexp" by compiling the pattern once for all.

Before: 
   % time ./orig/q grep -Ee '\<e\(info\|warn\|log\|error\)\>' >/dev/null

  real    0m1.511s
  user    0m1.465s
  sys     0m0.013s

After: 
   % time ./q grep -Ee '\<e\(info\|warn\|log\|error\)\>' >/dev/null

  real    0m0.106s
  user    0m0.067s
  sys     0m0.006s

------- Comment #2 From TGL 2007-03-18 19:55:00 0000 -------
Created an attachment (id=113693) [edit]
qgrep-02_add_-l_and_-L_options.patch

Add some "-l/--list" and "-L/--invert-list" options, similar to GNU Grep
"--files-with-matches" and "--files-without-match".  Only a list of files 
will be displayed in this mode.  Like in GNU Grep, when this option is use, 
"--count" is ignored.

------- Comment #3 From TGL 2007-03-18 19:55:47 0000 -------
Created an attachment (id=113695) [edit]
qgrep-03_add_a_--skip_option.patch

Add a "-S/--skip <pattern>" option.  It is a generalisation of the 
--skip-comments option: lines which match the pattern are ignored.
The skip pattern is interpreted just like the search pattern, depending
on other options (substring or regexp, case sensitive or insensitive).
I find it useful to drop some false-positive when grepping for some
actual code:
   % ./q grep -ves -S '^[      
]*\(e\(info\|warn\|error\|log\)\>\|DESCRIPTION=\)' '\<which\>'
  app-arch/rpm2targz/rpm2targz-9.0-r2.ebuild:     sys-apps/which"
  app-arch/rpm2targz/rpm2targz-9.0-r3.ebuild:     sys-apps/which"
  app-arch/rpm2targz/rpm2targz-9.0-r4.ebuild:             sys-apps/which )"
  app-arch/rpm2targz/rpm2targz-9.0-r5.ebuild:             sys-apps/which )"
  app-dicts/stardict/stardict-2.4.8.ebuild:       export PKG_CONFIG=`which
pkg-config`
  app-dicts/verbiste/verbiste-0.1.16.ebuild:      cp $(which gettextize)
"${T}"/ || die "could not copy gettextize"
  ...

------- Comment #4 From TGL 2007-03-18 19:56:33 0000 -------
Created an attachment (id=113697) [edit]
qgrep-04_add_a_--with-name_option.patch

Add a "-H/--with-name" option, which makes qgrep display cat/pkg-ver instead 
of ebuild paths.  Also, when using -E/--eclass, only the eclass name is 
displayed:
   % ./q grep -N foo
  app-admin/skey-1.1.5-r5:        # allow invokation as otp-foo. #71015
  app-admin/skey-1.1.5-r6:        # allow invokation as otp-foo. #71015
  app-admin/system-config-printer-0.7.27:         net-print/foomatic
  ...
   % ./q grep -NE foo
  toolchain-funcs: #   gen_usr_ldscript libfoo.so
  subversion: # e.g. http://foo/trunk, svn://bar/trunk
  kmod: # if is_kernel 2 6; then foo; fi
  ...

------- Comment #5 From TGL 2007-03-18 19:57:17 0000 -------
Created an attachment (id=113698) [edit]
qgrep-05_add_a_--extended_option.patch

Add a "-x/--extended" option, to allow extended regular expressions.
For instance:
   % ./q grep -NEx '^[[:space:]]*e(info|warn|error|log)\>'
  vim-spell:      einfo "To enable ${VIM_SPELL_LANGUAGE} spell checking, use"
  vim-spell:      einfo "    :setlocal spell spelllang=${VIM_SPELL_CODE}"
  vim-spell:      einfo "The following (Vim internal, not file) encodings are
supported for"
  ...

------- Comment #6 From TGL 2007-03-18 19:58:00 0000 -------
Created an attachment (id=113699) [edit]
qgrep-06_take_additional_args_as_a_search_restriction.patch

Currently, qgrep only read it's first command line argument, and ignore the 
later ones.  Also, it always search through all ebuilds (or eclasses).  With
this patch, later arguments are interpreted as the set of files qgrep should
search in.  Arguments can be:

 - eclass names (when using "-E").  This one is convenient for instance when 
you don't remember what functions an eclass define:
   % ./q grep -Es '()' games
  egamesconf() {
  egamesinstall() {
  gameswrapper() {
  ...

 - ebuild names, with or without it's "category/":
   % ./q grep -Ne '^KEYW' portage-utils app-portage/gentoolkit
  app-portage/gentoolkit-0.2.2: KEYWORDS="alpha amd64 arm hppa ia64 m68k mips
ppc ppc64 s390 sh sparc x86 ~x86-fbsd"
  app-portage/gentoolkit-0.2.3: KEYWORDS="alpha amd64 arm hppa ia64 m68k mips
ppc ppc64 s390 sh sparc ~sparc-fbsd x86 ~x86-fbsd"
  app-portage/gentoolkit-0.2.4_pre1: KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64
~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~sparc-fbsd ~x86 ~x86-fbsd"
   app-portage/portage-utils-0.1.23: KEYWORDS="alpha amd64 arm hppa ia64 m68k
mips ppc ppc64 s390 sh sparc ~sparc-fbsd x86 ~x86-fbsd"
  app-portage/portage-utils-0.1.24: KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64
~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~sparc-fbsd ~x86 ~x86-fbsd"

 - category names (must be followed by a "/", or it will be 
interpreted as a package name):
   % ./q grep -Nx '^# \$Header.*\<solar\>' app-portage/ sys-devel/
  app-portage/portage-utils-0.1.24: # $Header:
/var/cvsroot/gentoo-x86/app-portage/portage-utils/portage-utils-0.1.24.ebuild,v
1.1 2007/02/11 22:49:21 solar Exp $
  sys-devel/gcc-3.2.3-r4: # $Header:
/var/cvsroot/gentoo-x86/sys-devel/gcc/gcc-3.2.3-r4.ebuild,v 1.22 2006/08/14
16:32:23 solar Exp $
  sys-devel/gcc-3.3.5-r1: # $Header:
/var/cvsroot/gentoo-x86/sys-devel/gcc/gcc-3.3.5-r1.ebuild,v 1.32 2006/08/14
16:32:23 solar Exp $
  ...

 - full "cat/pkg-ver".  I like this one to get a quick stripped view of a 
particular ebuild:
   % ./q grep -se . app-portage/portage-utils-0.1.24 | more
  inherit toolchain-funcs
  DESCRIPTION="small and fast portage helper tools written in C"
  HOMEPAGE="http://www.gentoo.org/"
  SRC_URI="mirror://gentoo/${P}.tar.bz2"
  ...

------- Comment #7 From TGL 2007-03-18 19:59:59 0000 -------
Created an attachment (id=113701) [edit]
qgrep-all_in_one.patch

Merge of the 6 previous patches.  Don't worry, it's actually not too big:

  % diffstat qgrep-all_in_one.patch
   qgrep.c |  160
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
   1 file changed, 147 insertions(+), 13 deletions(-)

------- Comment #8 From solar 2007-03-18 20:37:11 0000 -------
(In reply to comment #1)
> Created an attachment (id=113690) [edit]
> qgrep-01_regexp_compilation_speedup.patch

Pretty impressive speedup.

solar@here /var/cvsroot/gentoo-projects/portage-utils $ time ./q grep -e
'\<e\(info\|warn\|log\|error\)\>' >/dev/null

real    2m36.379s
user    0m2.616s
sys     0m4.884s
solar@here /var/cvsroot/gentoo-projects/portage-utils $ time /usr/bin/q grep -e
'\<e\(info\|warn\|log\|error\)\>' >/dev/null

real    6m10.265s
user    2m27.957s
sys     0m10.597s

------- Comment #9 From solar 2007-03-18 20:42:09 0000 -------
(In reply to comment #2)
> Created an attachment (id=113693) [edit]
> qgrep-02_add_-l_and_-L_options.patch

I like this. Saves us from having to use awk '{print $1}' however if you could
make it work with the -vv that would be handy.

------- Comment #10 From solar 2007-03-18 20:49:27 0000 -------
(In reply to comment #4)
> Created an attachment (id=113697) [edit]
> qgrep-04_add_a_--with-name_option.patch
> 
> Add a "-H/--with-name" option, which makes qgrep display cat/pkg-ver instead 
> of ebuild paths. 

I think you mean "Add a -N option" here vs -H. Also if using -H -N -H do you
think the last option given should negate the other? 

------- Comment #11 From solar 2007-03-18 20:56:26 0000 -------
(In reply to comment #6)
> Created an attachment (id=113699) [edit]
> qgrep-06_take_additional_args_as_a_search_restriction.patch

nice I like it.

------- Comment #12 From TGL 2007-03-18 21:19:30 0000 -------
(In reply to comment #9)
> (In reply to comment #2)
> > Created an attachment (id=113693) [edit]
> > qgrep-02_add_-l_and_-L_options.patch
> 
> however if you could make it work with the -vv that would be handy.
> 

I'm not sure i understand, what output would you expect for -lvv?


(In reply to comment #10)
> (In reply to comment #4)
> > Created an attachment (id=113697) [edit]
> > qgrep-04_add_a_--with-name_option.patch
> > 
> 
> I think you mean "Add a -N option" 

Oops, yes, sure.

> Also if using -H -N -H do you think the last
> option given should negate the other? 

Imho, options order should not change their behavior. I prefer having some
arbitrary priorities (-N stronger than -H, like -l is stronger than -c).  What
about keeping that behavior, but adding some warnings for incoherent
combinations?

------- Comment #13 From solar 2007-03-19 00:33:30 0000 -------
(In reply to comment #12)
> (In reply to comment #9)
> > (In reply to comment #2)
> > > Created an attachment (id=113693) [edit]
> > > qgrep-02_add_-l_and_-L_options.patch
> > 
> > however if you could make it work with the -vv that would be handy.
> 
> I'm not sure i understand, what output would you expect for -lvv?

With the two or more -v options we currently display the line number.

solar@here ~ $ qgrep -Hvv '$(which '
app-dicts/verbiste/verbiste-0.1.16.ebuild:28:   cp $(which gettextize) "${T}"/
|| die "could not copy gettextize"


user@shell ~ $ qgrep -lvv '$(which '
app-dicts/verbiste/verbiste-0.1.16.ebuild:28:

------- Comment #14 From TGL 2007-03-24 11:21:54 0000 -------
(In reply to comment #13)
> 
> user@shell ~ $ qgrep -lvv '$(which '
> app-dicts/verbiste/verbiste-0.1.16.ebuild:28:
> 

Ok, i will attach one more patch with the following behavior:

 * "-l" lists matching files once (no change here):
  % ./qgrep -l unpack | head -n4
  app-accessibility/SphinxTrain/SphinxTrain-0.9.1-r1.ebuild
  app-accessibility/at-poke/at-poke-0.2.2.ebuild
  app-accessibility/brltty/brltty-3.7.2.ebuild
  app-accessibility/dasher/dasher-4.0.2.ebuild

 * "-lv" lists matching files once per matching line (not really useful, but a
logical intermediate between -l and -lvv):
  % ./qgrep -lv unpack | head -n4
  app-accessibility/SphinxTrain/SphinxTrain-0.9.1-r1.ebuild
  app-accessibility/SphinxTrain/SphinxTrain-0.9.1-r1.ebuild
  app-accessibility/at-poke/at-poke-0.2.2.ebuild
  app-accessibility/at-poke/at-poke-0.2.2.ebuild

 * "-lvv" lists matching files once per matching line, and give the line
numbers (what you asked, except i've dropped the colon char at EOL):
  % ./qgrep -lvv unpack | head -n4
  app-accessibility/SphinxTrain/SphinxTrain-0.9.1-r1.ebuild:22
  app-accessibility/SphinxTrain/SphinxTrain-0.9.1-r1.ebuild:23
  app-accessibility/at-poke/at-poke-0.2.2.ebuild:33
  app-accessibility/at-poke/at-poke-0.2.2.ebuild:34


This patch also adds usage warning for two unsupported/meaningless options
combinations:
 * --list (or --invert-list) and --count
 * --with-name and --with-filename

------- Comment #15 From TGL 2007-03-24 11:22:37 0000 -------
Created an attachment (id=114221) [edit]
qgrep-07_misc_options_warnings_and_-lvv_support.patch

------- Comment #16 From TGL 2007-03-24 11:23:40 0000 -------
Created an attachment (id=114222) [edit]
qgrep-all_in_one.patch

Updated all-in-one patch (includes patches #01 to #07).

------- Comment #17 From TGL 2007-03-24 19:18:03 0000 -------
Created an attachment (id=114281) [edit]
qgrep-07_misc_options_warnings_and_-lvv_support.patch

I had used some warnf()/errf() where warn()/err() was what i meant.

------- Comment #18 From TGL 2007-03-24 19:18:29 0000 -------
Created an attachment (id=114282) [edit]
qgrep-all_in_one.patch

------- Comment #19 From solar 2007-03-26 16:18:14 0000 -------
solar@onyx /var/cvsroot/gentoo-projects/portage-utils $ cvs ci -m "-  Misc
enhancements for qgrep. TGL bug 171374" 
...
/var/cvsroot/gentoo-projects/portage-utils/qgrep.c,v  <--  qgrep.c
new revision: 1.18; previous revision: 1.17

------- Comment #20 From samLT 2007-03-30 11:53:19 0000 -------
Created an attachment (id=114944) [edit]
strstr_in_qgrep_name_match.patch

instead of only matching the exact category, package name, or eclass with
strcmp, we can use strstr. this allows us for example to grep
 * in every vim eclasses instead of just vim.eclass in case we use vim as the
optionnal argument.
 * to grep in every games categories using 
   qgrep searchme games/

and so on...

------- Comment #21 From samLT 2007-03-30 16:35:40 0000 -------
(In reply to comment #20)

>  * in every vim eclasses instead of just vim.eclass in case we use vim as the
> optionnal argument.

well, actually this one is not a good example since we then lose the ability to
only grep in the vim eclass.

so... I think using strstr instead of strcmp, is only usefull for the CATEGORY

------- Comment #22 From TGL 2007-03-30 19:39:10 0000 -------
(In reply to comment #20)
> we can use strstr. 

I'm not sure i like this idea, it's a bit to much magic imho.  It's like in
"qlist cat/pkg", i always forget to add this --exact option which is almost
always what i actually want.  Here, I expect the usual use case to be searching
in "one/some specific category(ies)" rather than in "all categories that match
some substrings".  For the rare occasions i would want the later, i can live
with either this:
% cd /usr/portage
% qgrep searchme *games*/
or this (to avoid changing dir):
% qgrep searchme $(sed -n '/games/s:$:/:p' /usr/portage/profiles/categories)

That said, i understand it's really a matter of taste... It's up to upstream :)

------- Comment #23 From solar 2007-04-05 18:42:19 0000 -------
This is released in 0.1.25

Bug #168334 ; q -r dies with a segfault after emerge --sync
Bug #168442 ; does not  properly parse the profile location
Bug #170795 ; add a -E/--eclass option to qgrep
Bug #170797 ; add a -s/--skip-comments option to qgrep
Bug #171024 ; opening '/usr/portage/.metadata.x' failed
Bug #171374 ; Misc enhancements for qgrep
Bug #172240 ; -A/-B options for qgrep (context lines) 
Bug #172338 ; qgrepping through installed ebuilds (in the VDB) 
Bug #173005 ; Colorized output for qgrep.

------- Comment #24 From solar 2007-04-05 18:43:04 0000 -------
Closing

First Last Prev Next    No search results available      Search page      Enter new bug