Skip to content

Commit 60bce78

Browse files
authored
Merge pull request #89 from archlinux/greposcope
Add greposcope: script for downloading and searching pattern in diffoscope output of unreproducible packages
2 parents 0095ad7 + 19e5709 commit 60bce78

File tree

2 files changed

+94
-1
lines changed

2 files changed

+94
-1
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ BASH_SCRIPTS = \
1010
package/parse-submodules \
1111
package/pkgsearch \
1212
package/rebuild-todo \
13-
package/pkggrep
13+
package/pkggrep \
14+
package/greposcope
1415

1516
PYTHON_SCRIPTS = \
1617
package/staging2testing \

package/greposcope

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/usr/bin/bash
2+
3+
# SPDX-License-Identifier: GPL-2.0
4+
5+
# Dependencies:
6+
# rebuilderd-tools
7+
# parallel
8+
9+
set -eou pipefail
10+
11+
progname="greposcope"
12+
tmp_dir="${TMPDIR:-/tmp}/${progname}-${UID}"
13+
rebuilderd_host="https://reproducible.archlinux.org"
14+
extra_grep_opt=""
15+
pattern=""
16+
17+
help() {
18+
cat <<EOF
19+
Usage: ${progname} [OPTIONS] pattern
20+
21+
Download and search for 'pattern' in diffoscope outputs of every unreproducible packages reported at ${rebuilderd_host}.
22+
This is useful to identify packages that are unreproducible because of a specific issue.
23+
24+
OPTIONS
25+
-h, --help Show this message
26+
-i, --ignore-case Ignore case distinctions in patterns and input data
27+
28+
Examples:
29+
$ ${progname} "gzip compressed data"
30+
$ ${progname} -i zipinfo
31+
EOF
32+
}
33+
34+
while ((${#})); do
35+
case "${1}" in
36+
-h|--help)
37+
help
38+
exit 0
39+
;;
40+
-i|--ignore-case)
41+
extra_grep_opt="--ignore-case"
42+
;;
43+
--)
44+
shift
45+
break
46+
;;
47+
-*)
48+
echo -e >&2 "Invalid argument -- '${1}'\nTry '${progname} --help' for more information"
49+
exit 1
50+
;;
51+
*)
52+
pattern="${1}"
53+
;;
54+
esac
55+
shift
56+
done
57+
58+
if [ -z "${pattern}" ]; then
59+
echo -e >&2 "No pattern provided\nTry '${progname} --help' for more information"
60+
exit 1
61+
fi
62+
63+
mkdir -p "${tmp_dir}"
64+
65+
echo -e "==> Fetching the list of unreproducible packages...\n"
66+
mapfile -t pkg_list < <(rebuildctl -H "${rebuilderd_host}" pkgs ls --status BAD | awk '{print $3}')
67+
68+
if ! (( ${#pkg_list[@]} )); then
69+
echo "==> No unreproducible packages found"
70+
exit 0
71+
fi
72+
73+
updated_pkg_list=()
74+
for pkg in "${pkg_list[@]}"; do
75+
if [ ! -f "${tmp_dir}/${pkg}.diffoscope" ]; then
76+
updated_pkg_list+=("${pkg}")
77+
fi
78+
done
79+
80+
pkg_list=("${updated_pkg_list[@]}")
81+
82+
if ! (( ${#pkg_list[@]} )); then
83+
echo "==> All diffoscope outputs are already downloaded"
84+
else
85+
echo -e "==> Downloading diffoscope outputs of ${#pkg_list[@]} unreproducible packages...\nThis may take some time...\n"
86+
parallel --bar -j "$(nproc)" \
87+
rebuildctl -H "${rebuilderd_host}" pkgs diffoscope --name {} "&>" "${tmp_dir}/{}.diffoscope" ::: "${pkg_list[@]}" || true
88+
fi
89+
90+
echo -e "\n==> Searching for \"${pattern}\" in diffoscope outputs...\n"
91+
parallel --silent -j "$(nproc)" \
92+
"grep --color=always --with-filename --line-number ${extra_grep_opt} '${pattern}' {}" ::: "${tmp_dir}"/*.diffoscope || true

0 commit comments

Comments
 (0)