-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpackage.sh
executable file
·68 lines (56 loc) · 1.51 KB
/
package.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env bash
readonly script_dir="$(readlink -f "$(dirname "${SCRIPT_SOURCE[0]}")")"
set -eux -o pipefail
get_build_date() {
date -u +"%Y%m%d-%H%M%S"
}
get_commit_id() {
git rev-parse --short HEAD
}
get_cvs_branch() {
local commit_id=${1:-HEAD}
basename "$(git branch -r --contains "${commit_id}" | head -n1)"
}
get_last_header() {
grep -Eie '(^saunafs|sfs).*urgency' debian/changelog | head -n1
}
export -f get_last_header
get_app_version() {
get_last_header | awk '{print $2}' | tr -d '()'
}
get_version_metadata_string() {
local branch_name branch_status commit_id timestamp version
commit_id="$(get_commit_id)"
branch_name="$(get_cvs_branch "${commit_id}")"
branch_status="unstable"
if [ "${branch_name}" == "main" ]; then
branch_status="stable"
fi
timestamp="$(get_build_date)"
version="$(get_app_version)"
echo "${version}-${timestamp}-${branch_status}-${branch_name}-${commit_id}"
}
WORKSPACE="${WORKSPACE:-"${script_dir}"}"
OSNAME=$(lsb_release -si)
RELEASE=$(lsb_release -sr | sed 's@n/a@testing@')
VERSION_LONG_STRING="$(get_version_metadata_string)"
BUNDLE="saunafs-bundle-${OSNAME}-${RELEASE}-${VERSION_LONG_STRING}"
MAKEFLAGS="-j$(nproc)"
export MAKEFLAGS VERSION_LONG_STRING WORKSPACE
rm -rf saunafs-bundle-*
mkdir "${BUNDLE}"
cd "${BUNDLE}"
case "${OSNAME}" in
Ubuntu|Debian)
"${WORKSPACE}/create-deb-package.sh"
;;
CentOS|Fedora)
"${WORKSPACE}/create-rpm-package.sh"
;;
*)
echo "Unsupported Operating system"
exit 1
;;
esac
cd ${WORKSPACE}
tar -cf ${BUNDLE}.tar ${BUNDLE}