3 # Copyright (c) 2021 Intel and/or its affiliates.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at:
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
19 function gather_nginx () {
21 # Ensure stable NGINX archive is downloaded.
24 # - DOWNLOAD_DIR - Path to directory pybot takes the build to test from.
25 # - NGINX_VER - Version number of Nginx.
27 pushd "${DOWNLOAD_DIR}" || die "Pushd failed."
28 nginx_repo="http://nginx.org/download/"
29 # Use downloaded packages with specific version
30 echo "Downloading NGINX package of specific version from repo ..."
31 # Downloading NGINX version based on what VPP is using. Currently
32 # it is not easy way to detect from VPP version automatically.
33 nginx_stable_ver="${NGINX_VER}".tar.gz
35 if [[ ! -f "${nginx_stable_ver}" ]]; then
36 wget -nv --no-check-certificate \
37 "${nginx_repo}/${nginx_stable_ver}" || {
38 die "Failed to get NGINX package from: ${nginx_repo}."
41 popd || die "Popd failed."
45 function common_dirs () {
47 # Set global variables, create some directories (without touching content).
48 # This function assumes running in remote testbed. It might override other
49 # functions if included from common.sh.
52 # - ${1} - Version number of Nginx.
54 # - BASH_FUNCTION_DIR - Path to existing directory this file is located in.
55 # - CSIT_DIR - Path to CSIT framework.
56 # - DOWNLOAD_DIR - Path to directory pybot takes the build to test from.
57 # - NGINX_DIR - Path to NGINX framework.
58 # - NGINX_VER - Version number of Nginx.
60 # - die - Print to stderr and exit.
64 this_file=$(readlink -e "${BASH_SOURCE[0]}") || {
65 die "Some error during locating of this source file."
67 BASH_FUNCTION_DIR=$(dirname "${this_file}") || {
68 die "Some error during dirname call."
70 CSIT_DIR=$(readlink -e "/tmp/openvpp-testing") || {
71 die "Readlink failed."
73 DOWNLOAD_DIR=$(readlink -f "${CSIT_DIR}/download_dir") || {
74 die "Readlink failed."
76 mkdir -p "${CSIT_DIR}/${NGINX_VER}" || die "Mkdir failed."
77 NGINX_DIR=$(readlink -e "${CSIT_DIR}/${NGINX_VER}") || {
78 die "Readlink failed."
84 function nginx_compile () {
86 # Compile NGINX archive.
89 # - NGINX_DIR - Path to NGINX framework.
90 # - CSIT_DIR - Path to CSIT framework.
91 # - NGINX_INS_PATH - Path to NGINX install path.
93 # - die - Print to stderr and exit.
96 NGINX_INS_PATH="${DOWNLOAD_DIR}/${NGINX_VER}"
97 pushd "${NGINX_DIR}" || die "Pushd failed."
99 # Set installation prefix.
100 param="--prefix=${NGINX_INS_PATH} "
101 # Set nginx binary pathname.
102 param+="--sbin-path=${NGINX_INS_PATH}/sbin/nginx "
103 # Set nginx.conf pathname.
104 param+="--conf-path=${NGINX_INS_PATH}/conf/nginx.conf "
105 # Enable ngx_http_stub_status_module.
106 param+="--with-http_stub_status_module "
107 # Force PCRE library usage.
108 param+="--with-pcre "
109 # Enable ngx_http_realip_module.
110 param+="--with-http_realip_module "
112 ./configure "${params[@]}" || die "Failed to configure NGINX!"
113 make -j 16;make install || die "Failed to compile NGINX!"
117 function nginx_extract () {
119 # Extract NGINX framework.
122 # - NGINX_DIR - Path to NGINX framework.
123 # - CSIT_DIR - Path to CSIT framework.
124 # - DOWNLOAD_DIR - Path to directory pybot takes the build to test from.
125 # - NGINX_VER - Version number of Nginx.
127 # - die - Print to stderr and exit.
131 pushd "${CSIT_DIR}" || die "Pushd failed."
132 tar -xvf ${DOWNLOAD_DIR}/${NGINX_VER}.tar.gz --strip=1 \
133 --directory "${NGINX_DIR}" || {
134 die "Failed to extract NGINX!"