-
Notifications
You must be signed in to change notification settings - Fork 0
/
repodiff
executable file
·74 lines (61 loc) · 1.48 KB
/
repodiff
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
#!/bin/sh
REPO_BASE="${REPO_BASE:-/srv/repository/leste}"
usage() {
cat <<EOF >&2
usage: $(basename "$0") [-v] [repo1] [repo2]
-v show package versions
-m list packages in repo2 but missing from repo1
Environment:
REPO_BASE: path to repo base (default: $REPO_BASE)
Output:
>foo : package is newer in repo1
<foo : package is newer in repo2
EOF
exit 1
}
for i in $@; do
case "$1" in
-v)
vflag=1
shift
;;
-m)
mflag=1
shift
;;
-*)
usage
;;
esac
done
if [ -z "$1" ] || [ -z "$2" ]; then
usage
fi
# Use tempfiles because it's cleaner, and no need for bashism
l1="$(mktemp XXXX.txt)"
l2="$(mktemp XXXX.txt)"
if ! [ "$mflag" = 1 ]; then
reprepro -b "$REPO_BASE" list "$1" | cut -d' ' -f2- | sort | uniq > "$l1" || exit 1
reprepro -b "$REPO_BASE" list "$2" | cut -d' ' -f2- | sort | uniq > "$l2" || exit 1
join --nocheck-order "$l1" "$l2" | while read -r package firstver secondver; do
if dpkg --compare-versions "$firstver" lt "$secondver"; then
if [ -n "$vflag" ]; then
echo "<$package $firstver < $secondver"
else
echo "<$package"
fi
else
if [ -n "$vflag" ]; then
echo ">$package $firstver > $secondver"
else
echo ">$package"
fi
fi
done
fi
if [ "$mflag" = 1 ]; then
reprepro -b "$REPO_BASE" list "$1" | cut -d' ' -f2 | sort -u > "$l1" || exit 1
reprepro -b "$REPO_BASE" list "$2" | cut -d' ' -f2 | sort -u > "$l2" || exit 1
diff --new-line-format="" --unchanged-line-format="" "$l1" "$l2"
fi
rm -f "$l1" "$l2"