icingaweb2: Add get_snapshot for RPM
This commit is contained in:
parent
4131d7f3ec
commit
8be508efe7
|
@ -0,0 +1,59 @@
|
|||
#!/bin/bash
|
||||
# Copyright (c) 2017 Icinga Development Team <info@icinga.com>
|
||||
# Licensed as GPL-2.0+
|
||||
|
||||
set -e
|
||||
|
||||
while getopts ":p:U:b:" opt
|
||||
do
|
||||
case "$opt" in
|
||||
p)
|
||||
PROJECT="$OPTARG"
|
||||
;;
|
||||
U)
|
||||
UPSTREAM_GIT_URL="$OPTARG"
|
||||
;;
|
||||
b)
|
||||
UPSTREAM_GIT_BRANCH="$OPTARG"
|
||||
;;
|
||||
\?)
|
||||
echo "Unknown argument: $OPTARG" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
: ${PROJECT:=icingaweb2}
|
||||
: ${UPSTREAM_GIT_URL:=https://github.com/Icinga/$PROJECT.git}
|
||||
: ${UPSTREAM_GIT_BRANCH:=master}
|
||||
|
||||
workdir=`pwd`
|
||||
|
||||
set -x
|
||||
|
||||
if [ -d "${PROJECT}.git/" ]; then
|
||||
cd "${PROJECT}.git"
|
||||
if [ ! -d .git ]; then
|
||||
echo "This is not a GIT repository: $(pwd)" >&2
|
||||
exit 1
|
||||
fi
|
||||
git fetch origin -p
|
||||
git reset --hard "origin/${UPSTREAM_GIT_BRANCH}"
|
||||
git clean -fdx
|
||||
else
|
||||
git clone -b "${UPSTREAM_GIT_BRANCH}" "${UPSTREAM_GIT_URL}" "${PROJECT}.git/"
|
||||
cd "${PROJECT}.git"
|
||||
fi
|
||||
|
||||
git_version=$(git describe --tags HEAD)
|
||||
package_version=$(echo "$git_version" | sed -e 's/^v//' -e 's/-/./g')
|
||||
tarball="${workdir}/${PROJECT}-${package_version}.tar"
|
||||
|
||||
git archive --format=tar --prefix="${PROJECT}-${package_version}/" -o "${tarball}" HEAD
|
||||
|
||||
# pack tarball
|
||||
gzip -vf9 "${tarball}"
|
||||
sha256sum "${tarball}.gz"
|
||||
|
||||
# store package version for build scripts
|
||||
echo -e "${package_version}\t$(git rev-parse HEAD)\t$(basename "${tarball}.gz")" > "${workdir}/${PROJECT}.version"
|
Loading…
Reference in New Issue