-
Notifications
You must be signed in to change notification settings - Fork 2
/
repo-report
executable file
·163 lines (139 loc) · 4.61 KB
/
repo-report
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/usr/local/bin/bash
report_home=/home/blub
report_db="${report_home}/dep.all.gz"
report_db_small="${report_home}/dep.small.gz"
report_db2="${report_home}/unstable.dep.gz"
report_db2_small="${report_home}/unstable.dep.small.gz"
repos=(testing linux multilib extra community core)
repos2=(unstable)
repo_root=/home/amzo/public_ftp
www_root=/home/blub/public_www/repo-report
depdb='rr-update-repo'
ircpath="/home/blub/ircbot/irc/irc.freenode.net/#archbsd"
www_url="http://users.archbsd.net/~blub/repo-report"
source /etc/repo-report.conf
dbfull="${report_db}"
dbsmall="${report_db_small}"
db2full="${report_db2}"
db2small="${report_db2_small}"
lockfile=${report_home}/.repo-report.lck
if [[ "$1" != "go" ]]; then
if ! lockf -t0 "${lockfile}" "$0" go "$@"; then
echo "Lock file exists. If you are sure that no other report is running, remove ${lockfile}"
exit 1
fi
exit 0
else
shift
fi
die() {
printf "=> $1" "$@" >&2
exit 1
}
announce=0
quick=no
subdir=$(date -v-1d '+%Y-%m-%d')
while (( $# > 0 )); do
case "$1" in
-v) announce=1 ;;
-r?*)
arg=${1#-r}
repos=(${arg})
;;
-r)
if (( $# < 2 )); then
echo "-r option needs a parameter"
exit 1
fi
shift
repos=($1)
;;
quick)
quick=yes
subdir=$(date '+%Y-%m-%d')
;;
today)
subdir=$(date '+%Y-%m-%d')
;;
esac
shift
done
if (( announce )); then
echo "==> [repo-report] user-requested repo-report started..." \
>> "$ircpath/in"
fi
www="${www_root}/$subdir"
part2=0
mkdir -p "$www"
rm -f "$www"/{depdb_output,broken,verbose,full,info,broken_quiet,integrity,integ_{libraries{,_verbose},packages}}.txt
rm -f "$www"/{dep,dep.unstable,full}.db.gz
rm -f "$www"/{need-libstdc++{,_quiet},json.broken}.txt
rm -rf "${www}/unstable"
if [[ $quick != yes ]]; then
for i in "${repos[@]}"; do
cd "${repo_root}/$i/os/x86_64" || die "failed to cd into ${repo_root}/$i/os/x86_64"
echo "Running $depdb for $i" >&2
echo "Running $depdb for $i" >> "${www}/depdb_output.txt"
$depdb "${dbfull}" &>> "${www}/depdb_output.txt"
echo "" >> "${www}/depdb_output.txt"
done
# 2nd repository
if cp "${dbfull}" "${db2full}"; then
part2=1
for i in "${repos2[@]}"; do
if ! cd "${repo_root}/$i/os/x86_64" 2>/dev/null ; then
echo "No such repository: $i - skipping part 2" >> "${www}/depdb_output.txt"
part2=0
break
fi
# Add the part for 'unstable' here...
echo "Running $depdb for $i" >&2
echo "Running $depdb for $i" >> "${www}/depdb_output.txt"
$depdb "${db2full}" &>> "${www}/depdb_output.txt"
echo "" >> "${www}/depdb_output.txt"
done
fi
fi
cd "${www}" || die "failed to change into directory ${www}"
createinfo() {
local www="$1"; shift
pkgdepdb $@ -Ivv > "$www/info.txt"
pkgdepdb $@ -Pb > "$www/broken.txt"
pkgdepdb $@ -Pbq | sort > "$www/broken_quiet.txt"
pkgdepdb $@ -Pbv > "$www/verbose.txt"
pkgdepdb $@ -Pbvv > "$www/full.txt"
pkgdepdb $@ -Pqv '-fpkglibdepends:libstdc++*' '-flibdepends:libstdc++*' > "$www/need-libstdc++.txt"
pkgdepdb $@ --json=q -Pbvvvq > "$www/json.broken.txt"
}
createinteg() {
local www="$1"; shift
pkgdepdb $@ -qvj1 --integrity > "$www/integrity.txt"
}
echo "filling $www" >> "${www}/depdb_output.txt"
cp "${dbfull}" "${dbsmall}"
pkgdepdb -d "${dbsmall}" --rm-files
createinfo "${www}" -d "${dbsmall}"
createinteg "${www}" -d "${dbfull}"
cp "${dbfull}" "${www}/full.db.gz"
cp "${dbsmall}" "${www}/dep.db.gz"
if (( $part2 )); then
echo "unstable part..." >> "${www}/depdb_output.txt"
mkdir -p "${www}/unstable"
cp "${db2full}" "${db2small}"
pkgdepdb -d "${db2small}" --rm-files
createinfo "${www}/unstable" -d "${db2small}"
createinteg "${www}/unstable" -d "${db2full}"
cp "${db2full}" "${www}/full.unstable.db.gz"
cp "${db2small}" "${www}/dep.unstable.db.gz"
fi
broken=$(wc -l "$www/broken_quiet.txt" | awk '{ print $1 }')
integ=$(grep -o '^[^:]*' "$www/integrity.txt" | sort | uniq | wc -l | awk '{ print $1 }')
fileconf=$(grep ' packages contain file: ' "$www/integrity.txt" | wc -l | awk '{ print $1 }')
grep '^[^ ]' "$www/need-libstdc++.txt" > "$www/need-libstdc++_quiet.txt"
gxxdep=$(cat "$www/need-libstdc++_quiet.txt" | wc -l | awk '{ print $1 }')
grep '^missing package:' "$www/integrity.txt" | sort | uniq > "$www/integ_packages.txt"
grep ': doesn'\''t pull in ' "$www/integrity.txt" > "$www/integ_libraries.txt"
grep ': doesn'\''t pull in \| not pulled in for ' "$www/integrity.txt" > "$www/integ_libraries_verbose.txt"
ln -shf "${subdir}" "${www_root}/current"
echo "==> [repo-report] finished: [broken:${broken}] [depend-issues:${integ}] [file-conflicts:${fileconf}] [libstdc++ linked:${gxxdep}]), check: $www_url/$subdir" \
>> "$ircpath/in"