2010-09-21 13:12:14 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Copyright (c) 2009, 2010 SUSE Linux Product GmbH, Germany.
|
2022-03-05 00:16:27 +01:00
|
|
|
# Copyright (c) 2022 SUSE LLC
|
2010-09-21 13:12:14 +02:00
|
|
|
# Licensed under GPL v2, see COPYING file for details.
|
|
|
|
#
|
2022-03-05 00:16:27 +01:00
|
|
|
# Written by Michael Matz and Stephan Kulow
|
|
|
|
# Enhanced by Andreas Jaeger and Dirk Müller
|
2010-09-21 13:12:14 +02:00
|
|
|
|
|
|
|
# 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
|
2022-03-05 00:16:27 +01:00
|
|
|
echo "usage: $0 [-a|--check-all] old.rpm new.rpm"
|
|
|
|
exit 1
|
2010-09-21 13:12:14 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
source $FUNCTIONS
|
|
|
|
|
2022-03-05 00:16:27 +01:00
|
|
|
oldrpm=$(readlink -f $1)
|
|
|
|
newrpm=$(readlink -f $2)
|
2017-11-06 17:16:43 +01:00
|
|
|
rename_script=
|
2010-09-21 13:12:14 +02:00
|
|
|
|
|
|
|
# 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.
|
|
|
|
|
2017-11-06 17:16:43 +01:00
|
|
|
cmp_rpm_meta "$rename_script" "$oldrpm" "$newrpm"
|
2010-09-21 13:12:14 +02:00
|
|
|
RES=$?
|
|
|
|
case $RES in
|
|
|
|
0)
|
2015-02-02 12:33:28 +01:00
|
|
|
echo "RPM meta information is identical"
|
2010-09-21 13:12:14 +02:00
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
1)
|
2011-02-28 15:13:34 +01:00
|
|
|
echo "RPM meta information is different"
|
2010-09-21 13:12:14 +02:00
|
|
|
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
|
|
|
|
|
2022-03-05 00:16:27 +01:00
|
|
|
dir=$(mktemp -d)
|
|
|
|
unpackage $oldrpm $dir/old &
|
|
|
|
unpackage $newrpm $dir/new &
|
2010-09-21 13:12:14 +02:00
|
|
|
cd $dir
|
2022-03-05 00:16:27 +01:00
|
|
|
wait
|
2010-09-21 13:12:14 +02:00
|
|
|
|
|
|
|
check_single_file()
|
|
|
|
{
|
|
|
|
local file=$1
|
|
|
|
case $file in
|
|
|
|
*.spec)
|
2022-03-05 00:16:27 +01:00
|
|
|
sed -i -e 's,^Release:.*$,Release: @RELEASE@,' old/$file
|
|
|
|
sed -i -e 's,^Release:.*$,Release: @RELEASE@,' new/$file
|
|
|
|
diff --speed-large-files -su0 old/$file new/$file | head -n 20
|
|
|
|
return "${PIPESTATUS[0]}"
|
|
|
|
;;
|
2010-09-21 13:12:14 +02:00
|
|
|
*)
|
2022-03-05 00:16:27 +01:00
|
|
|
echo "$file differs"
|
|
|
|
# Nothing else should be changed
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
return 1
|
2010-09-21 13:12:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ret=0
|
2020-05-29 21:27:45 +02:00
|
|
|
for file in "${files[@]}"; do
|
2022-03-05 00:16:27 +01:00
|
|
|
if ! check_single_file $file; then
|
|
|
|
ret=1
|
|
|
|
if test -z "$check_all"; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
fi
|
2010-09-21 13:12:14 +02:00
|
|
|
done
|
|
|
|
|
2015-01-21 13:54:20 +01:00
|
|
|
rm -rf $dir
|
2010-09-21 13:12:14 +02:00
|
|
|
exit $ret
|
2015-03-20 20:33:05 +01:00
|
|
|
# vim: tw=666 ts=2 shiftwidth=2 et
|