forked from openSUSE/build-compare
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrpm-check.sh
739 lines (706 loc) · 24 KB
/
rpm-check.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
#! /bin/bash
#
# Copyright (c) 2009, 2010, 2011, 2012 SUSE Linux Product GmbH, Germany.
# Licensed under GPL v2, see COPYING file for details.
#
# Written by Michael Matz and Stephan Coolo
# Enhanced by Andreas Jaeger
FUNCTIONS=${0%/*}/functions.sh
check_all=
case $1 in
-a | --check-all)
check_all=1
shift
esac
if test "$#" != 2; then
echo "usage: $0 [-a|--check-all] old.rpm new.rpm"
exit 1
fi
source $FUNCTIONS
oldrpm=`readlink -f $1`
newrpm=`readlink -f $2`
rename_script=`mktemp`
if test ! -f $oldrpm; then
echo "can't open $oldrpm"
exit 1
fi
if test ! -f $newrpm; then
echo "can't open $newrpm"
exit 1
fi
#usage unjar <file>
function unjar()
{
local file
file=$1
if [[ $(type -p fastjar) ]]; then
UNJAR=fastjar
elif [[ $(type -p jar) ]]; then
UNJAR=jar
elif [[ $(type -p unzip) ]]; then
UNJAR=unzip
else
echo "ERROR: jar, fastjar, or unzip is not installed (trying file $file)"
exit 1
fi
case $UNJAR in
jar|fastjar)
# echo jar -xf $file
${UNJAR} -xf $file
;;
unzip)
unzip -oqq $file
;;
esac
}
# list files in directory
#usage unjar_l <file>
function unjar_l()
{
local file
file=$1
if [[ $(type -p fastjar) ]]; then
UNJAR=fastjar
elif [[ $(type -p jar) ]]; then
UNJAR=jar
elif [[ $(type -p unzip) ]]; then
UNJAR=unzip
else
echo "ERROR: jar, fastjar, or unzip is not installed (trying file $file)"
exit 1
fi
case $UNJAR in
jar|fastjar)
${UNJAR} -tf $file
;;
unzip)
unzip -l $file
;;
esac
}
filter_disasm()
{
sed -e 's/^ *[0-9a-f]\+://' -e 's/\$0x[0-9a-f]\+/$something/' -e 's/callq *[0-9a-f]\+/callq /' -e 's/# *[0-9a-f]\+/# /' -e 's/\(0x\)\?[0-9a-f]\+(/offset(/' -e 's/[0-9a-f]\+ </</' -e 's/^<\(.*\)>:/\1:/' -e 's/<\(.*\)+0x[0-9a-f]\+>/<\1 + ofs>/'
}
cmp_spec $rename_script
RES=$?
case $RES in
0)
echo "RPM meta information is identical"
if test -z "$check_all"; then
exit 0
fi
;;
1)
echo "RPM meta information is different"
if test -z "$check_all"; then
exit 1
fi
;;
2)
echo "RPM file checksum differs."
RES=0
;;
*)
echo "Wrong exit code!"
exit 1
;;
esac
file1=`mktemp`
file2=`mktemp`
dir=`mktemp -d`
echo "Extracting packages"
unrpm $oldrpm $dir/old
unrpm $newrpm $dir/new
cd $dir
bash $rename_script
dfile=`mktemp`
diff_two_files()
{
if ! cmp -s old/$file new/$file; then
echo "$file differs ($ftype)"
hexdump -C old/$file > $file1
hexdump -C new/$file > $file2
diff -u $file1 $file2 | head -n 200
return 1
fi
return 0
}
trim_man_first_line()
{
# Handles the first line if it is like:
#.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28)
#.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.43.3.
local f=$1
sed -i -e '1{
s|^\.\\"[[:blank:]]\+Automatically[[:blank:]]generated[[:blank:]]by[[:blank:]]Pod::Man[[:blank:]].*|.\\" Overly verbose Pod::Man|
s|^\.\\"[[:blank:]]\+DO[[:blank:]]NOT[[:blank:]]MODIFY[[:blank:]]THIS[[:blank:]]FILE![[:blank:]]\+It[[:blank:]]was[[:blank:]]generated[[:blank:]]by[[:blank:]]help2man[[:blank:]].*|.\\" Overly verbose help2man|
}' $f
}
trim_man_TH()
{
# Handles lines like:
# .TH debhelper 7 "2010-02-27" "7.4.15" "Debhelper"
# .TH DIRMNGR-CLIENT 1 2010-02-27 "Dirmngr 1.0.3" "GNU Privacy Guard"
# .TH ccmake 1 "March 06, 2010" "ccmake 2.8.1-rc3"
# .TH QEMU-IMG 1 "2010-03-14" " " " "
# .TH kdecmake 1 "May 07, 2010" "cmake 2.8.1"
# .TH "appender.h" 3 "12 May 2010" "Version 1.2.1" "log4c" \" -*- nroff -*-
# .TH "appender.h" 3 "Tue Aug 31 2010" "Version 1.2.1" "log4c" \" -*- nroff -*-
# .TH "OFFLINEIMAP" "1" "11 May 2010" "John Goerzen" "OfflineIMAP Manual"
# .TH gv 3guile "13 May 2010"
#.TH "GIT\-ARCHIMPORT" "1" "09/13/2010" "Git 1\&.7\&.1" "Git Manual"
# .TH LDIRECTORD 8 "2010-10-20" "perl v5.12.2" "User Contributed Perl Documentation"
# .TH ccmake 1 "February 05, 2012" "ccmake 2.8.7"
# .TH "appender.h" 3 "Tue Aug 31 2010" "Version 1.2.1" "log4c" \" -*- nroff -*-
# .TH ARCH "1" "September 2010" "GNU coreutils 8.5" "User Commands"
# .TH "GCM-CALIBRATE" "1" "03 February 2012" "" ""
#.TH Locale::Po4a::Xml.pm 3pm "2015-01-30" "Po4a Tools" "Po4a Tools"
local f=$1
# (.TH quoted section) (quoted_date)(*)
sed -i -e 's|^\([[:blank:]]*\.TH[[:blank:]]\+"[^"]\+"[[:blank:]]\+[^[:blank:]]\+\)[[:blank:]]\+\("[^"]\+"\)\([[:blank:]]\+.*\)\?|\1 "qq2000-01-01"\3|' $f
# (.TH unquoted section) (quoted_date)(*)
sed -i -e 's|^\([[:blank:]]*\.TH[[:blank:]]\+[^"][^[:blank:]]\+[[:blank:]]\+[^[:blank:]]\+\)[[:blank:]]\+\("[^"]\+"\)\([[:blank:]]\+.*\)\?|\1 "uq2000-02-02"\3|' $f
# (.TH quoted section) (unquoted_date)(*)
sed -i -e 's|^\([[:blank:]]*\.TH[[:blank:]]\+"[^"]\+"[[:blank:]]\+[^[:blank:]]\+\)[[:blank:]]\+\([^"][^[:blank:]]\+\)\([[:blank:]]\+.*\)\?|\1 qu2000-03-03\3|' $f
# (.TH unquoted section) (unquoted_date)(*)
sed -i -e 's|^\([[:blank:]]*\.TH[[:blank:]]\+[^"][^[:blank:]]\+[[:blank:]]\+[^[:blank:]]\+\)[[:blank:]]\+\([^"][^[:blank:]]\+\)\([[:blank:]]\+.*\)\?|\1 uu2000-04-04\3|' $f
}
strip_numbered_anchors()
{
# Remove numbered anchors on Docbook / HTML files.
# This should be save since we remove them from old and new files.
# A trailing </a> or </div> tag will stay also on both files.
for f in old/$file new/$file; do
sed -i -e 's%<[ ]*a[ ]\+name[^<]*[0-9]\+[^<]*%%g' \
-e 's%<[ ]*a[ ]\+href[^<]*#[^<]*[0-9]\+[^<]*%%g' \
-e 's%<[^<]*id="ftn\.[^<]*[0-9]\+[^<]*%%g' $f
done
}
check_compressed_file()
{
local file=$1
local ext=$2
local tmpdir=`mktemp -d`
local ftype
local ret=0
echo "$ext file with odd filename: $file"
if test -n "$tmpdir"; then
mkdir $tmpdir/{old,new}
cp --parents --dereference old/$file $tmpdir/
cp --parents --dereference new/$file $tmpdir/
if pushd $tmpdir > /dev/null ; then
case "$ext" in
bz2)
mv old/$file{,.bz2}
mv new/$file{,.bz2}
bzip2 -d old/$file.bz2
bzip2 -d new/$file.bz2
;;
gzip)
mv old/$file{,.gz}
mv new/$file{,.gz}
gzip -d old/$file.gz
gzip -d new/$file.gz
;;
xz)
mv old/$file{,.xz}
mv new/$file{,.xz}
xz -d old/$file.xz
xz -d new/$file.xz
;;
esac
ftype=`/usr/bin/file old/$file | sed 's@^[^:]\+:[[:blank:]]*@@'`
case $ftype in
POSIX\ tar\ archive)
echo "$ext content is: $ftype"
mv old/$file{,.tar}
mv new/$file{,.tar}
if ! check_single_file ${file}.tar; then
ret=1
fi
;;
ASCII\ cpio\ archive\ *)
echo "$ext content is: $ftype"
mv old/$file{,.cpio}
mv new/$file{,.cpio}
if ! check_single_file ${file}.cpio; then
ret=1
fi
;;
*)
echo "unhandled $ext content: $ftype"
if ! diff_two_files; then
ret=1
fi
;;
esac
popd > /dev/null
fi
rm -rf "$tmpdir"
fi
return $ret
}
check_single_file()
{
local file="$1"
case $file in
*.spec)
sed -i -e "s,Release:.*$release1,Release: @RELEASE@," old/$file
sed -i -e "s,Release:.*$release2,Release: @RELEASE@," new/$file
;;
*.exe.mdb|*.dll.mdb)
# Just debug information, we can skip them
echo "$file skipped as debug file."
return 0
;;
*.a)
flist=`ar t new/$file`
pwd=$PWD
fdir=`dirname $file`
cd old/$fdir
ar x `basename $file`
cd $pwd/new/$fdir
ar x `basename $file`
cd $pwd
for f in $flist; do
if ! check_single_file $fdir/$f; then
return 1
fi
done
return 0
;;
*.cpio)
flist=`cpio --quiet --list --force-local < "new/$file"`
pwd=$PWD
fdir=$file.extract.$PPID.$$
mkdir old/$fdir new/$fdir
cd old/$fdir
cpio --quiet --extract --force-local < "../${file##*/}"
cd $pwd/new/$fdir
cpio --quiet --extract --force-local < "../${file##*/}"
cd $pwd
local ret=0
for f in $flist; do
if ! check_single_file $fdir/$f; then
ret=1
if test -z "$check_all"; then
break
fi
fi
done
rm -rf old/$fdir new/$fdir
return $ret
;;
*.tar|*.tar.bz2|*.tar.gz|*.tgz|*.tbz2)
flist=`tar tf new/$file`
pwd=$PWD
fdir=`dirname $file`
cd old/$fdir
tar xf `basename $file`
cd $pwd/new/$fdir
tar xf `basename $file`
cd $pwd
local ret=0
for f in $flist; do
if ! check_single_file $fdir/$f; then
ret=1
if test -z "$check_all"; then
break
fi
fi
done
return $ret
;;
*.zip|*.jar|*.war)
cd old
unjar_l ./$file |sort > flist
# 10-05-2010 14:39
sed -i -e "s, [0-9][0-9]-[0-9][0-9]-[0-9]\+ [0-9][0-9]:[0-9][0-9] , date ," flist
# 2012-02-03 07:59
sed -i -e "s, 20[0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9] , date ," flist
cd ../new
unjar_l ./$file |sort> flist
sed -i -e "s, [0-9][0-9]-[0-9][0-9]-[0-9]\+ [0-9][0-9]:[0-9][0-9] , date ,; " flist
sed -i -e "s, 20[0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9] , date ," flist
cd ..
if ! cmp -s old/flist new/flist; then
echo "$file has different file list"
diff -u old/flist new/flist
return 1
fi
flist=`grep date new/flist | sed -e 's,.* date ,,'`
pwd=$PWD
fdir=`dirname $file`
cd old/$fdir
unjar `basename $file`
cd $pwd/new/$fdir
unjar `basename $file`
cd $pwd
local ret=0
for f in $flist; do
if test -f new/$fdir/$f && ! check_single_file $fdir/$f; then
ret=1
if test -z "$check_all"; then
break
fi
fi
done
return $ret;;
*.pyc|*.pyo)
perl -e "open fh, '+<', 'old/$file'; seek fh, 4, SEEK_SET; print fh '0000';"
perl -e "open fh, '+<', 'new/$file'; seek fh, 4, SEEK_SET; print fh '0000';"
;;
*.bz2)
bunzip2 -c old/$file > old/${file/.bz2/}
bunzip2 -c new/$file > new/${file/.bz2/}
check_single_file ${file/.bz2/}
return $?
;;
*.gz)
gunzip -c old/$file > old/${file/.gz/}
gunzip -c new/$file > new/${file/.gz/}
check_single_file ${file/.gz/}
return $?
;;
*png)
# Try to remove timestamps, only if convert from ImageMagick is installed
if [[ $(type -p convert) ]]; then
convert old/$file +set date:create +set date:modify old/${file/.png/_n.png}
convert old/$file +set date:create +set date:modify new/${file/.png/_n.png}
if ! cmp -s old/${file/.png/_n.png} new/${file/.png/_n.png}; then
echo "$file differs ($ftype)"
hexdump -C old/${file/.png/_n.png} > $file1
hexdump -C new/${file/.png/_n.png} > $file2
diff -u $file1 $file2 | head -n 20
return 1
fi
return 0
fi
;;
/usr/share/locale/*/LC_MESSAGES/*.mo|/usr/share/locale-bundle/*/LC_MESSAGES/*.mo)
for f in old/$file new/$file; do
sed -i -e "s,POT-Creation-Date: ....-..-.. ..:..+....,POT-Creation-Date: 1970-01-01 00:00+0000," $f
done
;;
/usr/share/doc/packages/*/*.html|\
/usr/share/doc/kde/HTML/*/*/*.html|/usr/share/doc/*/html/*.html)
for f in old/$file new/$file; do
# texi2html output, e.g. in kvm, indent, qemu
sed -i -e "s|^<!-- Created on .*, 20.. by texi2html .\...|<!-- Created on August 7, 2009 by texi2html 1.82|" $f
sed -i -e 's|^ *This document was generated by <em>Autobuild</em> on <em>.*, 20..</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html .\...</em></a>.$| This document was generated by <em>Autobuild</em> on <em>August 7, 2009</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.82</em></a>.|' $f
# doxygen docu, e.g. in libssh and log4c
sed -i -e 's|Generated on ... ... [0-9]* [0-9]*:[0-9][0-9]:[0-9][0-9] 20[0-9][0-9] for |Generated on Mon May 10 20:45:00 2010 for |' $f
# Generated on Sat Aug 14 2010 16:49:48 for libssh
sed -i -e 's|Generated on ... ... [0-9]* 20[0-9][0-9] [0-9]*:[0-9][0-9]:[0-9][0-9] for |Generated on Mon May 10 20:45:00 2010 for |' $f
done
strip_numbered_anchors
;;
/usr/share/javadoc/*.html |\
/usr/share/javadoc/*/*.html|/usr/share/javadoc/*/*/*.html)
strip_numbered_anchors
# There are more timestamps in html, so far we handle only some primitive versions.
for f in old/$file new/$file; do
# Javadoc:
# <head>
# <!-- Generated by javadoc (version 1.7.0_75) on Tue Feb 03 02:20:12 GMT 2015 -->
# <!-- Generated by javadoc on Tue Feb 03 00:02:48 GMT 2015 -->
# <meta name="date" content="2015-02-03">
# </head>
sed -i -e '
/^<head>/{
: next
n
/^<\/head>/{
b end_head
}
s/^\(<!-- Generated by javadoc\) \((\(build\|version\) [0-9._]\+) on ... ... .. ..:..:.. \(GMT\|UTC\) ....\) \(-->\)/\1 some-date-removed-by-build-compare \5/
t next
s/^\(<!-- Generated by javadoc\) \(on ... ... .. ..:..:.. \(GMT\|UTC\) ....\) \(-->\)/\1 some-date-removed-by-build-compare \3/
t next
s/^<meta name="date" content="[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}">/<meta name="date" content="some-date-removed-by-build-compare">/
b next
}
: end_head
' $f
# Gjdoc HtmlDoclet:
sed -i -e 's%Generated by Gjdoc HtmlDoclet [0-9,.]*, part of <a href="http://www.gnu.org/software/classpath/cp-tools/" title="" target="_top">GNU Classpath Tools</a>, on .*, 20.. [0-9]*:..:.. \(a\|p\)\.m\. GMT.%Generated by Gjdoc.%' $f
sed -i -e 's%<!DOCTYPE html PUBLIC "-//gnu.org///DTD XHTML 1.1 plus Target 1.0//EN"\(.*\)GNU Classpath Tools</a>, on [A-Z][a-z]* [0-9]*, 20?? [0-9]*:??:?? \(a|p\)\.m\. GMT.</p>%<!DOCTYPE html PUBLIC "-//gnu.org///DTD XHTML 1.1 plus Target 1.0//EN"\1GNU Classpath Tools</a>, on January 1, 2009 0:00:00 a.m. GMT.</p>%' $f
sed -i -e 's%<!DOCTYPE html PUBLIC "-//gnu.org///DTD\(.*GNU Classpath Tools</a>\), on [a-zA-Z]* [0-9][0-9], 20.. [0-9]*:..:.. \(a\|p\)\.m\. GMT.</p>%<!DOCTYPE html PUBLIC "-//gnu.org///DTD\1,on May 1, 2010 1:11:42 p.m. GMT.</p>%' $f
# deprecated-list is randomly ordered, sort it for comparison
case $f in
*/deprecated-list.html)
sort -o $f $f
;;
esac
done
;;
/usr/share/javadoc/gjdoc.properties |\
/usr/share/javadoc/*/gjdoc.properties)
for f in old/$file new/$file; do
sed -i -e 's|^#[A-Z][a-z]\{2\} [A-Z][a-z]\{2\} [0-9]\{2\} ..:..:.. GMT 20..$|#Fri Jan 01 11:27:36 GMT 2009|' $f
done
;;
*/fonts.scale|*/fonts.dir|*/encodings.dir)
for f in old/$file new/$file; do
# sort files before comparing
sort -o $f $f
done
;;
/var/adm/perl-modules/*)
for f in old/$file new/$file; do
sed -i -e 's|^=head2 ... ... .. ..:..:.. ....: C<Module>|=head2 Wed Jul 1 00:00:00 2009: C<Module>|' $f
done
;;
/usr/share/man/man3/*3pm)
for f in old/$file new/$file; do
sed -i -e 's| 3 "20..-..-.." "perl v5....." "User Contributed Perl Documentation"$| 3 "2009-01-01" "perl v5.10.0" "User Contributed Perl Documentation"|' $f
trim_man_TH $f
trim_man_first_line $f
done
;;
/usr/share/man/man*/*|/usr/lib/texmf/doc/man/*/*)
for f in old/$file new/$file; do
trim_man_TH $f
trim_man_first_line $f
# generated by docbook xml:
#.\" Date: 09/13/2010
sed -i -e 's|Date: [0-1][0-9]/[0-9][0-9]/201[0-9]|Date: 09/13/2010|' $f
done
;;
*.elc)
# emacs lisp files
for f in old/$file new/$file; do
sed -i -e 's|Compiled by abuild@.* on ... ... .. ..:..:.. 20..$|compiled by abuild@buildhost on Wed Jul 01 00:00:00 2009|' $f
done
;;
/var/lib/texmf/web2c/*/*fmt |\
/var/lib/texmf/web2c/metafont/*.base|\
/var/lib/texmf/web2c/metapost/*.mem)
# binary dump of TeX and Metafont formats, we can ignore them for good
echo "difference in $file ignored."
return 0
;;
*/libtool)
for f in old/$file new/$file; do
sed -i -e 's|^# Libtool was configured on host [A-Za-z0-9]*:$|# Libtool was configured on host x42:|' $f
done
;;
/etc/mail/*cf|/etc/sendmail.cf)
# from sendmail package
for f in old/$file new/$file; do
# - ##### built by abuild@build33 on Thu May 6 11:21:17 UTC 2010
sed -i -e 's|built by abuild@[a-z0-9]* on ... ... [0-9]* [0-9]*:[0-9][0-9]:[0-9][0-9] .* 20[0-9][0-9]|built by abuild@build42 on Thu May 6 11:21:17 UTC 2010|' $f
done
;;
/usr/share/doc/kde/HTML/*/*/index.cache|/usr/share/doc/kde/HTML/*/*/*/index.cache|\
/usr/share/gtk-doc/html/*/*.html|/usr/share/gtk-doc/html/*/*.devhelp2)
# various kde and gtk packages
strip_numbered_anchors
;;
*/created.rid)
# ruby documentation
# file just contains a timestamp and nothing else, so ignore it
echo "Ignore $file"
return 0
;;
*/rdoc/files/*.html)
# ruby documentation
# <td>Mon Sep 20 19:02:43 +0000 2010</td>
for f in old/$file new/$file; do
sed -i -e 's%<td>[A-Z][a-z][a-z] [A-Z][a-z][a-z] [0-9]\+ [0-9]\+:[0-9]\+:[0-9]\+ +0000 201[0-9]</td>%<td>Mon Sep 20 19:02:43 +0000 2010</td>%g' $f
done
strip_numbered_anchors
;;
*/Linux*Env.Set.sh)
# LibreOffice files, contains:
# Generated on: Mon Apr 18 13:19:22 UTC 2011
for f in old/$file new/$file; do
sed -i -e 's%^# Generated on:.*UTC 201[0-9] *$%# Generated on: Sometime%g' $f
done
;;
/usr/lib/libreoffice/solver/inc/*/deliver.log)
# LibreOffice log file
echo "Ignore $file"
return 0
;;
/var/adm/update-messages/*|/var/adm/update-scripts/*)
# encode version-release inside
oldfn=`echo "$file"|sed -e s/-$release2/-$release1/;`
# fetchmsttfonts embeds the release number in the update shell script.
echo sed -i -e "s/-$release1/-$release2/g;" "old/$oldfn"
sed -i -e "s/-$release1/-$release2/g;" "old/$oldfn"
if ! diff -u old/$oldfn new/$file; then
echo "$oldfn is not same as $file"
return 1
fi
echo "$file and $oldfn are same"
return 0
;;
*.ps)
for f in "old/$file" "new/$file"; do
sed -i -e '
/^%%CreationDate:[[:blank:]]/d
/^%%Creator:[[:blank:]]groff[[:blank:]]version[[:blank:]]/d
' "$f"
done
;;
*pdf)
# PDF files contain a unique ID, remove it
# Format of the ID is:
# /ID [<9ACE247A70CF9BEAFEE15E116259BD6D> <9ACE247A70CF9BEAFEE15E116259BD6D>]
# with optional spaces. pdftex creates also:
# /CreationDate (D:20120103083206Z)
# /ModDate (D:20120103083206Z)
# and possibly XML metadata as well
for f in "old/$file" "new/$file"; do
sed -i \
'/obj/,/endobj/{
s%/ID \?\[ \?<[^>]\+> \?<[^>]\+> \?\]%/IDrandom%g;
s%/CreationDate \?(D:[^)]*)%/CreationDate (D: XXX)%g;
s%/ModDate \?(D:[^)]*)%/ModDate (D: XXX)%g;
s%<pdf:CreationDate>[^<]*</pdf:CreationDate>%<pdf:CreationDate>XXX</pdf:CreationDate>%g;
s%<pdf:ModDate>[^<]*</pdf:ModDate>%<pdf:ModDate>XXX</pdf:ModDate>%g;
s%<xap:CreateDate>[^<]*</xap:CreateDate>%<xap:CreateDate>XXX</xap:CreateDate>%g;
s%<xap:ModifyDate>[^<]*</xap:ModifyDate>%<xap:ModifyDate>XXX</xap:ModifyDate>%g;
s%<xap:MetadataDate>[^<]*</xap:MetadataDate>%<xap:MetadataDate>XXX</xap:MetadataDate>%g;
}' "$f"
done
;;
esac
ftype=`/usr/bin/file old/$file | sed 's@^[^:]\+:[[:blank:]]*@@'`
case $ftype in
PE32\ executable*Mono\/\.Net\ assembly*)
echo "PE32 Mono/.Net assembly: $file"
if [ -x /usr/bin/monodis ] ; then
monodis old/$file 2>/dev/null|sed -e 's/GUID = {.*}/GUID = { 42 }/;'> ${file1}
monodis new/$file 2>/dev/null|sed -e 's/GUID = {.*}/GUID = { 42 }/;'> ${file2}
if ! cmp -s ${file1} ${file2}; then
echo "$file differs ($ftype)"
diff -u ${file1} ${file2}
return 1
fi
else
echo "Cannot compare, no monodis installed"
return 1
fi
;;
ELF*executable*|ELF*[LM]SB\ shared\ object*)
objdump -d --no-show-raw-insn old/$file | filter_disasm > $file1
if ! test -s $file1; then
# objdump has no idea how to handle it
if ! diff_two_files; then
ret=1
break
fi
fi
sed -i -e "s,old/,," $file1
objdump -d --no-show-raw-insn new/$file | filter_disasm > $file2
sed -i -e "s,new/,," $file2
if ! diff -u $file1 $file2 > $dfile; then
echo "$file differs in assembler output"
head -n 200 $dfile
return 1
fi
echo "" >$file1
echo "" >$file2
# Don't compare .build-id and .gnu_debuglink sections
sections="$(objdump -s new/$file | grep "Contents of section .*:" | sed -r "s,.* (.*):,\1,g" | grep -v -e "\.build-id" -e "\.gnu_debuglink" | tr "\n" " ")"
for section in $sections; do
objdump -s -j $section old/$file | sed "s,old/,," >> $file1
objdump -s -j $section new/$file | sed "s,new/,," >> $file2
done
if ! diff -u $file1 $file2 > $dfile; then
echo "$file differs in ELF sections"
head -n 200 $dfile
else
echo "$file: only difference was in build-id or gnu_debuglink, GOOD."
return 0
fi
return 1
;;
*ASCII*|*text*)
if ! cmp -s old/$file new/$file; then
echo "$file differs ($ftype)"
diff -u old/$file new/$file | head -n 200
return 1
fi
;;
directory|setuid,\ directory|sticky,\ directory)
# tar might package directories - ignore them here
return 0
;;
bzip2\ compressed\ data*)
if ! check_compressed_file "$file" "bz2"; then
return 1
fi
;;
gzip\ compressed\ data*)
if ! check_compressed_file "$file" "gzip"; then
return 1
fi
;;
XZ\ compressed\ data*)
if ! check_compressed_file "$file" "xz"; then
return 1
fi
;;
POSIX\ tar\ archive)
mv old/$file{,.tar}
mv new/$file{,.tar}
if ! check_single_file ${file}.tar; then
return 1
fi
;;
cpio\ archive)
mv old/$file{,.cpio}
mv new/$file{,.cpio}
if ! check_single_file ${file}.cpio; then
return 1
fi
;;
symbolic\ link\ to\ *)
readlink "old/$file" > $file1
readlink "new/$file" > $file2
if ! diff -u $file1 $file2; then
echo "symlink target for $file differs"
return 1
fi
;;
*)
if ! diff_two_files; then
return 1
fi
;;
esac
return 0
}
# We need /proc mounted for some tests, so check that it's mounted and
# complain if not.
PROC_MOUNTED=0
if [ ! -d /proc/self/ ]; then
echo "/proc is not mounted"
mount -orw -n -tproc none /proc
PROC_MOUNTED=1
fi
# preserve cmp_spec result for check_all runs
ret=$RES
for file in $files; do
if ! check_single_file $file; then
ret=1
if test -z "$check_all"; then
break
fi
fi
done
if [ "$PROC_MOUNTED" -eq "1" ]; then
echo "Unmounting proc"
umount /proc
fi
rm $file1 $file2 $dfile $rename_script
rm -rf $dir
if test "$ret" = 0; then
echo "RPM content is identical"
fi
exit $ret
# vim: tw=666 ts=2 et