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
|
#!/bin/sh
case $(hostname) in
'rechenknecht') # on the master mirror
tmp_dir=$(
readlink -e "/tmp/${0##*/}."* || \
mktemp -d "${0##*/}.XXXXXXXX" --tmpdir=/tmp
)
checksum=$(
sha512sum "$0" | \
awk '{print $1}'
)
cd "${tmp_dir}"
for pkgfile in /srv/arch-mirror/arch/arch/archlinux32/pool/*-i686.pkg.tar.xz; do
if [ -f "${pkgfile##*/}.so.needs" ]; then
continue
fi
mkdir x
bsdtar -xf "$pkgfile" -C x
find 'x' \
-name 'opt' -prune , \
-type f \
-exec objdump -x '{}' \; 2>/dev/null | \
sed '
/^architecture:.* i386:x86-64, /,/^architecture:.* i386:x86-32, / d
/\sNEEDED\s/ {
s/^\s*\S\+\s\+\(\S\+\)\(\s.*\)\?$/\1/
/\.c32$/d
s,^.*/,,
t
}
/^Version References:$/,/^$/ {
/^\s*required from / {
s/^\s*required from \(\S\+\):\s*$/'"${checksum}"'\1/
T end
h
d
}
s/^\s*\(0x[0-9a-fA-F]\+\)\s\+0x[0-9a-fA-F]\+\s\+[0-9]\+\s\+\(\S\+\)$/\2-\1/
T end
G
s/^\(\S\+\)\n'"${checksum}"'\(\S\+\)$/\2-\1/
t
}
:end
d
' | \
sort -u > \
"${pkgfile##*/}.so.needs"
sed -i '
/^\(libav.*\.so\)\.[0-9]\+$/ {
:a
N
s/^\(libav.*\.so\)\(\.[0-9]\+\)\?\n\1\.[0-9]\+$/\1/
t a
P
D
}
' "${pkgfile##*/}.so.needs"
find 'x' \
-name 'opt' -prune , \
\( -type f -o -type l \) \
-printf "${checksum}"'%f\n' \
-exec objdump -x '{}' \; 2>/dev/null | \
sed '
/^architecture:.* i386:x86-64, /,/^architecture:.* i386:x86-32, / d
/^'"${checksum}"'/ {
h
d
}
/\sSONAME\s/ {
s/^\s*\S\+\s\+\(\S\+\)\s.*$/\1/
t
}
/^Version definitions:$/,/^$/ {
s/^[0-9]\+\s\+0x[0-9a-fA-F]\+\s\+\(0x[0-9a-fA-F]\+\)\s\+\(\S\+\)$/\2-\1/
T end
G
s/^\(\S\+\)\n'"${checksum}"'\(\S\+\)$/\2-\1/
t
}
:end
d
' | \
sort -u >> \
"${pkgfile##*/}.so.provides"
rm -rf --one-file-system x
printf .
done
;;
'buildmaster.archlinux32.org') # on the buildmaster
base_dir=~/builder
. ~/builder/lib/load-configuration
mysql_load_min_and_max_versions
{
printf 'SET @link_dep_id = ('
printf 'SELECT `dependency_types`.`id`'
printf ' FROM `dependency_types`'
printf ' WHERE `dependency_types`.`name`="link"'
printf ');'
printf 'CREATE TEMPORARY TABLE `x` ('
printf '`it` VARCHAR(128),'
printf '`kind` VARCHAR(16),'
printf '`pkgname` VARCHAR(64),'
printf '`epoch` MEDIUMINT,'
printf '`pkgver` VARCHAR(64),'
printf '`pkgrel` MEDIUMINT,'
printf '`spr_total` VARCHAR(8),'
printf '`sub_pkgrel` MEDIUMINT,'
printf '`architecture` VARCHAR(4),'
printf 'UNIQUE KEY `content`(`it`,`kind`,`pkgname`,`epoch`,`pkgver`,`pkgrel`,`sub_pkgrel`,`architecture`)'
printf ');\n'
printf 'LOAD DATA LOCAL INFILE "%s" INTO TABLE `x`;\n' \
~/so-todos
printf 'INSERT IGNORE INTO `install_targets`(`name`) SELECT `x`.`it` FROM `x`;\n'
printf 'SELECT row_count();\n'
printf 'INSERT IGNORE INTO `install_target_providers`('
printf '`package`,'
printf '`install_target`,'
printf '`version`'
printf ') SELECT '
printf '`binary_packages`.`id`,'
printf '`install_targets`.`id`,'
printf '%s' \
"${min_version_id}"
printf ' FROM `x`'
printf ' JOIN `install_targets`'
printf ' ON `x`.`it`=`install_targets`.`name`'
printf ' AND `x`.`kind`="provides"'
printf ' JOIN `architectures`'
printf ' ON `x`.`architecture`=`architectures`.`name`'
mysql_join_architectures_binary_packages
printf ' AND `binary_packages`.`pkgname`=`x`.`pkgname`'
printf ' AND `binary_packages`.`epoch`=`x`.`epoch`'
printf ' AND `binary_packages`.`pkgver`=`x`.`pkgver`'
printf ' AND `binary_packages`.`pkgrel`=`x`.`pkgrel`'
printf ' AND `binary_packages`.`sub_pkgrel`=`x`.`sub_pkgrel`'
printf ' AND (`binary_packages`.`sub_pkgrel_omitted` = (`x`.`spr_total`=""));'
printf 'SELECT row_count();'
for version_info in \
"${min_version_id},\">=\"" \
"${max_version_id},\"<\""; do
printf 'INSERT IGNORE INTO `dependencies` ('
printf '`dependent`,'
printf '`depending_on`,'
printf '`dependency_type`,'
printf '`version`,'
printf '`version_relation`) SELECT '
printf '`binary_packages`.`id`,'
printf '`install_targets`.`id`,@link_dep_id,%s' \
"${version_info}"
printf ' FROM `x`'
printf ' JOIN `install_targets`'
printf ' ON `x`.`it`=`install_targets`.`name`'
printf ' AND `x`.`kind`="needs"'
printf ' JOIN `architectures` ON `x`.`architecture`=`architectures`.`name`'
mysql_join_architectures_binary_packages
printf ' AND `binary_packages`.`pkgname`=`x`.`pkgname`'
printf ' AND `binary_packages`.`epoch`=`x`.`epoch`'
printf ' AND `binary_packages`.`pkgver`=`x`.`pkgver`'
printf ' AND `binary_packages`.`pkgrel`=`x`.`pkgrel`'
printf ' AND `binary_packages`.`sub_pkgrel`=`x`.`sub_pkgrel`'
printf ' AND (`binary_packages`.`sub_pkgrel_omitted` = (`x`.`spr_total`=""));'
printf 'SELECT row_count();'
done
} | \
mysql buildmaster
;;
*) # on some intermediate box, e.g. on nlopc43
ssh rechenknecht '
cd /tmp/'"${0##*/}"'.*
ls | \
sed '"'"'
s/^\(\S\+\)-\(\([^-:]\+\):\)\?\([^-:]\+\)-\([^-.]\+\)\(\.\([0-9]\+\)\)\?-\([^-]\+\)\.pkg\.tar\.xz\.so\.\(needs\|provides\)$/\0 \9 \1 \3 \4 \5 \6 \7 \8/
t
d
'"'"' | \
while read -r f r; do
sed "
s/\$/ $r/
" "$f"
done' | \
pv --line-mode | \
tr ' ' '\t' | \
ssh buildmaster 'tee so-todos | wc -l'
;;
esac
|