forked from digidotcom/xbgw-app
-
Notifications
You must be signed in to change notification settings - Fork 1
/
make.sh
executable file
·74 lines (60 loc) · 1.75 KB
/
make.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
69
70
71
72
73
74
#!/bin/sh
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Copyright (c) 2016 Digi International Inc. All Rights Reserved.
. tools/build_help.sh
# Make sure the zip command is available.
if ! type zip >/dev/null ; then
echo "Error: zip command could not be found."
exit 1
fi
store_build_data(){
if [ -n "$BUILD_BRANCH" ]
then
# Extract build version from BUILD_BRANCH environment variable.
VERSION=${BUILD_BRANCH#release/xbgw-}
if [ "$VERSION" != "$BUILD_BRANCH" ]
then
VERSION="${VERSION}b${BUILD_NUMBER}"
# Release build
cat > build.py <<EOF
EOF
else
# Regular test build
VERSION="${BUILD_BRANCH} (#${BUILD_NUMBER})"
cat > build.py <<EOF
build_number = "${BUILD_NUMBER}"
build_branch = "${BUILD_BRANCH}"
EOF
fi
else
# Developer machine
BUILD_HOST=$(uname -n)
BUILD_TIME=$(date -Iseconds)
BUILD_REV=$(git rev-parse HEAD)
VERSION="${BUILD_HOST} - ${BUILD_TIME}"
cat > build.py <<EOF
build_host = "${BUILD_HOST}"
EOF
fi
# Content for all build.py
cat >> build.py <<EOF
build_rev = "${BUILD_REV}"
build_time = "${BUILD_TIME}"
version = "${VERSION}"
EOF
}
# Install venv, activate it and grab requirements
create_environment
python _make.py
# Byte-compile the pubsub library
cd venv/lib/python2.7/site-packages
python -m compileall pubsub
# Don't need to be in virtual environment anymore
deactivate
# Collect all of pubsub into xbgw.zip
find pubsub -name "*.pyc" -print0 |xargs -0 zip ../../../../xbgw.zip
cd -
store_build_data