-
Notifications
You must be signed in to change notification settings - Fork 0
/
match-spec-maintainer
executable file
·43 lines (37 loc) · 1.34 KB
/
match-spec-maintainer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
# Find spec files with contents matching a perl-style regex and create a list
# of them along with their maintainers.
#
# Copyright © 2020–2024 Daniel Fandrich.
# This program is free software; you can redistribute it and/or modify
# Licensed under GNU General Public License 2.0 or later.
# Some rights reserved. See COPYING.
set -e
readonly SPEC_TREE="${SPEC_TREE:-.}"
readonly TMPFILE="$(mktemp)"
readonly TMP2FILE="$(mktemp)"
readonly TMP3FILE="$(mktemp)"
readonly MAINTFILE="$(mktemp)"
trap 'rm -f "${TMPFILE}" "${TMP2FILE}" "${TMP3FILE}" "${MAINTFILE}"' 0
# Source for the maintdb
readonly MAINTDB_URL='https://pkgsubmit.mageia.org/data/maintdb.txt'
# For consistent sorting
export LC_ALL=C
find "${SPEC_TREE}" -name '*.spec' -print0 | \
xargs -0 -n32 grep -lP "$1" | \
sed -e 's@^.*/@@' -e 's/\.spec$//' | \
sort -u > "${TMPFILE}"
wc -l < "${TMPFILE}" | tr -d '\n' 1>&2
echo ' matches' 1>&2
# Alternate, slower way to get the maintdb
#mgarepo maintdb get | sort -u > "${MAINTFILE}"
curl -f -s --compressed "$MAINTDB_URL" | sort -u > "${MAINTFILE}"
wc -l < "${MAINTFILE}" | tr -d '\n' 1>&2
echo ' packages' 1>&2
# Packages with maintainers
join "${TMPFILE}" "${MAINTFILE}" > "${TMP2FILE}"
awk '{print $1}' "${TMP2FILE}" > "${TMP3FILE}"
comm -23 "${TMPFILE}" "${TMP3FILE}" | \
sed 's/$/ ?/' | \
sort "${TMP2FILE}" - | \
tr ' ' '\t'