devzone 7.1.0 → 7.2.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 (76) hide show
  1. package/.devcontainer/Dockerfile +15 -22
  2. package/.devcontainer/ai/host-check.message +12 -12
  3. package/.devcontainer/ai/host-check.sh +1 -1
  4. package/.devcontainer/catalog/app.sh +5 -12
  5. package/.devcontainer/catalog/catalog-watcher.sh +7 -7
  6. package/.devcontainer/catalog.sh +1 -1
  7. package/.devcontainer/cluster.sh +1 -11
  8. package/.devcontainer/devcontainer.json +1 -11
  9. package/.devcontainer/devzone +19 -23
  10. package/.devcontainer/devzone-ai.sh +1 -1
  11. package/.devcontainer/devzone-cluster.sh +2 -3
  12. package/.devcontainer/devzone-modules.sh +7 -2
  13. package/.devcontainer/devzone-repair.sh +11 -21
  14. package/.devcontainer/devzone-services.sh +21 -20
  15. package/.devcontainer/devzone-status.sh +4 -12
  16. package/.devcontainer/gitlab/demo/.gitlab-ci.yml +1 -1
  17. package/.devcontainer/help.sh +3 -5
  18. package/.devcontainer/isolation.sh +1 -1
  19. package/.devcontainer/kube-account.sh +12 -173
  20. package/.devcontainer/metrics-server.sh +1 -1
  21. package/.devcontainer/packages.sh +3 -3
  22. package/.devcontainer/password.sh +5 -6
  23. package/.devcontainer/ports-json.sh +0 -4
  24. package/.devcontainer/ports.sh +7 -103
  25. package/.devcontainer/services-admin.sh +2 -2
  26. package/.devcontainer/state-json.sh +4 -14
  27. package/.devcontainer/versions.env +2 -2
  28. package/.devcontainer/workspace-init.sh +1 -9
  29. package/Makefile +6 -6
  30. package/README.md +14 -33
  31. package/bin/SHA256SUMS +6 -6
  32. package/bin/devzone-darwin-amd64 +0 -0
  33. package/bin/devzone-darwin-arm64 +0 -0
  34. package/bin/devzone-linux-amd64 +0 -0
  35. package/bin/devzone-linux-arm64 +0 -0
  36. package/bin/devzone-windows-amd64.exe +0 -0
  37. package/bin/devzone-windows-arm64.exe +0 -0
  38. package/manage/devzone +7 -20
  39. package/manage/scripts/ci/check-names.sh +5 -6
  40. package/manage/scripts/ci/ticket-protocol.txt +7 -0
  41. package/manage/scripts/ci/versions-tools-plan.sh +1 -1
  42. package/manage/scripts/devzone-create.sh +4 -4
  43. package/manage/scripts/devzone-update.sh +18 -22
  44. package/manage/scripts/workspace/argocd-services.sh +1 -1
  45. package/manage/scripts/workspace/argocd-workspace.sh +2 -2
  46. package/manage/scripts/workspace/ports-workspace.sh +5 -5
  47. package/manage/scripts/workspace/services-workspace.sh +3 -3
  48. package/manage/scripts/workspace/workspace-update.sh +0 -3
  49. package/manage/workspace.sh +0 -14
  50. package/package.json +1 -1
  51. package/.devcontainer/argocd/argocd.sh +0 -222
  52. package/.devcontainer/argocd/catalog-argocd.sh +0 -119
  53. package/.devcontainer/argocd/services-hook.sh +0 -181
  54. package/.devcontainer/catalog/mysql/install.sh +0 -87
  55. package/.devcontainer/catalog/mysql/mysql.sh +0 -262
  56. package/.devcontainer/catalog/mysql/volume.sh +0 -71
  57. package/.devcontainer/command-aliases.sh +0 -234
  58. package/.devcontainer/git-identity.sh +0 -28
  59. package/.devcontainer/gitlab/argocd.sh +0 -54
  60. package/.devcontainer/gitlab/chart.sh +0 -39
  61. package/.devcontainer/gitlab/gitlab.sh +0 -168
  62. package/.devcontainer/gitlab/installation.sh +0 -193
  63. package/.devcontainer/gitlab/secrets.sh +0 -95
  64. package/.devcontainer/gitlab/seed.sh +0 -204
  65. package/.devcontainer/gitlab/test-gitlab-restes.sh +0 -16
  66. package/.devcontainer/gitlab/test-gitlab.sh +0 -489
  67. package/.devcontainer/kind-wrapper.sh +0 -45
  68. package/.devcontainer/kube-config.sh +0 -78
  69. package/.devcontainer/kube-reachable.sh +0 -64
  70. package/.devcontainer/ports-auto.sh +0 -247
  71. package/.devcontainer/post-create.sh +0 -91
  72. package/.devcontainer/postgres/postgres.sh +0 -309
  73. package/.devcontainer/rename-legacy-files.sh +0 -172
  74. package/.devcontainer/rename-legacy-ports.sh +0 -119
  75. package/.devcontainer/startup.sh +0 -65
  76. package/manage/scripts/ci/check-english.sh +0 -57
