18
18
19
19
set -o pipefail
20
20
21
+
22
+ #
23
+ # Helper functions for printing status information.
24
+ # Uses 'echo' instead of 'printf' due to Travis CI stdout sync issues.
25
+ #
21
26
info () { echo -e " I: ${1} " ; }
22
- die () { echo -e " E: ${1} " 1>&2 ; exit ${2:- 1} ; }
27
+ die () { echo -e " E: ${1} " 1>&2 ; exit " ${2:- 1} " ; }
23
28
29
+
30
+ #
31
+ # Sets the GitHub job status for a given commit.
32
+ #
24
33
set_status ()
25
34
{
26
35
local job_name=${NAME}
27
- local payload=$( <<< "
36
+ local payload=" "
37
+
38
+ payload=$( <<< "
28
39
{
29
40
'state': '${1}',
30
41
'description': '${2}',
@@ -38,10 +49,21 @@ set_status()
38
49
}
39
50
40
51
52
+ #
53
+ # Sources a pre-compiled GCC installation from AWS, installing the archive by
54
+ # extracting and prepending the executable directory to PATH.
55
+ #
56
+ # Note: Expects 'deps_url' and 'deps_dir' to already be defined.
57
+ #
41
58
_install_gcc ()
42
59
{
60
+ # Ignore shellcheck warnings: Variables defined in .travis.yml
61
+ # shellcheck disable=SC2154
43
62
local url=" ${deps_url} /gcc6-linux.tar.bz2"
63
+
64
+ # shellcheck disable=SC2154
44
65
local gcc_path=" ${deps_dir} /gcc/gcc-arm-none-eabi-6-2017-q2-update/"
66
+
45
67
local archive=" gcc.tar.bz2"
46
68
47
69
info " URL: ${url} "
@@ -64,14 +86,17 @@ _install_gcc()
64
86
}
65
87
66
88
89
+ #
90
+ # Downloads a list of packages from AWS, really fast.
91
+ #
67
92
_fetch_deps ()
68
93
{
69
94
local pkg=" ${1} "
70
95
local dep_list=" ${2} "
71
96
72
97
info " Fetching '${pkg} ' archives"
73
98
74
- while read dep; do
99
+ while read -r dep; do
75
100
76
101
curl --location " ${deps_url} /${dep} .deb" \
77
102
--output " ${deps_dir} /${dep} .deb" \
@@ -83,25 +108,37 @@ _fetch_deps()
83
108
wait
84
109
}
85
110
111
+
112
+ #
113
+ # Installs a list of Debian packages, fetching them if not locally found.
114
+ #
86
115
_install_deps ()
87
116
{
88
117
local pkg=" ${1} "
89
118
local dep_list=" ${2} "
119
+ local first_dep=" "
90
120
91
121
# Assume that if the first package isn't cached, none are.
92
- local first_dep=$( <<< " ${dep_list}" head -n1)
122
+ first_dep=$( <<< " ${dep_list}" head -n1)
93
123
[ ! -f " ${deps_dir} /${first_dep} .deb" ] && _fetch_deps " ${pkg} " " ${dep_list} "
94
124
95
125
# Install dependencies
96
126
info " Installing '${pkg} ' packages"
127
+
128
+ # Ignore shellcheck warnings: Word splitting is specifically used to build
129
+ # command in one go, and expression non-expansion
130
+ # is intentional.
131
+ # shellcheck disable=SC2046 disable=SC2016
97
132
sudo dpkg -i $( <<< " ${dep_list}" sed -e ' s_^ *__' -e ' s_^\(.*\)$_' " ${deps_dir} " ' /\1.deb_' | tr $' \n ' ' ' )
98
133
}
99
134
100
135
136
+ #
137
+ # Wrapper for installing a given package.
138
+ #
101
139
source_pkg ()
102
140
{
103
- local pkg=" ${1} "
104
-
141
+ # Debian dependencies needed for a single package.
105
142
local aspell_deps=" aspell
106
143
aspell-en
107
144
dictionaries-common
@@ -115,10 +152,13 @@ source_pkg()
115
152
libsepol1-dev
116
153
libc-bin"
117
154
155
+ local pkg=" ${1} "
118
156
119
157
case " ${pkg} " in
120
158
121
159
" fuse" )
160
+ # 'fuse' does not require an 'apt-get update' to install in Travis CI, so
161
+ # there's no reason to upload it or its dependencies into AWS.
122
162
sudo apt-get -o=dir::cache=" ${deps_dir} /apt-get" install fuse \
123
163
|| die " Installation failed"
124
164
;;
0 commit comments