[1b9148c] | 1 | # $Id$
|
---|
| 2 |
|
---|
[a5fa1a9] | 3 | #----------------------------------#
|
---|
| 4 | wrt_ica_targets() { #
|
---|
| 5 | #----------------------------------#
|
---|
| 6 | local ICA_rebuild=$1
|
---|
| 7 | (
|
---|
| 8 | cat << EOF
|
---|
| 9 | ICA_rebuild: $ICA_rebuild
|
---|
| 10 |
|
---|
| 11 | EOF
|
---|
| 12 | ) >> $MKFILE
|
---|
| 13 | }
|
---|
| 14 |
|
---|
[1b9148c] | 15 | # Acknowledgment:
|
---|
| 16 | # The following code is a modified version of an original work written by
|
---|
[a5fa1a9] | 17 | # Greg Schafer for the "DIY Linux" project and is included here with his
|
---|
| 18 | # permission.
|
---|
[1b9148c] | 19 | # ref: http://www.diy-linux.org
|
---|
| 20 | #
|
---|
| 21 | #
|
---|
| 22 | # ---------------------------------------------------------------------------- #
|
---|
| 23 | # Here are the ICA functions.
|
---|
| 24 | # ---------------------------------------------------------------------------- #
|
---|
| 25 | #
|
---|
| 26 | # Here we prepare for the Iterative Comparison Analysis (ICA). Essentially, we
|
---|
| 27 | # copy most of our chroot phase files to a new location then perform some
|
---|
| 28 | # manipulations on the copied files to make diff comparisons easier. The steps
|
---|
| 29 | # involved are:-
|
---|
| 30 | # (1) copy the whole tree (minus the PRUNEPATH defined below) to the CMP_DIR
|
---|
| 31 | # location. Use tar as it seems like the most appropriate tool for copying
|
---|
| 32 | # large directory trees around.
|
---|
| 33 | # (2) delete all symlinks.
|
---|
| 34 | # (3) gunzip all `*.gz' files.
|
---|
| 35 | # (4) delete all hardlinked files (of course trying to leaving the "master"
|
---|
| 36 | # intact)
|
---|
| 37 | # (5) convert all `*.a' files (ar archives) into a directory of the same name
|
---|
| 38 | # containing the unpacked object files.
|
---|
| 39 | # (6) fully strip the whole lot (but being careful to strip only the debug
|
---|
| 40 | # symbols from object `*.o' files).
|
---|
| 41 |
|
---|
| 42 | #----------------------------------#
|
---|
| 43 | do_ica_prep() { #
|
---|
| 44 | #----------------------------------#
|
---|
| 45 | : <<inline_doc
|
---|
| 46 | desc:
|
---|
| 47 |
|
---|
[a5fa1a9] | 48 | usage:
|
---|
| 49 |
|
---|
| 50 | input vars:
|
---|
[1b9148c] | 51 | externals: --
|
---|
| 52 | modifies: --
|
---|
| 53 | returns: --
|
---|
[a5fa1a9] | 54 | on error:
|
---|
| 55 | on success:
|
---|
[1b9148c] | 56 | inline_doc
|
---|
| 57 |
|
---|
| 58 | local CMP_DIR F L BN
|
---|
| 59 | local ALL_FILES=/tmp/allfiles.$$
|
---|
| 60 | local UNIQUE_FILES=/tmp/uniquefiles.$$
|
---|
| 61 | local PRUNEPATH="$TT_PFX $PATCHES_DIR $SCRATCH_DIR $TARBALLS_DIR \
|
---|
| 62 | /dev /home /mnt /proc /root /sys /tmp /usr/src /lost+found"
|
---|
| 63 |
|
---|
| 64 | if [ ! -f "${STAMP_DIR}/icaprep" ]; then
|
---|
| 65 | CMP_DIR="${SCRATCH_DIR}/cmp/iter${ITER}"
|
---|
| 66 | test -d "$CMP_DIR" || mkdir -p $CMP_DIR
|
---|
| 67 |
|
---|
| 68 | echo -e "\n${BORDER}\n${CYAN}[ICA] - starting ICA preparation for\c"
|
---|
| 69 | echo -e " Iteration ${ITER}.${OFF}\n"
|
---|
| 70 |
|
---|
| 71 | # Create a file that we can pass to tar as an "exclude list".
|
---|
| 72 | # There might be an easier way to achieve tar exclusions? Strip
|
---|
| 73 | # the leading /.
|
---|
| 74 | for F in $PRUNEPATH; do
|
---|
| 75 | echo ${F#*/} >> $TMP_FILE
|
---|
| 76 | done
|
---|
| 77 |
|
---|
| 78 | echo -n "Copying files to ${CMP_DIR}... "
|
---|
| 79 | cd /
|
---|
| 80 | tar -X $TMP_FILE -cf - . | tar -C $CMP_DIR -xf - || {
|
---|
| 81 | echo -e "\n\n${RED}ERROR:${OFF} tar copy failed!\n" >&2
|
---|
| 82 | exit 1
|
---|
| 83 | }
|
---|
| 84 | echo "done."
|
---|
| 85 | rm -f $TMP_FILE
|
---|
| 86 |
|
---|
| 87 | echo -n "Removing symbolic links in ${CMP_DIR}... "
|
---|
| 88 | find $CMP_DIR -type l | xargs rm -f
|
---|
| 89 | echo "done."
|
---|
| 90 |
|
---|
| 91 | echo -n "Gunzipping \".gz\" files in ${CMP_DIR}... "
|
---|
| 92 | find $CMP_DIR -name '*.gz' | xargs gunzip
|
---|
| 93 | echo "done."
|
---|
| 94 |
|
---|
| 95 | # This was a bit tricky. You'll probably have to do it by hand
|
---|
| 96 | # to see what's actually going on. The "sort/uniq" part is
|
---|
| 97 | # inspired from the example DirCmp script from the book "Shell
|
---|
| 98 | # Programming Examples" by Bruce Blinn, published by Prentice
|
---|
| 99 | # Hall. We are essentially using the `-ls' option of the find
|
---|
| 100 | # utility to allow manipulations based on inode numbers.
|
---|
| 101 | #
|
---|
| 102 | # FIXME - this is a bit unreliable - rem out for now
|
---|
| 103 | #echo -n "Removing hardlinked file copies in ${CMP_DIR}... "
|
---|
| 104 | #find $CMP_DIR -ls | sort -n > $ALL_FILES
|
---|
| 105 | #find $CMP_DIR -ls | sort -n -u > $UNIQUE_FILES
|
---|
| 106 | #cat $UNIQUE_FILES $ALL_FILES | sort | uniq -u | awk '{ print $11 }' | xargs rm -f
|
---|
| 107 | #rm -f $ALL_FILES $UNIQUE_FILES
|
---|
| 108 | #echo "done."
|
---|
| 109 |
|
---|
| 110 | # ar archives contain date & time stamp info that causes us
|
---|
| 111 | # grief when trying to find differences. Here we perform some
|
---|
| 112 | # hackery to allow easy diffing. Essentially, replace each
|
---|
| 113 | # archive with a dir of the same name and extract the object
|
---|
| 114 | # files from the archive into this dir. Despite their names,
|
---|
| 115 | # libieee.a & libmcheck.a are not actual ar archives.
|
---|
| 116 | #
|
---|
| 117 | echo -n "Extracting object files from \".a\" files in ${CMP_DIR}... "
|
---|
| 118 | L=$(find $CMP_DIR -name '*.a' ! -name 'libieee.a' ! -name 'libmcheck.a')
|
---|
| 119 |
|
---|
| 120 | for F in $L; do
|
---|
| 121 | mv $F ${F}.XX
|
---|
| 122 | mkdir $F
|
---|
| 123 | cd $F
|
---|
| 124 | BN=${F##*/}
|
---|
| 125 | ar x ../${BN}.XX || {
|
---|
| 126 | echo -e "\n\n${RED}ERROR:${OFF} ar archive extraction failed!\n" >&2
|
---|
| 127 | exit 1
|
---|
| 128 | }
|
---|
| 129 | rm -f ../${BN}.XX
|
---|
| 130 | done
|
---|
| 131 | echo "done."
|
---|
| 132 |
|
---|
| 133 | echo -n "Stripping (debug) symbols from \".o\" files in ${CMP_DIR}... "
|
---|
| 134 | find $CMP_DIR -name '*.o' | xargs strip -p -g 2>/dev/null
|
---|
| 135 | echo "done."
|
---|
| 136 |
|
---|
| 137 | echo -n "Stripping (all) symbols from files OTHER THAN \".o\" files in ${CMP_DIR}... "
|
---|
| 138 | find $CMP_DIR ! -name '*.o' | xargs strip -p 2>/dev/null || :
|
---|
| 139 | echo "done."
|
---|
| 140 |
|
---|
| 141 | echo -e "\n${CYAN}[ICA] - ICA preparation for Iteration ${ITER}\c"
|
---|
| 142 | echo -e " complete.${OFF}\n${BORDER}"
|
---|
| 143 | do_stamp icaprep
|
---|
| 144 | fi
|
---|
| 145 | }
|
---|
| 146 |
|
---|
| 147 |
|
---|
| 148 | #----------------------------------#
|
---|
| 149 | do_ica_work() { # Do the ICA grunt work.
|
---|
| 150 | #----------------------------------#
|
---|
| 151 | : <<inline_doc
|
---|
| 152 | desc:
|
---|
[a5fa1a9] | 153 |
|
---|
[1b9148c] | 154 | usage: do_ica_work 1 2
|
---|
| 155 | do_ica_work 2 3
|
---|
| 156 |
|
---|
| 157 | input vars: $1 iteration number to use
|
---|
| 158 | $2 iteration number to use
|
---|
| 159 | externals: --
|
---|
| 160 | modifies: --
|
---|
| 161 | returns: --
|
---|
[a5fa1a9] | 162 | on error:
|
---|
| 163 | on success:
|
---|
[1b9148c] | 164 | inline_doc
|
---|
| 165 |
|
---|
| 166 | local ICA_DIR="${SCRATCH_DIR}/cmp"
|
---|
| 167 | local RAWDIFF=/tmp/rawdiff.$$
|
---|
| 168 | local REPORT="${SCRATCH_DIR}/logs/REPORT.${1}V${2}"
|
---|
| 169 |
|
---|
| 170 | cd $ICA_DIR
|
---|
| 171 |
|
---|
| 172 | echo -n "Diffing iter${1} and iter${2}... "
|
---|
| 173 | diff -ur iter${1} iter${2} > $RAWDIFF || :
|
---|
| 174 | echo "done."
|
---|
| 175 |
|
---|
| 176 | echo -e "The list of binary files that differ:\n" > $REPORT
|
---|
| 177 | grep "iles.*differ$" $RAWDIFF >> $REPORT
|
---|
| 178 | echo -e "\n" >> $REPORT
|
---|
| 179 |
|
---|
| 180 | echo -e "The list of files that exist \"only in\" 1 of the directories:\n" >> $REPORT
|
---|
| 181 |
|
---|
| 182 | if grep "^Only in" $RAWDIFF >/dev/null 2>&1; then
|
---|
| 183 | grep "^Only in" $RAWDIFF >> $REPORT
|
---|
| 184 | else
|
---|
| 185 | echo NONE >> $REPORT
|
---|
| 186 | fi
|
---|
| 187 |
|
---|
| 188 | grep -v "iles.*differ$" $RAWDIFF | grep -v "^Only in" > ${SCRATCH_DIR}/logs/${1}V${2}.ASCII.DIFF
|
---|
| 189 | rm -f $RAWDIFF
|
---|
| 190 |
|
---|
| 191 | }
|
---|