Commit 7c57b45c authored by Markus Frosch's avatar Markus Frosch 📣

get_snapshot: Set the application and modules versions for snapshots

parent 00b76a14
Pipeline #4473 passed with stages
in 16 minutes and 52 seconds
......@@ -27,8 +27,6 @@ done
: ${UPSTREAM_GIT_URL:=https://github.com/Icinga/$PROJECT.git}
: ${UPSTREAM_GIT_BRANCH:=master}
workdir=`pwd`
set -x
if [ -z "$UPSTREAM_GIT_NOREPO" ]; then
......@@ -57,24 +55,42 @@ if [ -z "$UPSTREAM_GIT_NOREPO" ]; then
fi
git_version=$(git describe --tags "${UPSTREAM_GIT_BRANCH}")
if [ `echo "$git_version" | grep -v -E '(g[0-9a-f]+)$'` ]; then
echo "This is a release tagged commit and does not fit the naming scheme, it will confuse the packaging server.
It's safer to wait for the next commit. Have a nice day."
exit 1
fi
package_version=$(echo "$git_version" | sed -e 's/^v//' -e 's/-/+/' -e 's/-/./g')
prefix="${PROJECT}_${package_version}"
tarball="${prefix}.orig.tar"
if [[ "$git_version" = *2.4.1* ]] || [[ "$git_version" = *2.4.0* ]]; then
package_version=$(echo "$git_version" | sed -e 's/^v//' -e 's/-/+t/' -e 's/-/./g')
else
package_version=$(echo "$git_version" | sed -e 's/^v//' -e 's/-/+/' -e 's/-/./g')
fi
tarball="${workdir}/${PROJECT}_${package_version}.orig.tar"
git archive --format=tar --prefix="${prefix}/" -o "../${tarball}" "${UPSTREAM_GIT_BRANCH}"
cd ../
# create files with the properly set versions for snapshot
rm -rf "${prefix:?}/"
mkdir -p "${prefix}"/library/Icinga/Application
sed -e "s~const VERSION.*~const VERSION = '${package_version}';~" \
"${PROJECT}.git"/library/Icinga/Application/Version.php \
> "${prefix}"/library/Icinga/Application/Version.php
for module in $(cd "${PROJECT}.git/modules"; ls); do
test -e "${PROJECT}.git/modules/${module}/module.info" || continue
mkdir -p "${prefix}/modules/${module}"
sed -e "s~^Version:.*~Version: ${package_version}~" \
"${PROJECT}.git/modules/${module}/module.info" \
> "${prefix}/modules/${module}/module.info"
done
git archive --format=tar --prefix="${PROJECT}_${package_version}/" -o "${tarball}" "${UPSTREAM_GIT_BRANCH}"
# add to tarball and remove tmpdir
tar --append -f "${tarball}" "${prefix}"/
rm -rf "${prefix:?}/"
# pack tarball
gzip -vf9 "${tarball}"
sha256sum "${tarball}.gz"
# store package version for build scripts
echo -e "${package_version}\t$(git rev-parse "${UPSTREAM_GIT_BRANCH}")\t$(basename "${tarball}.gz")\t${UPSTREAM_GIT_BRANCH}" > "${workdir}/${PROJECT}.version"
printf '%s\t%s\t%s\t%s' \
"${package_version}" \
"$(git rev-parse "${UPSTREAM_GIT_BRANCH}")" \
"$(basename "${tarball}.gz")" \
"${UPSTREAM_GIT_BRANCH}" \
> "${PROJECT}.version"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment