On Thu, Jun 25, 2020 at 07:32:04AM -0400, Michael Orlitzky wrote:
> On 2020-06-24 16:08, Michał Górny wrote:
> > 
> > $ git grep -l mgo...@gentoo.org '**/metadata.xml' | cut -d/ -f1-2 |
> > xargs gpy-py2 2>/dev/null
> > 
> 
> The big problem with this is that it misses any aliases (like graphics@)
> that you're a member of. But let's golf; this is POSIX sh, doesn't use
> grep to parse XML, and takes the maintainer's email address as an argument:
> 
> REPO=/var/db/repos/gentoo
> XPATH="/pkgmetadata/maintainer/email[normalize-space(text()) = '${1}']"
> 
> find -L "${REPO}" \
>   -mindepth 3 \
>   -maxdepth 3 \
>   -name 'metadata.xml' \
>   -exec sh -c "
>     for f in \"\${@}\"; do
>       xmllint --xpath \"${XPATH}\" \"\${f}\" >/dev/null 2>&1 && \
>         echo \"\$(dirname -- \"\${f}\")\" | sed \"s:${REPO%/}/::\"
>     done
>   " - {} +
> 

We can instead avoid parsing XML at all if we're not averse to using
`pquery`, and we can avoid the limitation of scanning the entire tree
for a single name/email by outputting the maintainers for all of the
problematic packages at once (in this case, packages output by
`gpy-py2`) in a greppable format. Not sure why pquery doesn't see
maintainers for things like automake:1.9, so this implementation is
imperfect, but here:

REPO=/var/db/repos/gentoo

for pkg in $(gpy-py2 -r "${REPO}"); do
        maint=$(pquery ${pkg} --one-attr maintainers | tail -1)
        if [[ ${maint} ]]; then
                echo "${pkg}: ${maint}"
        else
                echo "${pkg}: maintainer-needed"
        fi
done

Attachment: signature.asc
Description: PGP signature

Reply via email to