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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash -e
# Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#script is used on CI for creating daily builds
#this script should be run in docker container
LOGIN=${LOGIN}
TOKEN=${TOKEN}
IMAGE_NAME=${IMAGE_NAME:-wearemudita/mudita_os_builder:1.9}
WORK_DIR=${WORK_DIR:-MuditaOS}
ARTEFACTS_DIR=${ARTEFACTS_DIR:-/artefacts}
REPOSITORY_URL=${REPOSITORY_URL:-https://${TOKEN}:x-oauth-basic@github.com/mudita/MuditaOS}
CONFIG_LOG=config.log
VARS_TO_CHECK=(
REPOSITORY_URL
LOGIN
TOKEN
IMAGE_NAME
)
function printVar(){
echo "$1: '${!1}'"
}
function checkVariables() {
I=0
while [[ $I -lt ${#VARS_TO_CHECK[@]} ]]
do
printVar ${VARS_TO_CHECK[$I]}
if [[ -z "${!VARS_TO_CHECK[$I]}" ]]; then
echo "${VARS_TO_CHECK[$I]} is not set - aborting" 1>&2
exit 1
fi
I=$(( I + 1 ))
done
}
function checkIfGit() {
if [[ -d .git ]]; then
echo .git;
else
git rev-parse --git-dir 2> /dev/null;
fi;
}
function addTokens(){
git config user.githublogin ${LOGIN}
git config user.apitoken ${TOKEN}
}
##################### script ####################
checkVariables
if [ ! -d ${WORK_DIR} ]; then
mkdir ${WORK_DIR}
fi
pushd ${WORK_DIR}
if checkIfGit; then
git checkout master
git pull --ff-only
else
echo "not a git dir"
git clone ${REPOSITORY_URL} .
git checkout master
fi
if [ ! -d ccache ]; then
mkdir ccache
fi
CCACHE_DIR=$(pwd)/ccache
export CCACHE_DIR
DATE=$(date "+%Y.%m.%d")
addTokens
git submodule update --init --recursive
git tag -f daily-${DATE}
git push --tags origin
./configure.sh rt1051 RelWithDebInfo -G Ninja &> ${CONFIG_LOG}
cat ${CONFIG_LOG}
PKG_NAME_PREFIX=$(cat ${CONFIG_LOG} | grep CPACK_PACKAGE_FILE_NAME | cut -f2 -d: | tr -d "'")
cd build-rt1051-RelWithDebInfo
ninja
ninja package-standalone
ninja package-update
cp ${PKG_NAME_PREFIX}-image.tar.xz ${ARTEFACTS_DIR}
cp ${PKG_NAME_PREFIX}-Update.tar ${ARTEFACTS_DIR}
popd