Pass tox context
Allow passing tox context via env var and content meta. This makes certian contitional build steps easier for users to maintain. Change-Id: Ia5718f96ad31c22651b2cec8fdc636f8e75622cb Signed-off-by: Ron Stone <ronald.stone@windriver.com>
This commit is contained in:
90
_utils.sh
90
_utils.sh
@@ -10,6 +10,8 @@ confirmation () { message $GR$@$NC; }
|
|||||||
warn () { message $OG$@$NC; }
|
warn () { message $OG$@$NC; }
|
||||||
error () { message $RED$0:$?: $@$NC; exit 1; }
|
error () { message $RED$0:$?: $@$NC; exit 1; }
|
||||||
|
|
||||||
|
declare meta_ver=":MM(.)mm:"
|
||||||
|
|
||||||
# Check for and exit if file dependancies are not met. Takes a list of full or
|
# Check for and exit if file dependancies are not met. Takes a list of full or
|
||||||
# relative paths.
|
# relative paths.
|
||||||
check_file_deps () {
|
check_file_deps () {
|
||||||
@@ -17,6 +19,7 @@ check_file_deps () {
|
|||||||
do
|
do
|
||||||
if [ ! -f "${filereq}" ] && [ ! -L "${filereq}" ]; then error "${filereq} not found. Quiting."; exit 1; fi
|
if [ ! -f "${filereq}" ] && [ ! -L "${filereq}" ]; then error "${filereq} not found. Quiting."; exit 1; fi
|
||||||
done
|
done
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check for and exit if command dependancies are not met. Takes a list of
|
# Check for and exit if command dependancies are not met. Takes a list of
|
||||||
@@ -111,4 +114,91 @@ check_abbr_dups () {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Return this product version
|
||||||
|
#
|
||||||
|
# Finds and echos out this-ver value from _this.txt
|
||||||
|
# Calling context is responsible for parsing major and
|
||||||
|
# minor numbers into vars (g_YY and g_MM by convention)
|
||||||
|
get_this_version() {
|
||||||
|
|
||||||
|
local this_file="_this.txt"
|
||||||
|
local ver_file=$(find doc* -name $this_file)
|
||||||
|
[[ ! -f ${ver_file} ]] && \
|
||||||
|
error "$this_file not found. Quiting."
|
||||||
|
|
||||||
|
local _ver
|
||||||
|
local regex_ver="\.\.\s+\|this-ver\|\s+replace::\s+([0-9]{2}\.[0-9]{2})\s*"
|
||||||
|
|
||||||
|
local _this=$(grep this-ver $ver_file)
|
||||||
|
|
||||||
|
if [[ "${_this}" =~ $regex_ver ]]
|
||||||
|
then
|
||||||
|
_ver="${BASH_REMATCH[1]}"
|
||||||
|
else
|
||||||
|
error "Can't find local product version"
|
||||||
|
fi
|
||||||
|
echo $_ver
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# List hash of separator characters used in ":MM<char>mm:" style
|
||||||
|
# placeholders
|
||||||
|
#
|
||||||
|
# Takes path to the file to scan.
|
||||||
|
# Sets global hash 'spacers'. Note that BRE special characters will be escaped.
|
||||||
|
|
||||||
|
get_version_spacers() {
|
||||||
|
|
||||||
|
local _sep
|
||||||
|
check_file_deps $1 && \
|
||||||
|
local _f=$1
|
||||||
|
|
||||||
|
spacers=()
|
||||||
|
while read l; do
|
||||||
|
_sep=''
|
||||||
|
if [[ $l =~ ${meta_ver} ]]; then
|
||||||
|
[[ ${BASH_REMATCH[1]} == [\$\*\.\\\[\]] ]] && \
|
||||||
|
_sep="\\${BASH_REMATCH[1]}" || \
|
||||||
|
_sep="${BASH_REMATCH[1]}"
|
||||||
|
spacers["${_sep}"]=0
|
||||||
|
fi
|
||||||
|
done < $_f
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# Replace ":MM<char>mm:" placeholders in a target file.
|
||||||
|
#
|
||||||
|
# Takes path to file to manipulate and overwrites on disk
|
||||||
|
# Returns 0 on success
|
||||||
|
# Note: global hash 'spacers' must be set; see get_version_spacers
|
||||||
|
|
||||||
|
replace_version_placeholders() {
|
||||||
|
|
||||||
|
check_file_deps $1 && \
|
||||||
|
local _f=$1
|
||||||
|
local _rs
|
||||||
|
|
||||||
|
for sp in "${!spacers[@]}"; do
|
||||||
|
[[ $sp == '^' ]] && _rs="" || _rs=$sp
|
||||||
|
sed -i "s/:MM${sp}mm:/${g_YY}$_rs${g_MM}/g" $_f
|
||||||
|
done
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# Return the name of the current default branch
|
||||||
|
get_this_branch() {
|
||||||
|
|
||||||
|
local _regex_br="defaultbranch=(.*)\s*$"
|
||||||
|
local _config="$PWD/.gitreview"
|
||||||
|
|
||||||
|
if [[ $(cat $_config) =~ $_regex_br ]]; then
|
||||||
|
echo "${BASH_REMATCH[1]}"
|
||||||
|
else
|
||||||
|
error "$PWD is not a branch"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
declare utils_loaded=1
|
declare utils_loaded=1
|
||||||
1
tox.ini
1
tox.ini
@@ -10,6 +10,7 @@ setenv = VIRTUAL_ENV={envdir}
|
|||||||
OS_STDERR_CAPTURE=1
|
OS_STDERR_CAPTURE=1
|
||||||
OS_TEST_TIMEOUT=60
|
OS_TEST_TIMEOUT=60
|
||||||
LC_ALL=C
|
LC_ALL=C
|
||||||
|
DOCS_BUILD_CONTEXT=starlingx
|
||||||
deps = -r{toxinidir}/test-requirements.txt
|
deps = -r{toxinidir}/test-requirements.txt
|
||||||
|
|
||||||
[testenv:prebuild-docs]
|
[testenv:prebuild-docs]
|
||||||
|
|||||||
Reference in New Issue
Block a user