diff --git a/CHANGES.md b/CHANGES.md index ee9a90d..5c5e096 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,16 @@ +## Version 11.2.0 du 21/06/2024-20:34 + +* `21042e4` bug +* `e4176df` reginc: possibilité de renommer des fichiers +* `1787aa2` bug +* `d1f77aa` dkbuild: support dist none et tag LATEST +* `c2cfd77` bug +* `e7745c2` dk: support --plain-output +* `ce8f541` dkbuild: -g pour --profile +* `30594aa` maj distributions +* `2df175e` dkbuild: cosmetic +* `fbb05f8` support des versions AMUE + ## Version 11.1.0 du 01/02/2024-20:59 * `8570d12` pff: les répertoires liés peuvent contenir des fichiers diff --git a/VERSION.txt b/VERSION.txt index 68d8f15..b85c6c7 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -11.1.0 +11.2.0 diff --git a/dk b/dk index 781dc9b..d158eee 100755 --- a/dk +++ b/dk @@ -336,6 +336,8 @@ OPTIONS build deploy, by, bpy et update impliquent --stack -j, --no-cache Ne pas utiliser le cache lors du build + --plain-output + Afficher la sortie complète des containers lors du build -U, --pull Essayer de récupérer une version plus récente de l'image source -g, --ug, --no-update-apps @@ -1245,6 +1247,7 @@ function default_compose_build() { "${replace_env_args[@]}" "${env_args[@]}" \ build \ ${NO_CACHE:+--no-cache} \ + ${PROGRESS:+--progress "$PROGRESS"} \ ${PULL:+--pull} \ "${replace_build_args[@]}" "${build_args[@]}" \ "$@" @@ -1256,6 +1259,7 @@ function default_docker_build() { done ${FAKE:+qvals} "$DOCKER" build \ ${NO_CACHE:+--no-cache} \ + ${PROGRESS:+--progress "$PROGRESS"} \ ${PULL:+--pull} \ "${replace_env_args[@]}" "${env_args[@]}" \ "${replace_build_args[@]}" "${build_args[@]}" \ @@ -1305,6 +1309,7 @@ function auto_build() { done ${FAKE:+qvals} "$DOCKER" build \ ${NO_CACHE:+--no-cache} \ + ${PROGRESS:+--progress "$PROGRESS"} \ ${PULL:+--pull} \ "${replace_build_args[@]}" "$@" fi @@ -2499,6 +2504,7 @@ FAKE= VARS=() FORCE= NO_CACHE= +PROGRESS= PULL= HOST= WITH_REGISTRY_AUTH=1 @@ -2522,6 +2528,7 @@ args=( -e:,--build-arg:,--env: VARS -f,--force FORCE=1 -j,--no-cache NO_CACHE=1 + --plain-output PROGRESS=plain -U,--pull PULL=1 -h:,--host: HOST= -g,--ug,--no-update-apps update_apps_mode=b diff --git a/dkbuild b/dkbuild index 20df4db..d569a7c 100755 --- a/dkbuild +++ b/dkbuild @@ -86,18 +86,21 @@ $scriptname build [OPTIONS] [BUILDVARS...] configuration ne doit être chargé. -d, --dist DIST - -9, --d9 -0, --d10 -1, --d11 + -2, --d12 + -3, --d13 --r7, --rhel7 --r8, --rhel8 + --r9, --rhel9 --o7, --oracle7 --o8, --oracle8 + --o9, --oracle9 Ne faire le build que pour la distribution spécifiée. Par défaut, faire le build pour toutes les distributions définies. Si la distribution sélectionnée n'est pas valide pour ce build, elle est ignorée - --profile PROFILE + -g, --profile PROFILE -P, --prod -T, --test -E, --dtest @@ -221,9 +224,13 @@ construites. Une version est définie en ajoutant un préfixe à la distribution La commande 'setdists' permet de lister explicitement les distributions valides (et les versions associées le cas échéant). Si la distribution sélectionnée par l'utilisateur n'est pas dans la liste fournie, le script s'arrête sans erreur. + La première distribution listée est spéciale: c'est la distribution la plus récente, celle qui reçoit le tag :latest +La distribution 'none' est spéciale aussi: elle n'est pas mentionnée dans les +tags automatiquement attribués aux images. + La commande 'dist' permet de tester si la distribution spécifiée en argument a été sélectionnée par l'utilisateur. L'argument 'LATEST' permet de tester la dernière distribution. @@ -675,7 +682,8 @@ Les paramètres optionnels sont * 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 + les noms d'images comportant un tag. + Utiliser le tag spécial LATEST pour rajouter :latest si c'est approprié * 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é pour les noms d'images comportant un tag @@ -936,15 +944,18 @@ SHARED_ARGS1=( SHARED_LOCALS2="local DIST PROFILE ALL_PROFILES; local -a TMPENVIRON TMPARGS" SHARED_ARGS2=( -d:,--dist: DIST= - -9,--d9 DIST=d9 -0,--d10 DIST=d10 -1,--d11 DIST=d11 + -2,--d12 DIST=d12 + -3,--d13 DIST=d13 --r7,--rhel7 DIST=rhel7 --r8,--rhel8 DIST=rhel8 + --r9,--rhel9 DIST=rhel9 --ol7,--oracle7 DIST=ol7 --ol8,--oracle8 DIST=ol8 + --ol9,--oracle9 DIST=ol9 - -p:,--profile: PROFILE= + -g:,--profile: PROFILE= -P,--prod PROFILE=prod -T,--test PROFILE=test -E,--dtest PROFILE=dtest @@ -1072,12 +1083,13 @@ function reset_functions() { function include() { edebug "include $(qvals "$@")" - local file="$1" + local file="$1" cwd="$(pwd)" [ -d "$file" ] && file="$file/dkbuild" [ -f "$file" ] || die "$file: fichier introuvable" setx file=abspath "$file" cd "$(dirname "$file")" source "$file" + cd "$cwd" } function machine() { local machine version @@ -2036,6 +2048,14 @@ function define_functions_cmd() { imagetags+=("$imagetag") else for tag in "${set_tags[@]}" "${add_tags[@]}"; do + if [ "$tag" == LATEST ]; then + if [ -n "$HAVE_VERSION" -a "$VERSION" == "$LAST_VERSION" ]; then + tag=latest + else + # ignorer le tag LATEST s'il n'est pas applicable + continue + fi + fi imagetags+=("$imagetag:$tag") done fi @@ -2048,10 +2068,16 @@ function define_functions_cmd() { imagetags+=("$imagetag") else for tag in "${add_tags[@]}"; do + if [ "$tag" == LATEST ]; then + # toujours ignorer le tag LATEST dans add_tags + continue + fi imagetags+=("$imagetag:$tag") done [ -n "$VERSION" ] && imagetags+=("$imagetag:$VERSION-$DIST") - [ -n "$DIST" -a -z "$HAVE_VERSION" ] && imagetags+=("$imagetag:$DIST") + if [ -n "$DIST" -a "$DIST" != none -a -z "$HAVE_VERSION" ]; then + imagetags+=("$imagetag:$DIST") + fi fi done fi @@ -2060,7 +2086,7 @@ function define_functions_cmd() { if [ -z "$HAVE_VERSION" ]; then dist LATEST && imagetags+=("$imagetag:latest") elif [ "$VERSION" == "$LAST_VERSION" ]; then - imagetags+=("$imagetag:$DIST") + [ "$DIST" != none ] && imagetags+=("$imagetag:$DIST") dist LATEST && imagetags+=("$imagetag:latest") fi elif [ -n "$PROFILE" ]; then @@ -2983,10 +3009,10 @@ function _build_before() { PREV_PROFILE= } function _build_each() { - if [ "$PROFILE-$PVERSION" != "$PREV_PROFILE" ]; then - [ -n "$PREV_PROFILE" ] && eend - fi if [ -n "$DIST" -a "$DIST-$DVERSION" != "$PREV_DIST" ]; then + [ -n "$PREV_PROFILE" ] && eend + PREV_PROFILE= + [ -n "$PREV_DIST" ] && eend PREV_DIST="$DIST-$DVERSION" etitle "Distribution ${DVERSION:+$DVERSION-}$DIST" @@ -3128,10 +3154,10 @@ function _dump_before() { PREV_PROFILE= } function _dump_each() { - if [ "$PROFILE-$PVERSION" != "$PREV_PROFILE" ]; then - [ -n "$PREV_PROFILE" ] && eend - fi if [ -n "$DIST" -a "$DIST-$DVERSION" != "$PREV_DIST" ]; then + [ -n "$PREV_PROFILE" ] && eend + PREV_PROFILE= + [ -n "$PREV_DIST" ] && eend PREV_DIST="$DIST-$DVERSION" etitle "Distribution ${DVERSION:+$DVERSION-}$DIST" diff --git a/lib/ulib/base b/lib/ulib/base index 47bd9b8..d91fe48 100644 --- a/lib/ulib/base +++ b/lib/ulib/base @@ -1424,7 +1424,7 @@ function is_archive() { name="${name%.jar}" name="${name%.war}" name="${name%.ear}" - [ "$NUTOOLS_SH_ARCHIVE_SUPPORT" ] && name="${name%.sh}" + [ -n "$NUTOOLS_SH_ARCHIVE_SUPPORT" ] && name="${name%.sh}" [ "$name" != "$1" ] } function extract_archive() { @@ -1446,7 +1446,7 @@ function extract_archive() { cd "$destdir" jar xf "$arch" "$@" ) || return - elif [ "$NUTOOLS_SH_ARCHIVE_SUPPORT" ] && endswith "$arch" .sh; then + elif [ -n "$NUTOOLS_SH_ARCHIVE_SUPPORT" ] && endswith "$arch" .sh; then ( arch="$(abspath "$arch")" cd "$destdir" @@ -1469,7 +1469,7 @@ function get_archive_basename() { basename="${basename%.jar}" basename="${basename%.war}" basename="${basename%.ear}" - [ "$NUTOOLS_SH_ARCHIVE_SUPPORT" ] && basename="${basename%.sh}" + [ -n "$NUTOOLS_SH_ARCHIVE_SUPPORT" ] && basename="${basename%.sh}" # résultat echo "$basename" } @@ -1489,10 +1489,13 @@ function get_archive_appname() { appname="${appname%.jar}" appname="${appname%.war}" appname="${appname%.ear}" - [ "$NUTOOLS_SH_ARCHIVE_SUPPORT" ] && appname="${appname%.sh}" + [ -n "$NUTOOLS_SH_ARCHIVE_SUPPORT" ] && appname="${appname%.sh}" # supprimer la version et afficher echo "$appname" | awk '{ - if (match($0, /[-_.]([0-9]+([-_.][0-9]+)*([a-zA-Z][0-9]*|[-_.][0-9]+[a-zA-Z][0-9]*)?)$/)) { + if (match($0, /-([0-9]{5}(_(VA|VSR)[0-9]+)?)$/, vs)) { + # version style AMUE, e.g 64070 ou 64070_VA1 + print substr($0, 1, RSTART - 1) + } else if (match($0, /[-_.]([0-9]+([-_.][0-9]+)*([a-zA-Z][0-9]*|[-_.][0-9]+[a-zA-Z][0-9]*)?)$/)) { print substr($0, 1, RSTART - 1) } else if (match($0, /([0-9]+([-_.][0-9]+)*([a-zA-Z][0-9]*|[-_.][0-9]+[a-zA-Z][0-9]*)?)$/)) { print substr($0, 1, RSTART - 1) @@ -1511,7 +1514,10 @@ function get_archive_versionsuffix() { # --> -0.1 local basename="$(get_archive_basename "$1")" echo "$basename" | awk '{ - if (match($0, /([-_.][0-9]+([-_.][0-9]+)*([a-zA-Z][0-9]*|[-_.][0-9]+[a-zA-Z][0-9]*)?)$/, vs)) { + if (match($0, /(-[0-9]{5}(_(VA|VSR)[0-9]+)?)$/, vs)) { + # version style AMUE, e.g 64070 ou 64070_VA1 + print vs["1"] + } else if (match($0, /([-_.][0-9]+([-_.][0-9]+)*([a-zA-Z][0-9]*|[-_.][0-9]+[a-zA-Z][0-9]*)?)$/, vs)) { print vs["1"] } else if (match($0, /([0-9]+([-_.][0-9]+)*([a-zA-Z][0-9]*|[-_.][0-9]+[a-zA-Z][0-9]*)?)$/, vs)) { print vs["1"] @@ -1528,7 +1534,10 @@ function get_archive_version() { # --> 0.1 local basename="$(get_archive_basename "$1")" echo "$basename" | awk '{ - if (match($0, /[-_.]([0-9]+([-_.][0-9]+)*([a-zA-Z][0-9]*|[-_.][0-9]+[a-zA-Z][0-9]*)?)$/, vs)) { + if (match($0, /-([0-9]{5}(_(VA|VSR)[0-9]+)?)$/, vs)) { + # version style AMUE, e.g 64070 ou 64070_VA1 + print vs["1"] + } else if (match($0, /[-_.]([0-9]+([-_.][0-9]+)*([a-zA-Z][0-9]*|[-_.][0-9]+[a-zA-Z][0-9]*)?)$/, vs)) { print vs["1"] } else if (match($0, /([0-9]+([-_.][0-9]+)*([a-zA-Z][0-9]*|[-_.][0-9]+[a-zA-Z][0-9]*)?)$/, vs)) { print vs["1"] diff --git a/lib/ulib/crontab b/lib/ulib/crontab index cc08d1d..632e612 100644 --- a/lib/ulib/crontab +++ b/lib/ulib/crontab @@ -154,7 +154,7 @@ function ctmatch_one(ctval, ref, parts, part, i, j, start, end, ste #print "final: is " ref " ~ " ctval " ? " (ok? "yes": "no") #DEBUG return ok } -function ctmatch_all(M, H, dom, mon, dow, refM, refH, refdom, refmon, refdow, Mok, Hok, domok, monok, dowok) { +function ctmatch_all(M, H, dom, mon, dow, refM, refH, refdom, refmon, refdow, Mok, Hok, alldom, domok, monok, alldow, dowok, doxok) { if (refM == "**ANY**") return 1 gsub(/\*/, "0-59", M) @@ -163,16 +163,28 @@ function ctmatch_all(M, H, dom, mon, dow, refM, refH, refdom, refmon, refdow, gsub(/\*/, "0-23", H) Hok = ctmatch_one(H, refH) + alldom = dom == "*" gsub(/\*/, "1-31", dom) domok = ctmatch_one(dom, refdom) gsub(/\*/, "1-12", mon) monok = ctmatch_one(mon, refmon) + alldow = dow == "*" gsub(/\*/, "1-7", dow) dowok = ctmatch_one(dow, refdow) - return Mok && Hok && monok && (domok || dowok) + if (alldom && alldow) { + doxok = 1 + } else if (alldom) { + doxok = dowok + } else if (alldow) { + doxok = domok + } else { + doxok = domok || dowok + } + + return Mok && Hok && monok && doxok } function print_cmd(cmd) { print "__ctexec " quote_value(cmd) diff --git a/reginc b/reginc index 68acd27..170b240 100755 --- a/reginc +++ b/reginc @@ -12,62 +12,111 @@ remplacer les nombres de FROMmin à FROMmax par leur valeur correspondante, sachant que FROMmin doit être remplacé par TO. On peut mentionner autant de couples (FROM, TO) que nécessaire: ils seront traités dans l'ordre + $scriptname -r FROMmin-FROMmax TO FILEs... + +renommer les fichiers en remplaçant les nombres de FROMmin à FROMmax par leur +valeur correspondante, sachant que FROMmin doit être remplacé par TO + OPTIONS -n, --fake Afficher le fichier tel qu'il serait modifié au lieu de le modifier en - place" + place + -r, --rename + Renommer les fichiers au lieu de modifier le texte à l'intérieur du + fichier. Attention, l'ordre des arguments est différent avec cette + option" } -fake= +function process_file() { + local file from to fromb frome seds r + + file="$1"; shift + [ -n "$file" ] || die "vous devez spécifier le fichier à modifier" + + seds= + while [ $# -ge 2 ]; do + from="$1" + if [[ "$from" == *-* ]]; then + let fromb="${from%-*}" + let frome="${from#*-}" + else + let fromb="$from" + let frome="$from" + fi + let to="$2"; shift 2 + + if [ "$to" -eq "$fromb" ]; then + einfo "$fromb --> $to aucune modification n'est nécessaire" + + elif [ "$to" -lt "$fromb" ]; then + einfo "$fromb-$frome --> $to-$((to+frome-fromb))" + + let from=fromb + while [ "$from" -le "$frome" ]; do + seds="$seds${seds:+; }s/$from/$to/g" + let from=from+1 + let to=to+1 + done + + elif [ "$to" -gt "$fromb" ]; then + einfo "$frome-$fromb --> $((to+frome-fromb))-$to" + + let from=frome + let to=to+frome-fromb + while [ "$from" -ge "$fromb" ]; do + seds="$seds${seds:+; }s/$from/$to/g" + let from=from-1 + let to=to-1 + done + fi + done + + edebug "Script sed: $seds" + + [ -n "$Fake" ] && args=() || args=(-i) + args+=("$seds" "$file") + sed "${args[@]}"; r=$? + + [ -z "$Fake" -a $r -eq 0 ] +} + +Fake= +rename= args=( --help '$exit_with display_help' - -n,--fake fake=1 + -n,--Fake Fake=1 + -r,--rename rename=1 ) parse_args "$@"; set -- "${args[@]}" -file="$1"; shift -[ -n "$file" ] || die "vous devez spécifier le fichier à modifier" +if [ -n "$rename" ]; then + from="$1"; to="$2"; shift 2 -seds= -while [ $# -ge 2 ]; do - from="$1" - if [[ "$from" == *-* ]]; then - let fromb="${from%-*}" - let frome="${from#*-}" - else - let fromb="$from" - let frome="$from" - fi - let to="$2"; shift 2 + froms=("$@") + ac_set_tmpfile tmptos + echo "tos=(" >>"$tmptos" + for file in "${froms[@]}"; do + qval "$file" >>"$tmptos" + done + echo ")" >>"$tmptos" - if [ "$to" -eq "$fromb" ]; then - einfo "$fromb --> $to aucune modification n'est nécessaire" + Fake= process_file "$tmptos" "$from" "$to" + eval "$(<"$tmptos")" - elif [ "$to" -lt "$fromb" ]; then - einfo "$fromb-$frome --> $to-$((to+frome-fromb))" + i=0 + count=${#froms[*]} + while [ $i -lt $count ]; do + from="${froms[$i]}" + to="${tos[$i]}" + if [ "$to" == "$from" ]; then + ewarn "$from: renommage non nécessaire" + else + estep "$from --> $to" + [ -z "$Fake" ] && mv "$from" "$to" + fi + let i=i+1 + done - let from=fromb - while [ "$from" -le "$frome" ]; do - seds="$seds${seds:+; }s/$from/$to/g" - let from=from+1 - let to=to+1 - done - - elif [ "$to" -gt "$fromb" ]; then - einfo "$frome-$fromb --> $((to+frome-fromb))-$to" - - let from=frome - let to=to+frome-fromb - while [ "$from" -ge "$fromb" ]; do - seds="$seds${seds:+; }s/$from/$to/g" - let from=from-1 - let to=to-1 - done - fi -done - -edebug "Script sed: $seds" - -[ -n "$fake" ] && args=() || args=(-i) -args+=("$seds" "$file") -sed "${args[@]}" +else + process_file "$@" +fi