From: Jackie Huang Date: Mon, 14 Nov 2022 08:43:02 +0000 (+0800) Subject: scripts/build_inf.sh: add debian support X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=6b6859940a3261c15b8cd4a1f844b55db9649d28;p=pti%2Frtp.git scripts/build_inf.sh: add debian support Issue-ID: INF-281 Signed-off-by: Jackie Huang Change-Id: I86cbb82c2793d615dde7d72c8a76e2262b67f3d3 --- diff --git a/scripts/build_inf.sh b/scripts/build_inf.sh index 9f092ef..21a0afb 100755 --- a/scripts/build_inf.sh +++ b/scripts/build_inf.sh @@ -109,9 +109,12 @@ fi ######################################################################### WORKSPACE_YP=${WORKSPACE}/workspace_yocto WORKSPACE_CENTOS=${WORKSPACE}/workspace_centos +WORKSPACE_DEB=${WORKSPACE}/workspace_debian SCRIPT_YP=${SCRIPTS_DIR}/build_inf_yocto/build_inf_yocto.sh SCRIPT_CENTOS=${SCRIPTS_DIR}/build_inf_centos/build_inf_centos.sh SCRIPT_CENTOS_PRE=${SCRIPTS_DIR}/build_inf_centos/build_inf_prepare_jenkins.sh +SCRIPT_DEB=${SCRIPTS_DIR}/build_inf_debian/build_inf_debian.sh +SCRIPT_DEB_PRE=${SCRIPTS_DIR}/build_inf_debian/build_inf_prepare_jenkins.sh prepare_workspace () { msg_step="Create workspace for the multi-os builds" @@ -150,6 +153,50 @@ get_debug_info () { echo_step_end } +build_yocto () { + msg_step="Yocto builds" + echo_step_start + + RUN_CMD="${SCRIPT_YP} -w ${WORKSPACE_YP} ${DRYRUN} ${YP_ARGS}" + run_cmd "Start Yocto builds" + + echo_step_end +} + +build_centos () { + # dry-run is not supported yet for CentOS build + if [ -z "${DRYRUN}" ]; then + msg_step="CentOS builds" + echo_step_start + + if [ "$CI" = "true" ]; then + RUN_CMD="${SCRIPT_CENTOS_PRE} -w ${WORKSPACE_CENTOS}" + run_cmd "Prepare for CentOS builds" + fi + RUN_CMD="${SCRIPT_CENTOS} -w ${WORKSPACE_CENTOS} ${DRYRUN}" + run_cmd "Start CentOS builds" + + echo_step_end + fi +} + +build_debian () { + if [ -z "${DRYRUN}" ]; then + msg_step="Debian builds" + echo_step_start + + if [ "$CI" = "true" ]; then + RUN_CMD="${SCRIPT_DEB_PRE} -w ${WORKSPACE_DEB}" + run_cmd "Prepare for Debian builds" + fi + + RUN_CMD="${SCRIPT_DEB} -w ${WORKSPACE_DEB} ${DRYRUN}" + run_cmd "Start Yocto builds" + + echo_step_end + fi +} + ######################################################################### # Main process @@ -160,25 +207,7 @@ if [ "$CI" = "true" ]; then get_debug_info fi -msg_step="Yocto builds" -echo_step_start - -RUN_CMD="${SCRIPT_YP} -w ${WORKSPACE_YP} ${DRYRUN} ${YP_ARGS}" -run_cmd "Start Yocto builds" - -echo_step_end +#build_yocto +#build_centos +build_debian -# dry-run is not supported yet for CentOS build -if [ -z "${DRYRUN}" ]; then - msg_step="CentOS builds" - echo_step_start - - if [ "$CI" = "true" ]; then - RUN_CMD="${SCRIPT_CENTOS_PRE} -w ${WORKSPACE_CENTOS}" - run_cmd "Prepare for CentOS builds" - fi - RUN_CMD="${SCRIPT_CENTOS} -w ${WORKSPACE_CENTOS} ${DRYRUN}" - run_cmd "Start CentOS builds" - - echo_step_end -fi diff --git a/scripts/build_inf_debian/build_inf_prepare_jenkins.sh b/scripts/build_inf_debian/build_inf_prepare_jenkins.sh new file mode 100755 index 0000000..0fd9d2b --- /dev/null +++ b/scripts/build_inf_debian/build_inf_prepare_jenkins.sh @@ -0,0 +1,98 @@ +#!/bin/sh +# +# Copyright (C) 2022 Wind River Systems, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Ensure we fail the job if any steps fail. +set -e -o pipefail + +######################################################################### +# Variables +######################################################################### +WORKSPACE="" + +SCRIPTS_NAME=$(basename $0) + +######################################################################### +# Common Functions +######################################################################### + +help_info () { +cat << ENDHELP +Usage: +${SCRIPTS_NAME} [-w WORKSPACE_DIR] [-h] +where: + -w WORKSPACE_DIR is the path for the builds + -h this help info +examples: +$0 +$0 -w workspace_1234 +ENDHELP +} + +echo_step_start() { + [ -n "$1" ] && msg_step=$1 + echo "#########################################################################################" + echo "## ${SCRIPTS_NAME} - STEP START: ${msg_step}" + echo "#########################################################################################" +} + +echo_step_end() { + [ -n "$1" ] && msg_step=$1 + echo "#########################################################################################" + echo "## ${SCRIPTS_NAME} - STEP END: ${msg_step}" + echo "#########################################################################################" + echo +} + +echo_info () { + echo "INFO: $1" +} + +while getopts "w:h" OPTION; do + case ${OPTION} in + w) + WORKSPACE=`readlink -f ${OPTARG}` + ;; + h) + help_info + exit + ;; + esac +done + +######################################################################### +# Main process +######################################################################### +msg_step="Prepare build directories" +echo_step_start + +echo_info "Install minikube" +mkdir -p ${WORKSPACE}/dl-tools +cd ${WORKSPACE}/dl-tools +curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 +sudo install minikube-linux-amd64 /usr/local/bin/minikube +minikube version + +echo_info "Install helm" +curl -LO https://get.helm.sh/helm-v3.6.2-linux-amd64.tar.gz +tar xvf helm-v3.6.2-linux-amd64.tar.gz +sudo mv linux-amd64/helm /usr/local/bin/ + +echo_info "Install repo tool" +sudo wget https://storage.googleapis.com/git-repo-downloads/repo -O /usr/local/bin/repo +sudo chmod a+x /usr/local/bin/repo + +echo_step_end