version specific build targets implemented

This commit is contained in:
Achim Gsell
2020-12-01 16:05:36 +01:00
parent 418b79ed6a
commit 417bd2bf8b
+57 -24
View File
@@ -51,7 +51,7 @@ declare configure_with='undef'
#.............................................................................. #..............................................................................
# #
# compare to version numbers # compare two version numbers
# #
# original implementation found on stackoverflow: # original implementation found on stackoverflow:
# https://stackoverflow.com/questions/4023830/how-to-compare-two-strings-in-dot-separated-version-format-in-bash # https://stackoverflow.com/questions/4023830/how-to-compare-two-strings-in-dot-separated-version-format-in-bash
@@ -64,7 +64,7 @@ pbuild::version_compare () {
[[ $1 == $2 ]] && return 0 [[ $1 == $2 ]] && return 0
local IFS=. local IFS=.
local i ver1=($1) ver2=($2) local i ver1=($1) ver2=($2)
# fill empty fields in ver1 with zeros # fill empty fields in ver1 with zeros
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)); do for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)); do
ver1[i]=0 ver1[i]=0
@@ -90,7 +90,7 @@ pbuild::version_lt() {
pbuild::version_le() { pbuild::version_le() {
pbuild::version_compare "$1" "$2" pbuild::version_compare "$1" "$2"
local -i exit_code=$? local -i exit_code=$?
(( exit_code == 0 || exit_code = 2 )) (( exit_code == 0 || exit_code = 2 ))
} }
@@ -98,7 +98,7 @@ pbuild::version_gt() {
pbuild::version_compare "$1" "$2" pbuild::version_compare "$1" "$2"
(( $? == 1 )) (( $? == 1 ))
local -i exit_code=$? local -i exit_code=$?
(( exit_code == 0 || exit_code = 1 )) (( exit_code == 0 || exit_code = 1 ))
} }
pbuild::version_eq() { pbuild::version_eq() {
@@ -524,7 +524,14 @@ pbuild::prep() {
patch -p${strip_val} < "${BUILDBLOCK_DIR}/${PATCH_FILES[_i]}" patch -p${strip_val} < "${BUILDBLOCK_DIR}/${PATCH_FILES[_i]}"
done done
} }
if [[ -z "${SOURCE_URLS}" ]]; then
for fname in ${VERSIONS[@]/#/pbuild::set_download_url_}; do
if typeset -F ${fname} 2>/dev/null; then
$f
break
fi
done
fi
[[ -z "${SOURCE_URLS}" ]] && \ [[ -z "${SOURCE_URLS}" ]] && \
std::die 3 \ std::die 3 \
"%s " "${module_name}/${module_version}:" \ "%s " "${module_name}/${module_version}:" \
@@ -778,14 +785,9 @@ pbuild::make_all() {
#...................................................................... #......................................................................
find_modulefile() { find_modulefile() {
local "$1" local "$1"
local fnames=()
fnames+=( "modulefile-${V_MAJOR}.${V_MINOR}.${V_PATCHLVL}" )
fnames+=( "modulefile-${V_MAJOR}.${V_MINOR}" )
fnames+=( "modulefile-${V_MAJOR}" )
fnames+=( "modulefile" )
local fname='' local fname=''
local modulefile='' local modulefile=''
for fname in "${fnames[@]}"; do for fname in "${VERSIONS[@]/#/modulefile-}"; do
if [[ -r "${BUILDBLOCK_DIR}/${fname}" ]]; then if [[ -r "${BUILDBLOCK_DIR}/${fname}" ]]; then
modulefile="${BUILDBLOCK_DIR}/${fname}" modulefile="${BUILDBLOCK_DIR}/${fname}"
break; break;
@@ -802,7 +804,16 @@ pbuild::make_all() {
# install the doc-files specified in the build-script # install the doc-files specified in the build-script
# #
install_doc() { install_doc() {
test -n "${MODULE_DOCFILES}" || return 0 if [[ -z "${MODULE_DOCFILES}" ]]; then
for f in ${VERSIONS[@]/#/pbuild::install_docfiles_}; do
if typeset -F "$f" 2>/dev/null; then
$f
break
fi
done
fi
[[ -n "${MODULE_DOCFILES}" ]] || return 0
local -r docdir="${PREFIX}/${_DOCDIR}/${module_name}" local -r docdir="${PREFIX}/${_DOCDIR}/${module_name}"
std::info \ std::info \
@@ -1021,15 +1032,23 @@ pbuild::make_all() {
return 0 return 0
fi fi
local targets=() local targets=()
targets+=( "pre_${target}_${system}" "pre_${target}_${OS}" "pre_${target}" ) targets+=( ${VERSIONS[@]/#/pbuild::pre_${target}_${system}_} )
if typeset -F pbuild::${target}_${system} 1>/dev/null 2>&1; then targets+=( pbuild::pre_${target}_${system} )
targets+=( "${target}_${system}" ) targets+=( ${VERSIONS[@]/#/pbuild::pre_${target}_${OS}_} )
elif typeset -F pbuild::${target}_${OS} 1>/dev/null 2>&1; then targets+=( pbuild::pre_${target}_${OS} )
targets+=( "${target}_${OS}" ) targets+=( pbuild::pre_${target} )
else
targets+=( "${target}" ) targets+=( ${VERSIONS[@]/#/pbuild::${target}_${system}_} )
fi targets+=( pbuild::${target}_${system} )
targets+=( "post_${target}_${system}" "post_${target}_${OS}" "post_${target}" ) targets+=( ${VERSIONS[@]/#/pbuild::${target}_${OS}_} )
targets+=( pbuild::${target}_${OS} )
targets+=( pbuild::${target} )
targets+=( ${VERSIONS[@]/#/pbuild::post_${target}_${system}_} )
targets+=( pbuild::post_${target}_${system} )
targets+=( ${VERSIONS[@]/#/pbuild::post_${target}_${OS}_} )
targets+=( pbuild::post_${target}_${OS} )
targets+=( pbuild::post_${target} )
for t in "${targets[@]}"; do for t in "${targets[@]}"; do
# We cd into the dir before calling the function - # We cd into the dir before calling the function -
@@ -1040,7 +1059,7 @@ pbuild::make_all() {
# might/need to be set. # might/need to be set.
# #
cd "${dir}" cd "${dir}"
"pbuild::$t" typeset -F "$t" 2>/dev/null && "$t" || :
done done
touch "${BUILD_DIR}/.${target}" touch "${BUILD_DIR}/.${target}"
} }
@@ -1185,8 +1204,11 @@ pbuild.init_env() {
v="${v%%_*}" v="${v%%_*}"
fi fi
V_PKG="${v%%-*}" # version without the release number V_PKG="${v%%-*}" # version without the release number
V_RELEASE="${v#*-}" # release number if [[ $v == *-* ]]; then
V_RELEASE="${v#*-}" # release number
else
V_RELEASE=''
fi
case "${V_PKG}" in case "${V_PKG}" in
*.*.* ) *.*.* )
V_MAJOR="${V_PKG%%.*}" V_MAJOR="${V_PKG%%.*}"
@@ -1202,6 +1224,17 @@ pbuild.init_env() {
V_MAJOR="${V_PKG}" V_MAJOR="${V_PKG}"
;; ;;
esac esac
VERSIONS=( ${V_MAJOR} )
if [[ -n ${V_MINOR} ]]; then
VERSIONS=( ${V_MAJOR}.${V_MINOR} ${VERSIONS[@]} )
fi
if [[ -n ${V_PATCHLVL} ]]; then
VERSIONS=( ${V_MAJOR}.${V_MINOR}.${V_PATCHLVL} ${VERSIONS[@]} )
fi
if [[ -n ${V_RELEASE} ]]; then
VERSIONS=( ${V_MAJOR}.${V_MINOR}.${V_PATCHLVL}-${V_RELEASE} ${VERSIONS[@]} )
fi
} }
local -r module_name="$1" local -r module_name="$1"