-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreqprov
executable file
·113 lines (99 loc) · 2.34 KB
/
reqprov
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
set -efu -o pipefail
shopt -s extglob
DIFF=colordiff
REPO=sisyphus
for opt do
shift
case "$opt" in
--evr=*) EVR=${opt#*=} ;;
--skip-debuginfo) SKIPDEBUGINFO=1 ;;
--skip-match=*) SKIPMATCH=${opt#*=} ;;
--skip-ver=*) SEDVER=${opt#*=} ;;
--strip=*) STRIP=${opt#*=} ;;
--diff=*) DIFF=${opt#*=} ;;
--repo=*) REPO=${opt#*=} ;;
--) break ;;
*) set -- "$@" "$opt";;
esac
done
gear_describe()
{
set -- $(gear --describe --commit 2>/dev/null)
NAME=$1
VERSION=$2
RELEASE=$3
}
gear_describe
if [ -v EVR ]; then
SRPM="$NAME-$EVR"
else
SRPM="$NAME-$VERSION-$RELEASE"
fi
eval "$(hsh --printenv | grep -e '^def_repo=' -e '^workdir=')"
cd "$def_repo/${def_target:-$(arch)}/RPMS.hasher"
list=()
for i in $(set +f; echo *.rpm); do
SOURCERPM=$(rpm -qp --qf '%{SOURCERPM}' "$i")
SRCNAME=${SOURCERPM%-*-*}
SRCVREL=${SOURCERPM%.*.*}
[ "$SRPM" = "$SRCVREL" ] || continue
list+=( "$i" )
done
if [ ${#list[@]} -eq 0 ]; then
echo >&2 "No matching $SRPM RPMs are found in $PWD, try setting --evr= or build locally."
exit 1
fi
tmp=$(mktemp -d) && trap "rm -rf $tmp" 0
export QUOTING_STYLE=shell-escape
sep=
if [ "$#" -eq 0 ]; then
SKIPDEBUGINFO=1
set -- --fileclass
echo "Default comparison is $* with --skip-debuginfo"
elif [ "$*" = "-P" ]; then
set -- --provides
fi
# Use --fileclass to compare file lists.
sed_things() {
local r=$1 t=$2
if [ -v SEDVER ]; then
sort -o "$t" "$t"
V=$(rpm -qp "$r" --qf '%{V}' | sed 's/\./\\./g')
R=$(rpm -qp "$r" --qf '%{R}' | sed 's/\./\\./g')
sed -Ei "s/($SEDVER-)?$V(-$SEDVER)?(-$R)?/VERSION-RELEASE/g" "$t"
fi
if [ -v SKIPMATCH ]; then
sed -Ei "\!$SKIPMATCH!d" "$t"
fi
if [ -v STRIP ]; then
sed -Ei "s!$STRIP!!g" $tmp/$t
fi
}
for i in "${list[@]}"; do
name=${i%-*-*}
printf "%s= %s =\n" "$sep" "$name"
if [ -v SKIPDEBUGINFO ] && [[ "$name" =~ debuginfo ]]; then
echo skipped
continue
fi
rpmvrel=${i%.*.*}
rpmarch=${i#"$rpmvrel"}
rpm -qp "$i" "$@" > $tmp/$i~
sed_things "$i" "$tmp/$i~"
touch -r "$i" $tmp/$i~
r=$(set +f; ls /ALT/$REPO/files/*/RPMS/$name-+([^-])-+([^-])$rpmarch 2>/dev/null ||:)
if [ -e "$r" ]; then
rr=$(basename $r)
rpm -qp "$r" "$@" > $tmp/$rr
sed_things "$r" "$tmp/$rr"
touch -r "$r" $tmp/$rr
else
rr=/dev/null
fi
(
cd $tmp
$DIFF -u "$rr" "$i~" | sed 's/^/\t/' || :
)
sep=$'\n'
done |& less