From 4099e8f1e892b661a92d7ffb8284b00f57c1052d6bbf899b91d5568c9762cd24 Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Fri, 29 May 2020 07:56:29 +0000 Subject: [PATCH 1/4] - Colltect a list of known rpm tags and use it to build the queryformat string for the tags listed below (bsc#1172232) conflict obsolete oldsuggests provide recommend require suggest supplement OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/build-compare?expand=0&rev=274 --- build-compare.changes | 7 ++++ build-compare.spec | 2 +- functions.sh | 95 +++++++++++++++++++++++++++++-------------- 3 files changed, 72 insertions(+), 32 deletions(-) diff --git a/build-compare.changes b/build-compare.changes index fcc8443..ed96dee 100644 --- a/build-compare.changes +++ b/build-compare.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Fri May 29 07:30:51 UTC 2020 - olaf@aepfle.de + +- Colltect a list of known rpm tags and use it to build the + queryformat string for the tags listed below (bsc#1172232) + conflict obsolete oldsuggests provide recommend require suggest supplement + ------------------------------------------------------------------- Thu May 14 07:07:07 UTC 2020 - olaf@aepfle.de diff --git a/build-compare.spec b/build-compare.spec index af4c85a..06b8ba2 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: 20200514T095116.be3487c +Version: 20200529T095124.68a99b1 Release: 0 Source1: COPYING Source2: same-build-result.sh diff --git a/functions.sh b/functions.sh index 34f3cb1..2d39b88 100644 --- a/functions.sh +++ b/functions.sh @@ -10,36 +10,56 @@ RPM="rpm -qp --nodigest --nosignature" +declare -A rpm_querytags +collect_rpm_querytags() { + while read + do + : ${REPLY} + rpm_querytags[${REPLY}]=Y + done < <(rpm --querytags) +} + set_rpm_meta_global_variables() { local pkg=$1 local rpm_tags= local out=`mktemp` + local t v qt + local -a type variant list # Name, Version, Release QF_NAME="%{NAME}" QF_VER_REL="%{VERSION}-%{RELEASE}" QF_NAME_VER_REL="%{NAME}-%{VERSION}-%{RELEASE}" -# provides destroy this because at least the self-provide includes the -# -buildnumber :-( -QF_PROVIDES="[%{PROVIDENAME} %{PROVIDEFLAGS} %{PROVIDEVERSION}\\n]\\n" -QF_PROVIDES="${QF_PROVIDES}[%{REQUIRENAME} %{REQUIREFLAGS} %{REQUIREVERSION}\\n]\\n" -QF_PROVIDES="${QF_PROVIDES}[%{CONFLICTNAME} %{CONFLICTFLAGS} %{CONFLICTVERSION}\\n]\\n" -QF_PROVIDES="${QF_PROVIDES}[%{OBSOLETENAME} %{OBSOLETEFLAGS} %{OBSOLETEVERSION}\\n]\\n" - -rpm_tags="%{RECOMMENDNAME} %{RECOMMENDFLAGS} %{RECOMMENDVERSION}" -check_header "%{NAME} ${rpm_tags}" > "${out}" -if test -s "${out}" -then - QF_PROVIDES="${QF_PROVIDES}[${rpm_tags}\\n]\\n" -fi -rpm_tags="%{SUPPLEMENTNAME} %{SUPPLEMENTFLAGS} %{SUPPLEMENTVERSION}" -check_header "%{NAME} ${rpm_tags}" > "${out}" -if test -s "${out}" -then - QF_PROVIDES="${QF_PROVIDES}[${rpm_tags}\\n]\\n" -fi +QF_PROVIDES= +type=( +CONFLICT +OBSOLETE +OLDSUGGESTS +PROVIDE +RECOMMEND +REQUIRE +SUGGEST +SUPPLEMENT +) +variant=( + NAME + FLAGS + VERSION +) +for t in "${type[@]}" +do + unset list + list=() + for v in "${variant[@]}" + do + qt=${t}${v} + test -n "${rpm_querytags[${qt}]}" || continue + list+=("%{${qt}}") + done + QF_PROVIDES+="${t}\\n[${list[@]}\\n]\\n" +done # don't look at RELEASE, it contains our build number QF_TAGS="%{NAME} %{VERSION} %{EPOCH}\\n" @@ -54,24 +74,36 @@ QF_TAGS="${QF_TAGS}%{PAYLOADFORMAT} %{PAYLOADCOMPRESSOR} %{PAYLOADFLAGS}\\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_TAGS="${QF_TAGS}[%{VERIFYSCRIPTPROG} %{VERIFYSCRIPT}]\\n" # Only the first ChangeLog entry; should be enough QF_TAGS="${QF_TAGS}%{CHANGELOGTIME} %{CHANGELOGNAME} %{CHANGELOGTEXT}\\n" # scripts, might contain release number -script_types=' -PRETRANS -PREIN -POSTIN -PREUN -POSTUN -POSTTRANS -VERIFYSCRIPT -' QF_SCRIPT= -for script_type in ${script_types} +type=( + PRETRANS + PREIN + POSTIN + PREUN + POSTUN + POSTTRANS + VERIFYSCRIPT +) +variant=( + PROG + FLAGS + '' +) +for t in "${type[@]}" do - QF_SCRIPT="${QF_SCRIPT}[%{${script_type}PROG} %{${script_type}FLAGS} %{${script_type}}\\n]\\n" + unset list + list=() + for v in "${variant[@]}" + do + qt=${t}${v} + test -n "${rpm_querytags[${qt}]}" || continue + list+=("%{${qt}}") + done + QF_SCRIPT+="${t}\\n[${list[@]}\\n]\\n" done # Now the files. We leave out mtime and size. For normal files @@ -256,6 +288,7 @@ function cmp_rpm_meta () rpm_meta_old=`mktemp` rpm_meta_new=`mktemp` + collect_rpm_querytags set_rpm_meta_global_variables $oldrpm check_header "$QF_ALL" $oldrpm > $rpm_meta_old From 512e57198a1368e1a7079bdd5df8f42723a1d660d20f1be1dd3ad288c71d9e37 Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Fri, 29 May 2020 08:44:58 +0000 Subject: [PATCH 2/4] whitespace OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/build-compare?expand=0&rev=275 --- build-compare.spec | 2 +- functions.sh | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/build-compare.spec b/build-compare.spec index 06b8ba2..877da06 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: 20200529T095124.68a99b1 +Version: 20200529T104401.01cca87 Release: 0 Source1: COPYING Source2: same-build-result.sh diff --git a/functions.sh b/functions.sh index 2d39b88..e01b262 100644 --- a/functions.sh +++ b/functions.sh @@ -34,14 +34,14 @@ QF_NAME_VER_REL="%{NAME}-%{VERSION}-%{RELEASE}" QF_PROVIDES= type=( -CONFLICT -OBSOLETE -OLDSUGGESTS -PROVIDE -RECOMMEND -REQUIRE -SUGGEST -SUPPLEMENT + CONFLICT + OBSOLETE + OLDSUGGESTS + PROVIDE + RECOMMEND + REQUIRE + SUGGEST + SUPPLEMENT ) variant=( NAME From 8908bc34d3b4d796a1418158f7a222e8d73eecb5e93223d867e4d3d9092b6361 Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Fri, 29 May 2020 16:52:29 +0000 Subject: [PATCH 3/4] Remove usage of associative array variables to support bash3 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/build-compare?expand=0&rev=276 --- build-compare.spec | 2 +- functions.sh | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/build-compare.spec b/build-compare.spec index 877da06..8bd1481 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: 20200529T104401.01cca87 +Version: 20200529T185052.7a95d20 Release: 0 Source1: COPYING Source2: same-build-result.sh diff --git a/functions.sh b/functions.sh index e01b262..0e416a1 100644 --- a/functions.sh +++ b/functions.sh @@ -10,13 +10,16 @@ RPM="rpm -qp --nodigest --nosignature" -declare -A rpm_querytags +declare -a rpm_querytags collect_rpm_querytags() { - while read - do - : ${REPLY} - rpm_querytags[${REPLY}]=Y - done < <(rpm --querytags) + rpm_querytags=( $(rpm --querytags) ) +} +# returns 0 if tag is known, returns 1 if unknown +rpmtag_known() { + local needle="\<${1}\>" + local haystack="${rpm_querytags[@]}" + [[ "${haystack}" =~ ${needle} ]] + return $? } set_rpm_meta_global_variables() { @@ -54,8 +57,8 @@ do list=() for v in "${variant[@]}" do - qt=${t}${v} - test -n "${rpm_querytags[${qt}]}" || continue + qt="${t}${v}" + rpmtag_known "${qt}" || continue list+=("%{${qt}}") done QF_PROVIDES+="${t}\\n[${list[@]}\\n]\\n" @@ -99,8 +102,8 @@ do list=() for v in "${variant[@]}" do - qt=${t}${v} - test -n "${rpm_querytags[${qt}]}" || continue + qt="${t}${v}" + rpmtag_known "${qt}" || continue list+=("%{${qt}}") done QF_SCRIPT+="${t}\\n[${list[@]}\\n]\\n" From 6e953eae7cae9c013c08173f7ef6297227ef4101f2b3da1b320bf1a52608f1f6 Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Fri, 29 May 2020 19:27:45 +0000 Subject: [PATCH 4/4] - Remove usage of readarray to remain compatible with bash3 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/build-compare?expand=0&rev=277 --- build-compare.changes | 5 +++++ build-compare.spec | 2 +- functions.sh | 13 +++++++++---- pkg-diff.sh | 31 ++++++++++++++++++------------- srpm-check.sh | 2 +- 5 files changed, 34 insertions(+), 19 deletions(-) diff --git a/build-compare.changes b/build-compare.changes index ed96dee..4659593 100644 --- a/build-compare.changes +++ b/build-compare.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Fri May 29 19:20:21 UTC 2020 - olaf@aepfle.de + +- Remove usage of readarray to remain compatible with bash3 + ------------------------------------------------------------------- Fri May 29 07:30:51 UTC 2020 - olaf@aepfle.de diff --git a/build-compare.spec b/build-compare.spec index 8bd1481..7e57d87 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: 20200529T185052.7a95d20 +Version: 20200529T212652.102d844 Release: 0 Source1: COPYING Source2: same-build-result.sh diff --git a/functions.sh b/functions.sh index 0e416a1..3dd8134 100644 --- a/functions.sh +++ b/functions.sh @@ -276,7 +276,7 @@ function set_regex() { # 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 +# Sets ${files[@]} array with list of files that need further investigation function cmp_rpm_meta () { local RES @@ -366,14 +366,19 @@ function cmp_rpm_meta () get_value QF_CHECKSUM $rpm_meta_new | grep -v " 64$" | trim_release_new > $file2 RES=2 # done if the same + files=() echo "comparing file checksum" if cmp -s $file1 $file2; then RES=0 + else + # Get only files with different MD5sums + while read + do + : "${REPLY}" + files+=( "${REPLY}" ) + done < <(diff -U0 $file1 $file2 | sed -E -n -e '/^-\//{s/^-//;s/ [0-9a-f]+ [0-9]+$//;p}') fi - # Get only files with different MD5sums - files=`diff -U0 $file1 $file2 | fgrep -v +++ | grep ^+ | cut -b2- | sed -E -e 's/ [0-9a-f]+ [0-9]+$//'` - if test -n "$sh"; then echo "creating rename script" # Create a temporary helper script to rename files/dirs with release in it diff --git a/pkg-diff.sh b/pkg-diff.sh index ead49f5..16285f2 100644 --- a/pkg-diff.sh +++ b/pkg-diff.sh @@ -761,6 +761,7 @@ compare_archive() local f local -a content local -i ret=1 + local -a filelist "${handler}" 'f' "${file}" || return 1 @@ -783,8 +784,12 @@ compare_archive() "${handler}" 'x' "${new}" || return 1 popd > /dev/null fi - readarray -t content < 'cn' - for f in "${content[@]}" + while read + do + : "${REPLY}" + filelist+=( "${REPLY}" ) + done < 'cn' + for f in "${filelist[@]}" do if ! check_single_file "${file}/${f}" then @@ -1157,6 +1162,10 @@ fi echo "Comparing `basename $oldpkg` to `basename $newpkg`" case $oldpkg in + *.deb|*.ipk) + : cmp_deb_meta missing + RES=0 + ;; *.rpm) cmp_rpm_meta "$rename_script" "$oldpkg" "$newpkg" RES=$? @@ -1192,18 +1201,15 @@ unpackage $newpkg $dir/new case $oldpkg in *.deb|*.ipk) adjust_controlfile $dir/old $dir/new + files=() + while read + do + : "${REPLY}" + files+=( "${REPLY}" ) + done < <(cd ${dir} ; find old new -type f | sed -e 's/^...//' | sort -u) ;; esac -# 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` - newfiles=`cd $dir/new; find . -type f` - - files=`echo -e "$oldfiles\n$newfiles" | sort -u` -fi - cd $dir bash $rename_script @@ -1218,8 +1224,7 @@ fi # preserve cmp_rpm_meta result for check_all runs ret=$RES -readarray -t filesarray <<<"$files" -for file in "${filesarray[@]}"; do +for file in "${files[@]}"; do if ! check_single_file "$file"; then ret=1 if test -z "$check_all"; then diff --git a/srpm-check.sh b/srpm-check.sh index baca277..10880b5 100644 --- a/srpm-check.sh +++ b/srpm-check.sh @@ -87,7 +87,7 @@ check_single_file() } ret=0 -for file in $files; do +for file in "${files[@]}"; do if ! check_single_file $file; then ret=1 if test -z "$check_all"; then