2 # shellcheck disable=SC2103
4 # Copyright (C) 2021 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
5 # 2023 Michael Jeanson <mjeanson@efficios.com>
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
29 message_len
="${#message}"
30 padding_len
=$
(( (80 - (message_len
)) / 2 ))
32 printf '\n'; printf -- '#%.0s' {1.
.80}; printf '\n'
33 printf -- '-%.0s' {1.
.80}; printf '\n'
34 printf -- '#%.0s' $
(seq 1 $padding_len); printf '%s' "$message"; printf -- '#%.0s' $
(seq 1 $padding_len); printf '\n'
35 printf -- '-%.0s' {1.
.80}; printf '\n'
36 printf -- '#%.0s' {1.
.80}; printf '\n\n'
41 # Add ssh key for deployment
42 cp "$HOST_PUBLIC_KEYS" ~
/.ssh
/known_hosts
43 cp "$KEY_FILE_VARIABLE" ~
/.ssh
/id_rsa
45 export DEBIAN_FRONTEND
=noninteractive
48 print_header
"Install web tooling dependencies"
49 apt-get
install -y jekyll npm grunt python3 python3-pip python3-venv linkchecker
51 print_header
"Install babeltrace build dependencies"
52 apt-get
install -y asciidoc xmlto libdw-dev libelf-dev elfutils autoconf automake libglib2.0
-dev make doxygen flex bison
54 print_header
"Install NPM stuff"
57 print_header
"Install Python requirements"
58 python3
-m venv build_venv
59 source build_venv
/bin
/activate
60 pip
install -r requirements.txt
62 # Setting TERM avoids spurious warnings when configure is checking TPUT, as
63 # $TERM is not set in the build environment.
64 # As we've already opened a venv, set SKIP_VENV so the python job doesn't
65 # create a second nested virtual environment.
66 print_header
"Build website with grunt"
67 TERM
=dumb SKIP_VENV
=1 VERBOSE
=1 grunt build
:prod
--verbose
69 print_header
"Check links"
70 grunt connect
:prod watch
:prod
&
72 sleep 10 # While serve:prod starts up
74 OUTPUT_DIR
="$(mktemp -d)"
75 OUTPUT_FILE
="${OUTPUT_DIR}/linkchecker-out.csv"
77 # linkchecker drops privileges to 'nobody' when run as root
78 chown nobody
"${OUTPUT_DIR}"
80 # @Note: Only internal links are checked by default
81 if ! linkchecker
-q -F "csv/utf-8/${OUTPUT_FILE}" http
://localhost
:10000/ ; then
82 echo "Linkchecker failed or found broken links"
85 rm -rf "${OUTPUT_DIR}"
86 sleep 5 # Let serve:prod stop
89 rm -rf "${OUTPUT_DIR}"
93 print_header
"Deploy website"
94 grunt deploy
:prod
--verbose
96 # In the venv functions generated by the version of python installed on bionic
97 # nodes, the deactivate function checks undefined variables (eg. $1) which causes
98 # the build to fail when `set -u` is in effect.