* [devel] rpmsoname: unmapped and multimapped sonames
@ 2006-04-14 22:42 Alexey Tourbin
0 siblings, 0 replies; only message in thread
From: Alexey Tourbin @ 2006-04-14 22:42 UTC (permalink / raw)
To: devel
[-- Attachment #1.1: Type: text/plain, Size: 1520 bytes --]
Некоторые пакеты предоставляют (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 ~ $
(Далее приложен собственно скрипт.)
[-- Attachment #1.2: rpmsoname --]
[-- Type: text/plain, Size: 3506 bytes --]
#!/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__
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-04-14 22:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-14 22:42 [devel] rpmsoname: unmapped and multimapped sonames Alexey Tourbin
ALT Linux Team development discussions
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
public-inbox-index devel
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://lore.altlinux.org/org.altlinux.lists.devel
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git