From 24ff297a021e48d5339643863079c29562917e6f8ca760715d59d9fc802d75cc Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Mon, 6 Nov 2017 16:16:43 +0000 Subject: [PATCH] - Fix usage of cmp_spec and unrpm in srpm-check.sh - Catch empty rpm -qp --qf output for tags not understood by rpm OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/build-compare?expand=0&rev=242 --- build-compare.changes | 10 +++++++ build-compare.spec | 2 +- functions.sh | 67 ++++++++++++++++++++++++------------------- pkg-diff.sh | 6 ++-- srpm-check.sh | 7 +++-- 5 files changed, 56 insertions(+), 36 deletions(-) diff --git a/build-compare.changes b/build-compare.changes index 68db778..bbd4e99 100644 --- a/build-compare.changes +++ b/build-compare.changes @@ -1,3 +1,13 @@ +------------------------------------------------------------------- +Mon Nov 6 15:15:04 UTC 2017 - olaf@aepfle.de + +- Fix usage of cmp_spec and unrpm in srpm-check.sh + +------------------------------------------------------------------- +Fri Nov 3 14:03:04 UTC 2017 - olaf@aepfle.de + +- Catch empty rpm -qp --qf output for tags not understood by rpm + ------------------------------------------------------------------- Fri Oct 20 06:53:18 UTC 2017 - olaf@aepfle.de diff --git a/build-compare.spec b/build-compare.spec index 6fc7431..54eff8e 100644 --- a/build-compare.spec +++ b/build-compare.spec @@ -21,7 +21,7 @@ Summary: Build Result Compare Script License: GPL-2.0+ Group: Development/Tools/Building Url: https://github.com/openSUSE/build-compare -Version: 20171020T085619.7cef93b +Version: 20171106T161852.f10fa76 Release: 0 Source1: COPYING Source2: same-build-result.sh diff --git a/functions.sh b/functions.sh index 5b46274..7923178 100644 --- a/functions.sh +++ b/functions.sh @@ -146,7 +146,7 @@ function unpackage() # $1: printed info # $2: file1 # $3: file2 -# $4, $5: spec_old and spec_new, for cleanup. +# $4, $5: rpm_meta_old and rpm_meta_new, for cleanup. function comp_file() { echo "comparing $1" @@ -208,7 +208,7 @@ function set_regex() { # 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 () +function cmp_rpm_meta () { local RES local file1 file2 @@ -219,36 +219,45 @@ function cmp_spec () file1=`mktemp` file2=`mktemp` - spec_old=`mktemp` - spec_new=`mktemp` + rpm_meta_old=`mktemp` + rpm_meta_new=`mktemp` - check_header "$QF_ALL" $oldrpm > $spec_old - check_header "$QF_ALL" $newrpm > $spec_new + check_header "$QF_ALL" $oldrpm > $rpm_meta_old + check_header "$QF_ALL" $newrpm > $rpm_meta_new - name_new="$(get_value QF_NAME $spec_new)" - version_release_new="$(get_value QF_VER_REL $spec_new)" - name_ver_rel_new="$(get_value QF_NAME_VER_REL $spec_new)" + # rpm returns 0 even in case of error + if test -s $rpm_meta_old && test -s $rpm_meta_new ; then + : some output provided, all query tags understood by rpm + else + ls -l $rpm_meta_old $rpm_meta_new + echo "empty 'rpm -qp' output..." + return 1 + fi - version_release_old="$(get_value QF_VER_REL $spec_old)" - name_ver_rel_old="$(get_value QF_NAME_VER_REL $spec_old)" + name_new="$(get_value QF_NAME $rpm_meta_new)" + version_release_new="$(get_value QF_VER_REL $rpm_meta_new)" + name_ver_rel_new="$(get_value QF_NAME_VER_REL $rpm_meta_new)" + + version_release_old="$(get_value QF_VER_REL $rpm_meta_old)" + name_ver_rel_old="$(get_value QF_NAME_VER_REL $rpm_meta_old)" set_regex # Check the whole spec file at first, return 0 immediately if the # are the same. - cat $spec_old | trim_release_old > $file1 - cat $spec_new | trim_release_new > $file2 + cat $rpm_meta_old | trim_release_old > $file1 + cat $rpm_meta_new | trim_release_new > $file2 echo "comparing the rpm tags of $name_new" if diff -au $file1 $file2; then if test -z "$check_all"; then - rm $file1 $file2 $spec_old $spec_new + rm $file1 $file2 $rpm_meta_old $rpm_meta_new return 0 fi fi - get_value QF_TAGS $spec_old > $file1 - get_value QF_TAGS $spec_new > $file2 - comp_file rpmtags $file1 $file2 $spec_old $spec_new || return 1 + get_value QF_TAGS $rpm_meta_old > $file1 + get_value QF_TAGS $rpm_meta_new > $file2 + comp_file rpmtags $file1 $file2 $rpm_meta_old $rpm_meta_new || return 1 # This might happen when?! echo "comparing RELEASE" @@ -266,24 +275,24 @@ function cmp_spec () esac fi - get_value QF_PROVIDES $spec_old | trim_release_old | sort > $file1 - get_value QF_PROVIDES $spec_new | trim_release_new | sort > $file2 - comp_file PROVIDES $file1 $file2 $spec_old $spec_new || return 1 + get_value QF_PROVIDES $rpm_meta_old | trim_release_old | sort > $file1 + get_value QF_PROVIDES $rpm_meta_new | trim_release_new | sort > $file2 + comp_file PROVIDES $file1 $file2 $rpm_meta_old $rpm_meta_new || return 1 - get_value QF_SCRIPT $spec_old | trim_release_old > $file1 - get_value QF_SCRIPT $spec_new | trim_release_new > $file2 - comp_file scripts $file1 $file2 $spec_old $spec_new || return 1 + get_value QF_SCRIPT $rpm_meta_old | trim_release_old > $file1 + get_value QF_SCRIPT $rpm_meta_new | trim_release_new > $file2 + comp_file scripts $file1 $file2 $rpm_meta_old $rpm_meta_new || return 1 # First check the file attributes and later the md5s - get_value QF_FILELIST $spec_old | trim_release_old > $file1 - get_value QF_FILELIST $spec_new | trim_release_new > $file2 - comp_file filelist $file1 $file2 $spec_old $spec_new || return 1 + get_value QF_FILELIST $rpm_meta_old | trim_release_old > $file1 + get_value QF_FILELIST $rpm_meta_new | trim_release_new > $file2 + comp_file filelist $file1 $file2 $rpm_meta_old $rpm_meta_new || return 1 # now the md5sums. if they are different, we check more detailed # if there are different filenames, we will already have aborted before # file flag 64 means "ghost", filter those out. - get_value QF_CHECKSUM $spec_old | grep -v " 64$" | trim_release_old > $file1 - get_value QF_CHECKSUM $spec_new | grep -v " 64$" | trim_release_new > $file2 + get_value QF_CHECKSUM $rpm_meta_old | grep -v " 64$" | trim_release_old > $file1 + get_value QF_CHECKSUM $rpm_meta_new | grep -v " 64$" | trim_release_new > $file2 RES=2 # done if the same echo "comparing file checksum" @@ -294,7 +303,7 @@ function cmp_spec () # Get only files with different MD5sums files=`diff -U0 $file1 $file2 | fgrep -v +++ | grep ^+ | cut -b2- | awk '{print $1}'` - if test -f "$sh"; then + if test -n "$sh"; then echo "creating rename script" # Create a temporary helper script to rename files/dirs with release in it for f in `$RPM --qf '[%{FILENAMES} %{FILEFLAGS}\n]\n' "$oldrpm" | grep_release_old | grep -vw 64$ | awk '{ print $1}'` diff --git a/pkg-diff.sh b/pkg-diff.sh index fde4823..aa0bd18 100644 --- a/pkg-diff.sh +++ b/pkg-diff.sh @@ -223,7 +223,7 @@ echo "Comparing `basename $oldpkg` to `basename $newpkg`" case $oldpkg in *.rpm) - cmp_spec $rename_script $oldpkg $newpkg + cmp_rpm_meta "$rename_script" "$oldpkg" "$newpkg" RES=$? case $RES in 0) @@ -264,7 +264,7 @@ case $oldpkg in ;; esac -# files is set in cmp_spec for rpms, so if RES is empty we should assume +# files is set in cmp_rpm_meta for rpms, so if RES is empty we should assume # it wasn't an rpm and pick all files for comparison. if [ -z $RES ]; then oldfiles=`cd $dir/old; find . -type f` @@ -926,7 +926,7 @@ if [ ! -d /proc/self/ ]; then PROC_MOUNTED=1 fi -# preserve cmp_spec result for check_all runs +# preserve cmp_rpm_meta result for check_all runs ret=$RES for file in $files; do if ! check_single_file $file; then diff --git a/srpm-check.sh b/srpm-check.sh index 74a122a..ace1a9d 100644 --- a/srpm-check.sh +++ b/srpm-check.sh @@ -26,6 +26,7 @@ source $FUNCTIONS oldrpm=`readlink -f $1` newrpm=`readlink -f $2` +rename_script= # Get version-release from first RPM and keep for rpmlint check # Remember to quote the "." for future regexes @@ -36,7 +37,7 @@ ver_rel_new=$(rpm -qp --nodigest --nosignature --qf "%{RELEASE}" "${newrpm}"|sed # if those are not the same, the source RPM has changed and therefore # the resulting files are needed. -cmp_spec +cmp_rpm_meta "$rename_script" "$oldrpm" "$newrpm" RES=$? case $RES in 0) @@ -59,8 +60,8 @@ esac # nothing else dir=`mktemp -d` -unrpm $oldrpm $dir/old -unrpm $newrpm $dir/new +unpackage $oldrpm $dir/old +unpackage $newrpm $dir/new cd $dir check_single_file()