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 |