From 2afdf08eed7a86b0dce32002a8d5d5885e366b69 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Sun, 16 Jun 2019 15:04:36 +0200 Subject: [PATCH] Bugfixing version_greater() method --- .docker-files/entrypoint.sh | 2 +- .travis.yml | 5 ++++ .travis/test-entrypoint.sh | 35 ++++++++++++++++++++++++++++ 2019.04/apache/entrypoint.sh | 2 +- 2019.04/fpm-alpine/entrypoint.sh | 2 +- 2019.04/fpm/entrypoint.sh | 2 +- 2019.06-dev/apache/entrypoint.sh | 2 +- 2019.06-dev/fpm-alpine/entrypoint.sh | 2 +- 2019.06-dev/fpm/entrypoint.sh | 2 +- 2019.06-rc/apache/entrypoint.sh | 2 +- 2019.06-rc/fpm-alpine/entrypoint.sh | 2 +- 2019.06-rc/fpm/entrypoint.sh | 2 +- 12 files changed, 50 insertions(+), 10 deletions(-) create mode 100755 .travis/test-entrypoint.sh diff --git a/.docker-files/entrypoint.sh b/.docker-files/entrypoint.sh index 8f8c9eb..2d0bcf2 100644 --- a/.docker-files/entrypoint.sh +++ b/.docker-files/entrypoint.sh @@ -12,7 +12,7 @@ run_as() { # checks if the the first parameter is greater than the second parameter version_greater() { - [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] + [ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ] } # clones the whole develop branch (Friendica and Addons) diff --git a/.travis.yml b/.travis.yml index 703773c..b591b70 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,6 +52,11 @@ jobs: script: - ./generate-stackbrew-library.sh + - <<: *test-scripts + env: SCRIPT=test-entrypoint.sh + script: + - ./.travis/test-entrypoint.sh + - stage: test images (amd64) env: VERSION=2019.04 VARIANT=fpm-alpine ARCH=amd64 - env: VERSION=2019.04 VARIANT=fpm ARCH=amd64 diff --git a/.travis/test-entrypoint.sh b/.travis/test-entrypoint.sh new file mode 100755 index 0000000..9c1ea3e --- /dev/null +++ b/.travis/test-entrypoint.sh @@ -0,0 +1,35 @@ +#!/bin/sh +set -eu + +# copy of see .docker-files/entrypoint.sh - testing all versions +version_greater() { + [ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ] +} + +if ! version_greater "2019.06" "2019.06-rc"; then + exit 1; +fi +if ! version_greater "2019.06" "2019.04-rc"; then + exit 1; +fi +if version_greater "2019.06-rc" "2019.06"; then + exit 1; +fi +if version_greater "2019.04" "2019.06"; then + exit 1; +fi +if ! version_greater "2019.06" "2019.04"; then + exit 1; +fi +if ! version_greater "2019.07" "2019.06-rc"; then + exit 1; +fi +if version_greater "2019.05" "2019.06-rc"; then + exit 1; +fi +if version_greater "2019.05-dev" "2019.05"; then + exit 1; +fi +if ! version_greater "2019.05" "2019.05-dev"; then + exit 1; +fi diff --git a/2019.04/apache/entrypoint.sh b/2019.04/apache/entrypoint.sh index 8f8c9eb..2d0bcf2 100644 --- a/2019.04/apache/entrypoint.sh +++ b/2019.04/apache/entrypoint.sh @@ -12,7 +12,7 @@ run_as() { # checks if the the first parameter is greater than the second parameter version_greater() { - [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] + [ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ] } # clones the whole develop branch (Friendica and Addons) diff --git a/2019.04/fpm-alpine/entrypoint.sh b/2019.04/fpm-alpine/entrypoint.sh index 8f8c9eb..2d0bcf2 100644 --- a/2019.04/fpm-alpine/entrypoint.sh +++ b/2019.04/fpm-alpine/entrypoint.sh @@ -12,7 +12,7 @@ run_as() { # checks if the the first parameter is greater than the second parameter version_greater() { - [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] + [ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ] } # clones the whole develop branch (Friendica and Addons) diff --git a/2019.04/fpm/entrypoint.sh b/2019.04/fpm/entrypoint.sh index 8f8c9eb..2d0bcf2 100644 --- a/2019.04/fpm/entrypoint.sh +++ b/2019.04/fpm/entrypoint.sh @@ -12,7 +12,7 @@ run_as() { # checks if the the first parameter is greater than the second parameter version_greater() { - [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] + [ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ] } # clones the whole develop branch (Friendica and Addons) diff --git a/2019.06-dev/apache/entrypoint.sh b/2019.06-dev/apache/entrypoint.sh index 8f8c9eb..2d0bcf2 100644 --- a/2019.06-dev/apache/entrypoint.sh +++ b/2019.06-dev/apache/entrypoint.sh @@ -12,7 +12,7 @@ run_as() { # checks if the the first parameter is greater than the second parameter version_greater() { - [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] + [ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ] } # clones the whole develop branch (Friendica and Addons) diff --git a/2019.06-dev/fpm-alpine/entrypoint.sh b/2019.06-dev/fpm-alpine/entrypoint.sh index 8f8c9eb..2d0bcf2 100644 --- a/2019.06-dev/fpm-alpine/entrypoint.sh +++ b/2019.06-dev/fpm-alpine/entrypoint.sh @@ -12,7 +12,7 @@ run_as() { # checks if the the first parameter is greater than the second parameter version_greater() { - [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] + [ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ] } # clones the whole develop branch (Friendica and Addons) diff --git a/2019.06-dev/fpm/entrypoint.sh b/2019.06-dev/fpm/entrypoint.sh index 8f8c9eb..2d0bcf2 100644 --- a/2019.06-dev/fpm/entrypoint.sh +++ b/2019.06-dev/fpm/entrypoint.sh @@ -12,7 +12,7 @@ run_as() { # checks if the the first parameter is greater than the second parameter version_greater() { - [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] + [ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ] } # clones the whole develop branch (Friendica and Addons) diff --git a/2019.06-rc/apache/entrypoint.sh b/2019.06-rc/apache/entrypoint.sh index 8f8c9eb..2d0bcf2 100644 --- a/2019.06-rc/apache/entrypoint.sh +++ b/2019.06-rc/apache/entrypoint.sh @@ -12,7 +12,7 @@ run_as() { # checks if the the first parameter is greater than the second parameter version_greater() { - [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] + [ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ] } # clones the whole develop branch (Friendica and Addons) diff --git a/2019.06-rc/fpm-alpine/entrypoint.sh b/2019.06-rc/fpm-alpine/entrypoint.sh index 8f8c9eb..2d0bcf2 100644 --- a/2019.06-rc/fpm-alpine/entrypoint.sh +++ b/2019.06-rc/fpm-alpine/entrypoint.sh @@ -12,7 +12,7 @@ run_as() { # checks if the the first parameter is greater than the second parameter version_greater() { - [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] + [ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ] } # clones the whole develop branch (Friendica and Addons) diff --git a/2019.06-rc/fpm/entrypoint.sh b/2019.06-rc/fpm/entrypoint.sh index 8f8c9eb..2d0bcf2 100644 --- a/2019.06-rc/fpm/entrypoint.sh +++ b/2019.06-rc/fpm/entrypoint.sh @@ -12,7 +12,7 @@ run_as() { # checks if the the first parameter is greater than the second parameter version_greater() { - [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] + [ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ] } # clones the whole develop branch (Friendica and Addons)