blob: 0204d21e5fdcb53a1bfa97b060c297d8188b415c (
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
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
#!/bin/sh
# shellcheck source=conf/default.conf
. "${0%/*}/../conf/default.conf"
if [ -s "${work_dir}/build-master-sanity" ]; then
>&2 echo 'Build master is not sane.'
exit 1
fi
tmp_dir=$(mktemp -d)
trap 'rm -rf --one-file-system "${tmp_dir}"' EXIT
grep -vxF 'break_loops' "${work_dir}/build-list" | \
sort -k1,1 -u > \
"${tmp_dir}/build-list"
while read -r pkg rev mod_rev repo; do
generate_package_metadata "${pkg}" "${rev}" "${mod_rev}" "${repo}"
done < \
"${tmp_dir}/build-list"
mkdir "${tmp_dir}/loops"
find "${work_dir}/build-list.loops" -maxdepth 1 | \
grep '/loop_[0-9]\+$' | \
while read -r loop; do
sort -u "${loop}" | \
join -j 1 - "${tmp_dir}/build-list" | \
tr ' ' '.' > \
"${tmp_dir}/loops/${loop##*/}"
done
touch "${tmp_dir}/dependent-count"
tr ' ' '.' < \
"${tmp_dir}/build-list" | \
sponge "${tmp_dir}/build-list"
sums=''
while [ -s "${tmp_dir}/build-list" ] && [ "${sums}" != "$(sha512sum "${tmp_dir}/dependent-count")" ]; do
sums=$(
sha512sum "${tmp_dir}/dependent-count"
)
(
sed 's|^|? |' "${tmp_dir}/build-list"
sed 'p' "${tmp_dir}/dependent-count"
) | \
sort -k2,2 | \
uniq -uf1 | \
cut -d' ' -f2 | \
sponge "${tmp_dir}/build-list"
sed '
s|^|'"${work_dir}"'/package-infos/|
s|$|.build-depends|
' "${tmp_dir}/build-list" | \
xargs -r grep -vx 'base\|base-devel' | \
sort -u > \
"${tmp_dir}/build-list.build-depends"
sed '
s|^\S\+ |'"${work_dir}"'/package-infos/|
s|$|.build-depends|
' "${tmp_dir}/dependent-count" | \
xargs -r grep -Hvx 'base\|base-devel' | \
sed '
s|^.*/||
s|\.build-depends:| |
' | \
sort -k2,2 > \
"${tmp_dir}/dependent-count.build-depends"
rm -f "${tmp_dir}/dependent-count.new"
touch "${tmp_dir}/dependent-count.new"
while read -r sf; do
if [ -n "$(
(
sort -u "${work_dir}/package-infos/${sf}.builds"
cat "${tmp_dir}/build-list.build-depends"
) | \
sort | \
uniq -d
)" ]; then
continue
fi
count="/$(
sort -u "${work_dir}/package-infos/${sf}.builds" | \
join -1 1 -2 2 -o 2.1 - "${tmp_dir}/dependent-count.build-depends" | \
sort -u | \
join -1 1 -2 2 -o 2.1,2.2 - "${tmp_dir}/dependent-count" | \
tr '/ ' '\n' | \
grep -vxF '' | \
sort -u | \
tr '\n' '/'
)"
printf '%s %s\n' \
"${count}" \
"${sf}" >> \
"${tmp_dir}/dependent-count.new"
find "${tmp_dir}/loops" -type f -maxdepth 1 \
-exec grep -qxF "${sf}" {} \; \
-exec rm {} \;
done < \
"${tmp_dir}/build-list"
find "${tmp_dir}/loops" -maxdepth 1 | \
while read -r loop; do
if [ ! -f "${loop}" ]; then
continue
fi
if [ -n "$(
(
sed '
s|^|'"${work_dir}"'/package-infos/|
s|$|.builds|
' "${loop}" | \
xargs -r cat | \
sort -u
(
sed 'p' "${loop}"
cat "${tmp_dir}/build-list"
) | \
sort | \
uniq -u | \
sed '
s|^|'"${work_dir}"'/package-infos/|
s|$|.build-depends|
' | \
xargs -r cat | \
grep -vx 'base\|base-devel' | \
sort -u
) | \
sort | \
uniq -d
)" ]; then
continue
fi
count="/$(
sed '
s|^|'"${work_dir}"'/package-infos/|
s|$|.builds|
' "${loop}" | \
xargs -r cat | \
sort -u | \
join -1 1 -2 2 -o 2.1 - "${tmp_dir}/dependent-count.build-depends" | \
sort -u | \
join -1 1 -2 2 -o 2.1,2.2 - "${tmp_dir}/dependent-count" | \
tr '/ ' '\n' | \
grep -vxF '' | \
sort -u | \
tr '\n' '/'
)"
while read -r sf; do
printf '%s %s\n' "${count}" "${sf}" >> \
"${tmp_dir}/dependent-count.new"
find "${tmp_dir}/loops" -maxdepth 1 -type f -not -name "${loop##*/}" \
-exec grep -qxF "${sf}" {} \; \
-exec rm {} \;
done < \
"${loop}"
rm "${loop}"
done
cat "${tmp_dir}/dependent-count" "${tmp_dir}/dependent-count.new" | \
sort -k2,2 | \
sponge "${tmp_dir}/dependent-count"
done
while read -r count pkg; do
count=$(
echo "${count}" | \
tr '/' '\n' | \
grep -cvxF ''
) || true
printf '%s %s\n' "${pkg}" "${count}"
done < \
"${tmp_dir}/dependent-count" | \
sponge "${work_dir}/dependent-count"
|