Depends.rb
#!/usr/local/bin/ruby # Script to obtain the dependencies for a solaris package. # USAGE # ================================== # Assuming that you have installed the package in XXX location # using ./configure --prefix=/usr/sfw/XXX && gmake && gmake install # cd /usr/sfw/XXX; ruby depends.rb > depends.out # depends.out will contain the library dependencies in an # ARC Usable form. # ================================== #http://docs.sun.com/app/docs/doc/819-2242/6n4hvao48?a=view #Solaris Express Reference Manual Collection # man pages section 3: Library Interfaces and Headers # Library Interfaces and Headers # | perl -pi -e 's/^[ \t]+//g' | perl -pi -e 's/\(.*\) +\?//g' # ================================== $internal_libs =<<LIBS acct per-process accounting file format acct.h per-process accounting file format aio asynchronous input and output aio.h asynchronous input and output ar archive file format ar.h archive file format assert verify program assertion assert.h verify program assertion complex complex arithmetic complex.h complex arithmetic cpio cpio archive values cpio.h cpio archive values dirent format of directory entries dirent.h format of directory entries errno system error numbers errno.h system error numbers fcntl file control options fcntl.h file control options fenv floating-point environment fenv.h floating-point environment float floating types float.h floating types floatingpoint IEEE floating point definitions floatingpoint.h IEEE floating point definitions fmtmsg message display structures fmtmsg.h message display structures fnmatch filename-matching types fnmatch.h filename-matching types ftw file tree traversal ftw.h file tree traversal glob pathname pattern-matching types glob.h pathname pattern-matching types grp group structure grp.h group structure iconv codeset conversion facility iconv.h codeset conversion facility if sockets local interfaces if.h sockets local interfaces in Internet Protocol family inet definitions for internet operations inet.h definitions for internet operations in.h Internet Protocol family inttypes fixed size integer types inttypes.h fixed size integer types ipc XSI interprocess communication access structure ipc.h XSI interprocess communication access structure iso646 alternative spellings iso646.h alternative spellings langinfo language information constants langinfo.h language information constants lib300 graphics interface libraries lib300s graphics interface libraries lib4014 graphics interface libraries lib450 graphics interface libraries libadm general administrative library libaio asynchronous I/O library libauto_ef auto encoding finder library libbsdmalloc memory allocator interface library libbsm basic security library libc C library libc_db threads debugging library libcfgadm configuration administration library libcontract contract management library libcpc CPU performance counter library libcrypt encryption/decryption library libcurses screen handling and optimization library libcurses SunOS/BSD-compatible screen handling and optimization library libdat direct access transport library libdbm database subroutines library libdevid device ID library libdevinfo device information library libdl dynamic linking library libdoor doors library libdtrace DTrace dynamic tracing software library libefi EFI partition table library libelf ELF access library libexacct extended accounting file access library libform forms library libfstyp file system type identification library libgen definitions for pattern matching functions libgen string pattern-matching library libgen.h definitions for pattern matching functions libgss Generic Security Services library libhbaapi Common Fibre Channel HBA information library libidnkit IDN conversion library libintl internationalization library libkrb5 MIT Kerberos 5 library libkstat kernel statistics library libkvm Kernel Virtual Memory access library libl lex library liblayout layout service library liblgrp locality group library libm C math library libmail user mailbox lockfile management library libmalloc memory allocation library libmapmalloc alternative memory allocator library libmd Message Digest library libmd5 MD5 hashing library libmenu menus library libmlib mediaLib library libmlib_mt multi-threaded mediaLib libmp multiple precision library libMPAPI Common Mulitipath Management library libmpapi Common Mulitipath Management library libmtmalloc multi-threaded memory allocator library libmvec vector math library libnls network listener service library libnsl network services library libnvpair name-value pair library libpam PAM (Pluggable Authentication Module) library libpanel panels library libpctx process context library libpicl PICL library libpicltree PICL plug-in library libpkcs11 PKCS#11 Cryptographic Framework library libplot graphics interface libraries libpool pool configuration manipulation library libposix4 POSIX.1b Realtime Extensions library libproject project database access library libpthread POSIX threads library libresolv resolver library librpcsoc obsolete RPC library librpcsvc RPC services library librsm remote shared memory interface library librt POSIX.1b Realtime Extensions library librtld_db runtime linker debugging library libsasl simple authentication and security layer library libscf service configuration facility library libsctp SCTP sockets library libsec File Access Control List library libsecdb security attributes database library libsendfile sendfile library libslp service location protocol library libsmartcard smartcard library libsocket sockets library libssagent Sun Solstice Enterprise Agent library libssasnmp Sun Solstice Enterprise SNMP library libsys system library libsysevent system event interface library libtecla interactive command line input library libtermcap screen handling and optimization library libtermcap terminal independent operation library libtermlib screen handling and optimization library libthread threads library libtnfctl TNF probe control library libtsnet Solaris Trusted Extensions network library libtsol Solaris Trusted Extensions library libucb UCB source compatibility library libumem object-caching memory allocation library libusb user-space USB device management library libuuid UUID library libvolmgt volume management library libvt0 graphics interface libraries libw wide character library libwsreg product install registry library libxnet X/Open Networking library liby yacc library limits implementation-defined constants limits.h implementation-defined constants locale category macros locale.h category macros math mathematical declarations math.h mathematical declarations mman memory management declarations mman.h memory management declarations monetary monetary types monetary.h monetary types mqueue message queues mqueue.h message queues msg message queue structures msg.h message queue structures ndbm definitions for ndbm database operations ndbm.h definitions for ndbm database operations netdb definitions for network database operations netdb.h definitions for network database operations nl_types native language data types nl_types.h native language data types poll definitions for the poll() function poll.h definitions for the poll() function pthread threads pthread.h threads pwd password structure pwd.h password structure regex regular expression matching types regex.h regular expression matching types resource definitions for resource operations resource.h definitions for resource operations sched execution scheduling sched.h execution scheduling search search tables search.h search tables select select types select.h select types sem semaphore facility semaphore semaphores semaphore.h semaphores sem.h semaphore facility setjmp stack environment declarations setjmp.h stack environment declarations shm shared memory facility shm.h shared memory facility siginfo signal generation information siginfo.h signal generation information signal base signals signal.h base signals socket Internet Protocol family socket.h Internet Protocol family spawn spawn spawn.h spawn stat data returned by stat system call stat.h data returned by stat system call statvfs VFS File System information structure statvfs.h VFS File System information structure stdbool boolean type and values stdbool.h boolean type and values stddef standard type definitions stddef.h standard type definitions stdint integer types stdint.h integer types stdio standard buffered input/output stdio.h standard buffered input/output stdlib standard library definitions stdlib.h standard library definitions string string operations string.h string operations strings string operations strings.h string operations stropts STREAMS interface (STREAMS) stropts.h STREAMS interface (STREAMS) syslog definitions for system error logging syslog.h definitions for system error logging tar extended tar definitions tar.h extended tar definitions tcp definitions for the Internet Transmission Control Protocol (TCP) tcp.h definitions for the Internet Transmission Control Protocol (TCP) termios define values for termios termios.h define values for termios tgmath type-generic macros tgmath.h type-generic macros time time types timeb additional definitions for date and time timeb.h additional definitions for date and time time.h time types times file access and modification times structure times.h file access and modification times structure types32 fixed-width data types types32.h fixed-width data types types primitive system data types types.h primitive system data types ucontext user context ucontext.h user context uio definitions for vector I/O operations uio.h definitions for vector I/O operations ulimit ulimit commands ulimit.h ulimit commands un definitions for UNIX-domain sockets un.h definitions for UNIX-domain sockets unistd standard symbolic constants and types unistd.h standard symbolic constants and types utime access and modification times structure utime.h access and modification times structure utmpx user accounting database definitions utmpx.h user accounting database definitions utsname system name structure utsname.h system name structure values machine-dependent values values.h machine-dependent values wait wait status wait.h wait status wchar wide-character handling wchar.h wide-character handling wctype wide-character classification and mapping utilities wctype.h wide-character classification and mapping utilities wordexp word-expansion types wordexp.h word-expansion types LIBS $external_libs =<<LIBS libcrypto SSL (Solaris SUNWcry) libcypto_extra SSL (Solaris SUNWcry) libssl SSL (Solaris SUNWcry) libgcc_s GCC libgcc GCC libldap LDAP (Solaris) libprldap LDAP (Solaris) libsasl SASL libsasl2 SASL2 libnspr4 NSPR4 (Solaris) libplds4 NSPR4 (Solaris) libplc4 NSPR4 (Solaris) libsoftokn3 NSPR4 (Solaris) libssl3 NSPR4 (Solaris) libnss3 NSS3 (Solaris) libuutil Userland Utility Functions (Solaris) LIBS class Depends def getlibs(text) libs = {} text.split(/\n/).each do |line| case line when /^([^ \t]+) +(.*)$/ libs[$1] = $2 else throw "Invalid Input" end end return libs end def print(libs, types) ilibs = getlibs($internal_libs) elibs = getlibs($external_libs) internal = [] external = [] libs.keys.sort.each do |k| if (ilibs[k].nil?) external << "#{k} - (#{ref(libs[k])})" else internal << "#{k} - #{ilibs[k]}" end end puts "Default Libs" puts "=====================" internal.each do |k| puts k end puts "" puts "Other Libs" puts "=====================" external.each do |k| puts k end puts "" puts "Other Files" puts "=====================" types.keys.each do |k| puts k end end def ref(path) if (path !~ /:/) && (path !~ /notfound/) if path =~ /^([^ \t]+) +(.*)$/ name=`pkgchk -l -p #{$2.strip} | grep -v ':'`.strip info = `pkginfo #{name.strip}`.strip if info =~ /^([^ \t]+) +(.*)$/ return $2.strip end end end return path.strip end def process(files) libs = {} types = {} files.each do |fil| i = fil.strip begin File.open(i) do |f| stat = f.stat if (stat.executable? && !stat.directory?) type = `file #{i}` case type when /ELF/ ldd = `ldd #{i}` ldd.each do |j| y = j.strip.split(/[\t ]+/) x = y[0].split(/\./)[0] libs[x] = y[0] + ' ' + y[2..-1].join.strip end when /perl/ f.each do |line| case line when /^[ \t]*use[ \t]*(.*);$/ libs['perl:' + $1.strip] = i.strip end end when /python/ f.each do |line| case line when /^[ \t]*import[ \t]*(.*)$/ libs['python:' + $1.strip] = i.strip when /^[ \t]*from[ \t]*([^ \t]+)[ \t]+import[ \t]+(.*)$/ libs['python:' + $1.strip] = i.strip end end when /ruby/ f.each do |line| case line when /^[ \t]*require[ \t]*(.*)$/ libs['ruby:' + $1.strip] = i.strip end end else types[type] = 1 end end end rescue Exception => e puts e.message end end print(libs, types) end end Depends.new.process(`find .`)