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
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='
* 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...
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...
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
@ -1475,7 +1479,7 @@ function foreach_dists_profiles() {
local version dist dversion profile pversion
local VERSION DIST DVERSION PROFILE PVERSION
local HAVE_DVERSION
local HAVE_VERSION LAST_VERSION
declare -A dones
if [ -n "$before" ]; then
@ -1483,12 +1487,28 @@ function foreach_dists_profiles() {
fi
for dist in "${DISTS[@]}"; do
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
parse_dist "$DIST" DIST DVERSION
[ "$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
for DIST in "${SETDISTS[@]}"; do
parse_dist "$DIST" DIST DVERSION
[ "$DIST" == "$dist" ] || continue
@ -1912,20 +1932,16 @@ function define_functions_cmd() {
imagetags+=("$imagetag:$tag")
done
[ -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
done
fi
if [ -n "$autotag" ]; then
if [ -n "$DIST" ]; then
if dist LATEST; then
[ -n "$HAVE_VERSION" ] && imagetags+=("$imagetag:$DIST")
imagetags+=("$imagetag:latest")
fi
[ -n "$HAVE_VERSION" -a "$VERSION" == "$LAST_VERSION" ] && imagetags+=("$imagetag:$DIST")
dist LATEST && imagetags+=("$imagetag:latest")
elif [ -n "$PROFILE" ]; then
if profile DEFAULT; then
imagetags+=("$imagetag:latest")
fi
profile DEFAULT && imagetags+=("$imagetag:latest")
else
imagetags+=("$imagetag:latest")
fi