@@ -1,172 +0,0 @@
1
- #!/usr/bin/env bash
2
- # shellcheck shell=bash
3
- # Renames the files and folders that devzone wrote under their former French
4
- # names to their English names (#733, lot 3), and the state keys plateforme= to
5
- # platform= (lot 4) and ia= to ai= (#774, lot 3). #774, lot 4 adds the folders of the
6
- # port watcher, the state backup, the AI measures file and the packages marker.
7
- # #774, lot 5 adds the ports folder cap, the key ports_exclus=, the state files of
8
- # the port automation, the locks of the agent, of the catalog watcher and of the
9
- # state (rename-legacy-ports.sh).
10
- # Called by the pod startup, by the workspace init, and on the
11
- # workstation by devzone update and workspace update.
12
- # Idempotent: a name is renamed only when the old one exists and the new one
13
- # does not, so a second run does nothing. Two folders with both names are
14
- # merged, the old one emptied and removed. An existing file is never
15
- # overwritten. One line per rename or merge on stdout, exit 0. No alias of the
16
- # old names is kept after this migration. bash 3.2 (macOS).
17
- # DEVZONE_ROOT devzone folder (default: the parent of this .devcontainer)
18
- # DEVZONE_TMP_DIR temporary folder (default: /tmp), set by the tests
19
- # DEVZONE_PORTS_AUTO_DIR, DEVZONE_AGENT_STATE state folders of the port automation
20
- # and of the agent (defaults: devzone-ports-auto of the temporary folder, ~/.local/state/oc-lancer)
21
-
22
- ROOT="${DEVZONE_ROOT:-$(cd "$(dirname "$0")/.." && pwd)}"
23
- TMP_DIR="${DEVZONE_TMP_DIR:-/tmp}"
24
-
25
- # is_real_dir PATH: true for a folder that is not a symbolic link
26
- is_real_dir() {
27
- [ -d "$1" ] && [ ! -L "$1" ]
28
- }
29
-
30
- # merge_legacy OLD NEW: both are folders. Each entry of OLD that NEW does not
31
- # have is moved into NEW; an entry present on both sides is never overwritten,
32
- # it stays in OLD and a message on stderr names it. OLD is removed (rmdir) only
33
- # when it is left empty, and then the merge is announced on stdout. Hidden
34
- # entries are merged too. The shell options live in a subshell, so they do not
35
- # reach the other migrations.
36
- merge_legacy() {
37
- local old="$1" new="$2"
38
- (
39
- shopt -s dotglob nullglob
40
- local entry target
41
- for entry in "$old"/*; do
42
- target="$new/${entry##*/}"
43
- if [ -e "$target" ] || [ -L "$target" ]; then
44
- echo "devzone : $entry kept: $target already exists" >&2
45
- elif ! mv -- "$entry" "$target"; then
46
- echo "devzone : $entry not merged into $target" >&2
47
- fi
48
- done
49
- if rmdir -- "$old" 2>/dev/null; then
50
- echo "devzone : $old merged into $new"
51
- fi
52
- )
53
- return 0
54
- }
55
-
56
- # rename_legacy OLD NEW: moves OLD to NEW when OLD exists and NEW does not.
57
- # When both are folders, they are merged (see merge_legacy). Any other conflict
58
- # is reported on stderr and both names are left as they are.
59
- rename_legacy() {
60
- local old="$1" new="$2"
61
- if [ ! -e "$old" ] && [ ! -L "$old" ]; then
62
- return 0
63
- fi
64
- if [ -e "$new" ] || [ -L "$new" ]; then
65
- if is_real_dir "$old" && is_real_dir "$new"; then
66
- merge_legacy "$old" "$new"
67
- else
68
- echo "devzone : $old kept, $new already exists" >&2
69
- fi
70
- return 0
71
- fi
72
- if mv -- "$old" "$new"; then
73
- echo "devzone : $old renamed to $new"
74
- else
75
- echo "devzone : $old not renamed to $new" >&2
76
- fi
77
- return 0
78
- }
79
-
80
- # Failure markers of the modules: .devzone.modules-echec-<module> becomes
81
- # .devzone.modules-failed-<module>, one rename per marker found
82
- migrate_markers() {
83
- local f base
84
- for f in "$ROOT"/.devzone.modules-echec-*; do
85
- if [ ! -e "$f" ] && [ ! -L "$f" ]; then
86
- continue
87
- fi
88
- base="${f##*/}"
89
- rename_legacy "$f" "$ROOT/.devzone.modules-failed-${base#.devzone.modules-echec-}"
90
- done
91
- }
92
-
93
- # Folders and files of the devzone folder
94
- migrate_root() {
95
- rename_legacy "$ROOT/.devzone.paquets" "$ROOT/.devzone.packages"
96
- rename_legacy "$ROOT/.devzone.sauvegarde" "$ROOT/.devzone.backup"
97
- rename_legacy "$ROOT/.devzone.ports-workspace" "$ROOT/.devzone.workspace-ports"
98
- rename_legacy "$ROOT/.devzone.etat" "$ROOT/.devzone.state"
99
- rename_legacy "$ROOT/.devzone.catalogue-veilleur" "$ROOT/.devzone.catalog-watcher"
100
- migrate_markers
101
- # Failure marker of the AI module, renamed with it (#774)
102
- rename_legacy "$ROOT/.devzone.modules-failed-ia" "$ROOT/.devzone.modules-failed-ai"
103
- # Backup of the previous state (#774, lot 4)
104
- rename_legacy "$ROOT/.devzone.modules.prec" "$ROOT/.devzone.modules.prev"
105
- migrate_ports
106
- }
107
-
108
- # Port watcher, locks and state files of the port automation (#774, lot 5)
109
- # shellcheck source=SCRIPTDIR/rename-legacy-ports.sh
110
- # shellcheck disable=SC1091
111
- . "$(dirname "$0")/rename-legacy-ports.sh"
112
-
113
- # Fingerprint of the devzone skill, next to its SKILL.md in each assistant folder
114
- migrate_skills() {
115
- local d
116
- [ -n "${HOME:-}" ] || return 0
117
- for d in "$HOME/.claude/skills/devzone" "$HOME/.config/opencode/skills/devzone"; do
118
- rename_legacy "$d/.devzone-empreinte" "$d/.devzone-fingerprint"
119
- done
120
- # Measures of the host models (#774, lot 4); DEVZONE_AI_MEASURES points to
121
- # a file of the user, never renamed
122
- rename_legacy "$HOME/.config/devzone/ia-mesures.json" "$HOME/.config/devzone/ai-measures.json"
123
- }
124
-
125
- # Markers written in the temporary folder by the packages check
126
- migrate_tmp() {
127
- rename_legacy "$TMP_DIR/devzone-paquets.echec" "$TMP_DIR/devzone-packages.failed"
128
- rename_legacy "$TMP_DIR/devzone-paquets.maj" "$TMP_DIR/devzone-packages.updated"
129
- }
130
-
131
- # Key of the state file: the line <old>=<v> becomes <new>=<v>. When a <new>=
132
- # line is already there, only the old line goes. The file is rewritten in a
133
- # temporary file, then moved over it; the other lines are copied as they are.
134
- # A file without the old key is left alone.
135
- migrate_state_key() {
136
- local old="$1" new="$2"
137
- local f="$ROOT/.devzone.modules" tmp="$ROOT/.devzone.modules.tmp.$$"
138
- [ -f "$f" ] || return 0
139
- grep -q "^$old=" "$f" || return 0
140
- if grep -q "^$new=" "$f"; then
141
- sed "/^$old=/d" "$f" >"$tmp"
142
- else
143
- sed "s/^$old=/$new=/" "$f" >"$tmp"
144
- fi || {
145
- rm -f "$tmp"
146
- echo "devzone : $old= not renamed to $new=" >&2
147
- return 0
148
- }
149
- if mv -- "$tmp" "$f"; then
150
- echo "devzone : $old= renamed to $new="
151
- else
152
- rm -f "$tmp"
153
- echo "devzone : $old= not renamed to $new=" >&2
154
- fi
155
- return 0
156
- }
157
-
158
- # Keys of the state file: plateforme= (#733, lot 4), ia= (#774, lot 3), ports_exclus= (#774, lot 5)
159
- migrate_state_keys() {
160
- migrate_state_key plateforme platform
161
- migrate_state_key ia ai
162
- migrate_state_key ports_exclus excluded_ports
163
- }
164
-
165
- migrate_root
166
- migrate_skills
167
- migrate_tmp
168
- migrate_ports_auto
169
- migrate_agent_locks
170
- migrate_state_lock
171
- migrate_state_keys
172
- exit 0
@@ -1,119 +0,0 @@
1
- #!/usr/bin/env bash
2
- # shellcheck shell=bash
3
- # Migration of the names of the port watcher, of the locks and of the state files
4
- # of the port automation (#774, lot 5). Sourced by rename-legacy-files.sh, which
5
- # defines ROOT, TMP_DIR, is_real_dir and rename_legacy: never run alone. bash 3.2.
6
- #
7
- # Rule for a lock: a lock held by a live process is never moved or removed, it
8
- # is reported on stderr and the next run migrates it once its holder has gone.
9
-
10
- # pid_alive PID: true when PID is a live process
11
- pid_alive() {
12
- [ -n "${1:-}" ] && kill -0 "$1" 2>/dev/null
13
- }
14
-
15
- # lock_held DIR: true when the lock folder DIR names a live process in DIR/pid
16
- lock_held() {
17
- pid_alive "$(cat "$1/pid" 2>/dev/null || true)"
18
- }
19
-
20
- # migrate_lock OLD NEW: the lock folder OLD becomes NEW, unless a live process
21
- # holds it
22
- migrate_lock() {
23
- [ -e "$1" ] || [ -L "$1" ] || return 0
24
- if lock_held "$1"; then
25
- echo "devzone : $1 kept: held by a live process" >&2
26
- return 0
27
- fi
28
- rename_legacy "$1" "$2"
29
- }
30
-
31
- # is_watcher PID: true when PID is a live port watcher (its command line names
32
- # ports-workspace.sh, or is "workspace ports loop" of the Go watcher), so a pid
33
- # file left by a dead watcher never makes us signal an unrelated process that
34
- # reuses the number
35
- is_watcher() {
36
- [ -n "${1:-}" ] || return 1
37
- kill -0 "$1" 2>/dev/null || return 1
38
- ps -p "$1" -o command= 2>/dev/null | grep -Eq 'ports-workspace\.sh|workspace ports loop'
39
- }
40
-
41
- # Folders of the workstation port watcher (#774, lots 4 and 5): relais/ becomes
42
- # relays/, pris/ taken/, verrou lock and plafond cap. A watcher that is running
43
- # keeps the old folders and creates them again at each round, so it is stopped
44
- # first: SIGTERM, and its own handler removes its relays, its lock and its pid.
45
- # It is not restarted here (the files of the package are replaced after this
46
- # script): the file restart is left in its folder as the signal that this
47
- # migration, not the user, stopped it; devzone update starts it again once the
48
- # files are replaced, and a start or a stop by the user removes the signal. If
49
- # it does not stop within 2 s, nothing is renamed.
50
- migrate_ports() {
51
- local d="$ROOT/.devzone.workspace-ports" pid old n
52
- is_real_dir "$d" || return 0
53
- old=""
54
- for n in relais pris verrou plafond; do
55
- if [ -e "$d/$n" ] || [ -L "$d/$n" ]; then old=1; fi
56
- done
57
- [ -n "$old" ] || return 0
58
- pid="$(cat "$d/pid" 2>/dev/null || true)"
59
- if is_watcher "$pid"; then
60
- kill "$pid" 2>/dev/null || true
61
- for _ in 1 2 3 4 5 6 7 8 9 10; do
62
- is_watcher "$pid" || break
63
- sleep 0.2
64
- done
65
- if is_watcher "$pid"; then
66
- echo "devzone : port watcher (pid $pid) still running, $d folders kept under their old names" >&2
67
- return 0
68
- fi
69
- : >"$d/restart"
70
- echo "devzone : port watcher stopped to rename its folders, restart it: devzone workspace ports start"
71
- fi
72
- rename_legacy "$d/relais" "$d/relays"
73
- rename_legacy "$d/pris" "$d/taken"
74
- rename_legacy "$d/verrou" "$d/lock"
75
- rename_legacy "$d/plafond" "$d/cap"
76
- }
77
-
78
- # State of the port automation of the pod, one folder per instance in
79
- # $DEVZONE_PORTS_AUTO_DIR (default: devzone-ports-auto of the temporary folder):
80
- # verrou lock, occupes busy, actifs active, courant current. An instance whose
81
- # lock is held by a live watcher is left whole: its files are in use.
82
- migrate_ports_auto() {
83
- local base="${DEVZONE_PORTS_AUTO_DIR:-$TMP_DIR/devzone-ports-auto}" d
84
- for d in "$base"/*; do
85
- is_real_dir "$d" || continue
86
- if lock_held "$d/verrou"; then
87
- echo "devzone : $d kept: its watcher is running" >&2
88
- continue
89
- fi
90
- rename_legacy "$d/verrou" "$d/lock"
91
- rename_legacy "$d/occupes" "$d/busy"
92
- rename_legacy "$d/actifs" "$d/active"
93
- rename_legacy "$d/courant" "$d/current"
94
- done
95
- }
96
-
97
- # Locks of the agent (state folder of devzone agent) and of the catalog watcher
98
- migrate_agent_locks() {
99
- migrate_lock "${DEVZONE_AGENT_STATE:-${HOME:-/nonexistent}/.local/state/oc-lancer}/verrou" \
100
- "${DEVZONE_AGENT_STATE:-${HOME:-/nonexistent}/.local/state/oc-lancer}/lock"
101
- migrate_lock "$ROOT/.devzone.catalog-watcher/verrou" "$ROOT/.devzone.catalog-watcher/lock"
102
- }
103
-
104
- # Write lock of the state file: the folder .devzone.modules.verrou became
105
- # .devzone.modules.lockdir. It is a transient mkdir lock without pid: it is
106
- # not renamed, the old one is removed once it is older than 30 s, which is the
107
- # age after which state-lock.sh itself takes a lock for abandoned. A younger
108
- # one may belong to a write in progress: it is left for the next run.
109
- migrate_state_lock() {
110
- local old="$ROOT/.devzone.modules.verrou" t
111
- is_real_dir "$old" || return 0
112
- t="$(stat -c %Y "$old" 2>/dev/null || stat -f %m "$old" 2>/dev/null || true)"
113
- [ -n "$t" ] && [ "$(($(date +%s) - t))" -gt 30 ] || return 0
114
- if rm -rf -- "$old"; then
115
- echo "devzone : $old removed (abandoned write lock, now .devzone.modules.lockdir)"
116
- else
117
- echo "devzone : $old not removed" >&2
118
- fi
119
- }
@@ -1,65 +0,0 @@
1
- #!/usr/bin/env bash
2
- # At each startup, in order: git identity (deduced from the gh account),
3
- # Kubernetes clusters, gitlab.localhost name and 8929/2224
4
- # relay of the gitlab module if enabled, relays of the postgres and argocd
5
- # modules if enabled, port relays to the workstation, grouped credentials
6
- # (.password), then the summary of what remains to be done (devzone).
7
- # Sequential: the summary sees the identity just set; the failure of one step
8
- # does not prevent the following ones.
9
- # Never a question (gh, kubectl and its authentication plugins): output hidden
10
- # behind make, a wait would block (see post-create.sh)
11
- exec </dev/null
12
- ICI="$(dirname "$0")"
13
- # Former French names renamed first (#733): the packages check below reads the
14
- # English names
15
- bash "$ICI/rename-legacy-files.sh" || echo "startup : legacy names not renamed (devzone repair)"
16
- bash "$ICI/git-identity.sh" || echo "startup : git identity not handled (devzone start)"
17
- bash "$ICI/kube-config.sh" || echo "startup : clusters not handled (devzone start)"
18
- # Token of the limited Kubernetes account (#430): 24 h, renewed at each
19
- # startup; account set up on the way if missing. Without a chosen services
20
- # cluster, nothing to do
21
- bash "$ICI/kube-account.sh" jeton || echo "startup : kubernetes account token not renewed (devzone repair)"
22
- # gitlab module enabled: /etc/hosts is a Docker mount regenerated at each
23
- # startup, gitlab.localhost must be set again (ssh, glab and getent go through
24
- # the system resolver); hote-poser never fails (warning only)
25
- if bash "$ICI/devzone" is-enabled gitlab; then
26
- bash "$ICI/gitlab/gitlab.sh" hote-poser || echo "startup : gitlab.localhost name not set (devzone repair)"
27
- # TCP relay 8929/2224: curl and git over HTTP go through the local loop for
28
- # *.localhost, the relay must be restarted after each startup
29
- bash "$ICI/gitlab/gitlab.sh" relay-start || echo "startup : gitlab relay not started (devzone repair)"
30
- fi
31
- # postgres module enabled: the relay (port-forward to 127.0.0.1:5432) does not
32
- # survive the container stop, restarted here after the clusters
33
- if bash "$ICI/devzone" is-enabled postgres; then
34
- bash "$ICI/postgres/postgres.sh" relay-start || echo "startup : postgres relay not started (devzone repair)"
35
- fi
36
- # argocd module enabled: relay (port-forward to 127.0.0.1:8443), restarted
37
- # after the clusters like the one of postgres
38
- if bash "$ICI/devzone" is-enabled argocd; then
39
- bash "$ICI/argocd/argocd.sh" relay-start || echo "startup : argocd relay not started (devzone repair)"
40
- fi
41
- # mysql module enabled: the relay 127.0.0.1:3306, restarted like the one of
42
- # postgres after each startup
43
- if bash "$ICI/devzone" is-enabled mysql; then
44
- bash "$ICI/catalog/mysql/mysql.sh" relay-start || echo "startup : mysql relay not started (devzone repair)"
45
- fi
46
- # Port relays to the workstation (#290): the container IP changes at each
47
- # startup, each relay of the state is recreated; a failure prevents nothing
48
- bash "$ICI/ports.sh" restart || echo "startup : port relays not restarted (devzone repair)"
49
- # Automatic port watcher to the workstation (#394, guard #293): a single
50
- # instance in the background, real context set for this call only.
51
- # Kubernetes workspace (#517): no watcher, ports go through devzone workspace ports
52
- if [ "${DEVZONE_WORKSPACE:-}" != kubernetes ]; then
53
- DEVZONE_PORTS_AUTO_REAL=yes bash "$ICI/ports-auto.sh" demarrer >/dev/null 2>&1 || echo "startup : auto ports watcher not started (devzone repair)"
54
- fi
55
- # Application catalog: one <app>=off line per absent application, written
56
- # once, never an existing line modified (#414)
57
- bash "$ICI/catalog.sh" sync || echo "startup : catalog not synchronized (devzone repair)"
58
- # Catalog watcher: applies again on the fly as soon as .devzone.modules changes
59
- DEVZONE_CATALOG_REAL=yes bash "$ICI/catalog/catalog-watcher.sh" demarrer >/dev/null 2>&1 || echo "startup : catalog watcher not started (devzone repair)"
60
-
61
- # Grouped view of the credentials (#332), regenerated at each startup; a failure
62
- # prevents nothing and the content is never displayed
63
- bash "$ICI/password.sh" regenerer || echo "startup : grouped credentials not updated (devzone repair)"
64
- echo
65
- bash "$ICI/devzone"
@@ -1,57 +0,0 @@
1
- #!/usr/bin/env bash
2
- # CI check: the files listed in .english must be written in English (#502).
3
- # A file fails when one of its lines contains a French accented letter or one
4
- # of the frequent French words, whole word, case-insensitive. Each fault is
5
- # printed as "path:line: text" and the run exits 1; otherwise it prints
6
- # "english check: N files ok" and exits 0. A listed file that is missing is
7
- # an error too.
8
-
9
- set -u
10
-
11
- ICI="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12
- ROOT="$(cd "$ICI/../../.." && pwd)"
13
- LIST="$ROOT/.english"
14
-
15
- # Byte escapes and split fragments, so this file never matches its own rules
16
- # (a literal accented letter or whole word here would be reported).
17
- ACCENTS="$(printf '[\303\305][\200\202\204\206\207\210\211\212\213\216\217\222\223\224\226\231\233\234\240\242\244\246\247\250\251\252\253\256\257\264\266\270\271\273\274\277]')"
18
- WORDS="$(printf 'le_s|de_s|un_e|po_ur|av_ec|sa_ns|da_ns|fich_ier|doss_ier' | tr -d '_')"
19
- PATTERN="$ACCENTS|\\b($WORDS)\\b"
20
-
21
- # Byte matching only: the accents are matched as UTF-8 byte sequences
22
- LC_ALL=C
23
- export LC_ALL
24
-
25
- if [ ! -f "$LIST" ]; then
26
- echo "check-english: list not found: $LIST" >&2
27
- exit 1
28
- fi
29
-
30
- fails=0
31
- count=0
32
- while IFS= read -r f; do
33
- case "$f" in
34
- '' | '#'*) continue ;;
35
- esac
36
- file="$ROOT/$f"
37
- if [ ! -f "$file" ]; then
38
- echo "check-english: file listed but missing: $f" >&2
39
- fails=1
40
- continue
41
- fi
42
- count=$((count + 1))
43
- matches="$(grep -Ein -- "$PATTERN" "$file")" || matches=""
44
- while IFS= read -r m; do
45
- [ -n "$m" ] || continue
46
- n="${m%%:*}"
47
- printf '%s:%s: %s\n' "$f" "$n" "${m#*:}"
48
- fails=1
49
- done <<EOF
50
- $matches
51
- EOF
52
- done <"$LIST"
53
-
54
- if [ "$fails" -ne 0 ]; then
55
- exit 1
56
- fi
57
- echo "english check: $count files ok"