[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

script: scan-libraries



A perl script to scan the dynamic libraries used in the system.  This is
useful for determining which dynamic libraries will be included in the
LSB, although the distribution of library use may be significantly
different for ISV and add-on binaries vs. distribution binaries.

The script is preceeded by the output of a run ("scan-libraries --chop")
on a Red Hat 6.0 system (with 628 RPMs installed).  The output from
other glibc 2.1 distributions would be useful.

Note: you want to run this as root in order to pick up binaries that are
not world readable for some odd reason.

------- start of cut text --------------
2048 dynamic binaries

/lib/ld-linux        2505
libc                 2048
libm                 812
libX11               517
libXext              445
libdl                273
libICE               270
libSM                267
libstdc++-libc6.1-1  185
libz                 175
libpbm               173
libcrypt             164
libdb                152
libglib-1.2          147
libkdecore           132
libqt                132
libpgm               128
libnsl               128
libgtk-1.2           127
libgdk-1.2           127
libgmodule-1.2       127
libkdeui             121
libaudiofile         119
libesd               119
libXt                114
libgnomesupport      111
libgnome             108
libppm               105
libgdk_imlib         103
libtermcap           102
libgnomeui           101
libart_lgpl          101
libncurses           91
libXmu               82
libXpm               78
libgdbm              72
libjpeg              72
libpng               68
libpam               66
libtiff              62
libresolv            57
libkfm               55
libORBitutil         52
libIIOP              52
libORBit             52
libXaw               51
libORBitCosNaming    51
libgnorba            47
libreadline          44
libpnm               42
libungif             41
libkfile             40
libpam_misc          36
libncp               31
libpisock            30
libpanel_applet      23
libutil              22
libctutils           20
libttf               20
libkimgio            20
libext2fs            19
libcom_err           19
libslang             19
libtcl8.0            18
libsnmp              14
libconsole           14
libmediatool         13
libcapplet           13
libbfd-2.9.1.0.23    12
libtk8.0             12
libproc              11
libgd                11
libpthread           11
libgtkxmhtml         10
libgtop              10
libhistory           10
libgtop_sysdeps      10
libgtop_common       10
libnewt              10
libPropList          9
libMagick            8
libXaw3d             8
libutempter          7
libImlib             7
libamu               7
libvga               7
libe2p               6
libkhtmlw            5
libjscript           5
libwraster           4
libpwdb              4
/lib/libNoVersion    4
libuuid              4
libcfont             4
libXtst              4
libguile             4
libform              3
libzvt               3
libmimelib           3
libkspell            3
libXi                3
libkab               3
libxml               3
libmd5               2
libwwwtrans          2
libwwwcore           2
libwwwftp            2
libwwwgopher         2
libFnlib             2
libgdkcardimage      2
libwwwcache          2
libwwwhtml           2
libxmltok            2
libwwwnews           2
libwwwtelnet         2
libwwwdir            2
librle               2
libghttp             2
libwwwhttp           2
libvgagl             2
libexpect5.28        2
libwwwstream         2
libtclx8.0.4         2
libitcl3.0           2
libxmlparse          2
libwwwzip            2
libwwwfile           2
libwwwutils          2
libwwwxml            2
libXIE               2
libwwwapp            2
libwwwinit           2
libwwwmime           2
libwwwmux            2
libtcl               1
libtk                1
libtix4.1.8.0        1
libx11amp            1
libitk3.0            1
libss                1
libopcodes-2.9.1.0.23 1
libmikmod            1
libgpm               1
libpuke              1
libtkx8.0.4          1
libcrack             1
libuulib             1
libgnorbagtk         1
libgtop_names        1
------- end ----------------------------

------- start of cut text --------------
#!/usr/bin/perl
#
# $Id: scan-libraries,v 1.2 1999/06/10 02:10:28 quinlan Exp $
#
#    Copyright (C) 1999  Daniel Quinlan
#
#    This program 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.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

# "distribution" binary directories as per FHS
@dirs = ("/bin", "/usr/bin", "/sbin", "/usr/sbin", "/usr/X11R6/bin",
	 "/usr/games");
$prog = $0;
$prog =~ s@.*/@@;

use Getopt::Long;
&GetOptions("help", "chop", "files");

if ($opt_help) {
    &usage;
}

foreach $dir (@dirs) {
    next if ! -d "$dir";

    opendir(DIR, $dir) || die "can't opendir $dir: $!";
    @files = grep { -r "$dir/$_" && -f "$dir/$_" && -e "$dir/$_" } readdir(DIR);
    closedir DIR;

    foreach $file (@files) {
	$dynamic = 0;
	open(LDD, "ldd $dir/$file |");
	while (<LDD>) {
	    if (/(\S+)\s*\=\>\s*(\S+)/) {
		$dynamic = 1;
		($libname, $libfile) = ($1, $2);
	    }
	    if ($opt_chop) {
		$libname =~ s/\.so.*//;
	    }
	    $libnames{$libname}++;
	    $libfiles{$libfile}++;
	}
	close(LDD);
	$count_dynamic += $dynamic;
    }
}

print "$count_dynamic dynamic binaries\n\n";

for $libname (sort { $libnames{$b} <=> $libnames{$a} } keys %libnames) {
    printf "%-20s %d\n", $libname, $libnames{$libname};
}

if ($opt_files) {
    print "\n";
    for $libfile (sort { $libfiles{$b} <=> $libfiles{$a} } keys %libfiles) {
	print "$libfile: " . $libfiles{$libfile} . "\n";
    }
}

sub usage {
    print <<EOF;
usage: $prog [options] [command]

  -h     --help    print this help
  --chop           only show base library name
  --files          also count by file name (less useful)

EOF
    exit 0;
}
------- end ----------------------------


Reply to: