dkbuild: fin support tag & last version

This commit is contained in:
Jephté Clain 2023-01-08 15:22:24 +04:00
parent 1a764f15ff
commit c671cb399d
1 changed files with 28 additions and 12 deletions

40
dkbuild
View File

@ -637,9 +637,13 @@ Les paramètres optionnels sont
* host-mappings=MAPPINGS * host-mappings=MAPPINGS
définir des mappings d'hôte. si ce paramètre n'est pas spécifié, consulter définir des mappings d'hôte. si ce paramètre n'est pas spécifié, consulter
aussi la valeur par défaut 'docker host-mappings=' aussi la valeur par défaut 'docker host-mappings='
* set-tag=TAGS... ou set-tags=TAGS...
spécifier des tags à rajouter au nom de l'image, séparés par un espace. cette
liste remplace celle calculée automatiquement. ce paramètre est ignoré pour
les noms d'images comportant un tag
* add-tag=TAGS... ou add-tags=TAGS... * add-tag=TAGS... ou add-tags=TAGS...
spécifier des tags à rajouter à la liste calculée automatiquement, séparés par spécifier des tags à rajouter à la liste calculée automatiquement, séparés par
un espace. ce paramètre est ignoré si on spécifie un nom d'image avec un tag un espace. ce paramètre est ignoré pour les noms d'images comportant un tag
* image=IMAGES... ou images=IMAGES... * image=IMAGES... ou images=IMAGES...
liste de nom d'images, séparés par un espace. si les noms n'ont pas de tag, le liste de nom d'images, séparés par un espace. si les noms n'ont pas de tag, le
tag est construit à partir de DIST et VERSION sous la forme [VERSION-]DIST tag est construit à partir de DIST et VERSION sous la forme [VERSION-]DIST
@ -1475,7 +1479,7 @@ function foreach_dists_profiles() {
local version dist dversion profile pversion local version dist dversion profile pversion
local VERSION DIST DVERSION PROFILE PVERSION local VERSION DIST DVERSION PROFILE PVERSION
local HAVE_DVERSION local HAVE_VERSION LAST_VERSION
declare -A dones declare -A dones
if [ -n "$before" ]; then if [ -n "$before" ]; then
@ -1483,12 +1487,28 @@ function foreach_dists_profiles() {
fi fi
for dist in "${DISTS[@]}"; do for dist in "${DISTS[@]}"; do
parse_dist "$dist" dist dversion parse_dist "$dist" dist dversion
HAVE_DVERSION= # y a-t-il une version dans cette distribution ou ce profil, et si oui, laquelle?
HAVE_VERSION=
LAST_VERSION=
for DIST in "${SETDISTS[@]}"; do for DIST in "${SETDISTS[@]}"; do
parse_dist "$DIST" DIST DVERSION parse_dist "$DIST" DIST DVERSION
[ "$DIST" == "$dist" ] || continue [ "$DIST" == "$dist" ] || continue
[ -n "$DVERSION" -o -n "$SETVERSION" ] && HAVE_DVERSION=1 VERSION="$DVERSION"
for profile in "${PROFILES[@]}"; do
parse_profile "$profile" profile pversion
for PROFILE in "${SETPROFILES[@]}"; do
parse_profile "$PROFILE" PROFILE PVERSION
[ "$PROFILE" == "$profile" ] || continue
[ -n "$DVERSION" ] && PVERSION= || VERSION="$PVERSION"
[ -z "$VERSION" -a -n "$SETVERSION" ] && VERSION="$SETVERSION"
if [ -n "$VERSION" ]; then
HAVE_VERSION=1
LAST_VERSION="$VERSION"
fi
done
done
done done
for DIST in "${SETDISTS[@]}"; do for DIST in "${SETDISTS[@]}"; do
parse_dist "$DIST" DIST DVERSION parse_dist "$DIST" DIST DVERSION
[ "$DIST" == "$dist" ] || continue [ "$DIST" == "$dist" ] || continue
@ -1912,20 +1932,16 @@ function define_functions_cmd() {
imagetags+=("$imagetag:$tag") imagetags+=("$imagetag:$tag")
done done
[ -n "$VERSION" ] && imagetags+=("$imagetag:$VERSION-$DIST") [ -n "$VERSION" ] && imagetags+=("$imagetag:$VERSION-$DIST")
[ -n "$DIST" -a -z "$HAVE_DVERSION" ] && imagetags+=("$imagetag:$DIST") [ -n "$DIST" -a -z "$HAVE_VERSION" ] && imagetags+=("$imagetag:$DIST")
fi fi
done done
fi fi
if [ -n "$autotag" ]; then if [ -n "$autotag" ]; then
if [ -n "$DIST" ]; then if [ -n "$DIST" ]; then
if dist LATEST; then [ -n "$HAVE_VERSION" -a "$VERSION" == "$LAST_VERSION" ] && imagetags+=("$imagetag:$DIST")
[ -n "$HAVE_VERSION" ] && imagetags+=("$imagetag:$DIST") dist LATEST && imagetags+=("$imagetag:latest")
imagetags+=("$imagetag:latest")
fi
elif [ -n "$PROFILE" ]; then elif [ -n "$PROFILE" ]; then
if profile DEFAULT; then profile DEFAULT && imagetags+=("$imagetag:latest")
imagetags+=("$imagetag:latest")
fi
else else
imagetags+=("$imagetag:latest") imagetags+=("$imagetag:latest")
fi fi