Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create initial package based on the work of Matz and Coolo
build-compare rev 1 in openSUSE:Tools
- Loading branch information
0 parents
commit 5cba04f
Showing
4 changed files
with
338 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
------------------------------------------------------------------- | ||
Tue Jan 27 14:27:19 CET 2009 - adrian@suse.de | ||
|
||
- Create initial package based on the work of Matz and Coolo | ||
This package provides script for the main build script to be able | ||
to check if a new build has the same result than the former one. | ||
The Build Service is able to skip the new build than. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# | ||
# spec file for package build (Version 2009.01.27) | ||
# | ||
# Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany. | ||
# | ||
# All modifications and additions to the file contributed by third parties | ||
# remain the property of their copyright owners, unless otherwise agreed | ||
# upon. The license for this file, and modifications and additions to the | ||
# file, is the same license as for the pristine package itself (unless the | ||
# license for the pristine package is not an Open Source License, in which | ||
# case the license is the MIT License). An "Open Source License" is a | ||
# license that conforms to the Open Source Definition (Version 1.9) | ||
# published by the Open Source Initiative. | ||
|
||
# Please submit bugfixes or comments via http://bugs.opensuse.org/ | ||
# | ||
|
||
# norootforbuild | ||
|
||
|
||
Name: build-compare | ||
License: GPL v2 or later | ||
Group: Development/Tools/Building | ||
AutoReqProv: on | ||
Summary: A Script to Build SUSE Linux RPMs | ||
Version: 2009.01.27 | ||
Release: 2 | ||
Source: same-build-result.sh | ||
Source1: rpm-check.sh | ||
BuildRoot: %{_tmppath}/%{name}-%{version}-build | ||
BuildArch: noarch | ||
|
||
%description | ||
This package provides a script for building RPMs for SUSE Linux in a | ||
chroot environment. | ||
|
||
|
||
%prep | ||
mkdir $RPM_BUILD_DIR/%name-%version | ||
%setup -T 0 -D | ||
|
||
%build | ||
|
||
%install | ||
mkdir -p $RPM_BUILD_ROOT/usr/lib/build/ | ||
install -m 0755 %SOURCE0 %SOURCE1 $RPM_BUILD_ROOT/usr/lib/build/ | ||
|
||
%files | ||
%defattr(-,root,root) | ||
/usr/lib/build | ||
|
||
%changelog | ||
* Tue Jan 27 2009 adrian@suse.de | ||
- Initial package based on the work of Matz and Coolo | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,236 @@ | ||
#! /bin/bash | ||
# Written by Michael Matz and Stephan Coolo | ||
RPM="rpm -qp --nodigest --nosignature" | ||
|
||
if test "$#" != 2; then | ||
echo "usage: $0 old.rpm new.rpm" | ||
exit 1 | ||
fi | ||
|
||
oldrpm=`readlink -f $1` | ||
newrpm=`readlink -f $2` | ||
|
||
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 | ||
|
||
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>/' | ||
} | ||
|
||
QF="%{NAME}" | ||
|
||
# don't look at RELEASE, it contains our build number | ||
QF="$QF %{VERSION} %{EPOCH}\\n" | ||
QF="$QF %{SUMMARY}\\n%{DESCRIPTION}\\n" | ||
# ignored for now | ||
#QF="$QF %{VENDOR} %{DISTRIBUTION}" | ||
QF="$QF %{LICENSE} %{COPYRIGHT}\\n" | ||
QF="$QF %{GROUP} %{URL} %{EXCLUDEARCH} %{EXCLUDEOS} %{EXCLUSIVEARCH}\\n" | ||
QF="$QF %{EXCLUSIVEOS} %{RPMVERSION} %{PLATFORM}\\n" | ||
QF="$QF %{PAYLOADFORMAT} %{PAYLOADCOMPRESSOR} %{PAYLOADFLAGS}\\n" | ||
|
||
QF="$QF [%{PREINPROG} %{PREIN}\\n]\\n[%{POSTINPROG} %{POSTIN}\\n]\\n[%{PREUNPROG} %{PREUN}\\n]\\n[%{POSTUNPROG} %{POSTUN}\\n]\\n" | ||
|
||
# XXX We also need to check the existence (but not the content (!)) | ||
# of SIGGPG (and perhaps the other SIG*) | ||
|
||
# XXX We don't look at triggers | ||
|
||
QF="$QF [%{VERIFYSCRIPTPROG} %{VERIFYSCRIPT}]\\n" | ||
|
||
# Only the first ChangeLog entry; should be enough | ||
QF="$QF %{CHANGELOGTIME} %{CHANGELOGNAME} %{CHANGELOGTEXT}\\n" | ||
|
||
file1=`mktemp` | ||
file2=`mktemp` | ||
|
||
check_header() | ||
{ | ||
$RPM --qf "$QF" "$1" | ||
} | ||
|
||
check_header $oldrpm > $file1 | ||
check_header $newrpm > $file2 | ||
|
||
# the DISTURL tag can be used as checkin ID | ||
#echo "$QF" | ||
if ! diff -au $file1 $file2; then | ||
rm $file1 $file2 | ||
exit 1 | ||
fi | ||
|
||
release1=`$RPM --qf "%{RELEASE}" "$oldrpm"` | ||
release2=`$RPM --qf "%{RELEASE}" "$newrpm"` | ||
|
||
check_provides() | ||
{ | ||
|
||
# provides destroy this because at least the self-provide includes the | ||
# -buildnumber :-( | ||
QF="[%{PROVIDENAME} %{PROVIDEFLAGS} %{PROVIDEVERSION}\\n]\\n" | ||
QF="$QF [%{REQUIRENAME} %{REQUIREFLAGS} %{REQUIREVERSION}\\n]\\n" | ||
QF="$QF [%{CONFLICTNAME} %{CONFLICTFLAGS} %{CONFLICTVERSION}\\n]\\n" | ||
QF="$QF [%{OBSOLETENAME} %{OBSOLETEFLAGS} %{OBSOLETEVERSION}\\n]\\n" | ||
check_header "$1" | sed -e "s,-$2,-@RELEASE@," | ||
} | ||
|
||
check_provides $oldrpm $release1 > $file1 | ||
check_provides $newrpm $release2 > $file2 | ||
|
||
if ! diff -au $file1 $file2; then | ||
rm $file1 $file2 | ||
exit 1 | ||
fi | ||
|
||
# First check the file attributes and later the md5s | ||
|
||
# Now the files. We leave out mtime and size. For normal files | ||
# the size will influence the MD5 anyway. For directories the sizes can | ||
# differ, depending on which file system the package was built. To not | ||
# have to filter out directories we simply ignore all sizes. | ||
# Also leave out FILEDEVICES, FILEINODES (depends on the build host), | ||
# FILECOLORS, FILECLASS (???), FILEDEPENDSX and FILEDEPENDSN. | ||
# Also FILELANGS (or?) | ||
QF="[%{FILENAMES} %{FILEFLAGS} %{FILESTATES} %{FILEMODES:octal} %{FILEUSERNAME} %{FILEGROUPNAME} %{FILERDEVS} %{FILEVERIFYFLAGS} %{FILELINKTOS}\n]\\n" | ||
# ??? what to do with FILEPROVIDE and FILEREQUIRE? | ||
|
||
check_header $oldrpm > $file1 | ||
check_header $newrpm > $file2 | ||
|
||
if ! diff -au $file1 $file2; then | ||
rm $file1 $file2 | ||
exit 1 | ||
fi | ||
|
||
# now the md5sums. if they are different, we check more detailed | ||
# if there are different filenames, we will already have aborted before | ||
QF="[%{FILENAMES} %{FILEMD5S}\n]\\n" | ||
check_header $oldrpm > $file1 | ||
check_header $newrpm > $file2 | ||
|
||
# done if the same | ||
if cmp -s $file1 $file2; then | ||
rm $file1 $file2 | ||
exit 0 | ||
fi | ||
|
||
files=`diff -U0 $file1 $file2 | fgrep -v +++ | grep ^+ | cut -b2- | awk '{print $1}'` | ||
|
||
dir=`mktemp -d` | ||
cd $dir | ||
mkdir old | ||
cd old | ||
/usr/bin/unrpm -q $oldrpm | ||
cd .. | ||
|
||
mkdir new | ||
cd new | ||
/usr/bin/unrpm -q $newrpm | ||
cd .. | ||
|
||
dfile=`mktemp` | ||
ret=0 | ||
|
||
check_single_file() | ||
{ | ||
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 | ||
;; | ||
*.dll|*.exe) | ||
# we can't handle it well enough | ||
echo "mono files unhandled ($file)" | ||
ret=1 | ||
break;; | ||
*.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 | ||
check_single_file $fdir/$f | ||
done | ||
continue;; | ||
*.pyc|*.pyo) | ||
perl -E "open fh, '+<', 'old/$file'; seek fh, 3, SEEK_SET; print fh '0000';" | ||
perl -E "open fh, '+<', 'new/$file'; seek fh, 3, SEEK_SET; print fh '0000';" | ||
;; | ||
*.bz2) | ||
bunzip2 old/$file new/$file | ||
check_single_file ${file/.bz2/} | ||
continue;; | ||
*.gz) | ||
gunzip old/$file new/$file | ||
check_single_file ${file/.gz/} | ||
continue;; | ||
esac | ||
|
||
ftype=`/usr/bin/file old/$file | cut -d: -f2-` | ||
case $ftype in | ||
*executable*|*LSB\ shared\ object*) | ||
objdump -d old/$file | filter_disasm > $file1 | ||
sed -i -e "s,old/,," $file1 | ||
objdump -d 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 2000 $dfile | ||
ret=1 | ||
break | ||
fi | ||
objdump -s old/$file > $file1 | ||
sed -i -e "s,old/,," $file1 | ||
objdump -s new/$file > $file2 | ||
sed -i -e "s,new/,," $file2 | ||
if ! diff -u $file1 $file2 > $dfile; then | ||
echo "$file differs in ELF sections" | ||
head -n 200 $dfile | ||
else | ||
echo "WARNING: no idea about $file" | ||
fi | ||
ret=1 | ||
break | ||
;; | ||
*ASCII*|*text*) | ||
if ! cmp -s old/$file new/$file; then | ||
echo "$file differs ($ftype)" | ||
diff -u old/$file1 new/$file2 | head -n 200 | ||
ret=1 | ||
break | ||
fi | ||
;; | ||
*) | ||
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 | ||
ret=1 | ||
break | ||
fi | ||
;; | ||
esac | ||
} | ||
|
||
for file in $files; do | ||
check_single_file $file | ||
done | ||
|
||
rm $file1 $file2 $dfile | ||
rm -r $dir | ||
exit $ret | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
# The script decides if the new build differes from the former one, | ||
# using rpm-check.sh. | ||
# | ||
# Written by Adrian Schroeter <adrian@suse.de> | ||
|
||
CMPSCRIPT=${0%/*}/rpm-check.sh | ||
|
||
OLDDIR="$1" | ||
shift | ||
NEWDIRS="$*" | ||
|
||
|
||
echo "$CMPSCRIPT" | ||
|
||
if [ ! -d "$OLDDIR" ]; then | ||
echo "No valid directory with old build result given !" | ||
exit 1 | ||
fi | ||
if [ -z "$NEWDIRS" ]; then | ||
echo "No valid directory with new build result given !" | ||
exit 1 | ||
fi | ||
|
||
OLDRPMS=($(find "$OLDDIR" -name \*src.rpm|sort) $(find "$OLDDIR" -name \*rpm -a ! -name \*src.rpm|sort)) | ||
NEWRPMS=($(find $NEWDIRS -name \*src.rpm|sort) $(find $NEWDIRS -name \*rpm -a ! -name \*src.rpm|sort)) | ||
|
||
|
||
for opac in "$OLDRPMS"; do | ||
npac=${NEWRPMS[0]} | ||
NEWRPMS=(${NEWRPMS[@]:1}) # shift | ||
echo compare "$opac" "$npac" | ||
bash $CMPSCRIPT "$opac" "$npac" || exit 1 | ||
done | ||
|
||
echo compare validated built as indentical ! | ||
exit 0 | ||
|