Gentoo Archives: gentoo-dev

From: Steve Long <slong@××××××××××××××××××.uk>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] Re: [RFC] Major changes to the Gnome2 Eclasses
Date: Thu, 20 Mar 2008 08:16:52
Message-Id: frt6gb$vb6$1@ger.gmane.org
In Reply to: Re: [gentoo-dev] [RFC] Major changes to the Gnome2 Eclasses by "Rémi Cardona"
1 Rémi Cardona wrote:
2
3 > Now, basically, if the portage metadata or QA people could tell me a way
4 > to figure *all* the ebuilds that inherit gnome2 *and* have a
5 > pkg_preinst() function somewhere (either in the ebuild or in an eclass
6 > somewhere) I'd really appreciate it, as I really don't want to read
7 > through thousands of ebuilds to figure it out.
8 >
9 PORTDIR=$(portageq envvar PORTDIR)
10 # Get eclasses which export pkg_preinst()
11 preEclass=($(qgrep -EeCl 'EXPORT_FUNCTIONS.*pkg_preinst'))
12 # We don't want the eclass/ prefix
13 preEclass=("${preEclass[@]/#eclass\/}")
14 # or the .eclass suffix
15 preEclass=("${preEclass[@]/%.eclass}")
16 # make a regex for an ebuild with a pkg_preinst, or inheriting one
17 # of the eclasses
18 IFS='|'
19 search="^[[:space:]]*(pkg_preinst\(\)|inherit .*(${preEclass[*]}))"
20 unset IFS
21 # find matching ebuilds
22 while read ebuild; do grep -El "$search" "$PORTDIR/$ebuild"
23 done< <(qgrep -Cel 'inherit .*gnome2')
24 # just the packages (would need to count dirs in PORTDIR and amend awk
25 # accordingly to use the env var)
26 while read ebuild; do grep -El "$search" "/usr/portage/$ebuild"
27 done< <(qgrep -Cel 'inherit .*gnome2') | \
28 awk -F/ '!s[$4"/"$5]++ { print $4"/"$5 }'
29
30 If you wanted to do something with the files, you'd use:
31 grep -Eq "$search" "$PORTDIR/$ebuild" && files+=("$PORTDIR/$ebuild")
32 in the loop, and then access the "${files[@]}" array after. You can't do
33 that with a pipe, see http://wooledge.org/mywiki/BashFAQ/024
34
35
36 --
37 gentoo-dev@l.g.o mailing list