ktrace-netbsd (1550B)
1 #!/bin/sh 2 3 # Copyright 2024 Gregory D. Troxel 4 5 # Permission is granted to copy under the GNU GENERAL PUBLIC LICENSE, 6 # Version 3, or any later version. Alternatively, permission is 7 # granted to copy under the 2-clause BSD license as used by NetBSD. 8 9 # This script does a full build of unison, installs it to a DESTDIR, 10 # and then cleans the build. While doing so, it asks the operating 11 # system to log call system calls. That log is examined for pathname 12 # lookups, such as are invoked by exec system calls, and the names 13 # extracted. The list is filtered to absolute paths with /bin or 14 # /sbin, with /usr and /usr/pkg projected down, and then uniquified 15 # and counted. The point is to make a list of programs in bin-type 16 # directories that may have been executed. 17 18 if [ -f src/Makefile.OCaml ]; then 19 # in unison top level 20 true 21 else 22 echo "ktrace-netbsd: must be at top level of unison sources" 23 exit 1 24 fi 25 26 make clean 27 rm -f ktrace* 28 29 ktrace -i make 30 kdump > ktrace-make.txt 31 32 mkdir /tmp/U 33 ktrace -i make DESTDIR=/tmp/U install 34 kdump > ktrace-install.txt 35 # One could clean up the DESTDIR, but rm -rf in scripts is scary, so I 36 # won't, and it's in /tmp anyway. 37 38 ktrace -i make clean 39 kdump > ktrace-clean.txt 40 41 # Find NAMI lines, extract path, remove quotes, project to canonical 42 # bin, filter to absolute bin-like dirs, and uniqify-count. 43 cat ktrace-*.txt | egrep NAMI | \ 44 awk '{print $5}' | \ 45 sed -e 's/^"//' -e 's/"$//' | \ 46 sed -e 's,/usr,,' -e 's,/pkg,,' | \ 47 egrep '^/(bin|sbin)' | \ 48 sort | uniq -c \ 49 > NAMI.txt