From a855b04c21421b901e22b049782a53f3f1b33c77 Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Sat, 18 Nov 2023 08:02:04 +0400 Subject: [PATCH] =?UTF-8?q?dkbuild:=20les=20versions=20de=20profil=20sont?= =?UTF-8?q?=20ordonn=C3=A9es=20comme=20les=20versions=20de=20distribution?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dkbuild | 27 +++++++++++++++++-- lib/dkbuild/tests/README.md | 8 ++++++ ...test-distprofiles => test-ls-distprofiles} | 0 lib/dkbuild/tests/test-ls-distversions | 10 +++++++ lib/dkbuild/tests/test-ls-profileversions | 10 +++++++ 5 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 lib/dkbuild/tests/README.md rename lib/dkbuild/tests/{test-distprofiles => test-ls-distprofiles} (100%) create mode 100644 lib/dkbuild/tests/test-ls-distversions create mode 100644 lib/dkbuild/tests/test-ls-profileversions diff --git a/dkbuild b/dkbuild index f99e4de..c4f4f76 100755 --- a/dkbuild +++ b/dkbuild @@ -1273,14 +1273,37 @@ function define_functions_env() { return 1 } function profile() { - local profile version + local profile version default for profile in "$@"; do - [ "$profile" == DEFAULT ] && profile="${SETPROFILES[0]}" + if [ "$profile" == DEFAULT ]; then + default=1 + continue + fi parse_profile "$profile" profile version [ "$profile" == "$PROFILE" ] || continue [ -z "$version" -o "$version" == "$PVERSION" ] || continue return 0 done + if [ -n "$default" ]; then + # trouver la dernière occurence du premier profil mentionné. en + # effet, les versions doivent être ordonnées de la plus ancienne à + # la plus récente. + local first_profile last_version + for profile in "${SETPROFILES[@]}"; do + parse_profile "$profile" profile version + if [ -z "$first_profile" ]; then + first_profile="$profile" + last_version="$version" + elif [ "$profile" == "$first_profile" ]; then + last_version="$version" + fi + done + if [ "$first_profile" == "$PROFILE" ]; then + if [ -z "$last_version" -o "$last_version" == "$PVERSION" ]; then + return 0 + fi + fi + fi return 1 } declare -g -A ENVIRON diff --git a/lib/dkbuild/tests/README.md b/lib/dkbuild/tests/README.md new file mode 100644 index 0000000..da22bc9 --- /dev/null +++ b/lib/dkbuild/tests/README.md @@ -0,0 +1,8 @@ +# tests + +Lancer un test de cette façon +~~~sh +../../../dkbuild -j test-xxx +~~~ + +-*- coding: utf-8 mode: markdown -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8:noeol:binary \ No newline at end of file diff --git a/lib/dkbuild/tests/test-distprofiles b/lib/dkbuild/tests/test-ls-distprofiles similarity index 100% rename from lib/dkbuild/tests/test-distprofiles rename to lib/dkbuild/tests/test-ls-distprofiles diff --git a/lib/dkbuild/tests/test-ls-distversions b/lib/dkbuild/tests/test-ls-distversions new file mode 100644 index 0000000..7a04477 --- /dev/null +++ b/lib/dkbuild/tests/test-ls-distversions @@ -0,0 +1,10 @@ +# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8 +setdists v1-d11 v2-d11 v1-d10 + +if dist LATEST; then + info "$DIST est la distribution la plus récente" +fi +info "version=$VERSION" + +# pas de build automatique +AUTOBUILD= diff --git a/lib/dkbuild/tests/test-ls-profileversions b/lib/dkbuild/tests/test-ls-profileversions new file mode 100644 index 0000000..51915cc --- /dev/null +++ b/lib/dkbuild/tests/test-ls-profileversions @@ -0,0 +1,10 @@ +# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8 +setprofiles v1-prod v2-prod test + +if profile DEFAULT; then + info "$PROFILE est le profil par défaut" +fi +info "version=$VERSION" + +# pas de build automatique +AUTOBUILD=