rpm: Fix rpm build script version issues (#9808)
When creating a package using this script, it's not straighforward that the version is fetched at the "configure" stage, by "git describe" which generates a 'lasttag-ncommits-lastcommit' format description. RPM doesn't allow - in version, so the rpmbuild stage fails. Add hints of actions to perform to get this script working Use package standard functions for the message to be seen easily
This commit is contained in:
parent
c1772bb759
commit
f2e4a9ac51
|
@ -13,24 +13,33 @@ run autoreconf -ivf
|
||||||
run ./configure --enable-maintainer-mode
|
run ./configure --enable-maintainer-mode
|
||||||
run make dist
|
run make dist
|
||||||
|
|
||||||
version=$(grep PACKAGE_VERSION < config.h | cut -d '"' -f 2)
|
typeset version="$(grep PACKAGE_VERSION < config.h | cut -d '"' -f 2)"
|
||||||
if [ -z "${version}" ]
|
if [[ -z "${version}" ]]; then
|
||||||
then
|
run_failed "Cannot find netdata version."
|
||||||
echo >&2 "Cannot find netdata version."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
tgz="netdata-${version}.tar.gz"
|
|
||||||
if [ ! -f "${tgz}" ]
|
|
||||||
then
|
|
||||||
echo >&2 "Cannot find the generated tar.gz file '${tgz}'"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
srpm=$(run rpmbuild -ts "${tgz}" | cut -d ' ' -f 2)
|
if [[ "${version//-/}" != "$version" ]]; then
|
||||||
if [ -z "${srpm}" ] || [ ! -f "${srpm}" ]
|
# Remove all -* and _* suffixes to be as close as netdata release
|
||||||
then
|
typeset versionfix="${version%%-*}"; versionfix="${versionfix%%_*}"
|
||||||
echo >&2 "Cannot find the generated SRPM file '${srpm}'"
|
# Append the current datetime fox a 'unique' build
|
||||||
|
versionfix+="_$(date '+%m%d%H%M%S')"
|
||||||
|
# And issue hints & details on why this failed, and how to fix it
|
||||||
|
run_failed "Current version contains '-' which is fobidden by rpm. You must create a git annotated tag and rerun this script. Exemple:"
|
||||||
|
run_failed " git tag -a $versionfix -m 'Release by $(id -nu) on $(uname -n)' && $0"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
typeset tgz="netdata-${version}.tar.gz"
|
||||||
|
if [[ ! -f "${tgz}" ]]; then
|
||||||
|
run_failed "Cannot find the generated tar.gz file '${tgz}'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
typeset srpm="$(run rpmbuild -ts "${tgz}" | cut -d ' ' -f 2)"
|
||||||
|
if [[ -z "${srpm}" ]] || ! [[ -f "${srpm}" ]]; then
|
||||||
|
run_failed "Cannot find the generated SRPM file '${srpm}'"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -44,4 +53,4 @@ fi
|
||||||
|
|
||||||
run rpmbuild --rebuild "${srpm}"
|
run rpmbuild --rebuild "${srpm}"
|
||||||
|
|
||||||
echo >&2 "All done!"
|
run_ok "All done! Packages created in '$(rpm -E '%_rpmdir/%_arch')'"
|
||||||
|
|
Loading…
Reference in New Issue