diff --git a/common/func_ICA.sh b/common/func_ICA.sh index eea4453..181fbfb 100644 --- a/common/func_ICA.sh +++ b/common/func_ICA.sh @@ -75,181 +75,3 @@ EOF fi done } - -# Acknowledgment: -# The following code is a modified version of an original work written by -# Greg Schafer for the "DIY Linux" project and is included here with his -# permission. -# ref: http://www.diy-linux.org -# -# -# ---------------------------------------------------------------------------- # -# Here are the ICA functions. -# ---------------------------------------------------------------------------- # -# -# Here we prepare for the Iterative Comparison Analysis (ICA). Essentially, we -# copy most of our chroot phase files to a new location then perform some -# manipulations on the copied files to make diff comparisons easier. The steps -# involved are:- -# (1) copy the whole tree (minus the PRUNEPATH defined below) to the CMP_DIR -# location. Use tar as it seems like the most appropriate tool for copying -# large directory trees around. -# (2) delete all symlinks. -# (3) gunzip all `*.gz' files. -# (4) delete all hardlinked files (of course trying to leaving the "master" -# intact) -# (5) convert all `*.a' files (ar archives) into a directory of the same name -# containing the unpacked object files. -# (6) fully strip the whole lot (but being careful to strip only the debug -# symbols from object `*.o' files). - -#----------------------------------# -do_ica_prep() { # -#----------------------------------# -: <> $TMP_FILE - done - - echo -n "Copying files to ${CMP_DIR}... " - cd / - tar -X $TMP_FILE -cf - . | tar -C $CMP_DIR -xf - || { - echo -e "\n\n${RED}ERROR:${OFF} tar copy failed!\n" >&2 - exit 1 - } - echo "done." - rm -f $TMP_FILE - - echo -n "Removing symbolic links in ${CMP_DIR}... " - find $CMP_DIR -type l | xargs rm -f - echo "done." - - echo -n "Gunzipping \".gz\" files in ${CMP_DIR}... " - find $CMP_DIR -name '*.gz' | xargs gunzip - echo "done." - - # This was a bit tricky. You'll probably have to do it by hand - # to see what's actually going on. The "sort/uniq" part is - # inspired from the example DirCmp script from the book "Shell - # Programming Examples" by Bruce Blinn, published by Prentice - # Hall. We are essentially using the `-ls' option of the find - # utility to allow manipulations based on inode numbers. - # - # FIXME - this is a bit unreliable - rem out for now - #echo -n "Removing hardlinked file copies in ${CMP_DIR}... " - #find $CMP_DIR -ls | sort -n > $ALL_FILES - #find $CMP_DIR -ls | sort -n -u > $UNIQUE_FILES - #cat $UNIQUE_FILES $ALL_FILES | sort | uniq -u | awk '{ print $11 }' | xargs rm -f - #rm -f $ALL_FILES $UNIQUE_FILES - #echo "done." - - # ar archives contain date & time stamp info that causes us - # grief when trying to find differences. Here we perform some - # hackery to allow easy diffing. Essentially, replace each - # archive with a dir of the same name and extract the object - # files from the archive into this dir. Despite their names, - # libieee.a & libmcheck.a are not actual ar archives. - # - echo -n "Extracting object files from \".a\" files in ${CMP_DIR}... " - L=$(find $CMP_DIR -name '*.a' ! -name 'libieee.a' ! -name 'libmcheck.a') - - for F in $L; do - mv $F ${F}.XX - mkdir $F - cd $F - BN=${F##*/} - ar x ../${BN}.XX || { - echo -e "\n\n${RED}ERROR:${OFF} ar archive extraction failed!\n" >&2 - exit 1 - } - rm -f ../${BN}.XX - done - echo "done." - - echo -n "Stripping (debug) symbols from \".o\" files in ${CMP_DIR}... " - find $CMP_DIR -name '*.o' | xargs strip -p -g 2>/dev/null - echo "done." - - echo -n "Stripping (all) symbols from files OTHER THAN \".o\" files in ${CMP_DIR}... " - find $CMP_DIR ! -name '*.o' | xargs strip -p 2>/dev/null || : - echo "done." - - echo -e "\n${CYAN}[ICA] - ICA preparation for Iteration ${ITER}\c" - echo -e " complete.${OFF}\n${BORDER}" - do_stamp icaprep - fi -} - - -#----------------------------------# -do_ica_work() { # Do the ICA grunt work. -#----------------------------------# -: < $RAWDIFF || : - echo "done." - - echo -e "The list of binary files that differ:\n" > $REPORT - grep "iles.*differ$" $RAWDIFF >> $REPORT - echo -e "\n" >> $REPORT - - echo -e "The list of files that exist \"only in\" 1 of the directories:\n" >> $REPORT - - if grep "^Only in" $RAWDIFF >/dev/null 2>&1; then - grep "^Only in" $RAWDIFF >> $REPORT - else - echo NONE >> $REPORT - fi - - grep -v "iles.*differ$" $RAWDIFF | grep -v "^Only in" > ${SCRATCH_DIR}/logs/${1}V${2}.ASCII.DIFF - rm -f $RAWDIFF - -}