-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathcommon.sh
More file actions
executable file
·57 lines (45 loc) · 2 KB
/
common.sh
File metadata and controls
executable file
·57 lines (45 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "$SCRIPT_DIR/logging.functions.sh"
export RELEASE_CHANNEL=stable
if [[ "$HZ_VERSION" == *"SNAPSHOT"* ]]; then
export RELEASE_CHANNEL=snapshot
fi
if [[ "$HZ_VERSION" == *"BETA"* ]]; then
export RELEASE_CHANNEL=beta
fi
export PACKAGE_REPO=${RELEASE_CHANNEL}
if [[ "$HZ_VERSION" == *"-"* ]]; then
HZ_MINOR_VERSION="${HZ_VERSION}"
else
# Extract minor version from HZ_VERSION, works also for 5.10 etc..
# -d'.' splits by delimiter, -f selects first two components
HZ_MINOR_VERSION=$(echo "${HZ_VERSION}" | cut -f1,2 -d'.')
fi
export HZ_MINOR_VERSION
# Extract release version from package version - release version is the version part specific to the package
# Remove HZ_VERSION prefix from PACKAGE_VERSION,
# e.g. HZ_VERSION=5.1-DR8,PACKAGE_VERSION=5.1-DR8-1 -> -1
RELEASE_VERSION=${PACKAGE_VERSION#"$HZ_VERSION"}
# Remove '-' from RELEASE_VERSION
RELEASE_VERSION=${RELEASE_VERSION#-}
if [ -z "$RELEASE_VERSION" ]; then
# Default to 1 if not set
RELEASE_VERSION=1
fi
export RELEASE_VERSION
# See https://www.debian.org/doc/debian-policy/ch-controlfields.html#version
# "if it (= debian revision) isn’t present then the upstream_version must not contain a hyphen"
# So if our upstream version contains hyphen, e.g. 5.2-DR8, the deb package version should be 5.2-DR8-1
# For simplicity we add it in all cases, default to 1 when not specified in PACKAGE_VERSION
DEB_PACKAGE_VERSION="$HZ_VERSION"-$RELEASE_VERSION
export DEB_PACKAGE_VERSION
# For RPM the upstream version part must not contain -, use `.` instead of `-`
RPM_HZ_VERSION=$(echo $HZ_VERSION | sed -r -r 's/(-)/\./g')
export RPM_HZ_VERSION
RPM_PACKAGE_VERSION=$RPM_HZ_VERSION-$RELEASE_VERSION
export RPM_PACKAGE_VERSION
# For brew the version is lowercase and with `.` instead of `-`
BREW_PACKAGE_VERSION=$(echo $PACKAGE_VERSION | tr '[:upper:]' '[:lower:]' | sed -r -r 's/(-)/\./g')
export BREW_PACKAGE_VERSION
export HZ_DISTRIBUTION_FILE=distribution.tar.gz