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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
#!/bin/bash
mirror_base='/srv/arch-mirror/arch/arch/merged'
if [ ! -f '/tmp/packages' ]; then
packages=$(
ssh -p 22222 makepkg@141.35.51.219 '
find -L "'"${mirror_base}"'" \
-path '"'"'*testing/os/x86_64'"'"' \
-prune \
, \
-name '"'"'*staging'"'"' \
-prune \
, \
-name '"'"'any'"'"' \
-prune \
, \
-name '"'"'*.db.tar.gz'"'"' \
-printf '"'"'%%DBNAME%%\n%p\n\n'"'"' \
-exec bsdtar -Oxf {} \; 2>/dev/null
' \
| sed -n '
/^%\(DBNAME\|NAME\|VERSION\|DEPENDS\|PROVIDES\)%$/,/^$/p
' \
| sed '
/^%NAME%$/ i %DUMP%
$ a %DUMP%
' \
| while read -r line; do
if [ "${line}" = '%DBNAME%' ]; then
read -r dbname
read -r dummy
if [ -n "${dummy}" ]; then
>&2 printf 'Syntax error: %s\n' "${line}"
exit 1
fi
continue
fi
if [ "${line}" = '%NAME%' ]; then
read -r name
read -r dummy
if [ -n "${dummy}" ]; then
>&2 printf 'Syntax error: %s\n' "${line}"
exit 1
fi
continue
fi
if [ "${line}" = '%VERSION%' ]; then
read -r version
read -r dummy
if [ -n "${dummy}" ]; then
>&2 printf 'Syntax error: %s\n' "${line}"
exit 1
fi
continue
fi
if [ "${line}" = '%PROVIDES%' ]; then
while read -r provides; do
if [ -z "${provides}" ]; then
break
fi
printf 'provides %s %s %s %s\n' \
"${dbname}" \
"${name}" \
"${version}" \
"${provides}"
done
continue
fi
if [ "${line}" = '%DEPENDS%' ]; then
while read -r depends; do
if [ -z "${depends}" ]; then
break
fi
printf 'depends %s %s %s %s\n' \
"${dbname}" \
"${name}" \
"${version}" \
"${depends}"
done
continue
fi
if [ "${line}" = '%DUMP%' ]; then
if [ -n "${name}" ]; then
printf 'provides %s %s %s %s=%s\n' \
"${dbname}" \
"${name}" \
"${version}" \
"${name}" \
"${version}"
fi
continue
fi
>&2 printf 'Syntax error: %s\n' "${line}"
exit 1
done \
| sed '
s/\([<>=]\S\+\)-\S\+$/\1/
'
)
printf '%s\n' "${packages}" > /tmp/packages
else
packages=$(cat /tmp/packages)
fi
packages=$(
printf '%s\n' "${packages}" \
| sed '
s,^\(\S\+ \)\S\+/\([^/[:space:]]\+\)/\([^/[:space:]]\+\)\.db\.tar\.gz ,\1\2 \3 ,
s/\([<=>]\S\+\)\?$/ \1/
' \
| sed '
s/ $/ X X/
t
s/\([<>]=\)\(\S\+\)$/\1 \2/
t
s/\([<>=]\)\(\S\+\)$/\1 \2/
t
w /dev/stderr
'
)
matched_dependencies=$(
join -1 1 -2 3 -o 1.1,2.1,2.2,2.5,1.3,2.4,1.2 <(
printf '%s\n' "${packages}" \
| sed -n '
s/^provides \(\S\+\) \(\S\+ \)\{3\}/\1:/
T
p
' \
| sort -k1,1
# arch:install_target [=X] required_version
) <(
printf '%s\n' "${packages}" \
| sed -n '
s/^depends \(\S\+\) archlinuxewe \(\S\+\) \(\S\+\) /\2 \3 \1:/
T
p
' \
| sort -k3,3
# provider_name provider_version arch:install_target version_comparison provided_version
)
)
# arch:install_target depender_name depender_version required_version
# provided_version required_version_comparison provided_version_comparison
version_comparisons=$(
printf '%s\n' "${matched_dependencies}" \
| grep -v ' X\( \S\+\)\?$' \
| cut -d' ' -f4,5 \
| sort -u
)
# required_version provided_version
version_comparisons=$(
join -j 1 -o 1.2,2.2,2.3 \
<(
printf '%s\n' "${version_comparisons}" \
| tr ' ' '\n' \
| parallel -j100 -L2 vercmp \
| cat -n
) <(
printf '%s\n' "${version_comparisons}" \
| cat -n
) \
| sed '
s/ \(\S\+\) \(\S\+\)$/ \1<->\2/
' \
| sed '
s/^-\S\+ /-1 /
t
/^0 /b
s/^\S\+ /1 /
'
)
# (-1|0|1) required_version<->provided_version
version_comparisons=$(
{
join -1 4 -2 2 <(
printf '%s\n' "${matched_dependencies}" \
| sed '
s/ \(\S\+\) \(\S\+ \S\+ \S\+\)$/ \1<->\2/
' \
| sort -k4,4
) <(
printf '%s\n' "${version_comparisons}" \
| sort -k2,2
) \
| grep ' >=\? \S\+ -1$\| [<>]\?= \S\+ 0$\| <=\? \S\+ 1$' \
| sed '
s/^\(\S\+\)<->\S\+ /\1 /
' \
| awk '{print $2" "$3" "$4" "$1" "$5}'
printf '%s\n' "${matched_dependencies}" \
| grep ' X\( \S\+\)\?$' \
| awk '{print $1" "$2" "$3" "$4" "$6}'
}
)
# arch:install_target depender_name depender_version required_version required_version_comparison
{
printf '%s\n' "${matched_dependencies}" \
| awk '{print $1" "$2" "$3" "$4" "$6}'
printf '%s\n' "${version_comparisons}" \
| sed p
} \
| sort \
| uniq -u \
| sed 's/^\(\S\+\):\(\S\+\) /\1 \2 /' \
| while read -r arch install_target depender_name depender_version required_version required_version_comparison; do
printf '%s %s (%s) needs %s' \
"${depender_name}" \
"${depender_version}" \
"${arch}" \
"${install_target}"
if [ "${required_version_comparison}" != 'X' ]; then
printf '%s%s' \
"${required_version_comparison}" \
"${required_version}"
fi
printf '\n'
done \
| sort
|