source: common/func_ICA.sh@ 6b1576a

experimental
Last change on this file since 6b1576a was 1b9148c, checked in by George Boudreau <georgeb@…>, 19 years ago

inital creation of func_ICA.sh & func_check_version.sh

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