1 |
On Thu, Jun 25, 2020 at 07:32:04AM -0400, Michael Orlitzky wrote: |
2 |
> On 2020-06-24 16:08, Michał Górny wrote: |
3 |
> > |
4 |
> > $ git grep -l mgorny@g.o '**/metadata.xml' | cut -d/ -f1-2 | |
5 |
> > xargs gpy-py2 2>/dev/null |
6 |
> > |
7 |
> |
8 |
> The big problem with this is that it misses any aliases (like graphics@) |
9 |
> that you're a member of. But let's golf; this is POSIX sh, doesn't use |
10 |
> grep to parse XML, and takes the maintainer's email address as an argument: |
11 |
> |
12 |
> REPO=/var/db/repos/gentoo |
13 |
> XPATH="/pkgmetadata/maintainer/email[normalize-space(text()) = '${1}']" |
14 |
> |
15 |
> find -L "${REPO}" \ |
16 |
> -mindepth 3 \ |
17 |
> -maxdepth 3 \ |
18 |
> -name 'metadata.xml' \ |
19 |
> -exec sh -c " |
20 |
> for f in \"\${@}\"; do |
21 |
> xmllint --xpath \"${XPATH}\" \"\${f}\" >/dev/null 2>&1 && \ |
22 |
> echo \"\$(dirname -- \"\${f}\")\" | sed \"s:${REPO%/}/::\" |
23 |
> done |
24 |
> " - {} + |
25 |
> |
26 |
|
27 |
We can instead avoid parsing XML at all if we're not averse to using |
28 |
`pquery`, and we can avoid the limitation of scanning the entire tree |
29 |
for a single name/email by outputting the maintainers for all of the |
30 |
problematic packages at once (in this case, packages output by |
31 |
`gpy-py2`) in a greppable format. Not sure why pquery doesn't see |
32 |
maintainers for things like automake:1.9, so this implementation is |
33 |
imperfect, but here: |
34 |
|
35 |
REPO=/var/db/repos/gentoo |
36 |
|
37 |
for pkg in $(gpy-py2 -r "${REPO}"); do |
38 |
maint=$(pquery ${pkg} --one-attr maintainers | tail -1) |
39 |
if [[ ${maint} ]]; then |
40 |
echo "${pkg}: ${maint}" |
41 |
else |
42 |
echo "${pkg}: maintainer-needed" |
43 |
fi |
44 |
done |