#!/bin/bash # tracklist version 0.3 # Gilbert Ashley # tracklist logs commands using libsentry # and then produces a FILELIST of files and # directories created by the command. # This was a really fast hack, but amazingly useful. # It parses the libsentry log differently than # the src2pkg routine. tracklist lists only the # files and directories created, but not links (so far). CWD=$(pwd) KEEP_INSTALL_LIST="YES" # ANSI COLORS CRE="" NORMAL="" # RED: Failure or error message RED="" # GREEN: Success message GREEN="" # YELLOW: Warnings YELLOW="" # BLUE: Summary messages BLUE="" # CYAN: Current Process CYAN="" if [[ $1 ]] && [[ $2 ]] ; then INSTALL_COMMAND=$1 shift INSTALL_RULE="$@" else echo "We need 2 args!" fi echo $BLUE"Now Running 'sentry $INSTALL_COMMAND $INSTALL_RULE'"$NORMAL unset INSTW_ROOTPATH unset INSTW_TRANSL unset INSTW_BACKUP unset INSTW_LOGFILE unset INSTW_DBGFILE unset INSTW_DBGLVL unset INSTW_EXCLUDE cd $CWD; ( /usr/bin/sentry --logfile=~/FILELIST.tmp --dbglvl=0 --root=~ $INSTALL_COMMAND $INSTALL_RULE ); ## if [[ $? != 0 ]] ; then rm -f ~/FILELIST.tmp FAILED="$INSTALL_COMMAND $INSTALL_RULE" echo $RED"COMMAND FAILED: "$NORMAL "$FAILED" exit 1 fi sleep 1 cd $HOME if [[ $(cat ./FILELIST.tmp |grep -v 'FILELIST') = "" ]] ; then # 'make install' produced no errors but also produced no output echo $RED"FATAL! "$NORMAL"Running '$INSTALL_COMMAND $INSTALL_RULE' with sentry produced no files list. " echo "This may be the result of an empty or faulty install rule. "$RED"Exiting..."$NORMAL rm -f ~/FILELIST.tmp FAILED="NO FILES" else echo $BLUE"Tracking "$GREEN"Successful!"$NORMAL echo -n $BLUE"Processing file list..."$NORMAL # extract a list of the regular files cd $HOME cat ~/FILELIST.tmp |grep 'mkdir' |grep -v '#File exists' |cut -f3 >> ~/FILELIST cat ~/FILELIST.tmp |grep 'open' |grep '#success' |grep -v '#File exists' |grep -v 'FILELIST*' |grep -v /dev |grep -v /tmp |cut -f3 >> ~/FILELIST rm -f ~/FILELIST.tmp for fileordir in $(cat ~/FILELIST) ; do [[ -e "$fileordir" ]] && echo $fileordir >> ~/FILELIST.tmp done rm -f ~/FILELIST cat ~/FILELIST.tmp |sort -u | uniq >> ~/FILELIST rm -f ~/FILELIST.tmp echo $GREEN"Done!"$NORMAL unset LD_PRELOAD fi echo "" echo $BLUE"Files generated by the command: "$NORMAL"$INSTALL_COMMAND $INSTALL_RULE:" echo "" cat ~/FILELIST