Rémi Cardona wrote: > Now, basically, if the portage metadata or QA people could tell me a way > to figure *all* the ebuilds that inherit gnome2 *and* have a > pkg_preinst() function somewhere (either in the ebuild or in an eclass > somewhere) I'd really appreciate it, as I really don't want to read > through thousands of ebuilds to figure it out. > PORTDIR=$(portageq envvar PORTDIR) # Get eclasses which export pkg_preinst() preEclass=($(qgrep -EeCl 'EXPORT_FUNCTIONS.*pkg_preinst')) # We don't want the eclass/ prefix preEclass=("[EMAIL PROTECTED]/#eclass\/}") # or the .eclass suffix preEclass=("[EMAIL PROTECTED]/%.eclass}") # make a regex for an ebuild with a pkg_preinst, or inheriting one # of the eclasses IFS='|' search="^[[:space:]]*(pkg_preinst\(\)|inherit .*(${preEclass[*]}))" unset IFS # find matching ebuilds while read ebuild; do grep -El "$search" "$PORTDIR/$ebuild" done< <(qgrep -Cel 'inherit .*gnome2') # just the packages (would need to count dirs in PORTDIR and amend awk # accordingly to use the env var) while read ebuild; do grep -El "$search" "/usr/portage/$ebuild" done< <(qgrep -Cel 'inherit .*gnome2') | \ awk -F/ '!s[$4"/"$5]++ { print $4"/"$5 }'
If you wanted to do something with the files, you'd use: grep -Eq "$search" "$PORTDIR/$ebuild" && files+=("$PORTDIR/$ebuild") in the loop, and then access the "[EMAIL PROTECTED]" array after. You can't do that with a pipe, see http://wooledge.org/mywiki/BashFAQ/024 -- gentoo-dev@lists.gentoo.org mailing list