-
Notifications
You must be signed in to change notification settings - Fork 3
/
diff_repo
executable file
·97 lines (78 loc) · 2.15 KB
/
diff_repo
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
#!/bin/bash
set -e
manifest=$1
branch=$2
repofile=${3:-default}
usage() {
cat <<EOF >&2
$(basename $BASH_SOURCE) <manifest file> <branch> [repofile=default]
Examples:
$(basename $BASH_SOURCE) master/agl.manifest master
$(basename $BASH_SOURCE) koi/agl.manifest koi
$(basename $BASH_SOURCE) lamprey/agl.manifest lamprey
EOF
exit 1
}
[[ ! -f $manifest ]] && usage
[[ -z "$branch" ]] && usage
URL="https://git.automotivelinux.org/AGL/AGL-repo/plain/${repofile}.xml?h=${branch}"
#URL="https://gerrit.automotivelinux.org/gerrit/gitweb?p=AGL/AGL-repo.git;a=blob_plain;f=${1:-default}.xml;hb=HEAD"
tmpout=$(mktemp /tmp/$(basename $0).XXXXXXXX)
trap "rm -f $tmpout" STOP INT QUIT EXIT ERR
function info() { echo "$@" >&2; }
info "Using repo URL: $URL"
curl -s "$URL" >$tmpout
declare -A repo
while read a b c; do
ref=$(echo $a | cut -f1 -d'=')
layer=$(basename $b)
repo[$layer]=$ref
done < <($(dirname $0)/repo2manifest $tmpout)
info "Repo: ${#repo[@]} layers loaded"
#for x in ${!repo[@]}; do
# echo $x=${repo[$x]}
#done
function parse_manifest() {
local manifest=$1
local layer
local ref
sed 's/#.*$//g' <$manifest | awk '/[^[:space:]]+/ { if ($1 == "@include") { for(i=2;i<=NF;i++) { print "INCLUDE " $i}; } else {print "DIR "$2; for(i=3;i<=NF;i++) { print "REPO "$i}; print "HASH "$1 } }' | while read tag value; do
case $tag in
DIR)
layer=$(basename $value)
;;
REPO)
name="${value%%=*}"
url="${value#*=}"
;;
HASH)
ref="${value%%=*}"
locbr="${value#*=}"
echo $layer $ref
;;
INCLUDE)
parse_manifest $(dirname $manifest)/$value
;;
esac
done
}
declare -A mani
info "Parsing manifest $manifest"
while read layer ref; do
mani[$layer]=$ref
done < <(parse_manifest $manifest)
info "Manifest: ${#mani[@]} layers loaded"
#for x in ${!mani[@]}; do
# echo $x=${mani[$x]}
#done
info "Differences between $manifest and $branch/$repofile.xml:"
info "-----------------------------"
cnt=0
for l in ${!mani[@]}; do
[[ "${mani[$l]}" != "${repo[$l]}" ]] && {
printf "%-30s %-30s %-30s\n" $l ${repo[$l]} "(was: ${mani[$l]})"
(( cnt++ ))
} || true
done
info "-----------------------------"
info "$cnt differences"