--- binstats-1.08.orig/Makefile +++ binstats-1.08/Makefile @@ -12,8 +12,8 @@ PREFIX= /usr/local # If you want to install derefsymlink in some place other than # /usr/local/bin then make sure PATH is set accordingly in binstats -DESTBIN= $(PREFIX)/bin -DESTMAN= $(PREFIX)/man/man1 +DESTBIN= $(DESTDIR)/$(PREFIX)/bin +DESTMAN= $(DESTDIR)/$(PREFIX)/man/man1 derefsymlink: derefsymlink.o $(CC) -o $@ $(CFLAGS) $(LDFLAGS) derefsymlink.o @@ -24,4 +24,4 @@ install -m 644 binstats.1 derefsymlink.1 $(DESTMAN) clean: - rm -f derefsymlink derefsymlink.o + rm -f derefsymlink derefsymlink.o *~ *.00 bstats.log* --- binstats-1.08.orig/binstats.1 +++ binstats-1.08/binstats.1 @@ -6,6 +6,7 @@ .RB [ -b [ inaries ]\c .RI = bindirs ] .RB [ -d [ ebug ]] +.RB [ -s [ kip-debian ] .RB [ -f [ ile ]\c .RI = logfile ] .RB [ -l [ ibraries ]\c @@ -33,6 +34,10 @@ Store temporary files in the current directory and do not remove them when finished. .TP +.B -skip-debian +Skip Debian tests that analyse installed packages even if this is a +Debian system. +.TP .BI -file " logfile" Output report to .I logfile --- binstats-1.08.orig/binstats +++ binstats-1.08/binstats @@ -100,6 +100,7 @@ # your system or ignore if USEPATH=1) EXEDIR="/bin /usr/bin /usr/local/bin /sbin /usr/sbin /usr/local/sbin /usr/X11R6/bin /usr/games" +USEMANPATH=1 # the list of directories where your man pages reside MANDIR="/usr/man /usr/share/man /usr/X11R6/man /usr/local/man" @@ -135,6 +136,8 @@ DEBUG=0 # another debugging option, set to 0 to reuse old temp files FILEOPS=1 +# Debian checks? Set to 1 to skip Debian-specific checks +NODEBIAN=0 #----------process command line arguments--------------- CLI_USAGE=\ @@ -143,7 +146,7 @@ [-l[ibraries]=\"/lib /usr/lib\"] [-m[anuals]=\"/usr/man /usr/local/man\"] [-p[ath]=\"/bin:/usr/bin:/usr/local/bin\"] - [-t[emp]=/tmp] [-v[ersion]]" + [-t[emp]=/tmp] [-s[kip-debian] [-v[ersion]]" for CLI_OPT do @@ -162,8 +165,11 @@ -l*=*) USELDSOCONF=0 DLIBDIR="$CLI_ARG" ;; -m*=*) MANDIR="$CLI_ARG" ;; + -m*=*) USEMANPATH=0 + MANDIR="$CLI_ARG" ;; -p*=*) PATH="$CLI_ARG" ;; -t*=*) TMPDIR="$CLI_ARG" ;; + -s*=*) NODEBIAN=1 ;; -v*) echo "binstats-$BSVER" exit 0 ;; *) echo "$CLI_USAGE" @@ -177,6 +183,10 @@ EXEDIR=`echo $OLDPATH | tr : ' ' | sed s:\~:$HOME:g` fi +if [ $USEMANPATH -eq 1 -a -n "ype -p manpath" ];then + MANDIR=`manpath | tr : ' '` +fi + if [ $USELDSOCONF -eq 1 ]; then # use /etc/ld.so.conf plus the two "trusted" locations LDSOCONF=`cat /etc/ld.so.conf | grep -v '^#' | xargs echo` @@ -188,49 +198,91 @@ # name of temp log BSLOGTMP=$BSLOG.$PIDNO +# Create the files we are going to use +# backup old log file +if [ -f $BSLOG ]; then mv -f $BSLOG $BSLOG~; fi +{ umask 066; touch $BSLOG; [ -e $BSLOGTMP ] && rm -f $BSLOGTMP; touch $BSLOGTMP ; } if [ $DEBUG -gt 0 ]; then - TMPDIR=. + BINSDIR=. PIDNO=00 else - TMPDIR=$TMPDIR/binstats.$PIDNO - mkdir -m 700 $TMPDIR || exit 1 + BINSDIR=`mktemp -t -d binstats.XXXXXX` || { echo "$0: Cannot create temporary directory!" >&2; exit 1; } +fi +# tidy up +if [ $DEBUG -eq 0 ]; then + trap " [ -d \"$BINSDIR\" ] && /bin/rm -rf -- \"$BINSDIR\"" 0 1 2 3 13 15 fi - # list of executables -EXELIST=$TMPDIR/exelist.$PIDNO +EXELIST=$BINSDIR/exelist.$PIDNO # list of dynamic libraries -DLIBLIST=$TMPDIR/dliblist.$PIDNO +DLIBLIST=$BINSDIR/dliblist.$PIDNO # list of man pages -MANLIST=$TMPDIR/manlist.$PIDNO +MANLIST=$BINSDIR/manlist.$PIDNO # executable types -EXEFILE=$TMPDIR/exefile.$PIDNO +EXEFILE=$BINSDIR/exefile.$PIDNO # list of dependent (used) libraries -EXELIB=$TMPDIR/exelib.$PIDNO +EXELIB=$BINSDIR/exelib.$PIDNO # list of unused libraries -DLIBUN=$TMPDIR/dlibun.$PIDNO +DLIBUN=$BINSDIR/dlibun.$PIDNO +# list of unused libraries with packages +DLIBUNP=$BINSDIR/dlibunp.$PIDNO + +# Unused library packages +LIBPUN=$BINSDIR/libpun.$PIDNO +# Package list +PACKLIST=$BINSDIR/packlist.$PIDNO # temporary storage -DTEMPA=$TMPDIR/dtempa.$PIDNO # all dynamic libs in $DLIBDIR -DTEMPB=$TMPDIR/dtempb.$PIDNO # missing dynamic libs in $EXELIB -DTEMPC=$TMPDIR/dtempc.$PIDNO # dereferenced list of $DTEMPA - -ETEMPA=$TMPDIR/etempa.$PIDNO # all files in $EXEDIR -ETEMPB=$TMPDIR/etempb.$PIDNO # output of ldd on files in $EXEFILE -ETEMPC=$TMPDIR/etempc.$PIDNO # statically linked binaries in $ETEMPB -ETEMPD=$TMPDIR/etempd.$PIDNO # duplicate executable names in $ETEMPA -ETEMPE=$TMPDIR/etempe.$PIDNO # 'not stripped' binaries in $EXEFILE -ETEMPF=$TMPDIR/etempf.$PIDNO # setuid binaries in $EXEFILE +DTEMPA=$BINSDIR/dtempa.$PIDNO # all dynamic libs in $DLIBDIR +DTEMPB=$BINSDIR/dtempb.$PIDNO # missing dynamic libs in $EXELIB +DTEMPC=$BINSDIR/dtempc.$PIDNO # dereferenced list of $DTEMPA + +ETEMPA=$BINSDIR/etempa.$PIDNO # all files in $EXEDIR +ETEMPB=$BINSDIR/etempb.$PIDNO # output of ldd on files in $EXEFILE +ETEMPC=$BINSDIR/etempc.$PIDNO # statically linked binaries in $ETEMPB +ETEMPD=$BINSDIR/etempd.$PIDNO # duplicate executable names in $ETEMPA +ETEMPE=$BINSDIR/etempe.$PIDNO # 'not stripped' binaries in $EXEFILE +ETEMPF=$BINSDIR/etempf.$PIDNO # setuid binaries in $EXEFILE -MTEMPA=$TMPDIR/mtempa.$PIDNO # all files in $MANDIR -MTEMPB=$TMPDIR/mtempb.$PIDNO # duplicate executable names in $MTEMPA +MTEMPA=$BINSDIR/mtempa.$PIDNO # all files in $MANDIR +MTEMPB=$BINSDIR/mtempb.$PIDNO # duplicate executable names in $MTEMPA + +# A wrapper around readlink(1). +derefsymlink() +{ + while [ $# -gt 0 ]; do + if [ "$1" = -f ]; then + shift + while read f; do + readlink -f "$f" || echo "$f" + done < "$1" + elif [ "$1" = -s ]; then + while read f; do + readlink -f "$f" || echo "$f" + done + else + readlink -f "$1" || echo "$1" + fi + shift + done +} + +isdebian() +{ + if [ -e /etc/debian_version ] && [ "$NODEBIAN" -eq 0 ] ; then + return 0 + else + return 1 + fi +} #----------begin program--------------- if [ $FILEOPS -gt 0 ]; then echo "Look in $EXEDIR for executables" -find $EXEDIR -perm +111 -maxdepth 1 -type f -follow -print | \ +find $EXEDIR -perm +111 -maxdepth 1 -type f -follow -print 2>/dev/null| \ derefsymlink -s | sort | uniq | \ awk -F '/' '{ printf "%s:%s\n", $NF, $0 }' > $ETEMPA @@ -259,15 +311,15 @@ # And ldd (1.9.2) prints some hex numbers after library name in parentheses if [ $LDDBA -eq 0 ]; then grep 'executable' $EXEFILE | cut -d ':' -f 1 | \ - xargs ldd | col -b | cut -d '(' -f 1 >& $ETEMPB + xargs ldd 2>/dev/null | col -b | cut -d '(' -f 1 >& $ETEMPB else grep 'executable' $EXEFILE | cut -d ':' -f 1 | \ - xargs ldd | awk cut -d '(' -f 1 >& $ETEMPB + xargs ldd 2>/dev/null | awk cut -d '(' -f 1 >& $ETEMPB fi echo "List the used dynamic libraries" grep 'lib[^:]*\.so' $ETEMPB | sort -b | uniq -c > $EXELIB -grep 'statically linked' $ETEMPB > $ETEMPC +grep 'statically linked' $EXEFILE > $ETEMPC echo "Hunt down binaries that depend on missing libraries" awk \ @@ -287,6 +339,39 @@ diff -du $DLIBLIST $DTEMPC | grep '^-/' | cut -b 2- > $DLIBUN +# If this is a Debian system, add the packages in too +if isdebian ; then + echo "Search for packages holding unused dynamic libraries" + >$PACKLIST + >$DLIBUNP + cat $DLIBUN | + while read file; do + package=`dpkg -S $file 2>/dev/null | cut -f 1 -d :` + if [ -n "$package" ] ; then + echo $package >>$PACKLIST + echo "$file ($package)" >>$DLIBUNP + else + echo "$file" >>$DLIBUNP + fi + done + echo "Reviewing packages holding unused dynamic libraries" + cat $PACKLIST | sort -u | + while read package ; do + # TODO, could be done on packages that begin with 'lib' + unused=1 + for library in `dpkg -L $package |grep lib/`; do + if [ -z "`grep ^$library\$ $DLIBUN`" ] ; then + unused=0 + break + fi + done + if [ $unused -eq 1 ] ; then + echo "$package" >>$LIBPUN + fi + done +fi + + echo "Find un-stripped binaries" grep 'not stripped' $EXEFILE | sort > $ETEMPE @@ -325,6 +410,7 @@ JAVAC=`grep 'Java bytecode' $EXEFILE | wc -l` LIBC=`cat $EXELIB | wc -l` UNLIBC=`cat $DLIBUN | wc -l` +LIBPUNC=`cat $LIBPUN | wc -l` DLLIBC=`grep 'DLL' $EXELIB | wc -l` SELFC=`grep 'ELF' $ETEMPC | wc -l` SECOFFC=`grep 'ECOFF' $ETEMPC | wc -l` @@ -405,6 +491,9 @@ echo "Used libraries: $LIBC" >> $BSLOGTMP echo " DLL: $DLLIBC" >> $BSLOGTMP echo "Unused libs: $UNLIBC" >> $BSLOGTMP +if isdebian ; then +echo "Packages with unused libs: $LIBPUNC" >> $BSLOGTMP +fi echo "Man pages: $MANC" >> $BSLOGTMP echo " Duplicate names: $MANDUPC" >> $BSLOGTMP @@ -470,8 +559,7 @@ DOTLINE=0 if [ $SELFC -gt 0 ]; then echo "statically linked (ELF):" >> $BSLOGTMP - grep -B 1 'statically linked (ELF)' $ETEMPB | grep '^/' | \ - cut -d ':' -f 1 >> $BSLOGTMP + grep 'ELF' $ETEMPC | cut -d ':' -f 1 >> $BSLOGTMP DOTLINE=1 fi if [ $ELFUNSTR -gt 0 ]; then @@ -571,7 +659,18 @@ if [ $UNLIBC -gt 0 ]; then echo "--------------------------------------------------------------" >> $BSLOGTMP echo "unused:" >> $BSLOGTMP - cat $DLIBUN >> $BSLOGTMP + if isdebian ; then + cat $DLIBUNP >> $BSLOGTMP + else + cat $DLIBUN >> $BSLOGTMP + fi +fi +echo "==============================================================" >> $BSLOGTMP +if isdebian && [ $LIBPUNC -gt 0 ]; then + echo "PACKAGES:" >> $BSLOGTMP + echo "--------------------------------------------------------------" >> $BSLOGTMP + echo "with all libraries unused:" >> $BSLOGTMP + cat $LIBPUN >> $BSLOGTMP fi echo "==============================================================" >> $BSLOGTMP if [ $MANDUPC -gt 0 ]; then @@ -580,8 +679,6 @@ echo "==============================================================" >> $BSLOGTMP fi -# backup old log file -if [ -f $BSLOG ]; then mv -f $BSLOG $BSLOG~; fi # filter through sed to beautify (note the embedded TAB) sed -e 's,^/\(.*[^:]\)$, /\1,g' $BSLOGTMP > $BSLOG rm -f $BSLOGTMP @@ -638,10 +735,6 @@ echo "Man pages: $MANC" echo " Duplicate names: $MANDUPC" -# tidy up -if [ $DEBUG -eq 0 ]; then - rm -rf $TMPDIR -fi echo "==============================================================" echo "More detailed information can be obtained in $BSLOG" --- binstats-1.08.orig/debian/changelog +++ binstats-1.08/debian/changelog @@ -0,0 +1,163 @@ +binstats (1.08-8) unstable; urgency=high + + * Fixed call to mktemp (Closes: #303261) + + -- Javier Fernandez-Sanguino Pen~a Tue, 5 Apr 2005 20:08:26 +0200 + +binstats (1.08-7) unstable; urgency=low + + * Adopting this package, as makejail Depends: on it (Closes: #292019) + * Updated Standard-Versions: + * Adjusted CFLAGS and LDFLAGS in debian/rules just in case + the binaries are built again + * Fixed binary-arch for the same reason, althoug the package remains + Arch: all + * Quote readlink calls (Closes: #218647) + * Add the package to the unused library list (Closes: #146465) + * Add a check to review which of the packages holding unused libraries + are not used at all. + * Redirect error output of the find call to /dev/null (in case it + finds dangling symlinks) + * Use mktemp instead of mkdir to prevent a race condition + * Change the script so BSLOG and BSLOGTMP are created before they are + used, this does not prevent some race conditions so don't run + this script in untrusted directories. + * Remove debugging output in Makefile, if present + + -- Javier Fernandez-Sanguino Pen~a Sat, 26 Feb 2005 23:25:48 +0100 + +binstats (1.08-6) unstable; urgency=low + + * Orphaning. + + -- Angel Ramos Mon, 24 Jan 2005 17:10:00 +0100 + +binstats (1.08-5) unstable; urgency=low + + * Fixed failures to find static linked executables (Closes: #124320). + * Fixed outputs error message for non-existence man directory + (Closes: #124323). + Thanks to Yamashita for patches :) + + -- Angel Ramos Tue, 8 Jan 2002 17:17:00 +0100 + +binstats (1.08-4) unstable; urgency=low + + * Fixed unnecessary error messages display bug (Closes: #117928). + + -- Angel Ramos Thu, 22 Nov 2001 10:57:21 +0100 + +binstats (1.08-3) unstable; urgency=low + + * New maintainer (Closes: #108347). + + -- Angel Ramos Fri, 21 Sep 2001 15:09:31 +0100 + +binstats (1.08-2) unstable; urgency=low + + * Orphaning. + * Moved to debhelper 3. + * Conforms to Standards version 3.5.4. + + -- Matej Vela Wed, 2 May 2001 08:26:01 +0200 + +binstats (1.08-1) unstable; urgency=low + + * New upstream version. + + -- Matej Vela Thu, 18 Jan 2001 23:55:55 +0100 + +binstats (1.07-1) unstable; urgency=low + + * New upstream version. Closes: Bug#57230. + * Uses readlink(1) from debianutils instead of having its own + derefsymlink(1). This makes the package `Architecture: all'. + * Uses mktemp(1) rather than tempfile(1) since the former is less + Debian specific. + * debian/copyright: Updated. + * Conforms to Standards version 3.2.1. + + -- Matej Vela Mon, 18 Dec 2000 04:21:34 +0100 + +binstats (1.05-1) unstable; urgency=low + + * New upstream version. + * Conforms to Standards version 3.1.1. + + -- Matej Vela Wed, 22 Dec 1999 15:24:06 +0100 + +binstats (1.04-1) unstable; urgency=low + + * New upstream version. + + -- Matej Vela Wed, 17 Nov 1999 07:04:23 +0100 + +binstats (1.03-1) unstable; urgency=low + + * New upstream version. Closes: Bug#17881. + * binstats: Separating manual page names with `,' instead of `:' + since many of them contain `:' characters. + * debian/control: Updated the description. Added a dependancy on + bsdmainutils since binstats needs col(1). + * debian/copyright: Updated author's e-mail and the wording of the + license. + + -- Matej Vela Sat, 13 Nov 1999 19:42:57 +0100 + +binstats (1.01-3) unstable; urgency=low + + * New maintainer. + * binstats: + * Using the value of $TMPDIR if set. + * Securely creating temporary files with tempfile(1). + * Applied patch from Laurent Bonnaud + correcting shared library filename patterns. Closes: Bug#46765. + * Added `-follow' to the invocation of find so that all programs + are accounted for. Closes: Bug#16157. + * Wrote binstats(1) and derefsymlink(1). Closes: Bug#39481. + * Conforms to Standards version 3.1.0: + * debian/control: Added build dependancies. + * debian/copyright: Corrected `/usr/doc/copyright/GPL' to + `/usr/share/common-licenses/GPL'. + * debian/rules: Using `-O2 -g -Wall' for CFLAGS. + + -- Matej Vela Fri, 5 Nov 1999 12:01:45 +0100 + +binstats (1.01-2) unstable; urgency=low + + * Updated to Standards-Version: 3.0.1.1. + + -- Johnie Ingram Sat, 18 Sep 1999 03:36:10 -0500 + +binstats (1.01-1) unstable; urgency=low + + * New upstream version. + + -- Johnie Ingram Thu, 5 Feb 1998 11:29:35 -0500 + +binstats (1.00-3) unstable; urgency=low, closes=16984 + + * Added patch from David Rocher so it understands new-style ldd output + (#16984) and counts libc6 binaries correctly. + * Updated to Standards-Version 2.4.0.0. + * No longer uses the deprecated dh_installdebfiles program. + * Added (useless) manpage. + + -- Johnie Ingram Thu, 5 Feb 1998 11:03:53 -0500 + +binstats (1.00-2) unstable; urgency=low, closes=15437 + + * Debian changelog is now compressed (#15437). + * Switched from debmake to debhelper packaging technology. + + -- Johnie Ingram Sat, 29 Nov 1997 00:45:03 -0500 + +binstats (1.00-1) unstable; urgency=low + + * Initial Release. + + -- Johnie Ingram Thu, 13 Nov 1997 21:17:32 -0500 + +Local variables: +mode: debian-changelog +End: --- binstats-1.08.orig/debian/control +++ binstats-1.08/debian/control @@ -0,0 +1,21 @@ +Source: binstats +Section: utils +Priority: optional +Maintainer: Javier Fernandez-Sanguino Pen~a +Standards-Version: 3.6.1 +Build-Depends: debhelper (>= 3) + +Package: binstats +Architecture: all +Depends: bsdmainutils, debianutils (>= 1.13.1), file +Description: Statistics tool for installed programs + A utility to aid the tidying up of binaries, interpreted scripts, and + dynamic libraries. It can find the number and identity of a.out and + ELF binaries, plus their debugging symbols status, setuid status, and + dynamic library dependence. It can count the number of Java bytecode + programs, tally up the main types of scripts, and look for unidentified + executable text files. + . + Also it is able to find any duplicated executable names, unused + libraries, binaries with missing libraries, statically linked binaries, + and duplicated manual page names. --- binstats-1.08.orig/debian/rules +++ binstats-1.08/debian/rules @@ -0,0 +1,54 @@ +#! /usr/bin/make -f + +export DH_COMPAT := 3 +export CFLAGS="-O2 -g -Wall" +export LDFLAGS="" + +clean: + dh_testdir + dh_testroot + dh_clean + make clean + +build: + make + +binary: binary-indep + +binary-indep: + dh_testdir + dh_testroot + dh_clean + dh_installdirs usr/bin + cp -p binstats debian/binstats/usr/bin + dh_installdocs README + dh_installman binstats.1 + dh_installchangelogs + dh_strip + dh_compress + dh_fixperms + dh_installdeb + dh_gencontrol + dh_md5sums + dh_builddeb + +binary-arch: build + dh_testdir + dh_testroot + dh_clean + dh_installdirs usr/bin usr/share/man/man1 + make install DESTBIN=`pwd`/debian/binstats/usr/bin \ + DESTMAN=`pwd`/debian/binstats/usr/share/man/man1 + cp -p binstats debian/binstats/usr/bin + dh_installdocs README + dh_installman binstats.1 + dh_installchangelogs + dh_strip + dh_compress + dh_fixperms + dh_installdeb + dh_gencontrol + dh_md5sums + dh_builddeb + +.PHONY: clean build binary binary-arch binary-indep --- binstats-1.08.orig/debian/copyright +++ binstats-1.08/debian/copyright @@ -0,0 +1,20 @@ +Upstream sources of binstats were obtained from +. It was modified to +use readlink(1) from the debianutils package rather than its own +derefsymlink utility. + +The original author is Peter Chang . + +binstats was packaged for Debian by Johnie Ingram , +and subsequently maintained by Matej Vela . +Now the new maintainer of the package is Angel Ramos . + + PS binstats is released under the GPL and as such the usual licence + conditions and lack of warranty apply. + +The Debian packaging is copyright (C) 1997-1998 Johnie Ingram, +(C) 1999-2001 Matej Vela, and also released under the terms of the GNU +General Public License; version 2, or any later version. + +On Debian systems, the complete text of the GNU General Public License +can be found in /usr/share/common-licenses/GPL.