[devel] rpmsoname: unmapped and multimapped sonames
Alexey Tourbin
=?iso-8859-1?q?at_=CE=C1_altlinux=2Eru?=
Сб Апр 15 02:42:33 MSD 2006
Некоторые пакеты предоставляют (provides) нечто похожее на soname'ы;
в таком случае должен существовать более или менее очевидный способ
сопоставления soname'а и соответствующего файла внутри пакета. Если
же не удается по soname'у определить файл, который этот soname
предоставляет, это может говорить об ошибке.
Уточнения: 1) basename у файла должен совпадать с soname'ом (это в
некотором смысле является необходимым и достаточным условием
использования разделяемой библиотеки); 2) симлинки должны разрешаться
в пределах пакета.
Вот список пакетов с потенциальными ошибками.
at на mash ~ $ time CMDCACHE_DISABLE=1 rpmsoname ~sisyphus/files/i586/RPMS >/dev/null
warning: ananas-engine-qt-0.9.2-alt1.i586.rpm: multimapped sonames:
libananasplugin.so /usr/lib/libananasplugin.so
libananasplugin.so /usr/lib/qt3/plugins/designer/libananasplugin.so
warning: bzlib-devel-1.0.3-alt5.i586.rpm: unmapped sonames:
libbz2.so
warning: jpilot-Mail-0.0.6-alt4.i586.rpm: unmapped sonames:
libmail.so.0
warning: libbluez-2.25-alt1.i586.rpm: unmapped sonames:
libsdp.so.2
warning: libx264-devel-0.0-alt0.20060330.2.i586.rpm: unmapped sonames:
libx264.so
warning: linuxsampler-0.3.3-alt1.i586.rpm: unmapped sonames:
liblinuxsampler.so.0
warning: unixODBC-2.2.11-alt2.1.i586.rpm: unmapped sonames:
libodbc.so
libodbcinst.so
CMDCACHE_DISABLE=1 rpmsoname ~sisyphus/files/i586/RPMS > /dev/null 425.70s user 84.80s system 93% cpu 9:05.14 total
at на mash ~ $
(Далее приложен собственно скрипт.)
----------- следующая часть -----------
#!/bin/sh -ef
export LC_ALL=C
rpmsoname()
{
rpm -qp --qf '[%{PROVIDES}\n]' "$1" >prov || return
grep -E '^lib[^/()]+[.]so\>[^/()]*$' prov >sonames || return 0
# Files map to themselves; symbolic links cause a headache.
# Sample file entry: perl5.8.7 /usr/bin/perl5.8.7
# Sample link etnry: libperl.so.5.8 /usr/lib/libperl.so.5.8 libperl.so.5.8.7
rpm -qp --qf '[%{BASENAMES}\t%{FILENAMES}\t%{FILELINKTOS}\n]' "$1" >list
awk -F'\t' '$NF==""{print$1"\t"$2}$NF{print>"/dev/fd/3"}' list >files 3>links
# Make links absolute. Sample diff:
# -perl5 /usr/bin/perl5 perl5.8.7
# +perl5 /usr/bin/perl5 /usr/bin/perl5.8.7
perl -MFile::Spec::Functions=rel2abs -MFile::Basename=dirname -ni -aF'\t' -le \
'$F[-1]=rel2abs$F[-1],dirname$F[-2];{$F[-1]=~s$/[^/]+/\.\./$/$&&redo}$,="\t",print на F' links
# Now follow links (i.e. a->b,b->c => a->c,b->c). Sample diff:
# -libpri.so /usr/lib/libpri.so /usr/lib/libpri.so.1
# +libpri.so /usr/lib/libpri.so /usr/lib/libpri.so.1.0
# libpri.so.1 /usr/lib/libpri.so.1 /usr/lib/libpri.so.1.0
while :; do
sort -t$'\t' -o links1 -k3,3 links
sort -t$'\t' -o links2 -k2,2 links
join -t$'\t' -13 -22 -o '1.1 1.2 2.3' links1 links2 >elinks
[ -s elinks ] || break
sort -t$'\t' -o links -u -k1,2 elinks links
done
# Join links against files.
sort -t$'\t' -o files -k2 files
sort -t$'\t' -o links -k3 links
join -t$'\t' -12 -23 -o '2.1 2.3' files links >filelinks
join -t$'\t' -12 -23 -o '2.1 2.3' -v2 files links >externlinks
# Now ready to join sonames on files+filelinks.
sort -o sonames -u sonames
sort -o map -u files filelinks
join -t$'\t' -j 1 -o '2.1 2.2' sonames map >mapped
join -t$'\t' -j 1 -o 0 -v1 sonames map >unmapped
# The results.
awk -F'\t' '{print$2"\t"$1}' mapped |sort -u
# Now warnings.
join -t$'\t' -j 1 -o '1.1 1.2 2.2' mapped mapped |awk -F'\t' \
'$2!=$3{print$1"\t"$2}' >multimapped
if [ -s multimapped ]; then
echo "warning: ${1##*/}: multimapped sonames:"
sort -u multimapped
fi >&2
if [ -s unmapped ]; then
echo "warning: ${1##*/}: unmapped sonames:"
# TODO: extra analysis based on externlinks
sort -u unmapped
fi >&2
}
. cmdcache ""
. rpmargs -c "cmdcache rpmsoname" "$@"
: <<'__EOF__'
=head1 NAME
rpmsoname - list files that provide sonames in RPM package(s)
=head1 SYNOPSIS
B<rpmsoname> [B<-h>] [I<options>] [I<FILE>...] [I<DIR>...]
=head1 DESCRIPTION
B<rpmsoname> produces two-column output (typically one line per each soname).
Column one contains file path; column two contains corresponding soname.
When processing a directory, an additional column is prepended to the
output, which is typically RPM file basename.
Note that the name B<rpmsoname> is probably a misnomer: the script does not
deal with ELF C<DT_SONAME> entries. What it does is try to map soname-like
entries from RPM C<PROVIDES> list to regular files within the very same RPM
package (using C<BASENAMES>, C<FILENAMES>, and C<FILELINKTOS> lists from RPM
header).
=head1 OPTIONS
Options and arguments manage a set of RPM packages to be processed;
they are those of rpmargs(1).
=head1 AUTHOR
Written by Alexey Tourbin <at на altlinux.org>.
=head1 COPYING
Copyright (c) 2006 Alexey Tourbin, ALT Linux Team.
This is free software; you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later version.
=head1 SEE ALSO
rpmargs(1)
=cut
__EOF__
----------- следующая часть -----------
Было удалено вложение не в текстовом формате...
Имя : =?iso-8859-1?q?=CF=D4=D3=D5=D4=D3=D4=D7=D5=C5=D4?=
Тип : application/pgp-signature
Размер : 189 байтов
Описание: =?iso-8859-1?q?=CF=D4=D3=D5=D4=D3=D4=D7=D5=C5=D4?=
Url : <http://lists.altlinux.org/pipermail/devel/attachments/20060415/386785e2/attachment-0001.bin>
Подробная информация о списке рассылки Devel