Commit 4b8b28d3 authored by Markus Frosch's avatar Markus Frosch 📣
Browse files

Allow snapshot builds

parent d5765752
Pipeline #2447 failed with stages
in 24 seconds
## Build
/build/
/ccache/
## Snapshot Artifacts
/*.git/
/*.tar*
/*.version
## Editors
*~
.*.sw[op]
#!/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:=icingadb}"
: "${UPSTREAM_GIT_URL:=https://git.icinga.com/icingadb/$PROJECT.git}"
: "${UPSTREAM_GIT_BRANCH:=master}"
workdir=$(pwd)
set -x
if [ -z "$UPSTREAM_GIT_NOREPO" ]; then
if [ -d "${PROJECT}.git/" ]; then
cd "${PROJECT}.git"
if [ ! -d .git ]; then
echo "This is not a GIT repository: $(pwd)" >&2
exit 1
fi
if [ -z "$UPSTREAM_GIT_NOUPDATE" ]; then
if [ "$(git config remote.origin.url)" != "${UPSTREAM_GIT_URL}" ]; then
git remote set-url origin "${UPSTREAM_GIT_URL}"
fi
git fetch origin -p
git checkout -f "${UPSTREAM_GIT_BRANCH}"
git reset --hard "origin/${UPSTREAM_GIT_BRANCH}"
fi
git clean -fdx
elif [ -z "$UPSTREAM_GIT_NOUPDATE" ]; then
git clone -b "${UPSTREAM_GIT_BRANCH}" "${UPSTREAM_GIT_URL}" "${PROJECT}.git/"
cd "${PROJECT}.git"
else
echo "Missing '${PROJECT}.git' directory!" >&2
exit 1
fi
fi
git_commit=$(git rev-parse "${UPSTREAM_GIT_BRANCH}")
if ! git_version=$(git describe --tags "${UPSTREAM_GIT_BRANCH}"); then
git_version=0.0.0.$(git rev-list "${UPSTREAM_GIT_BRANCH}" | wc -l).$(echo "$git_commit" | head -c 8)
fi
package_version=$(echo "$git_version" | sed -e 's/^v//' -e 's/-/./g')
tarball="${workdir}/${PROJECT}-${package_version}.tar"
git archive --format=tar --prefix="${PROJECT}-${git_commit}/" -o "${tarball}" "${UPSTREAM_GIT_BRANCH}"
# pack tarball
gzip -vf9 "${tarball}"
sha256sum "${tarball}.gz"
# store package version for build scripts
printf '%s\t%s\t%s\t%s\n' \
"${package_version}" \
"${git_commit}" \
"$(basename "${tarball}.gz")" \
"${UPSTREAM_GIT_BRANCH}" \
>"${workdir}/${PROJECT}.version"
%define revision 1
%define debug_package %{nil}
%global commit f10596b960b05a492f4524c123a2522d4626a6e0
%global shortcommit %(c=%{commit}; echo ${c:0:7})
Name: icingadb
Version: 0.0
Version: 0.0.0.%{shortcommit}
Release: %{revision}%{?dist}
Summary: Icinga DB
Group: System Environment/Daemons
License: GPLv2+
URL: https://git.icinga.com/icingadb/icingadb
Source0: %{name}-%{version}.tar.gz
Vendor: Icinga <info@icinga.com>
Packager: Icinga <info@icinga.com>
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}
BuildRequires: golang git
......@@ -32,7 +33,7 @@ Provides: group(icingadb)
Icinga DB
%prep
%setup -q
%setup -q -n %{name}-%{commit}
%build
mkdir -p %{gopath}/src/git.icinga.com/icingadb
......
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