- Timestamp:
- 04/09/2006 08:46:08 AM (18 years ago)
- Branches:
- experimental
- Children:
- dc526ea
- Parents:
- 091cc83
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
common/func_ICA.sh
r091cc83 r11869f1 76 76 done 77 77 } 78 79 # Acknowledgment:80 # The following code is a modified version of an original work written by81 # Greg Schafer for the "DIY Linux" project and is included here with his82 # permission.83 # ref: http://www.diy-linux.org84 #85 #86 # ---------------------------------------------------------------------------- #87 # Here are the ICA functions.88 # ---------------------------------------------------------------------------- #89 #90 # Here we prepare for the Iterative Comparison Analysis (ICA). Essentially, we91 # copy most of our chroot phase files to a new location then perform some92 # manipulations on the copied files to make diff comparisons easier. The steps93 # involved are:-94 # (1) copy the whole tree (minus the PRUNEPATH defined below) to the CMP_DIR95 # location. Use tar as it seems like the most appropriate tool for copying96 # large directory trees around.97 # (2) delete all symlinks.98 # (3) gunzip all `*.gz' files.99 # (4) delete all hardlinked files (of course trying to leaving the "master"100 # intact)101 # (5) convert all `*.a' files (ar archives) into a directory of the same name102 # containing the unpacked object files.103 # (6) fully strip the whole lot (but being careful to strip only the debug104 # symbols from object `*.o' files).105 106 #----------------------------------#107 do_ica_prep() { #108 #----------------------------------#109 : <<inline_doc110 desc:111 112 usage:113 114 input vars:115 externals: --116 modifies: --117 returns: --118 on error:119 on success:120 inline_doc121 122 local CMP_DIR F L BN123 local ALL_FILES=/tmp/allfiles.$$124 local UNIQUE_FILES=/tmp/uniquefiles.$$125 local PRUNEPATH="$TT_PFX $PATCHES_DIR $SCRATCH_DIR $TARBALLS_DIR \126 /dev /home /mnt /proc /root /sys /tmp /usr/src /lost+found"127 128 if [ ! -f "${STAMP_DIR}/icaprep" ]; then129 CMP_DIR="${SCRATCH_DIR}/cmp/iter${ITER}"130 test -d "$CMP_DIR" || mkdir -p $CMP_DIR131 132 echo -e "\n${BORDER}\n${CYAN}[ICA] - starting ICA preparation for\c"133 echo -e " Iteration ${ITER}.${OFF}\n"134 135 # Create a file that we can pass to tar as an "exclude list".136 # There might be an easier way to achieve tar exclusions? Strip137 # the leading /.138 for F in $PRUNEPATH; do139 echo ${F#*/} >> $TMP_FILE140 done141 142 echo -n "Copying files to ${CMP_DIR}... "143 cd /144 tar -X $TMP_FILE -cf - . | tar -C $CMP_DIR -xf - || {145 echo -e "\n\n${RED}ERROR:${OFF} tar copy failed!\n" >&2146 exit 1147 }148 echo "done."149 rm -f $TMP_FILE150 151 echo -n "Removing symbolic links in ${CMP_DIR}... "152 find $CMP_DIR -type l | xargs rm -f153 echo "done."154 155 echo -n "Gunzipping \".gz\" files in ${CMP_DIR}... "156 find $CMP_DIR -name '*.gz' | xargs gunzip157 echo "done."158 159 # This was a bit tricky. You'll probably have to do it by hand160 # to see what's actually going on. The "sort/uniq" part is161 # inspired from the example DirCmp script from the book "Shell162 # Programming Examples" by Bruce Blinn, published by Prentice163 # Hall. We are essentially using the `-ls' option of the find164 # utility to allow manipulations based on inode numbers.165 #166 # FIXME - this is a bit unreliable - rem out for now167 #echo -n "Removing hardlinked file copies in ${CMP_DIR}... "168 #find $CMP_DIR -ls | sort -n > $ALL_FILES169 #find $CMP_DIR -ls | sort -n -u > $UNIQUE_FILES170 #cat $UNIQUE_FILES $ALL_FILES | sort | uniq -u | awk '{ print $11 }' | xargs rm -f171 #rm -f $ALL_FILES $UNIQUE_FILES172 #echo "done."173 174 # ar archives contain date & time stamp info that causes us175 # grief when trying to find differences. Here we perform some176 # hackery to allow easy diffing. Essentially, replace each177 # archive with a dir of the same name and extract the object178 # files from the archive into this dir. Despite their names,179 # libieee.a & libmcheck.a are not actual ar archives.180 #181 echo -n "Extracting object files from \".a\" files in ${CMP_DIR}... "182 L=$(find $CMP_DIR -name '*.a' ! -name 'libieee.a' ! -name 'libmcheck.a')183 184 for F in $L; do185 mv $F ${F}.XX186 mkdir $F187 cd $F188 BN=${F##*/}189 ar x ../${BN}.XX || {190 echo -e "\n\n${RED}ERROR:${OFF} ar archive extraction failed!\n" >&2191 exit 1192 }193 rm -f ../${BN}.XX194 done195 echo "done."196 197 echo -n "Stripping (debug) symbols from \".o\" files in ${CMP_DIR}... "198 find $CMP_DIR -name '*.o' | xargs strip -p -g 2>/dev/null199 echo "done."200 201 echo -n "Stripping (all) symbols from files OTHER THAN \".o\" files in ${CMP_DIR}... "202 find $CMP_DIR ! -name '*.o' | xargs strip -p 2>/dev/null || :203 echo "done."204 205 echo -e "\n${CYAN}[ICA] - ICA preparation for Iteration ${ITER}\c"206 echo -e " complete.${OFF}\n${BORDER}"207 do_stamp icaprep208 fi209 }210 211 212 #----------------------------------#213 do_ica_work() { # Do the ICA grunt work.214 #----------------------------------#215 : <<inline_doc216 desc:217 218 usage: do_ica_work 1 2219 do_ica_work 2 3220 221 input vars: $1 iteration number to use222 $2 iteration number to use223 externals: --224 modifies: --225 returns: --226 on error:227 on success:228 inline_doc229 230 local ICA_DIR="${SCRATCH_DIR}/cmp"231 local RAWDIFF=/tmp/rawdiff.$$232 local REPORT="${SCRATCH_DIR}/logs/REPORT.${1}V${2}"233 234 cd $ICA_DIR235 236 echo -n "Diffing iter${1} and iter${2}... "237 diff -ur iter${1} iter${2} > $RAWDIFF || :238 echo "done."239 240 echo -e "The list of binary files that differ:\n" > $REPORT241 grep "iles.*differ$" $RAWDIFF >> $REPORT242 echo -e "\n" >> $REPORT243 244 echo -e "The list of files that exist \"only in\" 1 of the directories:\n" >> $REPORT245 246 if grep "^Only in" $RAWDIFF >/dev/null 2>&1; then247 grep "^Only in" $RAWDIFF >> $REPORT248 else249 echo NONE >> $REPORT250 fi251 252 grep -v "iles.*differ$" $RAWDIFF | grep -v "^Only in" > ${SCRATCH_DIR}/logs/${1}V${2}.ASCII.DIFF253 rm -f $RAWDIFF254 255 }
Note:
See TracChangeset
for help on using the changeset viewer.