#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License"). You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright (c) 2000 by Sun Microsystems, Inc.
# All rights reserved.
#
# ident "%Z%%M% %I% %E% SMI"
#
# check for perl5 -- we use things unavailable in perl4
#
$DBM_DIR_CHARACTERIZATION = "directory for the dbm databases";
$Usage =
"Usage: get_depend_info
-dbdir <$DBM_DIR_CHARACTERIZATION> [ -s ] [ -cons ] [ -root directory ]
[ -f ] [ -p ] [ -pkg SUNWxxx ] [ filename ]
[-h for help]\n";
$Help =
"This program statically analyzes executable files and their
can accept filename(s) or packages as the list of files to be
analyzed. By default, the program will report the file
dependencies and which packages those dependencies came from.
There is one required argument:
-dbdir <dir> the $DBM_DIR_CHARACTERIZATION
The optional argument -h produces this message instead of any processing.
The optional argument -cons tells the tool to be conservative and not to
The optional argument -root allows you to specify a new root (useful for
doing analysis on build trees).
The optional argument -pkg allows you to specify a package name.
The optional argument -f only outputs the filename of the dependencies
The optional argument -p only outputs the packanames of the dependencies
The optional argument -s ONLY outputs symbolic links for files or packages.
No ldd or strings analysis is done.
Some Examples:
get_depend_info -dbdir ./DBM -pkg SUNWnisu
get_depend_info -f -dbdir ./DBM -pkg SUNWnisu
get_depend_info -s -dbdir ./DBM -pkg SUNWnisu
NOTE: Run make_pkg_db to create the database directory for get_depend_info
";
#
# process arguments
#
@PkgList = "";
$PackageOnly = false;
$FileOnly = false;
$Verbose = true;
$Silent = false;
$SymLink = false;
$NoStrings = false;
$Root = "";
while (@ARGV) {
exit 0;
$SymLink = true;
$Silent = true;
$PackageOnly = true;
$Verbose = false;
$FileOnly = true;
$Verbose = false;
$NoStrings = true;
}else {
}
}
if (!$DBDir) {
exit 1;
}
if ($PKGName) {
# For a given pkg definition directory, this subroutine will
# go through the proto files and look for executable files.
# It will then put all the executable files into @filelist
$Silent = true;
}
}
&OpenDBs;
# make sure file exists
next;
}
next;
}
# destfile represents the actual file we are interested in!
}
}
else {
}
# if the -s flag is set, tell 'em about sym links and go to the next file
# Handle the case where the user resets $ROOT
# make sure we are dealing with an executable
if (($mode !~ /(.)(.*)7/) && ($mode !~ /(.)(.*)5/) && ($mode !~ /(.)(.*)3/) && ($mode !~ /(.)(.*)1/)){
print("Input file is not an executable\n");
next;
}
# Kernel modules are handled separately
next;
}
# take care of scripts
next;
}
# Its not a script, not a kernel module, so its get to be a binary
}
}
&CloseDBs;
#===========================END OF MAIN====================================
#
# use map file to see if this is a file that gives a known bad ldd return
#
# if ($Unsup{$FileID} == 1) {
# $outstring = "* unsupported or unknown file type, per map file";
# return ($outstring);
# }
# $err = "";
# if ($?) { # if some error (don't just get wait status here)
# $errnum = 0 + $!;
# $err = "==$?==$errnum==";
# if (($err eq "==256==29==") || ($err eq "==256==0==")) {
# $err = "*"; # these are normal ldd returns
# } else {
# die "Unexpected ldd return $? $!";
# }
# $string =~ s/\/usr\/bin\/ldd:[^\0]*://g; # trim up error line
# $err = "*";
# }
# on a non-zero ldd, return nothing
$line =~ s/^\s+//; # trim leading ws
}
}
sub CloseDBs {
# close the dbs
}
sub OpenDBs {
# open the databases for read-only
}
sub HandleKernelMod {
# search for the magic right, starting from the right (ie. end of path)
# rindex() returns where the "kernel" began, add 6 to get
# "{some path}/kernel"
$index += 6;
# OK, now pull out the absolute path
# There are two ways to figure out the dependencies.
$found = 0;
# first, check to see if there is a module relative to
# this file
$found++;
}
# Haven't found it yet, check /kernel
$found++;
}
$found++;
}
}
}
return;
}
# the ldd failed, so now let's look at the string output
}
}
$found = 0;
# first, check to see if there is a module relative to
# this file
$found++;
}
# Haven't found it yet, check /kernel
$found++;
}
$found++;
}
}
}
}
# use map file to see if this is a file that gives a known bad ldd return
}
}
}
}
}
}
sub HandleScripts {
s/^\s+//; # trim leading ws
s/=/ /g; # get rid of all =
s/\`/ /g; # get rid of all `
next if ($_ =~ /^#/); # strip out obvious comments
next unless $_; # skip if blank
$line = $_;
}
}
}
$count = 0;
# make sure we don't output dupes
}
}
$count++;
}
# remember to play nice
}
sub HandleBinaries {
# Parse the ldd output.
$found = 0;
$found++;
}
$found++;
}
}
}
# For the strings output, we parse it to see if we can match it to
# any files distributed in a package.
}
}
}
sub Output {
# If they want a package listing, a unique sorted list
# will be outputted later. Here we simply push elements onto
# this list.
}
return;
}
# If they want a package listing, a unique sorted list
# will be outputted later. Here we simply push elements onto
# this list.
return;
}
return;
}
}
sub HandlePackageName {
}
}
sub OutputPackageList {
# If the user specified a package list, here we sort
# the list and make sure we don't output dupes.
$pkg =~ s/\s*$//; # trim extra space off the end
# make sure this entry isn't a dupe before
# printing it
}
}
# reset the list for the next entry
}