[build] Allow OBS builds without explicit version tag

The mce-dev version information is recorded in several files. To keep
these in sync, there is a script that will cause rpm builds to fail unless
all of the places have the same version.

While this is good for making sure releases do not end up using out of
sync version numbers, it also makes it impossible to do builds in OBS
without creating explicit version tag.

The same way as mce itself already does, relax the version checking for
spec file so that versions constructed from matching version + extra git
hash identification are also accepted.
This commit is contained in:
Simo Piiroinen
2016-11-10 08:53:12 +02:00
parent 22a9feb64e
commit 5a8d06c02e

View File

@@ -8,23 +8,34 @@ PC_VERS=$(grep '^Version:' $PC_PATH |sed -e 's/^.*:[[:space:]]*//')
DEB_PATH=debian/changelog
DEB_VERS=$(head -1 $DEB_PATH | sed -e 's/^.*(//' -e 's/).*$//')
SPEC_PATH=${RPM_SOURCE_DIR:-rpm}/${RPM_PACKAGE_NAME:-mce-headers}.spec
SPEC_VERS=$(grep '^Version:' $SPEC_PATH |sed -e 's/^.*:[[:space:]]*//')
RPM_PATH=${RPM_SOURCE_DIR:-rpm}/${RPM_PACKAGE_NAME:-mce-headers}.spec
RPM_VERS=$(grep '^Version:' $RPM_PATH |sed -e 's/^.*:[[:space:]]*//')
# Remove initial part of rpm version that equals with version from pkgconfig
RPM_XTRA=${RPM_VERS#$PC_VERS}
# From that remove initial part that equals with version from spec-file
RPM_XTRA=${RPM_XTRA#$RPM_VERS}
# If the result is non-empty string, then OBS is doing
# delta-after-matching-tag kind of build, which is ok.
# But empty string means that spec and Makefile are completely
# out of sync, which is bad.
RES=0
if [ "$DEB_VERS" != "$PC_VERS" ]; then
echo >&2 "$PC_PATH $PC_VERS vs $DEB_PATH $DEB_VERS"
RES=1
fi
if [ "$SPEC_VERS" != "$PC_VERS" ]; then
echo >&2 "$PC_PATH $PC_VERS vs $SPEC_PATH $SPEC_VERS"
RES=1
if [ "$RPM_VERS" != "$PC_VERS" ]; then
if [ -z "$RPM_XTRA" ]; then
echo >&2 "$PC_PATH $PC_VERS vs $RPM_PATH $RPM_VERS"
RES=1
else
echo "(ignoring patch level in spec file: $RPM_XTRA)"
fi
fi
if [ $RES != 0 ]; then
echo >&2 "Conflicting package versions"
fi