-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare_building.sh
executable file
·55 lines (43 loc) · 1.75 KB
/
prepare_building.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
#!/bin/bash -x
REPO_TO_BUILD=${1}
BRANCH_TO_BUILD=${2:-main}
FORCE_BUILD=${3:-false}
VERSION_DEFAULT="0.0.0"
DISTRIBUTION="stable"
VERSION_PACKAGE=""
export DEBFULLNAME="Travis Bot"
export DEBEMAIL="travis-ci@alternc.net"
if [ ! -d "$REPO_TO_BUILD" ]; then
exit 1;
fi
cd "$REPO_TO_BUILD" || exit 1
#Move to branch and clear any local change
git reset --hard HEAD
git fetch --all
git checkout "${BRANCH_TO_BUILD}"
#Get current version package
VERSION_PACKAGE=$(dpkg-parsechangelog --show-field Version)
#Get current tag (only published version)
#If any tag set use a defautlt tag status
if [[ ${FORCE_BUILD} == false ]];then
TAG_STATUS=$(git describe --tags || echo "${VERSION_DEFAULT}-0-g$(git rev-list --max-parents=0 HEAD)")
else
TAG_STATUS=$(git describe --tags --exclude nightly || echo "${VERSION_DEFAULT}-0-g$(git rev-list --max-parents=0 HEAD)")
fi
#If tag status is TAG or TAG-COMMIT_COUNT-SHA1. Then if - is present, current checkout is not a tagged
if [[ "${TAG_STATUS}" =~ "-" ]]; then
VERSION_PACKAGE="${VERSION_PACKAGE}+$(date +'%y%m%d%H%M%S')"
DISTRIBUTION="experimental"
(git rev-parse --git-dir > /dev/null 2>&1 && git checkout debian/changelog) || true
(git rev-parse --git-dir > /dev/null 2>&1 && echo|dch --distribution "${DISTRIBUTION}" --force-bad-version --newversion "${VERSION_PACKAGE}" autobuild) || true
fi
#Force compression mode
mkdir -p debian/source/
printf "3.0 (native)" > debian/source/format
printf "compression = \"gzip\"\ncompression-level = 9\n" >> debian/source/options
#Set compression mode on rules part
printf "override_dh_builddeb:\n dh_builddeb -- -Zgzip\n" >> debian/rules
#Nightly packages are yet done, we must stop here
if [[ "${TAG_STATUS}" == "nightly" && "${FORCE_BUILD}" == false ]]; then
exit 1
fi