devzone 2.0.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/.devcontainer/agent-errors.sh +6 -6
  2. package/.devcontainer/agent-pod-manifest.sh +4 -4
  3. package/.devcontainer/agent-session.sh +2 -2
  4. package/.devcontainer/agent-state-json.sh +2 -2
  5. package/.devcontainer/agent-workspace.sh +1 -1
  6. package/.devcontainer/agent.sh +7 -7
  7. package/.devcontainer/ai/host-models.sh +2 -2
  8. package/.devcontainer/ai/plugins/devzone-guard-v2.js +3 -3
  9. package/.devcontainer/ai/plugins/devzone-guard.js +3 -3
  10. package/.devcontainer/argocd/argocd.sh +90 -89
  11. package/.devcontainer/argocd/catalog-argocd.sh +2 -2
  12. package/.devcontainer/argocd/services-hook.sh +3 -3
  13. package/.devcontainer/argocd/services.sh +1 -1
  14. package/.devcontainer/catalog/app.sh +114 -116
  15. package/.devcontainer/catalog/catalog-watcher.sh +62 -62
  16. package/.devcontainer/catalog/mysql/app.conf +1 -1
  17. package/.devcontainer/catalog/mysql/install.sh +40 -40
  18. package/.devcontainer/catalog/mysql/mysql.sh +141 -141
  19. package/.devcontainer/catalog/mysql/volume.sh +39 -39
  20. package/.devcontainer/catalog.sh +112 -112
  21. package/.devcontainer/chart-direct.sh +1 -1
  22. package/.devcontainer/cluster.sh +216 -218
  23. package/.devcontainer/clusters.sh +41 -41
  24. package/.devcontainer/command-aliases.sh +17 -8
  25. package/.devcontainer/devzone +93 -1496
  26. package/.devcontainer/devzone-ai-guard.sh +76 -0
  27. package/.devcontainer/devzone-ai.sh +201 -0
  28. package/.devcontainer/devzone-cluster.sh +210 -0
  29. package/.devcontainer/devzone-modules.sh +126 -0
  30. package/.devcontainer/devzone-platform.sh +189 -0
  31. package/.devcontainer/devzone-repair.sh +94 -0
  32. package/.devcontainer/devzone-services.sh +241 -0
  33. package/.devcontainer/devzone-skill.sh +97 -0
  34. package/.devcontainer/devzone-status.sh +140 -0
  35. package/.devcontainer/devzone-version.sh +78 -0
  36. package/.devcontainer/git-identity.sh +28 -0
  37. package/.devcontainer/gitlab/chart.sh +2 -2
  38. package/.devcontainer/gitlab/gitlab.sh +81 -82
  39. package/.devcontainer/gitlab/installation.sh +109 -109
  40. package/.devcontainer/gitlab/secrets.sh +47 -47
  41. package/.devcontainer/gitlab/seed.sh +77 -77
  42. package/.devcontainer/gitlab/test-gitlab.sh +242 -243
  43. package/.devcontainer/help.sh +1 -1
  44. package/.devcontainer/isolation.sh +30 -30
  45. package/.devcontainer/kind-wrapper.sh +17 -17
  46. package/.devcontainer/kube-account.sh +112 -113
  47. package/.devcontainer/kube-config.sh +45 -46
  48. package/.devcontainer/{invite-kube.sh → kube-prompt.sh} +6 -6
  49. package/.devcontainer/kube-reachable.sh +40 -40
  50. package/.devcontainer/memory.sh +1 -1
  51. package/.devcontainer/metrics-server.sh +2 -2
  52. package/.devcontainer/opencode.jsonc +2 -2
  53. package/.devcontainer/packages.sh +136 -135
  54. package/.devcontainer/password.sh +1 -1
  55. package/.devcontainer/ports-auto.sh +152 -153
  56. package/.devcontainer/ports-json.sh +16 -15
  57. package/.devcontainer/ports.sh +126 -122
  58. package/.devcontainer/post-create.sh +52 -52
  59. package/.devcontainer/postgres/postgres.sh +174 -174
  60. package/.devcontainer/rename-legacy-files.sh +103 -0
  61. package/.devcontainer/services-admin.sh +3 -3
  62. package/.devcontainer/skills/devzone/SKILL.md +40 -41
  63. package/.devcontainer/startup.sh +48 -49
  64. package/.devcontainer/state-gitops.sh +1 -1
  65. package/.devcontainer/state-json.sh +36 -62
  66. package/.devcontainer/state.sh +2 -2
  67. package/.devcontainer/workspace-init.sh +16 -2
  68. package/Makefile +1 -1
  69. package/README.md +191 -195
  70. package/charts/devzone-workspace/templates/statefulset.yaml +1 -1
  71. package/manage/devzone +7 -11
  72. package/manage/scripts/argocd-workspace.sh +1 -1
  73. package/manage/scripts/{check-charts.sh → ci/check-charts.sh} +1 -1
  74. package/manage/scripts/{check-english.sh → ci/check-english.sh} +1 -1
  75. package/manage/scripts/{check-go-layout.sh → ci/check-go-layout.sh} +1 -1
  76. package/manage/scripts/{check-names.sh → ci/check-names.sh} +7 -6
  77. package/manage/scripts/{check-utf8-vars.sh → ci/check-utf8-vars.sh} +1 -1
  78. package/manage/scripts/{versions.sh → ci/versions.sh} +8 -8
  79. package/manage/scripts/create-cluster.sh +1 -1
  80. package/manage/scripts/create-mode.sh +11 -18
  81. package/manage/scripts/devzone-create.sh +7 -35
  82. package/manage/scripts/devzone-manifest.sh +1 -1
  83. package/manage/scripts/devzone-update.sh +12 -8
  84. package/manage/scripts/launch.sh +7 -48
  85. package/manage/scripts/ports-apps.sh +1 -1
  86. package/manage/scripts/ports-workspace.sh +7 -7
  87. package/manage/scripts/poste.sh +6 -7
  88. package/manage/scripts/uninstall.sh +8 -8
  89. package/manage/scripts/workspace-egress.sh +2 -2
  90. package/manage/scripts/workspace-update.sh +5 -2
  91. package/manage/scripts/workspace-wait.sh +2 -2
  92. package/manage/workspace.sh +2 -12
  93. package/package.json +1 -1
  94. package/.devcontainer/docker-relay.sh +0 -149
  95. package/.devcontainer/docker-without-host.sh +0 -12
  96. package/.devcontainer/git-identite.sh +0 -28
  97. package/manage/scripts/docker-workstation.sh +0 -73
  98. package/manage/scripts/migrate-revert.sh +0 -60
  99. package/manage/scripts/migrate.sh +0 -243
  100. /package/manage/scripts/{ci-dns.sh → ci/ci-dns.sh} +0 -0
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env bash
2
- # Invite Kubernetes du shell (#337) : ⎈ ctx/ns.
2
+ # Kubernetes prompt of the shell (#337): ⎈ ctx/ns.
3
3
 
