Skip to content

Commit

Permalink
#1369: made "*" latest stable, and fixed mac bug
Browse files Browse the repository at this point in the history
  • Loading branch information
MattesMrzik committed Jan 5, 2024
1 parent a7a58f5 commit f995608
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
5 changes: 2 additions & 3 deletions documentation/functions.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,10 @@ Determines whether the actual version is contained in the security file for the
=== doCheckVersionRange
Determines whether a version is in a version range.

=== doGetLatestSoftwareVersion
=== doGetAnyLatestSoftwareVersion
Determines the latest available version of software and returns it. If a prefix is given, it will be taken into account.

=== doGetLatestStableSoftwareVersion
=== doGetLatestSoftwareVersion
Determines the latest stable available version of software and returns it. If a prefix is given, it will be taken into account.

=== doGetNextVersion
Expand Down Expand Up @@ -432,4 +432,3 @@ In this case, it does the handling to `list`, `get`, or `set` the version and ex

If -- is passed, a variable is set that prevents further calls of this function and ends with the return value 0.
If none of these options are passed, the return value is 255.

22 changes: 14 additions & 8 deletions scripts/src/main/resources/scripts/functions
Original file line number Diff line number Diff line change
Expand Up @@ -1300,12 +1300,12 @@ function doInstall() {
if [ -z "${version}" ]
then
version=$(doGetLatestSoftwareVersion "${software}")
doDebug "Resolved latest version of ${software} to ${version}"
doDebug "Resolved latest stable version of ${software} to ${version}"
elif [ "${version:${#version}-2}" = "*!" ]
then
doDebug "Resolving version prefix ${version}"
edition=$(doGetSoftwareEdition "${software}")
resolved_version=$(doGetLatestStableSoftwareVersion "${software}" "${version}")
resolved_version=$(doGetAnyLatestSoftwareVersion "${software}" "${version}")
if [ -n "${resolved_version}" ]
then
doDebug "Resolved version prefix ${version} to ${resolved_version}"
Expand Down Expand Up @@ -1854,7 +1854,7 @@ function doGetSoftwareEdition() {

# $1: software
# $2: optional prefix
function doGetLatestSoftwareVersion() {
function doGetAnyLatestSoftwareVersion() {
local software="${1}"
local prefix="${2}"
local edition
Expand All @@ -1864,7 +1864,7 @@ function doGetLatestSoftwareVersion() {
then
version="$(find "${DEVON_IDE_HOME}"/urls/"${software}"/"${edition}" -mindepth 1 -maxdepth 1 -print | awk -F'/' '{print $NF}' | sort -rV | head -1)"
else
prefix="${prefix:0:${#prefix}-1}"
prefix="${prefix:0:${#prefix}-2}" # 2 for "*!"
prefix="${prefix/./[.]}"
version="$(find "${DEVON_IDE_HOME}"/urls/"${software}"/"${edition}" -mindepth 1 -maxdepth 1 -print | awk -F'/' '{print $NF}' | grep "^${prefix}" | sort -rV | head -1)"
fi
Expand All @@ -1873,18 +1873,24 @@ function doGetLatestSoftwareVersion() {

# $1: software
# $2: optional prefix
function doGetLatestStableSoftwareVersion() {
function doGetLatestSoftwareVersion() {
local software="${1}"
local prefix="${2}"
local edition
local version
if [ -z "${prefix}" ]
then
mapfile -t versions < <(find "${DEVON_IDE_HOME}"/urls/"${software}"/"${edition}" -mindepth 1 -maxdepth 1 -print | awk -F'/' '{print $NF}' | sort -rV)
versions=()
while IFS= read -r line; do
versions+=("$line")
done < <(find "${DEVON_IDE_HOME}"/urls/"${software}"/"${edition}" -mindepth 1 -maxdepth 1 -print | awk -F'/' '{print $NF}' | sort -rV)
else
prefix="${prefix:0:${#prefix}-2}" # 2 for "*!"
prefix="${prefix:0:${#prefix}-1}" # 1 for "*"
prefix="${prefix/./[.]}"
mapfile -t versions < <(find "${DEVON_IDE_HOME}"/urls/"${software}"/"${edition}" -mindepth 1 -maxdepth 1 -print | awk -F'/' '{print $NF}' | grep "^${prefix}" | sort -rV)
versions=()
while IFS= read -r line; do
versions+=("$line")
done < <(find "${DEVON_IDE_HOME}"/urls/"${software}"/"${edition}" -mindepth 1 -maxdepth 1 -print | awk -F'/' '{print $NF}' | grep "^${prefix}" | sort -rV)
fi

# version is not considered stable (see IDEasy VersionSegment) if:
Expand Down

0 comments on commit f995608

Please sign in to comment.