Skip to content

Commit

Permalink
Merge branch 'morten/fixup-comaintainers'
Browse files Browse the repository at this point in the history
Foxboron committed Nov 1, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents f3bb144 + 0f950c8 commit 8203f35
Showing 3 changed files with 85 additions and 71 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ TAG = $(shell git describe --abbrev=0 --tags)
SCRIPTS = \
admin/checkservices \
aur/review \
package/co-maintainers \
package/pkgsearch \
package/staging2testing \
security/security-tracker-check \
package/cleanup-list.py \
70 changes: 0 additions & 70 deletions package/co-maintainers

This file was deleted.

84 changes: 84 additions & 0 deletions package/pkgsearch
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/bin/bash

# SPDX-License-Identifier: GPL-2.0

set -o errexit
shopt -s extglob

help(){
cat << EOF
Usage:
$PROGRAM
Flags:
-m [maintainer] find packages from maintainer
-q local packages
-s print the package maintainers
-l [limit] co-maintainer limit to filter on default: 1
-f [repository] filter on repository, Default: core extra multilib community
-o list flagged packages
-n use pkgname instead of pkgbase (not recommended as we sort away split pkgs)
-h help messages
Example:
Packages from a maintainer with 2 maintainers
$ pkgsearch -m Foxboron -l 2
Orphaned packages in [extra]
$ pkgsearch -f extra -l 0 -m orphan
Packages installed on the system from [core] with 1 maintainer
$ pkgsearch -q -f core -l 1
Locally installed packages from [community], orphaned, and flagged out-of-date
$ pkgsearch -q -f community -l 0 -m orphan -o
EOF
}


limit_maintainers=1
see_maintainers=0
out_of_date=""
name=".pkgbase"
filter=()

while true; do
case "$1" in
-m) shift; maintainer_query="maintainer=$1" ;;
-q) local_packages=1;;
-s) see_maintainers=1;;
-l) shift; limit_maintainers=$1;;
-f) shift; filter+=("${1,,}");;
-o) out_of_date="Flagged";;
-n) name=".pkgname";;
-h) help;;
"") break;;
esac
shift
done

find_packages(){
test ${#filter} -eq 0 && filter=(core extra community multilib)
if ((local_packages)); then
# shellcheck disable=SC2046
expac -S "%r %a %n %e" $(expac %n) | grep -P "^($(tr ' ' '|' <<< "${filter[*]}")) "
else
filter=("${filter[@]^}") # Uppercase the repo names
filter=("${filter[@]/#/&repo=}") # Prepend &repo= to all elements
query="?${maintainer_query}$(printf "%s" "${filter[@]}")&flagged=$out_of_date"
curl -s "https://www.archlinux.org/packages/search/json/$query" \
| jq -r '.results[] | "\(.repo) \(.arch) \(.pkgname) \(.pkgbase)"' | sort | uniq
fi
}

while read -r repo arch pkg _; do
# shellcheck disable=SC2016
format="select(.maintainers | length == \$LIMIT) | \"\(${name})\""
if ((see_maintainers)); then
# shellcheck disable=SC2016
format="select(.maintainers | length == \$LIMIT) | \"\(${name})\", (.maintainers | join(\" \"))"
fi
curl -s "https://www.archlinux.org/packages/$repo/$arch/$pkg/json/" | \
jq -r --argjson LIMIT "$limit_maintainers" "$format"
done <<< "$(find_packages | sort -u -k4,4)"

0 comments on commit 8203f35

Please sign in to comment.