summaryrefslogtreecommitdiff
path: root/packaging/functions.sh
diff options
context:
space:
mode:
Diffstat (limited to 'packaging/functions.sh')
-rw-r--r--packaging/functions.sh125
1 files changed, 99 insertions, 26 deletions
diff --git a/packaging/functions.sh b/packaging/functions.sh
index c8047ab..ba2a797 100644
--- a/packaging/functions.sh
+++ b/packaging/functions.sh
@@ -15,16 +15,38 @@ check_header()
$RPM --qf "$QF" "$1"
}
-function check_provides()
+# Trim release string:
+# - it is used as direntry below certain paths
+# - it is assigned to some variable in scripts, at the end of a line
+# - it is used in PROVIDES, at the end of a line
+function trim_release_old()
+{
+ sed -e "/\(\/boot\|\/lib\/modules\|\/lib\/firmware\|\/usr\/src\|$release_old\$\)/{s,-$release_old_regex_l,-@RELEASE_LONG@,g;s,-$release_old_regex_s,-@RELEASE_SHORT@,g}"
+}
+function trim_release_new()
+{
+ sed -e "/\(\/boot\|\/lib\/modules\|\/lib\/firmware\|\/usr\/src\|$release_new\$\)/{s,-$release_new_regex_l,-@RELEASE_LONG@,g;s,-$release_new_regex_s,-@RELEASE_SHORT@,g}"
+}
+# Get single directory or filename with long or short release string
+function grep_release_old()
{
+ grep -E "(/boot|/lib/modules|/lib/firmware|/usr/src)/[^/]+(-${release_old_regex_l}(\$|[^/]+\$)|-${release_old_regex_s}(\$|[^/]+\$))"
+}
+function grep_release_new()
+{
+ grep -E "(/boot|/lib/modules|/lib/firmware|/usr/src)/[^/]+(-${release_new_regex_l}(\$|[^/]+\$)|-${release_new_regex_s}(\$|[^/]+\$))"
+}
+function check_provides()
+{
+ local pkg=$1
# 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_header "$pkg"
}
#usage unrpm <file> $dir
@@ -51,6 +73,11 @@ function unrpm()
# Sets $files with list of files that need further investigation
function cmp_spec ()
{
+ local RES
+ local file1 file2
+ local f
+ local sh=$1
+
QF="%{NAME}"
# don't look at RELEASE, it contains our build number
@@ -81,36 +108,63 @@ function cmp_spec ()
# the DISTURL tag can be used as checkin ID
#echo "$QF"
+ echo "comparing rpmtags"
if ! diff -au $file1 $file2; then
- rm $file1 $file2
- return 1
+ if test -z "$check_all"; then
+ rm $file1 $file2
+ return 1
+ fi
fi
# Remember to quote the . which is in release
- release1=`$RPM --qf "%{RELEASE}" "$oldrpm"|sed -e 's/\./\\./g'`
- release2=`$RPM --qf "%{RELEASE}" "$newrpm"|sed -e 's/\./\\./g'`
- # This might happen with a forced rebuild of factory
- if [ "${release1%.*}" != "${release2%.*}" ] ; then
- echo "release prefix mismatch"
- return 1
+ release_old=$($RPM --qf "%{RELEASE}" "$oldrpm")
+ release_new=$($RPM --qf "%{RELEASE}" "$newrpm")
+ # Short version without B_CNT
+ release_old_regex_s=${release_old%.*}
+ release_old_regex_s=${release_old_regex_s//./\\.}
+ release_new_regex_s=${release_new%.*}
+ release_new_regex_s=${release_new_regex_s//./\\.}
+ # Long version with B_CNT
+ release_old_regex_l=${release_old//./\\.}
+ release_new_regex_l=${release_new//./\\.}
+ # This might happen when?!
+ echo "comparing RELEASE"
+ if [ "${release_old%.*}" != "${release_new%.*}" ] ; then
+ case $($RPM --qf '%{NAME}' "$newrpm") in
+ kernel-*)
+ # Make sure all kernel packages have the same %RELEASE
+ echo "release prefix mismatch"
+ if test -z "$check_all"; then
+ return 1
+ fi
+ ;;
+ # Every other package is allowed to have a different RELEASE
+ *) ;;
+ esac
fi
- check_provides $oldrpm $release1 > $file1
- check_provides $newrpm $release2 > $file2
+ check_provides $oldrpm | trim_release_old | sort > $file1
+ check_provides $newrpm | trim_release_new | sort > $file2
+ echo "comparing PROVIDES"
if ! diff -au $file1 $file2; then
- rm $file1 $file2
- return 1
+ if test -z "$check_all"; then
+ rm $file1 $file2
+ return 1
+ fi
fi
# scripts, might contain release number
QF="[%{PREINPROG} %{PREIN}\\n]\\n[%{POSTINPROG} %{POSTIN}\\n]\\n[%{PREUNPROG} %{PREUN}\\n]\\n[%{POSTUNPROG} %{POSTUN}\\n]\\n"
- check_header $oldrpm | sed -e "s,-$release1$,-@RELEASE@," > $file1
- check_header $newrpm | sed -e "s,-$release2$,-@RELEASE@," > $file2
+ check_header $oldrpm | trim_release_old > $file1
+ check_header $newrpm | trim_release_new > $file2
+ echo "comparing scripts"
if ! diff -au $file1 $file2; then
- rm $file1 $file2
- return 1
+ if test -z "$check_all"; then
+ rm $file1 $file2
+ return 1
+ fi
fi
# First check the file attributes and later the md5s
@@ -125,23 +179,28 @@ function cmp_spec ()
# 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 | trim_release_old > $file1
+ check_header $newrpm | trim_release_new > $file2
- check_header $oldrpm > $file1
- check_header $newrpm > $file2
-
+ echo "comparing filelist"
if ! diff -au $file1 $file2; then
- rm $file1 $file2
- return 1
+ if test -z "$check_all"; then
+ rm $file1 $file2
+ return 1
+ fi
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
+ # file flag 64 means "ghost", filter those out.
+ QF="[%{FILENAMES} %{FILEMD5S} %{FILEFLAGS}\n]\\n"
+ check_header $oldrpm |grep -v " 64$"| trim_release_old > $file1
+ check_header $newrpm |grep -v " 64$"| trim_release_new > $file2
RES=2
# done if the same
+ echo "comparing file checksum"
if cmp -s $file1 $file2; then
RES=0
fi
@@ -149,6 +208,20 @@ 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
+ 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}'`
+ do
+ echo mv -v \"old/${f}\" \"old/`echo ${f} | trim_release_old`\"
+ done >> "${sh}"
+ #
+ for f in `$RPM --qf '[%{FILENAMES} %{FILEFLAGS}\n]\n' "$newrpm" | grep_release_new | grep -vw 64$ | awk '{ print $1}'`
+ do
+ echo mv -v \"new/${f}\" \"new/`echo ${f} | trim_release_new`\"
+ done >> "${sh}"
+ fi
+ #
rm $file1 $file2
return $RES
}