blob: ff4247c6e1741bfc39cc53bd669e020c93aeda50 (
plain)
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
|
#!/bin/sh
# clean up unnecessary data
# shellcheck source=conf/default.conf
. "${0%/*}/../conf/default.conf"
# we only clean if run interactive or if no one is logged in
if ! tty -s && \
[ -n "$(users)" ]; then
>&2 echo 'Skipping clean up.'
exit
fi
if [ -s "${work_dir}/build-master-sanity" ]; then
>&2 echo 'Build master is not sane.'
exit
fi
# remove blocked/broken/locked markes of packages not on the buildlist anymore
{
find "${work_dir}/package-states" -maxdepth 1 \( -name '*.broken' -o -name '*.locked' -o -name '*.blocked' \) -printf '%f\n' | \
sed '
s|^\(.*\)\.\([^.]\+\)\.\([^.]\+\)\.\([^.]\+\)\.\([^.]\+\)$|state \0 \1 \2 \3 \4 \5|
'
awk '{
print "order " $1 "." $2 "." $3 "." $4 " " $1 " " $2 " " $3 " " $4 " broken"
print "order " $1 "." $2 "." $3 "." $4 " " $1 " " $2 " " $3 " " $4 " blocked"
print "order " $1 "." $2 "." $3 "." $4 " " $1 " " $2 " " $3 " " $4 " locked"
}' "${work_dir}/build-list"
} | \
sort -k3 | \
uniq -uf2 | \
grep '^state ' | \
awk '{print $2}' | \
sed "s|^|${work_dir}/package-states/|" | \
xargs -rn1 rm
# remove logs where package is not broken/locked anymore
{
find "${build_log_directory}/error" -maxdepth 1 -type f -printf '1 %f %f\n' | \
sed 's|\.[^. ]\+\.build-log\.gz$||'
find "${work_dir}/package-states" -maxdepth 1 \( \
-name '*.broken' -o \
-name '*.done' -o \
-name '*.locked' -o \
-name '*.testing' \
\) -printf '0 0 %f\n' | \
sed 's|\.[^.]\+$||'
} | \
sort -k3,3 -k1,2 | \
uniq --group=prepend -f2 | \
while read -r num file _; do
if [ "${num}" = '0' ]; then
while read -r line; do
if [ -z "${line}" ]; then
break
fi
done
continue
fi
if [ -z "${num}${file}" ]; then
continue
fi
rm -f "${build_log_directory}/error/${file}"
done
# only keep 10 newest logs per failed package
find "${build_log_directory}/error" -maxdepth 1 -type f -printf '%f\n' | \
sed 's|^\(.*\)\(\.\([^.]\+\)\.build-log\.gz\)$|\1\2 \3 \1|' | \
sort -k3,3 -k2r,2 | \
uniq -f2 --group=prepend | \
cut -d' ' -f1 | \
{
count=0
while read -r a; do
if [ -z "${a}" ]; then
count=0
continue
fi
if [ ${count} -ge 10 ]; then
rm "${build_log_directory}/error/${a}"
fi
count=$((count+1))
done
}
# only keep last 50 lines of ssh-log
tail -n50 "${work_dir}/ssh-log" | \
sponge "${work_dir}/ssh-log"
# only keep namcap logs of last 2 weeks for succeeded packages
find "${build_log_directory}/success" -maxdepth 1 -type f -mtime +14 \
-not -exec zgrep -q '^+.*ELF file .* has text relocations' '{}' \; \
-delete
# remove old package meta data
delete_old_metadata
|