-
Notifications
You must be signed in to change notification settings - Fork 31
/
common.sh
41 lines (35 loc) · 1.09 KB
/
common.sh
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
#!/bin/bash Please-source-me
# Common utilities and setup for builds
set -euxo pipefail
# get_remote_revision GITURL BRANCH
get_remote_revision() {
local URL="$1"
local BRANCH="$2"
local REVISION
REVISION=$(git ls-remote --tags --heads "${URL}" "refs/${BRANCH}" | cut -f 1)
if [[ -z "$REVISION" ]]; then
>&2 echo "Unable to get remote revision for ${URL} refs/${BRANCH}"
exit 255
fi
echo "$REVISION"
}
# initialise REVISION OUTPUT_FILENAME [optional previously built revision]
initialise() {
local REVISION="$1"
local OUTPUT="$2"
local LAST_REVISION="${3-previously-unbuilt}"
echo "ce-build-revision:${REVISION}"
echo "ce-build-output:${OUTPUT}"
if [[ "${REVISION}" == "${LAST_REVISION}" ]]; then
echo "ce-build-status:SKIPPED"
exit
fi
}
# complete <source folder> <name to be extracted as> <dest tar.xz file>
complete() {
local SOURCE="$1"
local FULLNAME="$2"
local OUTPUT="$3"
env XZ_DEFAULTS="-T 0" tar Jcf "${OUTPUT}" --transform "s,^./,./${FULLNAME}/," -C "${SOURCE}" .
echo "ce-build-status:OK"
}