4
- # Rend l invite Kubernetes (⎈ ctx/ns) avec cache par mtime.
5
- devzone_invite_kube() {
4
+ # Renders the Kubernetes prompt (⎈ ctx/ns), with a cache keyed on the mtime.
5
+ devzone_kube_prompt() {
6
6
  local kubeconfig="${KUBECONFIG:-$HOME/.kube/config:$HOME/.kube/hote.config}"
7
7
  local files=() f sig="" cache mtime ctx ns result ici
8
8
  ici="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
@@ -16,7 +16,7 @@ devzone_invite_kube() {
16
16
  fi
17
17
  sig+="${f}:${mtime};"
18
18
  done
19
- cache="${XDG_CACHE_HOME:-$HOME/.cache}/devzone-invite-kube"
19
+ cache="${XDG_CACHE_HOME:-$HOME/.cache}/devzone-kube-prompt"
20
20
  mkdir -p "$(dirname "$cache")"
21
21
  if [ -f "$cache" ]; then
22
22
  if [ "$(sed -n '1p' "$cache" 2>/dev/null)" = "$sig" ]; then
@@ -31,10 +31,10 @@ devzone_invite_kube() {
31
31
  ns="$(kubectl config view -o jsonpath="{.contexts[?(@.name==\"$ctx\")].context.namespace}" 2>/dev/null || true)"
32
32
  [ -n "$ns" ] || ns=default
33
33
  # shellcheck disable=SC1090,SC1091
34
- if ( . "$ici/cluster.sh"; cluster_est_local "$ctx" ) >/dev/null 2>&1; then
34
+ if ( . "$ici/cluster.sh"; cluster_is_local "$ctx" ) >/dev/null 2>&1; then
35
35
  result="$(printf '\001\033[36m\002⎈ %s/%s\001\033[0m\002' "$ctx" "$ns")"
36
36
  else
37
- result="$(printf '\001\033[1;31m\002⎈ %s/%s distant\001\033[0m\002' "$ctx" "$ns")"
37
+ result="$(printf '\001\033[1;31m\002⎈ %s/%s remote\001\033[0m\002' "$ctx" "$ns")"
38
38
  fi
39
39
  fi
40
40
  printf '%s\n%s\n' "$sig" "$result" >"$cache"
@@ -1,64 +1,64 @@
1
1
  #!/usr/bin/env bash
2
- # Clusters joignables depuis le conteneur (#291). Avec le Docker de l'hôte,
3
- # l'API d'un cluster kind écoute sur 127.0.0.1 DU POSTE : dans le conteneur,
4
- # 127.0.0.1 est le conteneur lui-même.
5
- # 1. Nœud kind trouvé (conteneur qui publie ce port) : le conteneur devzone
6
- # rejoint le réseau Docker du nœud et vise https://<nœud>:6443, l'adresse
7
- # que kind prévoit pour les conteneurs (kind get kubeconfig --internal) ;
8
- # le nom du nœud est dans le certificat de l'API. Marche sous Linux comme
9
- # avec Docker Desktop, sans rien exposer sur le réseau du poste.
10
- # 2. Sinon : https://host.docker.internal:<port>, avec le nom d'origine pour
11
- # la vérification TLS (--tls-server-name) ; suffit avec Docker Desktop, où
12
- # host.docker.internal mène au 127.0.0.1 du poste.
13
- # Bibliothèque sourcée (cluster.sh, enveloppe kind) ; exécutée directement :
14
- # kube-reachable.sh FICHIER
15
- # kube_joignable_depuis_conteneur FICHIER réécrit 127.0.0.1/localhost, idempotent
2
+ # Clusters reachable from the container (#291). With the host's Docker, the API
3
+ # of a kind cluster listens on 127.0.0.1 OF THE WORKSTATION: inside the
4
+ # container, 127.0.0.1 is the container itself.
5
+ # 1. kind node found (container publishing this port): the devzone container
6
+ # joins the Docker network of the node and targets https://<node>:6443, the
7
+ # address kind provides for containers (kind get kubeconfig --internal);
8
+ # the node name is in the API certificate. Works under Linux as with Docker
9
+ # Desktop, without exposing anything on the workstation's network.
10
+ # 2. Otherwise: https://host.docker.internal:<port>, with the original name for
11
+ # the TLS check (--tls-server-name); enough with Docker Desktop, where
12
+ # host.docker.internal leads to the workstation's 127.0.0.1.
13
+ # Sourced library (cluster.sh, kind wrapper); run directly:
14
+ # kube-reachable.sh FILE
15
+ # kube_reachable_from_container FILE rewrites 127.0.0.1/localhost, idempotent
16
16
 
17
- # Nœud kind de plan de contrôle qui publie ce port sur le poste (vide sinon)
18
- kube_noeud_kind() {
17
+ # kind control-plane node that publishes this port on the workstation (empty otherwise)
18
+ kube_kind_node() {
19
19
  docker ps --filter "label=io.x-k8s.kind.role=control-plane" --filter "publish=$1" \
20
20
  --format '{{.Names}}' 2>/dev/null | head -1
21
21
  }
22
22
 
23
- # Le conteneur devzone rejoint le réseau du nœud (idempotent : déjà membre = rien)
24
- kube_rejoindre_reseau() {
25
- local noeud="$1" moi reseau
26
- moi="$(hostname)"
27
- for reseau in $(docker inspect "$noeud" \
28
- --format '{{range $nom, $v := .NetworkSettings.Networks}}{{$nom}} {{end}}' 2>/dev/null); do
29
- docker network connect "$reseau" "$moi" >/dev/null 2>&1 || true
23
+ # The devzone container joins the node's network (idempotent: already a member = nothing)
24
+ kube_join_network() {
25
+ local node="$1" me network
26
+ me="$(hostname)"
27
+ for network in $(docker inspect "$node" \
28
+ --format '{{range $name, $v := .NetworkSettings.Networks}}{{$name}} {{end}}' 2>/dev/null); do
29
+ docker network connect "$network" "$me" >/dev/null 2>&1 || true
30
30
  done
31
31
  }
32
32
 
33
- kube_joignable_depuis_conteneur() {
34
- local fichier="${1:-}" nom serveur hote port noeud
35
- [ -n "$fichier" ] || return 0
33
+ kube_reachable_from_container() {
34
+ local file="${1:-}" name server host port node
35
+ [ -n "$file" ] || return 0
36
36
  # Kubernetes workspace (#517): the pod reaches the API through the cluster service, no docker call
37
37
  if [ "${DEVZONE_WORKSPACE:-}" = kubernetes ]; then return 0; fi
38
- KUBECONFIG="$fichier" kubectl config view \
38
+ KUBECONFIG="$file" kubectl config view \
39
39
  -o jsonpath='{range .clusters[*]}{.name}{"\t"}{.cluster.server}{"\n"}{end}' 2>/dev/null |
40
- while IFS=$'\t' read -r nom serveur; do
41
- case "$serveur" in
40
+ while IFS=$'\t' read -r name server; do
41
+ case "$server" in
42
42
  https://127.0.0.1:* | https://localhost:*) ;;
43
43
  *) continue ;;
44
44
  esac
45
- hote="${serveur#https://}"
46
- hote="${hote%%:*}"
47
- port="${serveur##*:}"
48
- noeud="$(kube_noeud_kind "$port")"
49
- if [ -n "$noeud" ]; then
50
- kube_rejoindre_reseau "$noeud"
51
- KUBECONFIG="$fichier" kubectl config set-cluster "$nom" \
52
- --server="https://${noeud}:6443" >/dev/null 2>&1 || true
45
+ host="${server#https://}"
46
+ host="${host%%:*}"
47
+ port="${server##*:}"
48
+ node="$(kube_kind_node "$port")"
49
+ if [ -n "$node" ]; then
50
+ kube_join_network "$node"
51
+ KUBECONFIG="$file" kubectl config set-cluster "$name" \
52
+ --server="https://${node}:6443" >/dev/null 2>&1 || true
53
53
  else
54
- KUBECONFIG="$fichier" kubectl config set-cluster "$nom" \
54
+ KUBECONFIG="$file" kubectl config set-cluster "$name" \
55
55
  --server="https://host.docker.internal:${port}" \
56
- --tls-server-name="$hote" >/dev/null 2>&1 || true
56
+ --tls-server-name="$host" >/dev/null 2>&1 || true
57
57
  fi
58
58
  done
59
59
  return 0
60
60
  }
61
61
 
62
62
  if [ "${BASH_SOURCE[0]}" = "$0" ]; then
63
- kube_joignable_depuis_conteneur "${1:-}"
63
+ kube_reachable_from_container "${1:-}"
64
64
  fi
@@ -55,7 +55,7 @@ memory_cluster_ki() {
55
55
  local output line providerID memory node total=0 max=0 n=0 all_kind=1
56
56
  MEMORY_KI=""
57
57
  MEMORY_RULE=""
58
- output="$(compte_admin "$(compte_ctx)" get nodes \
58
+ output="$(account_admin "$(account_context)" get nodes \
59
59
  -o jsonpath='{range .items[*]}{.spec.providerID}{"|"}{.status.allocatable.memory}{"\n"}{end}' 2>/dev/null)" || return 1
60
60
  [ -n "$output" ] || return 1
61
61
  while IFS= read -r line; do
@@ -27,7 +27,7 @@ if [ "${1:-}" = retirer ]; then
27
27
  # Local clusters only: removal on a remote cluster has nothing to remove
28
28
  # (devzone never installs there)
29
29
  mapfile -t contexts < <(printf '%s\n' ${known[@]+"${known[@]}"} |
30
- while IFS= read -r c; do cluster_est_local "$c" && echo "$c"; done || true)
30
+ while IFS= read -r c; do cluster_is_local "$c" && echo "$c"; done || true)
31
31
  set -- ${contexts[@]+"${contexts[@]}"}
32
32
  fi
33
33
  code=0
@@ -56,7 +56,7 @@ if [ "$requested" -eq 0 ]; then
56
56
  # Local clusters only: never an automatic installation on a remote cluster
57
57
  # of the host (prod, staging…); for another one, name it as an argument
58
58
  mapfile -t contexts < <(printf '%s\n' ${known[@]+"${known[@]}"} |
59
- while IFS= read -r c; do cluster_est_local "$c" && echo "$c"; done || true)
59
+ while IFS= read -r c; do cluster_is_local "$c" && echo "$c"; done || true)
60
60
  set -- ${contexts[@]+"${contexts[@]}"}
61
61
  fi
62
62
 
@@ -1,8 +1,8 @@
1
- // devzone : configuration opencode par défaut (devzone enable ia la tient à jour ; retirer cette ligne pour la personnaliser)
1
+ // devzone : default opencode configuration (devzone enable ia keeps it up to date; remove this line to customise it)
2
2
  {
3
3
  "$schema": "https://opencode.ai/config.json",
4
4
  // Modèles gratuits de la version d'opencode fixée par devzone.
5
- // Partage et mises à jour désactivés : les versions sont fixées par devzone.
5
+ // Sharing and updates disabled: versions are pinned by devzone.
6
6
  "model": "opencode/big-pickle",
7
7
  "small_model": "opencode/mimo-v2.6-flash-free",
8
8
  "share": "disabled",
@@ -1,35 +1,36 @@
1
1
  #!/usr/bin/env bash
2
- # Paquets système gardés après un rebuild (#351) : une liste dans le dossier
3
- # devzone (<racine>/.devzone.paquets, entête de commentaire + un nom de paquet
4
- # par ligne, triés, sans doublon), réinstallée à chaque création du conteneur
5
- # (post-create.sh). Un paquet installé à la main est perdu par un rebuild, sauf
6
- # s'il est dans cette liste.
7
- # packages.sh ou packages.sh list liste avec l'état de chaque paquet
8
- # packages.sh add <nom>… valide, installe, ajoute à la liste
9
- # packages.sh remove <nom>… retire de la liste et désinstalle (sauf paquet de l'image)
10
- # packages.sh apply installe tout ce qui manque (post-create.sh)
11
- # L'état d'un paquet vient de dpkg-query -W -f='${Status}' ; les commandes
12
- # système passent par des variables surchargeables pour les tests (sudo, apt-get,
13
- # apt-cache, dpkg-query, marque, horodatage). Compatible bash 3.2 (macOS).
2
+ # System packages kept after a rebuild (#351): a list in the devzone folder
3
+ # (<root>/.devzone.packages, a comment header + one package name per line, sorted,
4
+ # without duplicates), reinstalled at each container creation (post-create.sh).
5
+ # A package installed by hand is lost by a rebuild, unless it is in this list.
6
+ # packages.sh or packages.sh list list with the state of each package
7
+ # packages.sh add <name>… validates, installs, adds to the list
8
+ # packages.sh remove <name>… removes from the list and uninstalls (except image packages)
9
+ # packages.sh apply installs everything missing (post-create.sh)
10
+ # The state of a package comes from dpkg-query -W -f='${Status}'; the system
11
+ # commands go through overridable variables for the tests (sudo, apt-get,
12
+ # apt-cache, dpkg-query, mark, timestamp). Compatible with bash 3.2 (macOS).
14
13
  set -euo pipefail
15
14
 
16
- ICI="$(cd "$(dirname "$0")" && pwd)"
17
- RACINE="${DEVZONE_RACINE:-$(dirname "$ICI")}"
18
- LISTE="${RACINE}/.devzone.paquets"
19
- MARQUE="${DEVZONE_PAQUETS_MARQUE:-/tmp/devzone-paquets.echec}"
20
- MAJ="${DEVZONE_PAQUETS_MAJ:-/tmp/devzone-paquets.maj}"
21
- SUDO="${DEVZONE_PAQUETS_SUDO-sudo}"
22
- APT="${DEVZONE_PAQUETS_APT:-apt-get}"
23
- APTCACHE="${DEVZONE_PAQUETS_APTCACHE:-apt-cache}"
24
- DPKGQUERY="${DEVZONE_PAQUETS_DPKG_QUERY:-dpkg-query}"
15
+ HERE="$(cd "$(dirname "$0")" && pwd)"
16
+ ROOT="${DEVZONE_ROOT:-$(dirname "$HERE")}"
17
+ LIST="${ROOT}/.devzone.packages"
18
+ MARK="${DEVZONE_PACKAGES_MARKER:-/tmp/devzone-packages.failed}"
19
+ UPDATED="${DEVZONE_PACKAGES_UPDATE:-/tmp/devzone-paquets.maj}"
20
+ SUDO="${DEVZONE_PACKAGES_SUDO-sudo}"
21
+ APT="${DEVZONE_PACKAGES_APT:-apt-get}"
22
+ APTCACHE="${DEVZONE_PACKAGES_APTCACHE:-apt-cache}"
23
+ DPKGQUERY="${DEVZONE_PACKAGES_DPKG_QUERY:-dpkg-query}"
25
24
  FORMAT="-f=\${Status}"
26
- ENTETE="# paquets ajoutés par devzone packages add ; réinstallés à chaque création du conteneur"
27
- PRESENT="# déjà présent"
25
+ # Stored values, kept byte for byte (the users' list file): the header and the
26
+ # « already present » mark are written in UTF-8 as byte escapes (contract).
27
+ HEADER=$'# paquets ajout\303\251s par devzone packages add ; r\303\251install\303\251s \303\240 chaque cr\303\251ation du conteneur'
28
+ PRESENT_MARK=$'# d\303\251j\303\240 pr\303\251sent'
28
29
 
29
30
 
30
- refuse() { echo "devzone : paquets : $*" >&2; exit 1; }
31
+ refuse() { echo "devzone : packages : $*" >&2; exit 1; }
31
32
 
32
- en_root() {
33
+ as_root() {
33
34
  if [ -n "$SUDO" ]; then
34
35
  "$SUDO" "$@"
35
36
  else
@@ -37,191 +38,191 @@ en_root() {
37
38
  fi
38
39
  }
39
40
 
40
- installe() {
41
+ is_installed() {
41
42
  "$DPKGQUERY" -W "$FORMAT" "$1" 2>/dev/null | grep -q 'install ok installed'
42
43
  }
43
44
 
44
- # Lignes de la liste telles quelles (nom, ou nom suivi de la marque PRESENT).
45
- lignes_liste() {
46
- [ -f "$LISTE" ] || return 0
47
- grep -vE '^[[:space:]]*(#|$)' "$LISTE" 2>/dev/null |
45
+ # List lines as they are (name, or name followed by the present mark).
46
+ list_lines() {
47
+ [ -f "$LIST" ] || return 0
48
+ grep -vE '^[[:space:]]*(#|$)' "$LIST" 2>/dev/null |
48
49
  sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e '/^$/d' |
49
50
  sort -k1,1 -u || true
50
51
  }
51
52
 
52
- # Noms seuls : la marque de fin de ligne est ignorée.
53
- noms_liste() {
54
- lignes_liste | sed -e 's/[[:space:]]*#.*$//' | sort -u || true
53
+ # Names only: the end-of-line mark is ignored.
54
+ list_names() {
55
+ list_lines | sed -e 's/[[:space:]]*#.*$//' | sort -u || true
55
56
  }
56
57
 
57
- nom_listee() {
58
- local nom
59
- while IFS= read -r nom; do
60
- [ "$nom" = "$1" ] && return 0
61
- done < <(noms_liste)
58
+ name_listed() {
59
+ local name
60
+ while IFS= read -r name; do
61
+ [ "$name" = "$1" ] && return 0
62
+ done < <(list_names)
62
63
  return 1
63
64
  }
64
65
 
65
- # Vrai si le paquet a été marqué comme déjà présent dans l'image.
66
- marque_presente() {
67
- grep -qxF -e "$1 $PRESENT" "$LISTE" 2>/dev/null
66
+ # True if the package was marked as already present in the image.
67
+ mark_present() {
68
+ grep -qxF -e "$1 $PRESENT_MARK" "$LIST" 2>/dev/null
68
69
  }
69
70
 
70
- # Réécrit la liste : un seul en-tête, puis les lignes données (triées par nom).
71
- ecrire_liste() {
71
+ # Rewrites the list: a single header, then the given lines (sorted by name).
72
+ write_list() {
72
73
  local tmp
73
74
  tmp="$(mktemp)"
74
75
  {
75
- echo "$ENTETE"
76
+ echo "$HEADER"
76
77
  [ "$#" -eq 0 ] || printf '%s\n' "$@" | sort -k1,1 -u
77
78
  } >"$tmp"
78
- mv "$tmp" "$LISTE"
79
+ mv "$tmp" "$LIST"
79
80
  }
80
81
 
81
- maj_index() {
82
- local dernier
83
- dernier="$(cat "$MAJ" 2>/dev/null || true)"
84
- if [ -n "$dernier" ] && [ $(( $(date +%s) - dernier )) -lt 3600 ]; then
82
+ update_index() {
83
+ local last
84
+ last="$(cat "$UPDATED" 2>/dev/null || true)"
85
+ if [ -n "$last" ] && [ $(( $(date +%s) - last )) -lt 3600 ]; then
85
86
  return 0
86
87
  fi
87
- en_root "$APT" update || return 1
88
- date +%s >"$MAJ"
88
+ as_root "$APT" update || return 1
89
+ date +%s >"$UPDATED"
89
90
  }
90
91
 
91
- lister() {
92
- local paquets paquet
93
- paquets="$(noms_liste)"
94
- if [ -z "$paquets" ]; then
95
- echo "aucun paquet (devzone packages add <nom>)"
92
+ list_packages() {
93
+ local packages package
94
+ packages="$(list_names)"
95
+ if [ -z "$packages" ]; then
96
+ echo "no package (devzone packages add <name>)"
96
97
  return 0
97
98
  fi
98
- while IFS= read -r paquet; do
99
- [ -n "$paquet" ] || continue
100
- if installe "$paquet"; then
101
- echo " ✔ $paquet"
99
+ while IFS= read -r package; do
100
+ [ -n "$package" ] || continue
101
+ if is_installed "$package"; then
102
+ echo " ✔ $package"
102
103
  else
103
- echo " ○ $paquet"
104
+ echo " ○ $package"
104
105
  fi
105
- done < <(printf '%s\n' "$paquets")
106
+ done < <(printf '%s\n' "$packages")
106
107
  }
107
108
 
108
- ajouter() {
109
+ add_packages() {
109
110
  local -a a=()
110
- local -a entrees=()
111
- local arg nom ligne deja=""
111
+ local -a entries=()
112
+ local arg name line already=""
112
113
  for arg in "$@"; do
113
114
  case "$arg" in
114
- -*) refuse "argument inconnu : $arg (devzone packages add <nom>…)" ;;
115
+ -*) refuse "unknown argument: $arg (devzone packages add <name>…)" ;;
115
116
  *) a+=("$arg") ;;
116
117
  esac
117
118
  done
118
- [ "${#a[@]}" -gt 0 ] || refuse "ajouter attend au moins un nom : devzone packages add <nom>…"
119
- maj_index || echo "index apt non mis à jour" >&2
120
- for nom in "${a[@]}"; do
121
- if ! "$APTCACHE" show "$nom" >/dev/null 2>&1; then
122
- refuse "paquet inconnu : $nom (liste inchangée)"
119
+ [ "${#a[@]}" -gt 0 ] || refuse "add expects at least one name: devzone packages add <name>…"
120
+ update_index || echo "apt index not updated" >&2
121
+ for name in "${a[@]}"; do
122
+ if ! "$APTCACHE" show "$name" >/dev/null 2>&1; then
123
+ refuse "unknown package: $name (list unchanged)"
123
124
  fi
124
125
  done
125
- # Ce qui est déjà installé avant l'installation vient de l'image : marqué.
126
- for nom in "${a[@]}"; do
127
- if installe "$nom"; then
128
- deja="$deja $nom"
126
+ # What is already installed before the installation comes from the image: marked
127
+ for name in "${a[@]}"; do
128
+ if is_installed "$name"; then
129
+ already="$already $name"
129
130
  fi
130
131
  done
131
- if en_root DEBIAN_FRONTEND=noninteractive "$APT" install -y --no-install-recommends "${a[@]}"; then
132
- while IFS= read -r ligne; do
133
- entrees+=("$ligne")
134
- done < <(lignes_liste)
135
- for nom in "${a[@]}"; do
136
- if nom_listee "$nom"; then
132
+ if as_root DEBIAN_FRONTEND=noninteractive "$APT" install -y --no-install-recommends "${a[@]}"; then
133
+ while IFS= read -r line; do
134
+ entries+=("$line")
135
+ done < <(list_lines)
136
+ for name in "${a[@]}"; do
137
+ if name_listed "$name"; then
137
138
  continue
138
139
  fi
139
- case " $deja " in
140
- *" $nom "*)
141
- entrees+=("$nom $PRESENT")
142
- echo "$nom : déjà présent avant devzone packages (marqué ; retirer le laissera installé)"
140
+ case " $already " in
141
+ *" $name "*)
142
+ entries+=("$name $PRESENT_MARK")
143
+ echo "$name : already present before devzone packages (marked ; removing will leave it installed)"
143
144
  ;;
144
- *) entrees+=("$nom") ;;
145
+ *) entries+=("$name") ;;
145
146
  esac
146
147
  done
147
- ecrire_liste "${entrees[@]}"
148
+ write_list "${entries[@]}"
148
149
  else
149
- refuse "installation impossible : ${a[*]} (liste inchangée)"
150
+ refuse "installation failed: ${a[*]} (list unchanged)"
150
151
  fi
151
152
  }
152
153
 
153
- retirer() {
154
+ remove_packages() {
154
155
  local -a a=()
155
- local -a desinstalles=()
156
- local -a restantes=()
157
- local arg nom ligne nom_ligne
156
+ local -a removals=()
157
+ local -a remaining=()
158
+ local arg name line name_line
158
159
  for arg in "$@"; do
159
160
  case "$arg" in
160
- -*) refuse "argument inconnu : $arg (devzone packages remove <nom>…)" ;;
161
+ -*) refuse "unknown argument: $arg (devzone packages remove <name>…)" ;;
161
162
  *) a+=("$arg") ;;
162
163
  esac
163
164
  done
164
- [ "${#a[@]}" -gt 0 ] || refuse "retirer attend au moins un nom : devzone packages remove <nom>…"
165
- for nom in "${a[@]}"; do
166
- nom_listee "$nom" ||
167
- refuse "paquet non listé : $nom (fourni par l'image ?) : devzone packages remove n'ajoute pas les paquets de l'image"
168
- if ! marque_presente "$nom"; then
169
- desinstalles+=("$nom")
165
+ [ "${#a[@]}" -gt 0 ] || refuse "remove expects at least one name: devzone packages remove <name>…"
166
+ for name in "${a[@]}"; do
167
+ name_listed "$name" ||
168
+ refuse "package not listed: $name (provided by the image?) : devzone packages remove does not add image packages"
169
+ if ! mark_present "$name"; then
170
+ removals+=("$name")
170
171
  fi
171
172
  done
172
- if [ "${#desinstalles[@]}" -gt 0 ] && ! en_root "$APT" remove -y "${desinstalles[@]}"; then
173
- refuse "désinstallation impossible : ${desinstalles[*]} (liste inchangée)"
173
+ if [ "${#removals[@]}" -gt 0 ] && ! as_root "$APT" remove -y "${removals[@]}"; then
174
+ refuse "removal failed: ${removals[*]} (list unchanged)"
174
175
  fi
175
- for nom in "${a[@]}"; do
176
- if marque_presente "$nom"; then
177
- echo "$nom : retiré de la liste, laissé installé (présent avant devzone packages)"
176
+ for name in "${a[@]}"; do
177
+ if mark_present "$name"; then
178
+ echo "$name : removed from the list, left installed (present before devzone packages)"
178
179
  fi
179
180
  done
180
- while IFS= read -r ligne; do
181
- nom_ligne="${ligne%% *}"
181
+ while IFS= read -r line; do
182
+ name_line="${line%% *}"
182
183
  case " ${a[*]} " in
183
- *" $nom_ligne "*) ;;
184
- *) restantes+=("$ligne") ;;
184
+ *" $name_line "*) ;;
185
+ *) remaining+=("$line") ;;
185
186
  esac
186
- done < <(lignes_liste)
187
- ecrire_liste "${restantes[@]+"${restantes[@]}"}"
187
+ done < <(list_lines)
188
+ write_list "${remaining[@]+"${remaining[@]}"}"
188
189
  }
189
190
 
190
- appliquer() {
191
- local paquet
192
- local -a manquants=()
193
- while IFS= read -r paquet; do
194
- [ -n "$paquet" ] || continue
195
- if ! installe "$paquet"; then
196
- manquants+=("$paquet")
191
+ apply_packages() {
192
+ local package
193
+ local -a missing=()
194
+ while IFS= read -r package; do
195
+ [ -n "$package" ] || continue
196
+ if ! is_installed "$package"; then
197
+ missing+=("$package")
197
198
  fi
198
- done < <(printf '%s\n' "$(noms_liste)")
199
- if [ "${#manquants[@]}" -eq 0 ]; then
200
- rm -f "$MARQUE"
199
+ done < <(printf '%s\n' "$(list_names)")
200
+ if [ "${#missing[@]}" -eq 0 ]; then
201
+ rm -f "$MARK"
201
202
  return 0
202
203
  fi
203
- maj_index || echo "index apt non mis à jour" >&2
204
- for paquet in "${manquants[@]}"; do
205
- en_root DEBIAN_FRONTEND=noninteractive "$APT" install -y --no-install-recommends "$paquet" || true
204
+ update_index || echo "apt index not updated" >&2
205
+ for package in "${missing[@]}"; do
206
+ as_root DEBIAN_FRONTEND=noninteractive "$APT" install -y --no-install-recommends "$package" || true
206
207
  done
207
- local -a restants=()
208
- for paquet in "${manquants[@]}"; do
209
- if ! installe "$paquet"; then
210
- restants+=("$paquet")
208
+ local -a still_missing=()
209
+ for package in "${missing[@]}"; do
210
+ if ! is_installed "$package"; then
211
+ still_missing+=("$package")
211
212
  fi
212
213
  done
213
- if [ "${#restants[@]}" -gt 0 ]; then
214
- printf '%s\n' "${restants[@]}" >"$MARQUE"
214
+ if [ "${#still_missing[@]}" -gt 0 ]; then
215
+ printf '%s\n' "${still_missing[@]}" >"$MARK"
215
216
  return 1
216
217
  fi
217
- rm -f "$MARQUE"
218
+ rm -f "$MARK"
218
219
  }
219
220
 
220
221
  case "${1:-}" in
221
- '' | list) lister ;;
222
- add) ajouter "${@:2}" ;;
223
- remove) retirer "${@:2}" ;;
224
- apply) appliquer ;;
222
+ '' | list) list_packages ;;
223
+ add) add_packages "${@:2}" ;;
224
+ remove) remove_packages "${@:2}" ;;
225
+ apply) apply_packages ;;
225
226
  -h | --help | aide) awk 'NR==1{next} /^#$/{exit} /^#/{sub(/^# ?/,""); print; next} {exit}' "${BASH_SOURCE[0]}" ;;
226
- *) refuse "commande inconnue : ${1:-(aucune)} (devzone packages --help)" ;;
227
+ *) refuse "unknown command: ${1:-(none)} (devzone packages --help)" ;;
227
228
  esac
@@ -8,7 +8,7 @@
8
8
  set -euo pipefail
9
9
 
10
10
  PASSWORD_HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
11
- PASSWORD_ROOT="${DEVZONE_RACINE:-$(dirname "$PASSWORD_HERE")}"
11
+ PASSWORD_ROOT="${DEVZONE_ROOT:-$(dirname "$PASSWORD_HERE")}"
12
12
  PASSWORD_TARGET="$PASSWORD_ROOT/.password"
13
13
 
14
14
  # Regenerates $ROOT/.password from workspace/.gitlab, workspace/.postgres,