639e435594
The recently released mock-1.4.20 replaces mockchain with a bash wrapper that calls mock --chain. However, the StarlingX mockchain-parallel utility assumes mockchain is python, and fails to determine the mockchain version as a result. This causes build failures when mock-1.4.20 is installed. This update enhances mockchain-parallel to use the version from the installed mock rpm if the version cannot be determined from mockchain itself. This allows mockchain-parallel to work with mock-1.4.20, as well as previously supported versions of mock. Change-Id: Ic0360fc64e277f1816036b6259e6e51d94c7f368 Closes-Bug: 1849147 Signed-off-by: Don Penney <don.penney@windriver.com>
109 lines
3.1 KiB
Bash
Executable File
109 lines
3.1 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
|
|
#
|
|
# Copyright (c) 2018 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
#
|
|
# The following tries to choose the best mockchain-parallel-* implementation
|
|
# to use, based on the version of /usr/bin/mockchain
|
|
#
|
|
# We want to use a compatable API, and to use the same python version.
|
|
#
|
|
|
|
interpreter_path () {
|
|
local path=${1}
|
|
if [ ! -f ${path} ]; then
|
|
return 1
|
|
fi
|
|
readlink -f $(head -n 1 ${path} | sed 's/^#!//' | awk '{ print $1 }' )
|
|
}
|
|
|
|
get__version__ () {
|
|
local path=${1}
|
|
if [ ! -f ${path} ]; then
|
|
return 1
|
|
fi
|
|
grep __VERSION__= ${path} | cut -d '=' -f 2 | sed 's/"//g'
|
|
}
|
|
|
|
VC_LESS_THAN=0
|
|
VC_EQUAL=1
|
|
VC_GREATER_THAN=2
|
|
ver_comp () {
|
|
local v1=${1}
|
|
local v2=${2}
|
|
local v_greater=""
|
|
|
|
if [ "${v1}" == "${v2}" ]; then
|
|
echo $VC_EQUAL
|
|
return
|
|
fi
|
|
|
|
v_greater=$((echo ${v1}; echo ${v2}) | sort -rV | head -n 1)
|
|
if [ "${v1}" == "${v_greater}" ]; then
|
|
echo $VC_GREATER_THAN
|
|
return
|
|
fi
|
|
|
|
echo $VC_LESS_THAN
|
|
}
|
|
|
|
MOCKCHAIN_PATH="/usr/bin/mockchain"
|
|
MOCKCHAIN_PARALLEL_PATH_ROOT="${MY_REPO}/build-tools/mockchain-parallel"
|
|
DEFAULT_MOCKCHAIN_PARALLEL_PATH="${MOCKCHAIN_PARALLEL_PATH_ROOT}-1.3.4"
|
|
|
|
MOCKCHAIN_INTERPRETER_PATH=$(interpreter_path ${MOCKCHAIN_PATH})
|
|
MOCKCHAIN_VER=$(get__version__ ${MOCKCHAIN_PATH})
|
|
if [ -z "${MOCKCHAIN_VER}" ]; then
|
|
MOCKCHAIN_VER=$(rpm -q --queryformat '%{VERSION}' mock)
|
|
if [ -z "${MOCKCHAIN_VER}" ]; then
|
|
echo "Error: Failed to determine version of '${MOCKCHAIN_PATH}'"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
BEST_VER=""
|
|
BEST_MOCKCHAIN_PARALLEL_PATH=""
|
|
|
|
for MOCKCHAIN_PARALLEL_PATH in $(ls -1 ${MOCKCHAIN_PARALLEL_PATH_ROOT}-*); do
|
|
MOCKCHAIN_PARALLEL_VER=$(get__version__ ${MOCKCHAIN_PARALLEL_PATH})
|
|
if [ -z "${MOCKCHAIN_PARALLEL_VER}" ]; then
|
|
echo "Warning: Failed to determine version of '${MOCKCHAIN_PARALLEL_PATH}'"
|
|
continue
|
|
fi
|
|
COMP=$(ver_comp "${MOCKCHAIN_VER}" "${MOCKCHAIN_PARALLEL_VER}")
|
|
echo $MOCKCHAIN_PARALLEL_PATH $MOCKCHAIN_PARALLEL_VER $COMP
|
|
if [ $COMP -eq $VC_EQUAL ]; then
|
|
BEST_VER=${MOCKCHAIN_PARALLEL_VER}
|
|
BEST_MOCKCHAIN_PARALLEL_PATH=${MOCKCHAIN_PARALLEL_PATH}
|
|
break
|
|
fi
|
|
if [ $COMP -gt $VC_EQUAL ]; then
|
|
if [ "${BEST_VER}" == "" ]; then
|
|
BEST_VER=${MOCKCHAIN_PARALLEL_VER}
|
|
BEST_MOCKCHAIN_PARALLEL_PATH=${MOCKCHAIN_PARALLEL_PATH}
|
|
continue
|
|
fi
|
|
|
|
COMP=$(ver_comp ${MOCKCHAIN_PARALLEL_VER} ${BEST_VER})
|
|
if [ $COMP -gt $VC_EQUAL ]; then
|
|
BEST_VER=${MOCKCHAIN_PARALLEL_VER}
|
|
BEST_MOCKCHAIN_PARALLEL_PATH=${MOCKCHAIN_PARALLEL_PATH}
|
|
fi
|
|
fi
|
|
done
|
|
|
|
MOCKCHAIN_PARALLEL_INTERPRETER_PATH=${BEST_MOCKCHAIN_PARALLEL_INTERPRETER_PATH}
|
|
MOCKCHAIN_PARALLEL_PATH=${BEST_MOCKCHAIN_PARALLEL_PATH}
|
|
|
|
if [ -z "${MOCKCHAIN_PARALLEL_PATH}" ]; then
|
|
MOCKCHAIN_PARALLEL_PATH="${DEFAULT_MOCKCHAIN_PARALLEL_PATH}"
|
|
fi
|
|
|
|
echo "PYTHONDONTWRITEBYTECODE=true exec ${MOCKCHAIN_PARALLEL_INTERPRETER_PATH} ${MOCKCHAIN_PARALLEL_PATH} $@"
|
|
PYTHONDONTWRITEBYTECODE=true exec ${MOCKCHAIN_PARALLEL_INTERPRETER_PATH} ${MOCKCHAIN_PARALLEL_PATH} "$@"
|