RPM="rpm -qp --nodigest --nosignature"
+function is_prerelease_project() {
+ local proj_name=$1
+ if [[ $proj_name =~ "prerelease" ]] || [[ $proj_name =~ "trbs" ]]; then
+ return 1
+ fi
+
+ return 0
+}
+
declare -a rpm_querytags
collect_rpm_querytags() {
rpm_querytags=( $(rpm --querytags) )
QF_TAGS="%{NAME} %{VERSION} %{EPOCH}\\n"
QF_TAGS="${QF_TAGS}%{SUMMARY}\\n%{DESCRIPTION}\\n"
# the DISTURL tag can be used as checkin ID
-QF_TAGS="${QF_TAGS}%{VENDOR} %{DISTRIBUTION} %{DISTURL}\\n"
+QF_TAGS="${QF_TAGS}%{VENDOR}\\n"
QF_TAGS="${QF_TAGS}%{LICENSE}\\n"
QF_TAGS="${QF_TAGS}%{GROUP} %{URL} %{EXCLUDEARCH} %{EXCLUDEOS} %{EXCLUSIVEARCH}\\n"
QF_TAGS="${QF_TAGS}%{EXCLUSIVEOS} %{RPMVERSION} %{PLATFORM}\\n"
local file2="$tmpdir/file2"
local rpm_meta_old="$tmpdir/rpm-meta-old"
local rpm_meta_new="$tmpdir/rpm-meta-new"
+ local QF
collect_rpm_querytags
set_rpm_meta_global_variables $oldrpm
check_header "$QF_ALL" $oldrpm > $rpm_meta_old
check_header "$QF_ALL" $newrpm > $rpm_meta_new
+ if [ -n $newrpm ]; then
+ # if the rpm is from prerelease projects, do not compare project name.
+ QF="%{DISTRIBUTION}"
+ dist=$(check_header "$QF" $newrpm | sed -r 's/(.*)\/.*/\1/')
+ if ! is_prerelease_project $dist; then
+ echo "This is a prerelease project. Do not compare the project name."
+ QF="\n___QF_DISTURL___\n%{DISTURL}\n___QF_DISTURL___\n"
+ echo `check_header "$QF" $oldrpm | sed -r 's/.*\/(.*\/.*)/\1/'` >> $rpm_meta_old
+ echo `check_header "$QF" $newrpm | sed -r 's/.*\/(.*\/.*)/\1/'` >> $rpm_meta_new
+ else
+ QF="\n___QF_DISTURL_DISTRIBUTION___\n%{DISTURL} %{DISTRIBUTION}\n___QF_DISTURL_DISTRIBUTION___\n"
+ echo "This is not a prerelease project. Compare the project name."
+ check_header "$QF" $oldrpm >> $rpm_meta_old
+ check_header "$QF" $newrpm >> $rpm_meta_new
+ fi
+ fi
+
# 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
CMPSCRIPT=${0%/*}/pkg-diff.sh
SCMPSCRIPT=${0%/*}/srpm-check.sh
+FUNCTIONS=${0%/*}/functions.sh
declare -a exit_code
# exit_code[0]='' # binaries_differ
echo "No valid directory with new build result given !"
exit 1
fi
+source $FUNCTIONS
-if test `find $NEWDIRS -name '*.rpm' -and ! -name '*.delta.rpm' | wc -l` != `find $OLDDIR -name '*.rpm' -and ! -name '*.delta.rpm' | wc -l`; then
- echo "different number of subpackages"
- find $OLDDIR -name '*.rpm' -and ! -name '*.delta.rpm' -print0 | xargs -0 rpm -qp --qf '%{NAME}\n' | sort > ${file1}
- find $NEWDIRS -name '*.rpm' -and ! -name '*.delta.rpm' -print0 | xargs -0 rpm -qp --qf '%{NAME}\n' | sort > ${file2}
- diff -u ${file1} ${file2}
- exit 1
-fi
+first_rpm=$(find $NEWDIRS -name *.rpm | head -1)
+dist=$(rpm -qp --nodigest --nosignature --qf "%{DISTRIBUTION}" $first_rpm | sed -r 's/(.*)\/.*/\1/')
+prerelease=0
+if ! is_prerelease_project $dist; then
+ echo "This is a prerelease project. Do not check the existence of source rpm files."
-osrpm=$(find "$OLDDIR" -name \*src.rpm)
-nsrpm=$(find $NEWDIRS -name \*src.rpm)
+ prerelease=1
+ num_new_pkgs=`find $NEWDIRS -name '*.rpm' -and ! -name '*.delta.rpm' -and ! -name '*.src.rpm' | wc -l`
+ num_old_pkgs=`find $OLDDIR -name '*.rpm' -and ! -name '*.delta.rpm' -and ! -name '*.src.rpm' | wc -l`
+ if test $num_new_pkgs != $num_old_pkgs; then
+ echo "different number of subpackages"
+ find $OLDDIR $NEWDIRS -name '*.rpm' -and ! -name '*.delta.rpm' -and ! -name '*.src.rpm'
+ exit 1
+ fi
-if test ! -f "$osrpm"; then
- echo no old source rpm in $OLDDIR
- exit 1
-fi
+else
+ if test `find $NEWDIRS -name '*.rpm' -and ! -name '*.delta.rpm' | wc -l` != `find $OLDDIR -name '*.rpm' -and ! -name '*.delta.rpm' | wc -l`; then
+ echo "different number of subpackages"
+ find $OLDDIR $NEWDIRS -name '*.rpm' -and ! -name '*.delta.rpm'
+ exit 1
+ fi
-if test ! -f "$nsrpm"; then
- echo no new source rpm in $NEWDIRS
- exit 1
-fi
+ osrpm=$(find "$OLDDIR" -name \*src.rpm)
+ nsrpm=$(find $NEWDIRS -name \*src.rpm)
-echo "compare $osrpm $nsrpm"
-if bash $SCMPSCRIPT $check_all "$osrpm" "$nsrpm"
-then
- : src.rpm identical
-else
- test -z "${check_all}" && exit 1
- exit_code[3]='srcrpm_differs'
+ if test ! -f "$osrpm"; then
+ echo no old source rpm in $OLDDIR
+ exit 1
+ fi
+
+ if test ! -f "$nsrpm"; then
+ echo no new source rpm in $NEWDIRS
+ exit 1
+ fi
+
+ echo "compare $osrpm $nsrpm"
+ if bash $SCMPSCRIPT $check_all "$osrpm" "$nsrpm"
+ then
+ : src.rpm identical
+ else
+ test -z "${check_all}" && exit 1
+ exit_code[3]='srcrpm_differs'
+ fi
fi
# technically we should not all exclude all -32bit but filter for different archs,
fi
if test -n "$OTHERDIR"; then
- old_log=$OLDDIR/rpmlint.log
- new_log=$OTHERDIR/rpmlint.log
- if test -e ${old_log} && test -e ${new_log} ; then
- echo "comparing ${old_log} and ${new_log}"
- # Remove --time-report from rpmlint
- # Sort the files first since the order of messages is not deterministic
- # Remove release from files
- remove_check_time_report ${old_log}|sort -u|sed -e "s,$ver_rel1,@VERSION@-@RELEASE@,g" -e "s|/tmp/rpmlint\..*spec|.spec|g" > $file1
- remove_check_time_report ${new_log}|sort -u|sed -e "s,$ver_rel2,@VERSION@-@RELEASE@,g" -e "s|/tmp/rpmlint\..*spec|.spec|g" > $file2
- # Remove odd warning about not-hardlinked files
- # Remove odd warning about data and time, it comes and goes
- # Remove warning about python mtime mismatch, a republish will not help
- # Remove odd warning about filenames, they contain VERSION-RELEASE
- # Remove durations from progress reports
- # Remove odd output about number of checks and packages
- sed -i -e "
- /: W: files-duplicate /d
- /: W: file-contains-date-and-time /d
- /: W: python-bytecode-inconsistent-mtime /d
- /: W: filename-too-long-for-joliet /d
- /: I: \(filelist-initialization\|check-completed\) /s| [0-9]\+\.[0-9] s| x.x s|
- s/; has taken [0-9]\+\.[0-9] s/; has taken x.x s/
- /^checks: [0-9]\+, packages: [0-9]\+/d
- " $file1 $file2
- if ! cmp -s $file1 $file2; then
- echo "rpmlint.log files differ:"
- diff -u $file1 $file2 |head -n 20
- exit_code[1]='rpmlint_differs'
- fi
- rm $file1 $file2
+ if [ $prerelease -eq 1 ] ; then
+ echo "do not compare rpmlint.log if it is a prerelease project!"
else
- if test -e "${new_log}"
- then
- exit_code[1]='rpmlint_new'
- echo "rpmlint.log is new"
- elif test -e "${old_log}"
- then
- exit_code[1]='rpmlint_old'
- echo "rpmlint.log disappeared"
+ old_log=$OLDDIR/rpmlint.log
+ new_log=$OTHERDIR/rpmlint.log
+ if test -e ${old_log} && test -e ${new_log} ; then
+ echo "comparing ${old_log} and ${new_log}"
+ # Remove --time-report from rpmlint
+ # Sort the files first since the order of messages is not deterministic
+ # Remove release from files
+ remove_check_time_report ${old_log}|sort -u|sed -e "s,$ver_rel1,@VERSION@-@RELEASE@,g" -e "s|/tmp/rpmlint\..*spec|.spec|g" > $file1
+ remove_check_time_report ${new_log}|sort -u|sed -e "s,$ver_rel2,@VERSION@-@RELEASE@,g" -e "s|/tmp/rpmlint\..*spec|.spec|g" > $file2
+ # Remove odd warning about not-hardlinked files
+ # Remove odd warning about data and time, it comes and goes
+ # Remove warning about python mtime mismatch, a republish will not help
+ # Remove odd warning about filenames, they contain VERSION-RELEASE
+ # Remove durations from progress reports
+ # Remove odd output about number of checks and packages
+ sed -i -e "
+ /: W: files-duplicate /d
+ /: W: file-contains-date-and-time /d
+ /: W: python-bytecode-inconsistent-mtime /d
+ /: W: filename-too-long-for-joliet /d
+ /: I: \(filelist-initialization\|check-completed\) /s| [0-9]\+\.[0-9] s| x.x s|
+ s/; has taken [0-9]\+\.[0-9] s/; has taken x.x s/
+ /^checks: [0-9]\+, packages: [0-9]\+/d
+ " $file1 $file2
+ if ! cmp -s $file1 $file2; then
+ echo "rpmlint.log files differ:"
+ diff -u $file1 $file2 |head -n 20
+ exit_code[1]='rpmlint_differs'
+ fi
+ rm $file1 $file2
else
- echo "No rpmlint.log available"
+ if test -e "${new_log}"
+ then
+ exit_code[1]='rpmlint_new'
+ echo "rpmlint.log is new"
+ elif test -e "${old_log}"
+ then
+ exit_code[1]='rpmlint_old'
+ echo "rpmlint.log disappeared"
+ else
+ echo "No rpmlint.log available"
+ fi
fi
fi
fi
done
fi
+
if test -n "${exit_code[*]}"; then
exit 1
fi