From 0baab13ece382cc4921245fedc31efc0e575341fb4d2d812d1fc1c39b69cbe92 Mon Sep 17 00:00:00 2001 From: OBS User autobuild Date: Tue, 21 Sep 2010 11:12:13 +0000 Subject: [PATCH] Accepting request 48629 from openSUSE:Tools checked in (request 48629) OBS-URL: https://build.opensuse.org/request/show/48629 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/build-compare?expand=0&rev=82 --- build-compare.changes | 22 ------ build-compare.spec | 12 ++-- functions.sh | 138 ------------------------------------ rpm-check.sh | 158 +++++++++++++++++++++++++++++++----------- same-build-result.sh | 14 ++-- srpm-check.sh | 93 ------------------------- 6 files changed, 131 insertions(+), 306 deletions(-) delete mode 100644 functions.sh delete mode 100644 srpm-check.sh diff --git a/build-compare.changes b/build-compare.changes index ee347af..0463484 100644 --- a/build-compare.changes +++ b/build-compare.changes @@ -1,25 +1,3 @@ -------------------------------------------------------------------- -Mon Sep 20 19:24:10 UTC 2010 - aj@suse.de - -- Handle man pages generated from docbook. -- Handle rubygem documentation. - -------------------------------------------------------------------- -Mon Sep 20 18:45:01 UTC 2010 - aj@suse.de - -- Create common file functions.sh and cleanup code. - -------------------------------------------------------------------- -Mon Sep 20 15:21:55 UTC 2010 - lnussel@suse.de - -- exclude delta rpms - -------------------------------------------------------------------- -Mon Sep 20 07:58:59 UTC 2010 - aj@suse.de - -- Create script for just checking source rpms. - - ------------------------------------------------------------------- Thu Sep 9 20:02:33 UTC 2010 - aj@suse.de diff --git a/build-compare.spec b/build-compare.spec index 28730b4..1129951 100644 --- a/build-compare.spec +++ b/build-compare.spec @@ -25,11 +25,9 @@ AutoReqProv: on Summary: Build Result Compare Script Version: 2009.10.14 Release: 21 -Source1: COPYING -Source2: same-build-result.sh -Source3: rpm-check.sh -Source4: functions.sh -Source5: srpm-check.sh +Source: same-build-result.sh +Source1: rpm-check.sh +Source2: COPYING BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildArch: noarch @@ -47,8 +45,8 @@ mkdir $RPM_BUILD_DIR/%name-%version %install mkdir -p $RPM_BUILD_ROOT/usr/lib/build/ $RPM_BUILD_ROOT/%_defaultdocdir/%name -install -m 0755 %SOURCE2 %SOURCE3 %SOURCE4 %SOURCE5 $RPM_BUILD_ROOT/usr/lib/build/ -install -m 0644 %SOURCE1 $RPM_BUILD_ROOT/%_defaultdocdir/%name/ +install -m 0755 %SOURCE0 %SOURCE1 $RPM_BUILD_ROOT/usr/lib/build/ +install -m 0644 %SOURCE2 $RPM_BUILD_ROOT/%_defaultdocdir/%name/ %files %defattr(-,root,root) diff --git a/functions.sh b/functions.sh deleted file mode 100644 index 6d3d825..0000000 --- a/functions.sh +++ /dev/null @@ -1,138 +0,0 @@ -#! /bin/bash -# -# Copyright (c) 2009, 2010 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 - -# library of functions used by scripts - -RPM="rpm -qp --nodigest --nosignature" - -check_header() -{ - $RPM --qf "$QF" "$1" -} - -function 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@," -} - -#usage unrpm $dir -# Unpack rpm files in directory $dir -# like /usr/bin/unrpm - just for one file and with no options -function unrpm() -{ - local file - local dir - file=$1 - dir=$2 - CPIO_OPTS="--extract --unconditional --preserve-modification-time --make-directories --quiet" - mkdir -p $dir - pushd $dir 1>/dev/null - rpm2cpio $file | cpio ${CPIO_OPTS} - popd 1>/dev/null -} - -# Compare just the rpm meta data of two rpms -# Returns: -# 0 in case of same content -# 1 in case of errors or difference -# 2 in case of differences that need further investigation -# Sets $files with list of files that need further investigation -function cmp_spec () -{ - QF="%{NAME}" - - # don't look at RELEASE, it contains our build number - QF="$QF %{VERSION} %{EPOCH}\\n" - QF="$QF %{SUMMARY}\\n%{DESCRIPTION}\\n" - QF="$QF %{VENDOR} %{DISTRIBUTION} %{DISTURL}" - QF="$QF %{LICENSE} %{LICENSE}\\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 $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 - return 1 - fi - - release1=`$RPM --qf "%{RELEASE}" "$oldrpm"` - release2=`$RPM --qf "%{RELEASE}" "$newrpm"` - - check_provides $oldrpm $release1 > $file1 - check_provides $newrpm $release2 > $file2 - - if ! diff -au $file1 $file2; then - rm $file1 $file2 - return 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 - return 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 - - RES=2 - # done if the same - if cmp -s $file1 $file2; then - RES=0 - fi - - # Get only files with different MD5sums - files=`diff -U0 $file1 $file2 | fgrep -v +++ | grep ^+ | cut -b2- | awk '{print $1}'` - - rm $file1 $file2 - return $RES -} diff --git a/rpm-check.sh b/rpm-check.sh index 52bb489..8d8b393 100644 --- a/rpm-check.sh +++ b/rpm-check.sh @@ -6,7 +6,7 @@ # Written by Michael Matz and Stephan Coolo # Enhanced by Andreas Jaeger -FUNCTIONS=${0%/*}/functions.sh +RPM="rpm -qp --nodigest --nosignature" check_all= case $1 in @@ -20,8 +20,6 @@ if test "$#" != 2; then exit 1 fi -source $FUNCTIONS - oldrpm=`readlink -f $1` newrpm=`readlink -f $2` @@ -35,6 +33,18 @@ if test ! -f $newrpm; then exit 1 fi +#usage unrpm +# Unpack rpm files in current directory +# like /usr/bin/unrpm - just for one file and with no options +function unrpm() +{ + local file + file=$1 + CPIO_OPTS="--extract --unconditional --preserve-modification-time --make-directories --quiet" + + rpm2cpio $file | cpio ${CPIO_OPTS} +} + #usage unjar function unjar() { @@ -96,30 +106,115 @@ 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]\+ :/\1:/' -e 's/<\(.*\)+0x[0-9a-f]\+>/<\1 + ofs>/' } -cmp_spec $1 $2 -RES=$? -case $RES in - 0) - exit 0 - ;; - 1) - exit 1 - ;; - 2) - ;; - *) - echo "Wrong exit code!" - exit 1 - ;; -esac +QF="%{NAME}" + +# don't look at RELEASE, it contains our build number +QF="$QF %{VERSION} %{EPOCH}\\n" +QF="$QF %{SUMMARY}\\n%{DESCRIPTION}\\n" +QF="$QF %{VENDOR} %{DISTRIBUTION} %{DISTURL}" +QF="$QF %{LICENSE} %{LICENSE}\\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` -unrpm $oldrpm $dir/old -unrpm $newrpm $dir/new cd $dir +mkdir old +cd old +unrpm $oldrpm +cd .. + +mkdir new +cd new +unrpm $newrpm +cd .. dfile=`mktemp` @@ -320,12 +415,8 @@ check_single_file() # .TH "OFFLINEIMAP" "1" "11 May 2010" "John Goerzen" "OfflineIMAP Manual" # .TH gv 3guile "13 May 2010" # .TH ARCH "1" "September 2010" "GNU coreutils 8.5" "User Commands" - #.TH "GIT\-ARCHIMPORT" "1" "09/13/2010" "Git 1\&.7\&.1" "Git Manual" for f in old/$file new/$file; do - sed -i -e 's/.TH "\?\([^ "]*\)"\? "\?\([0-9][a-z]*\)"\? "\?\(20[0-9][0-9]-[0-9][0-9]-[0-9][0-9]\|[A-Z][a-z]* [0-9][0-9], 20[0-9][0-9]\|[0-9]* [A-Z][a-z]* 20[0-9][0-9]\|[A-Z][a-z][a-z] [A-Z][a-z][a-z] [0-9]\+ 20[0-9][0-9]\|[A-Z][a-z]* 20[0-9][0-9]\|[0-1][0-9]/[0-9][0-9]/201[0-9]\)"\? /.TH \1 \2 "2000-01-01" /' $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 + sed -i -e 's/.TH "\?\([^ "]*\)"\? "\?\([0-9][a-z]*\)"\? "\?\(20[0-9][0-9]-[0-9][0-9]-[0-9][0-9]\|[A-Z][a-z]* [0-9][0-9], 20[0-9][0-9]\|[0-9]* [A-Z][a-z]* 20[0-9][0-9]\|[A-Z][a-z]* [A-Z][a-z]* [0-9]\+ 20[0-9][0-9]\|[A-Z][a-z]* 20[0-9][0-9]\)"\? /.TH \1 \2 "2000-01-01" /' $f done ;; *.elc) @@ -371,19 +462,7 @@ check_single_file() sed -i -e 's%href="#\([a-z]*\.\)\?id[0-9]*">%href="#\1id0000000">%g' $f done ;; - */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 - # Mon Sep 20 19:02:43 +0000 2010 - for f in old/$file new/$file; do - sed -i -e 's%[A-Z][a-z][a-z] [A-Z][a-z][a-z] [0-9]\+ [0-9]\+:[0-9]\+:[0-9]\+ +0000 201[0-9]%Mon Sep 20 19:02:43 +0000 2010%g' $f - done - ;; + esac ftype=`/usr/bin/file old/$file | cut -d: -f2-` @@ -479,3 +558,4 @@ fi rm $file1 $file2 $dfile rm -r $dir exit $ret + diff --git a/same-build-result.sh b/same-build-result.sh index 42b1fa2..8607ba0 100644 --- a/same-build-result.sh +++ b/same-build-result.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (c) 2009, 2010 SUSE Linux Product Gmbh, Germany. +# Copyright (c) 2009 SUSE Linux Product Gmbh, Germany. # Licensed under GPL v2, see COPYING file for details. # # Written by Adrian Schroeter @@ -11,7 +11,6 @@ # /usr/lib/build/same-build-result.sh /.build.oldpackages /usr/src/packages/RPMS /usr/src/packages/SRPMS CMPSCRIPT=${0%/*}/rpm-check.sh -SCMPSCRIPT=${0%/*}/srpm-check.sh OLDDIR="$1" shift @@ -28,9 +27,9 @@ if [ -z "$NEWDIRS" ]; then exit 1 fi -if test `find $NEWDIRS -name '*.rpm' -and ! -name '*.delta.rpm' | wc -l` != `find $OLDDIR -name '*.rpm' -and ! -name '*.delta.rpm' | wc -l`; then +if test `find $NEWDIRS -name *.rpm | wc -l` != `find $OLDDIR -name *.rpm | wc -l`; then echo "different number of subpackages" - find $OLDDIR $NEWDIRS -name '*.rpm' -and ! -name '*.delta.rpm' + find $OLDDIR $NEWDIRS -name *.rpm exit 1 fi @@ -48,7 +47,7 @@ if test ! -f "$nsrpm"; then fi echo "compare $osrpm $nsrpm" -bash $SCMPSCRIPT "$osrpm" "$nsrpm" || exit 1 +bash $CMPSCRIPT "$osrpm" "$nsrpm" || exit 1 # technically we should not all exclude all -32bit but filter for different archs, # like done with -x86 @@ -57,8 +56,8 @@ bash $SCMPSCRIPT "$osrpm" "$nsrpm" || exit 1 # problem: a package can contain both noarch and arch subpackages, so we have to # take care of proper sorting of NEWRPMS, e.g. noarch/x.rpm and x86_64/w.rpm since OLDRPMS # has all the packages in a single directory and would sort this as w.rpm, x.rpm. -OLDRPMS=($(find "$OLDDIR" -name \*rpm -a ! -name \*src.rpm -a ! -name \*.delta.rpm|sort|grep -v -- -32bit-|grep -v -- -64bit-|grep -v -- '-x86-.*\.ia64\.rpm')) -NEWRPMS=($(find $NEWDIRS -name \*rpm -a ! -name \*src.rpm -a ! -name \*.delta.rpm|sort --field-separator=/ --key=7|grep -v -- -32bit-|grep -v -- -64bit-|grep -v -- '-x86-.*\.ia64\.rpm')) +OLDRPMS=($(find "$OLDDIR" -name \*rpm -a ! -name \*src.rpm|sort|grep -v -- -32bit-|grep -v -- -64bit-|grep -v -- '-x86-.*\.ia64\.rpm')) +NEWRPMS=($(find $NEWDIRS -name \*rpm -a ! -name \*src.rpm|sort --field-separator=/ --key=7|grep -v -- -32bit-|grep -v -- -64bit-|grep -v -- '-x86-.*\.ia64\.rpm')) rpmqp='rpm -qp --qf %{NAME} --nodigest --nosignature ' for opac in ${OLDRPMS[*]}; do @@ -81,3 +80,4 @@ fi echo compare validated built as identical ! exit 0 + diff --git a/srpm-check.sh b/srpm-check.sh deleted file mode 100644 index 39ef90b..0000000 --- a/srpm-check.sh +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2009, 2010 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 - -# Compare two source RPMs - -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` - - -# For source RPMs, we can just check the metadata in the spec file -# if those are not the same, the source RPM has changed and therefore -# the resulting files are needed. - -cmp_spec $1 $2 -RES=$? -case $RES in - 0) - exit 0 - ;; - 1) - exit 1 - ;; - 2) - ;; - *) - echo "Wrong exit code!" - exit 1 - ;; -esac - -# Now check that only the spec file has a changed release number and -# nothing else - -dir=`mktemp -d` -unrpm $oldrpm $dir/old -unrpm $newrpm $dir/new -cd $dir - -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 - if ! cmp -s old/$file new/$file; then - echo "$file differs (spec file)" - diff -u old/$file new/$file | head -n 200 - return 1 - fi - return 0 - ;; - *) - echo "$file differs" - # Nothing else should be changed - ;; - esac - return 1 -} - -ret=0 -for file in $files; do - if ! check_single_file $file; then - ret=1 - if test -z "$check_all"; then - break - fi - fi -done - -rm -r $dir -exit $ret