rocketdoo 3.8.0__tar.gz → 3.9.0__tar.gz
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.
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/LICENSE +2 -2
- {rocketdoo-3.8.0/rocketdoo.egg-info → rocketdoo-3.9.0}/PKG-INFO +4 -4
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/README.md +1 -1
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/pyproject.toml +1 -1
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/compose.py +20 -4
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/deploy/module_packager.py +0 -17
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/pack.py +52 -7
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/unpack.py +297 -7
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/gui/api/pack_ops.py +7 -1
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/pack_environment.py +6 -1
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/unpack_environment.py +70 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0/rocketdoo.egg-info}/PKG-INFO +4 -4
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/tests/test_compose.py +36 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/tests/test_e2e_pack_unpack.py +85 -10
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/tests/test_gui_api.py +37 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/tests/test_pack_environment.py +161 -0
- rocketdoo-3.9.0/tests/test_unpack_environment.py +1556 -0
- rocketdoo-3.8.0/tests/test_unpack_environment.py +0 -659
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/MANIFEST.in +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/__init__.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/ci_cli.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/cli.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/cli_output.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/__init__.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/addons_path.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/deploy/__init__.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/deploy/base.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/deploy/config_manager.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/deploy/odoo_sh.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/deploy/vps.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/edition_setup.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/generator.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/gitignore_manager.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/gitman_config.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/instance/__init__.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/instance/config_manager.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/instance/deployer_docker.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/instance/deployer_native.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/instance/secrets_store.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/instance/ssh_utils.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/mailpit.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/models/__init__.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/models/deploy.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/models/instance.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/models/profiles.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/models/project.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/module_scanner.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/odoo_db.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/port_validation.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/project_info.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/service.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/ssh_manager.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/core/traefik.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/deploy_cli.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/docker_cli.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/gui/__init__.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/gui/api/__init__.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/gui/api/deploy_ops.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/gui/api/docker_ops.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/gui/api/gitman.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/gui/api/instances.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/gui/api/mail.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/gui/api/modules.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/gui/api/odoo.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/gui/api/project.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/gui/api/setup.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/gui/api/traefik_ops.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/gui/api/workspace.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/gui/server.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/gui/static/index.html +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/gui_cli.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/init_project.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/instance_cli.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/mail_cli.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/scaffold.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/.devcontainer/devcontainer.json +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/.devcontainer/docker-compose.yaml +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/.gitignore.jinja +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/.vscode/launch.json +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/.vscode/launch.json.jinja +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/.vscode/settings.json +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/Dockerfile.jinja +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/addons/.gitkeep +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/ci/workflow.yaml.jinja +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/config/odoo.conf +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/config/odoo.conf.jinja +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/deploy/.deployignore +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/deploy/deploy.yaml +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/deploy/deploy.yaml.jinja +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/docker-compose.yaml.jinja +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/install_dependencies.sh +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/instance/Dockerfile.jinja +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/instance/docker-compose.jinja +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/instance/odoo.conf.jinja +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/odoo_pg_pass +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/profiles/README.md +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/profiles/odoo15-ce.yaml +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/profiles/odoo15-ee.yaml +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/profiles/odoo16-ce.yaml +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/profiles/odoo16-ee.yaml +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/profiles/odoo17-ce.yaml +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/profiles/odoo17-ee.yaml +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/profiles/odoo18-ce.yaml +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/profiles/odoo18-ee.yaml +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/profiles/odoo19-ce.yaml +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/profiles/odoo19-ee.yaml +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/profiles/odoo20-ce.yaml +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/templates/profiles/odoo20-ee.yaml +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/traefik_cli.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo/welcome.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo.egg-info/SOURCES.txt +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo.egg-info/dependency_links.txt +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo.egg-info/entry_points.txt +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo.egg-info/requires.txt +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/rocketdoo.egg-info/top_level.txt +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/setup.cfg +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/tests/test_addons_path.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/tests/test_ci_cli.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/tests/test_cli_output.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/tests/test_core_contract.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/tests/test_deploy_config_manager.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/tests/test_docker_cli.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/tests/test_e2e_scaffold.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/tests/test_edition_setup.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/tests/test_gitignore_manager.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/tests/test_gui_mail.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/tests/test_gui_static.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/tests/test_imports.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/tests/test_mail_cli.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/tests/test_mailpit.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/tests/test_models.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/tests/test_module_scanner.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/tests/test_odoo_db.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/tests/test_port_validation.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/tests/test_profiles.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/tests/test_project_info.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/tests/test_secrets_hardening.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/tests/test_ssh_manager.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/tests/test_templates.py +0 -0
- {rocketdoo-3.8.0 → rocketdoo-3.9.0}/tests/test_traefik.py +0 -0
|
@@ -57,7 +57,7 @@ If the Library as you received it specifies that a proxy can decide whether futu
|
|
|
57
57
|
<div RKD as ROCKETDOO V3=""></div>
|
|
58
58
|
|
|
59
59
|
Licencia: LGPL-3.0+
|
|
60
|
-
Versión: "3.
|
|
60
|
+
Versión: "3.9.0"
|
|
61
61
|
Autor: Horacio Montaño
|
|
62
|
-
Fecha:
|
|
62
|
+
Fecha: 11/10/2026
|
|
63
63
|
Descripción: Framework to development Odoo
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rocketdoo
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.9.0
|
|
4
4
|
Summary: Framework for creating Odoo development environments with Docker and custom templates.
|
|
5
5
|
Author-email: Horacio Montaño <horaciomontano@hdmsoft.com.ar>
|
|
6
6
|
License: GNU LESSER GENERAL PUBLIC LICENSE
|
|
@@ -62,9 +62,9 @@ License: GNU LESSER GENERAL PUBLIC LICENSE
|
|
|
62
62
|
<div RKD as ROCKETDOO V3=""></div>
|
|
63
63
|
|
|
64
64
|
Licencia: LGPL-3.0+
|
|
65
|
-
Versión: "3.
|
|
65
|
+
Versión: "3.9.0"
|
|
66
66
|
Autor: Horacio Montaño
|
|
67
|
-
Fecha:
|
|
67
|
+
Fecha: 11/10/2026
|
|
68
68
|
Descripción: Framework to development Odoo
|
|
69
69
|
Requires-Python: >=3.10
|
|
70
70
|
Description-Content-Type: text/markdown
|
|
@@ -97,7 +97,7 @@ Odoo Development Framework
|
|
|
97
97
|
- "Horacio Montaño"
|
|
98
98
|
|
|
99
99
|
## Version:
|
|
100
|
-
- "3.
|
|
100
|
+
- "3.9.0"
|
|
101
101
|
|
|
102
102
|
----------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
103
103
|
|
|
@@ -117,7 +117,12 @@ def compose_ps_result(*args: str, cwd: Path | None = None, timeout: int = 15) ->
|
|
|
117
117
|
if result.returncode != 0:
|
|
118
118
|
return [], result.stderr.strip()
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
return _parse_json_objects(result.stdout)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def _parse_json_objects(stdout: str) -> tuple[list[dict], str]:
|
|
124
|
+
"""Parse Compose's JSON output, either a single array or one object per line."""
|
|
125
|
+
output = stdout.strip()
|
|
121
126
|
if not output:
|
|
122
127
|
return [], ""
|
|
123
128
|
|
|
@@ -128,7 +133,7 @@ def compose_ps_result(*args: str, cwd: Path | None = None, timeout: int = 15) ->
|
|
|
128
133
|
return [], "unparseable compose output"
|
|
129
134
|
return [item for item in parsed if isinstance(item, dict)], ""
|
|
130
135
|
|
|
131
|
-
|
|
136
|
+
items = []
|
|
132
137
|
for line in output.splitlines():
|
|
133
138
|
line = line.strip()
|
|
134
139
|
if not line:
|
|
@@ -138,8 +143,19 @@ def compose_ps_result(*args: str, cwd: Path | None = None, timeout: int = 15) ->
|
|
|
138
143
|
except json.JSONDecodeError:
|
|
139
144
|
continue
|
|
140
145
|
if isinstance(item, dict):
|
|
141
|
-
|
|
142
|
-
return
|
|
146
|
+
items.append(item)
|
|
147
|
+
return items, ""
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def compose_ls(*args: str, timeout: int = 15) -> tuple[list[dict], str]:
|
|
151
|
+
"""`docker compose ls --format json` as a list of dicts, plus the reason it came back empty.
|
|
152
|
+
|
|
153
|
+
A host-wide query to the daemon, so it takes no `cwd`.
|
|
154
|
+
"""
|
|
155
|
+
result = run_compose_result("ls", "--format", "json", *args, timeout=timeout)
|
|
156
|
+
if not result["ok"]:
|
|
157
|
+
return [], result["stderr"]
|
|
158
|
+
return _parse_json_objects(result["stdout"])
|
|
143
159
|
|
|
144
160
|
|
|
145
161
|
def is_running(container: dict) -> bool:
|
|
@@ -193,23 +193,6 @@ class ModulePackager:
|
|
|
193
193
|
|
|
194
194
|
return output_path
|
|
195
195
|
|
|
196
|
-
def extract_archive(self, archive_path: Path, target_dir: Path):
|
|
197
|
-
"""
|
|
198
|
-
Extracts a module archive
|
|
199
|
-
|
|
200
|
-
Args:
|
|
201
|
-
archive_path: Path to archive file
|
|
202
|
-
target_dir: Directory where to extract
|
|
203
|
-
"""
|
|
204
|
-
console.print(f"📦 Extracting archive to: {target_dir}")
|
|
205
|
-
|
|
206
|
-
target_dir.mkdir(parents=True, exist_ok=True)
|
|
207
|
-
|
|
208
|
-
with tarfile.open(archive_path, "r:gz") as tar:
|
|
209
|
-
tar.extractall(target_dir)
|
|
210
|
-
|
|
211
|
-
console.print("✅ Archive extracted successfully", style="green")
|
|
212
|
-
|
|
213
196
|
def get_module_size(self, module: Dict) -> int:
|
|
214
197
|
"""
|
|
215
198
|
Calculates total size of a module in bytes
|
|
@@ -17,6 +17,7 @@ import json
|
|
|
17
17
|
import re
|
|
18
18
|
import subprocess
|
|
19
19
|
import zipfile
|
|
20
|
+
from collections.abc import Iterable
|
|
20
21
|
from datetime import datetime
|
|
21
22
|
from pathlib import Path
|
|
22
23
|
|
|
@@ -33,6 +34,11 @@ _SSH_DOCKERFILE_PATTERNS = [
|
|
|
33
34
|
|
|
34
35
|
_ALWAYS_EXCLUDE = {".ssh", "__pycache__", "node_modules", ".mypy_cache"}
|
|
35
36
|
|
|
37
|
+
# The names pack writes under rkd_backups/. Public because core/unpack.py
|
|
38
|
+
# reads back what this module writes, and the two drifting apart is its own
|
|
39
|
+
# class of bug: the writer owns the format.
|
|
40
|
+
BACKUP_FILENAME = re.compile(r"^(db|filestore)_.+_\d{8}_\d{6}\.(dump|tar\.gz)$")
|
|
41
|
+
|
|
36
42
|
_FILESTORE_PATH_TEMPLATES = [
|
|
37
43
|
"/var/lib/odoo/.local/share/Odoo/filestore/{db}",
|
|
38
44
|
"/var/lib/odoo/filestore/{db}",
|
|
@@ -183,15 +189,21 @@ def _verify_no_ssh_in_zip(zip_path: Path) -> list[str]:
|
|
|
183
189
|
return suspicious
|
|
184
190
|
|
|
185
191
|
|
|
186
|
-
def _create_zip(project_dir: Path, zip_path: Path, exclude_dirs: list[str]) -> int:
|
|
192
|
+
def _create_zip(project_dir: Path, zip_path: Path, exclude_dirs: list[str], exclude_files: Iterable[Path] = ()) -> int:
|
|
187
193
|
"""Creates the ZIP archive of the full environment.
|
|
188
194
|
|
|
189
|
-
Excludes: .ssh/, __pycache__, node_modules,
|
|
190
|
-
`rkd_backups/`, like every other
|
|
191
|
-
`rglob` walk below - it never
|
|
192
|
-
number of files included.
|
|
195
|
+
Excludes: .ssh/, __pycache__, node_modules, any extra dirs provided, and
|
|
196
|
+
the individual files in `exclude_files`. `rkd_backups/`, like every other
|
|
197
|
+
project subdirectory, is picked up by the `rglob` walk below - it never
|
|
198
|
+
needed a dedicated branch. Returns the number of files included.
|
|
199
|
+
|
|
200
|
+
`exclude_files` is matched on the path relative to the project, not on
|
|
201
|
+
file identity the way the output archive is: these paths are enumerated
|
|
202
|
+
from this same tree, under this same spelling, rather than typed by a
|
|
203
|
+
caller who could name the file some other way.
|
|
193
204
|
"""
|
|
194
205
|
excluded = _ALWAYS_EXCLUDE | set(exclude_dirs)
|
|
206
|
+
excluded_rel = {Path(item).relative_to(project_dir) for item in exclude_files}
|
|
195
207
|
|
|
196
208
|
def is_the_archive(item: Path) -> bool:
|
|
197
209
|
"""Whether this entry is the archive being written, under any name.
|
|
@@ -220,7 +232,7 @@ def _create_zip(project_dir: Path, zip_path: Path, exclude_dirs: list[str]) -> i
|
|
|
220
232
|
with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED, compresslevel=6) as zf:
|
|
221
233
|
for item in project_dir.rglob("*"):
|
|
222
234
|
rel = item.relative_to(project_dir)
|
|
223
|
-
if set(rel.parts) & excluded:
|
|
235
|
+
if rel in excluded_rel or set(rel.parts) & excluded:
|
|
224
236
|
continue
|
|
225
237
|
if item.is_file() and not is_the_archive(item):
|
|
226
238
|
zf.write(item, rel)
|
|
@@ -229,6 +241,29 @@ def _create_zip(project_dir: Path, zip_path: Path, exclude_dirs: list[str]) -> i
|
|
|
229
241
|
return file_count
|
|
230
242
|
|
|
231
243
|
|
|
244
|
+
def _stale_backups(backup_dir: Path, keep: set[Path | None]) -> list[Path]:
|
|
245
|
+
"""Backups left behind by earlier packs, which must not travel.
|
|
246
|
+
|
|
247
|
+
`rkd_backups/` grows by one (dump, filestore) pair per pack and nothing
|
|
248
|
+
removes them. `core/unpack.py` restores the newest pair and ignores the
|
|
249
|
+
rest, so every older pair is weight the recipient downloads and never
|
|
250
|
+
reads - gigabytes of it on a real database.
|
|
251
|
+
|
|
252
|
+
With `include_db=False` it is not only weight: `unpack()` decides whether
|
|
253
|
+
to restore from the dump existing, not from the manifest, so a pack that
|
|
254
|
+
carried no database on purpose arrived with an older one.
|
|
255
|
+
|
|
256
|
+
Only the names this module writes are recognised. The directory is rkd's;
|
|
257
|
+
the files in it are not necessarily, and dropping one the user put there
|
|
258
|
+
would be silent data loss in the shared copy.
|
|
259
|
+
"""
|
|
260
|
+
if not backup_dir.is_dir():
|
|
261
|
+
return []
|
|
262
|
+
return sorted(
|
|
263
|
+
item for item in backup_dir.iterdir() if item.is_file() and item not in keep and BACKUP_FILENAME.match(item.name)
|
|
264
|
+
)
|
|
265
|
+
|
|
266
|
+
|
|
232
267
|
# ─── read functions ──────────────────────────────────────────────────────────
|
|
233
268
|
|
|
234
269
|
|
|
@@ -363,8 +398,17 @@ def pack(
|
|
|
363
398
|
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
|
364
399
|
zip_path = Path(output) if output else root.parent / f"{project_name}_rkd_shared_{timestamp}.zip"
|
|
365
400
|
|
|
401
|
+
# A filestore with no dump beside it is dead weight: unpack() nests the
|
|
402
|
+
# whole restore, filestore included, under the dump existing. That is the
|
|
403
|
+
# shape left behind when pg_dump fails mid-pack, so this run's own
|
|
404
|
+
# filestore is only kept when its dump survived.
|
|
405
|
+
shipped = {db_backup_path, fs_backup_path} if db_backup_path else set()
|
|
406
|
+
stale = _stale_backups(backup_dir, shipped)
|
|
407
|
+
if stale:
|
|
408
|
+
report(f"{len(stale)} backup file(s) left out of the ZIP; unpack only restores the newest pair.")
|
|
409
|
+
|
|
366
410
|
try:
|
|
367
|
-
file_count = _create_zip(project_dir=root, zip_path=zip_path, exclude_dirs=[".ssh"])
|
|
411
|
+
file_count = _create_zip(project_dir=root, zip_path=zip_path, exclude_dirs=[".ssh"], exclude_files=stale)
|
|
368
412
|
except Exception as exc:
|
|
369
413
|
if original_dockerfile is not None:
|
|
370
414
|
_restore_dockerfile(dockerfile_path, original_dockerfile)
|
|
@@ -393,5 +437,6 @@ def pack(
|
|
|
393
437
|
"ssh_found_in_zip": bool(ssh_found_in_zip),
|
|
394
438
|
"ssh_suspicious": list(ssh_found_in_zip),
|
|
395
439
|
"file_count": file_count,
|
|
440
|
+
"stale_backups_skipped": len(stale),
|
|
396
441
|
"warnings": warnings,
|
|
397
442
|
}
|
|
@@ -20,7 +20,9 @@ import subprocess
|
|
|
20
20
|
import time
|
|
21
21
|
from pathlib import Path
|
|
22
22
|
|
|
23
|
-
from rocketdoo.core.compose import run_compose, run_compose_result
|
|
23
|
+
from rocketdoo.core.compose import compose_ls, run_compose, run_compose_result
|
|
24
|
+
from rocketdoo.core.mailpit import is_enabled as mailpit_is_enabled
|
|
25
|
+
from rocketdoo.core.pack import BACKUP_FILENAME
|
|
24
26
|
from rocketdoo.core.port_validation import find_available_port, is_port_in_use
|
|
25
27
|
from rocketdoo.core.project_info import project_exists, read_docker_compose
|
|
26
28
|
from rocketdoo.core.service import ProgressCallback, ServiceError, reporter
|
|
@@ -53,8 +55,13 @@ def _find_backup_files(project_dir: Path) -> tuple[Path | None, Path | None]:
|
|
|
53
55
|
if not backup_dir.exists():
|
|
54
56
|
return None, None
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
# Filtered by the same pattern pack writes, not by a looser glob: a file
|
|
59
|
+
# the user happens to keep here ("db_notes.dump") sorts by name like any
|
|
60
|
+
# other and could win the "newest" slot, sending pg_restore after a
|
|
61
|
+
# database that does not exist -- which also skips the filestore, since
|
|
62
|
+
# that step is nested under a successful restore.
|
|
63
|
+
dumps = sorted((p for p in backup_dir.glob("db_*.dump") if BACKUP_FILENAME.match(p.name)), reverse=True)
|
|
64
|
+
filestores = sorted((p for p in backup_dir.glob("filestore_*.tar.gz") if BACKUP_FILENAME.match(p.name)), reverse=True)
|
|
58
65
|
return (dumps[0] if dumps else None), (filestores[0] if filestores else None)
|
|
59
66
|
|
|
60
67
|
|
|
@@ -86,6 +93,17 @@ def _check_ports(meta: dict, auto_accept: bool = True) -> tuple[int, int, bool]:
|
|
|
86
93
|
def _update_ports_in_compose(project_dir: Path, new_odoo_port: int, new_vsc_port: int) -> None:
|
|
87
94
|
"""Rewrites only the two port mappings docker-compose.yaml carries for
|
|
88
95
|
Odoo and its debugger, in place, leaving the rest of the file untouched.
|
|
96
|
+
|
|
97
|
+
Bytes in, bytes out, because the text helpers translate newlines on both
|
|
98
|
+
sides. `read_text()` applies universal newlines and hands back a string
|
|
99
|
+
with every CRLF already collapsed to LF, so remapping one port in a
|
|
100
|
+
compose saved with CRLF - a Windows editor, or git's own core.autocrlf,
|
|
101
|
+
on a tool whose users are largely on WSL - rewrote every line in the file.
|
|
102
|
+
That is the half measured here. `write_text()` is the mirror image and
|
|
103
|
+
only bites on a host where os.linesep is CRLF, which is why reverting it
|
|
104
|
+
alone changes nothing on Linux and no test can pin it from here.
|
|
105
|
+
Line endings are not ours to change; #196 reached the same conclusion for
|
|
106
|
+
the generated workflows.
|
|
89
107
|
"""
|
|
90
108
|
compose_path = project_dir / "docker-compose.yaml"
|
|
91
109
|
if not compose_path.exists():
|
|
@@ -93,10 +111,212 @@ def _update_ports_in_compose(project_dir: Path, new_odoo_port: int, new_vsc_port
|
|
|
93
111
|
if not compose_path.exists():
|
|
94
112
|
return
|
|
95
113
|
|
|
96
|
-
content = compose_path.
|
|
114
|
+
content = compose_path.read_bytes().decode()
|
|
97
115
|
content = re.sub(r'"\d+:8069"', f'"{new_odoo_port}:8069"', content)
|
|
98
116
|
content = re.sub(r'"\d+:8888"', f'"{new_vsc_port}:8888"', content)
|
|
99
|
-
compose_path.
|
|
117
|
+
compose_path.write_bytes(content.encode())
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
# `\r?` because a compose saved with CRLF leaves one before the line end, and
|
|
121
|
+
# `[ \t]*$` does not match it: the name came back as None, so every CRLF
|
|
122
|
+
# compose looked like one without a `name:` and the whole conflict check
|
|
123
|
+
# quietly did nothing on it.
|
|
124
|
+
_PROJECT_NAME_LINE = re.compile(r"^name:[ \t]*(\S+)[ \t]*\r?$", re.MULTILINE)
|
|
125
|
+
_PROJECT_NAME_MAX_SUFFIX = 99
|
|
126
|
+
_VALID_PROJECT_NAME = re.compile(r"^[a-z0-9][a-z0-9_-]*$")
|
|
127
|
+
_MAILPIT_PORTS = (1025, 8025)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def _compose_file(project_dir: Path) -> Path | None:
|
|
131
|
+
for name in ("docker-compose.yaml", "docker-compose.yml"):
|
|
132
|
+
candidate = project_dir / name
|
|
133
|
+
if candidate.exists():
|
|
134
|
+
return candidate
|
|
135
|
+
return None
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def _compose_project_name(project_dir: Path) -> str | None:
|
|
139
|
+
"""Value of the top-level `name:` line, read as text so it is the same
|
|
140
|
+
expression that later rewrites it.
|
|
141
|
+
"""
|
|
142
|
+
compose_path = _compose_file(project_dir)
|
|
143
|
+
if compose_path is None:
|
|
144
|
+
return None
|
|
145
|
+
match = _PROJECT_NAME_LINE.search(compose_path.read_bytes().decode())
|
|
146
|
+
if not match:
|
|
147
|
+
return None
|
|
148
|
+
# YAML quotes are not part of the name. Read raw, `name: "demo"` came back
|
|
149
|
+
# as '"demo"', which never matched the manifest's parsed `demo`, so the
|
|
150
|
+
# copy was taken for one already renamed and the inventory was never
|
|
151
|
+
# consulted at all.
|
|
152
|
+
return match.group(1).strip("\"'") or None
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def _docker_inventory() -> dict:
|
|
156
|
+
"""{"ok": bool, "projects": {name: [config_files]}, "volumes": {name: project_label}}.
|
|
157
|
+
|
|
158
|
+
Any failure in either query yields `ok: False` with empty collections, so
|
|
159
|
+
a partial answer can never be read as "the name is free".
|
|
160
|
+
"""
|
|
161
|
+
failed = {"ok": False, "projects": {}, "volumes": {}}
|
|
162
|
+
|
|
163
|
+
entries, error = compose_ls("--all")
|
|
164
|
+
if error:
|
|
165
|
+
return failed
|
|
166
|
+
|
|
167
|
+
projects = {}
|
|
168
|
+
for entry in entries:
|
|
169
|
+
name = entry.get("Name")
|
|
170
|
+
if name:
|
|
171
|
+
files = str(entry.get("ConfigFiles") or "")
|
|
172
|
+
projects[name] = [f.strip() for f in files.split(",") if f.strip()]
|
|
173
|
+
|
|
174
|
+
try:
|
|
175
|
+
result = subprocess.run(
|
|
176
|
+
["docker", "volume", "ls", "--format", '{{.Name}}\t{{.Label "com.docker.compose.project"}}'],
|
|
177
|
+
capture_output=True,
|
|
178
|
+
text=True,
|
|
179
|
+
timeout=15,
|
|
180
|
+
)
|
|
181
|
+
except (OSError, subprocess.SubprocessError):
|
|
182
|
+
return failed
|
|
183
|
+
if result.returncode != 0:
|
|
184
|
+
return failed
|
|
185
|
+
|
|
186
|
+
volumes = {}
|
|
187
|
+
for line in result.stdout.splitlines():
|
|
188
|
+
name, _, label = line.partition("\t")
|
|
189
|
+
if name.strip():
|
|
190
|
+
volumes[name.strip()] = label.strip()
|
|
191
|
+
|
|
192
|
+
return {"ok": True, "projects": projects, "volumes": volumes}
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def _own_projects(root: Path, inventory: dict) -> set[str]:
|
|
196
|
+
"""Compose projects whose config file lives directly inside `root`."""
|
|
197
|
+
resolved = Path(root).resolve()
|
|
198
|
+
return {name for name, files in inventory["projects"].items() if any(Path(f).resolve().parent == resolved for f in files)}
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
def _name_taken_reason(name: str, own: set[str], inventory: dict) -> str:
|
|
202
|
+
"""Why `name` is already used by something that is not this copy, or ''."""
|
|
203
|
+
if name in inventory["projects"] and name not in own:
|
|
204
|
+
files = inventory["projects"][name]
|
|
205
|
+
where = f" in {Path(files[0]).parent}" if files else ""
|
|
206
|
+
return f"the Compose project '{name}' already exists{where}"
|
|
207
|
+
# Matched on the label, not on the volume's name. Compose names a project
|
|
208
|
+
# volume `{project}_{key}`, so a prefix test for `{name}-` never fires on a
|
|
209
|
+
# real one -- and this is the half that covers the case that actually
|
|
210
|
+
# destroys data: an original stopped with `rkd down` (no -v) is gone from
|
|
211
|
+
# `compose ls` but its volumes are still here, and a copy that reuses the
|
|
212
|
+
# project would mount them and let the restore DROP the original's
|
|
213
|
+
# database. The label is what Compose puts there to answer exactly this.
|
|
214
|
+
for volume, label in inventory["volumes"].items():
|
|
215
|
+
if label == name and label not in own:
|
|
216
|
+
return f"the Docker volume '{volume}' already belongs to the Compose project '{name}'"
|
|
217
|
+
return ""
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
def _resolve_project_name(root: Path, current: str | None, meta: dict, inventory: dict) -> dict:
|
|
221
|
+
"""Decide which Compose project name the copy should use. Writes nothing
|
|
222
|
+
and does not query Docker: the inventory is passed in.
|
|
223
|
+
"""
|
|
224
|
+
if current is None:
|
|
225
|
+
return {
|
|
226
|
+
"name": None,
|
|
227
|
+
"conflict": False,
|
|
228
|
+
"reason": "the compose file has no 'name:'; renaming only the containers would damage the other copy",
|
|
229
|
+
"renamable": False,
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
meta_name = (meta or {}).get("project_name")
|
|
233
|
+
if meta_name and meta_name != current:
|
|
234
|
+
return {"name": current, "conflict": False, "reason": "", "renamable": True}
|
|
235
|
+
|
|
236
|
+
if not inventory["ok"]:
|
|
237
|
+
return {
|
|
238
|
+
"name": current,
|
|
239
|
+
"conflict": None,
|
|
240
|
+
"reason": "Docker could not be queried, so name conflicts were not checked",
|
|
241
|
+
"renamable": True,
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
own = _own_projects(root, inventory)
|
|
245
|
+
reason = _name_taken_reason(current, own, inventory)
|
|
246
|
+
if not reason:
|
|
247
|
+
return {"name": current, "conflict": False, "reason": "", "renamable": True}
|
|
248
|
+
|
|
249
|
+
for suffix in range(2, _PROJECT_NAME_MAX_SUFFIX + 1):
|
|
250
|
+
candidate = f"{current}-{suffix}"
|
|
251
|
+
if not _name_taken_reason(candidate, own, inventory):
|
|
252
|
+
return {"name": candidate, "conflict": True, "reason": reason, "renamable": True}
|
|
253
|
+
|
|
254
|
+
return {
|
|
255
|
+
"name": current,
|
|
256
|
+
"conflict": True,
|
|
257
|
+
"reason": f"{reason}, and every name from '{current}-2' to '{current}-{_PROJECT_NAME_MAX_SUFFIX}' is taken too",
|
|
258
|
+
"renamable": True,
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
def _rename_project_in_compose(project_dir: Path, old: str, new: str) -> bool:
|
|
263
|
+
"""Rewrites the Compose identity (project name, image, container names and
|
|
264
|
+
named volumes) in place as text, line by line. PyYAML would drop the
|
|
265
|
+
`# rkd:mailpit` markers, and every line that is not identity must stay
|
|
266
|
+
byte for byte the same.
|
|
267
|
+
|
|
268
|
+
All or nothing. A compose whose top-level `name:` does not say `old` is
|
|
269
|
+
not renamed at all, not even its `container_name` lines: a copy that
|
|
270
|
+
renames only its containers while sharing the project name is the
|
|
271
|
+
destructive case, not a partial improvement on it. Compose then treats the
|
|
272
|
+
other copy's containers as this project's, recreates them and mounts its
|
|
273
|
+
volumes. Measured, not inferred. `unpack()` refuses the same case one
|
|
274
|
+
level up; this guard is here so no future caller can reach past it.
|
|
275
|
+
"""
|
|
276
|
+
compose_path = _compose_file(project_dir)
|
|
277
|
+
if compose_path is None:
|
|
278
|
+
return False
|
|
279
|
+
if _compose_project_name(project_dir) != old:
|
|
280
|
+
return False
|
|
281
|
+
|
|
282
|
+
token = re.compile(r"(?<![A-Za-z0-9_.])" + re.escape(old) + r"(?![A-Za-z0-9_.])")
|
|
283
|
+
value_line = re.compile(r"^(\s*#?\s*(?:-\s+)?(?:name|image):[ \t]*)(\S+)([ \t]*\r?\n?)$")
|
|
284
|
+
body_prefix = re.compile(r"^\s*#?\s*(?:-\s+)?")
|
|
285
|
+
|
|
286
|
+
original = compose_path.read_bytes().decode()
|
|
287
|
+
lines = []
|
|
288
|
+
for line in original.splitlines(keepends=True):
|
|
289
|
+
body = body_prefix.sub("", line)
|
|
290
|
+
if body.startswith(("name:", "image:")):
|
|
291
|
+
match = value_line.match(line)
|
|
292
|
+
if match and match.group(2) == old:
|
|
293
|
+
line = f"{match.group(1)}{new}{match.group(3)}"
|
|
294
|
+
elif body.startswith("container_name:") or body.startswith(f"{old}-"):
|
|
295
|
+
line = token.sub(new, line)
|
|
296
|
+
lines.append(line)
|
|
297
|
+
|
|
298
|
+
updated = "".join(lines)
|
|
299
|
+
if updated == original:
|
|
300
|
+
return False
|
|
301
|
+
compose_path.write_bytes(updated.encode())
|
|
302
|
+
return True
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
def _update_db_host_in_conf(project_dir: Path, old_host: str, new_host: str) -> bool:
|
|
306
|
+
"""Points `db_host` at the renamed database container, but only when it
|
|
307
|
+
still holds the old container name: `db` or an external host is the
|
|
308
|
+
user's, not ours.
|
|
309
|
+
"""
|
|
310
|
+
conf_path = project_dir / "config" / "odoo.conf"
|
|
311
|
+
if not conf_path.exists():
|
|
312
|
+
return False
|
|
313
|
+
pattern = re.compile(r"^(db_host\s*=\s*)" + re.escape(old_host) + r"([ \t]*\r?)$", re.MULTILINE)
|
|
314
|
+
original = conf_path.read_bytes().decode()
|
|
315
|
+
updated = pattern.sub(lambda m: f"{m.group(1)}{new_host}{m.group(2)}", original)
|
|
316
|
+
if updated == original:
|
|
317
|
+
return False
|
|
318
|
+
conf_path.write_bytes(updated.encode())
|
|
319
|
+
return True
|
|
100
320
|
|
|
101
321
|
|
|
102
322
|
def _get_db_container_name(project_dir: Path) -> str | None:
|
|
@@ -456,6 +676,10 @@ def inspect(project_root: Path | str | None = None) -> dict:
|
|
|
456
676
|
|
|
457
677
|
dump, filestore = _find_backup_files(root)
|
|
458
678
|
|
|
679
|
+
current_name = _compose_project_name(root)
|
|
680
|
+
inventory = _docker_inventory() if current_name else {"ok": False, "projects": {}, "volumes": {}}
|
|
681
|
+
resolved = _resolve_project_name(root, current_name, meta, inventory)
|
|
682
|
+
|
|
459
683
|
return {
|
|
460
684
|
"meta": raw_meta,
|
|
461
685
|
"has_meta": has_meta,
|
|
@@ -473,6 +697,14 @@ def inspect(project_root: Path | str | None = None) -> dict:
|
|
|
473
697
|
},
|
|
474
698
|
"uses_private_repos": bool(meta.get("uses_private_repos")),
|
|
475
699
|
"ssh_keys": list_private_keys(),
|
|
700
|
+
"project": {
|
|
701
|
+
"name": current_name,
|
|
702
|
+
"suggested_name": resolved["name"],
|
|
703
|
+
"conflict": resolved["conflict"],
|
|
704
|
+
"reason": resolved["reason"],
|
|
705
|
+
"renamable": resolved["renamable"],
|
|
706
|
+
},
|
|
707
|
+
"mailpit_port_conflict": mailpit_is_enabled(root) and any(is_port_in_use(p) for p in _MAILPIT_PORTS),
|
|
476
708
|
}
|
|
477
709
|
|
|
478
710
|
|
|
@@ -483,6 +715,7 @@ def unpack(
|
|
|
483
715
|
project_root: Path | str,
|
|
484
716
|
*,
|
|
485
717
|
ports: dict | None = None,
|
|
718
|
+
project_name: str | None = None,
|
|
486
719
|
ssh_key: str | None = None,
|
|
487
720
|
restore: bool = True,
|
|
488
721
|
build: bool = False,
|
|
@@ -491,7 +724,8 @@ def unpack(
|
|
|
491
724
|
"""Starts a previously packed environment.
|
|
492
725
|
|
|
493
726
|
Never prompts (RF9.2): `ports` and `ssh_key` arrive already decided by
|
|
494
|
-
the caller
|
|
727
|
+
the caller (`project_name` too: the Compose project name the copy should
|
|
728
|
+
take, or None to keep the one in the compose). When a database backup is present and `restore` is True, the
|
|
495
729
|
database and filestore are restored before the full environment starts;
|
|
496
730
|
`restore=False` (`--no-restore`) skips that whole branch even when a
|
|
497
731
|
backup exists, since a step failing mid-restore must never look like it
|
|
@@ -506,6 +740,12 @@ def unpack(
|
|
|
506
740
|
"Make sure you are inside the unzipped environment directory.",
|
|
507
741
|
)
|
|
508
742
|
|
|
743
|
+
if project_name is not None and not _VALID_PROJECT_NAME.match(project_name):
|
|
744
|
+
raise UnpackError(
|
|
745
|
+
f"'{project_name}' is not a valid Compose project name.",
|
|
746
|
+
"Use lowercase letters, digits, '-' and '_', starting with a letter or digit.",
|
|
747
|
+
)
|
|
748
|
+
|
|
509
749
|
meta = _effective_meta(_load_shared_meta(root) or {})
|
|
510
750
|
original_odoo_port = int(meta.get("odoo_port") or 8069)
|
|
511
751
|
original_vsc_port = int(meta.get("vsc_port") or 8888)
|
|
@@ -514,11 +754,41 @@ def unpack(
|
|
|
514
754
|
vsc_port = int(ports.get("vsc_port", original_vsc_port))
|
|
515
755
|
ports_changed = odoo_port != original_odoo_port or vsc_port != original_vsc_port
|
|
516
756
|
|
|
757
|
+
warnings: list[str] = []
|
|
758
|
+
|
|
517
759
|
if ports_changed:
|
|
518
760
|
_update_ports_in_compose(root, odoo_port, vsc_port)
|
|
519
761
|
report("docker-compose.yaml updated with new ports.", "ok")
|
|
520
762
|
|
|
521
|
-
|
|
763
|
+
current_name = _compose_project_name(root)
|
|
764
|
+
renamed_from = None
|
|
765
|
+
if project_name and current_name is None:
|
|
766
|
+
message = "The compose file has no 'name:', so the project was not renamed."
|
|
767
|
+
report(message, "warn")
|
|
768
|
+
warnings.append(message)
|
|
769
|
+
elif project_name and project_name != current_name:
|
|
770
|
+
old_db_host = _get_db_container_name(root)
|
|
771
|
+
if _rename_project_in_compose(root, current_name, project_name):
|
|
772
|
+
renamed_from = current_name
|
|
773
|
+
report(f"Compose project renamed from '{current_name}' to '{project_name}'.", "ok")
|
|
774
|
+
new_db_host = _get_db_container_name(root)
|
|
775
|
+
if old_db_host and new_db_host:
|
|
776
|
+
if _update_db_host_in_conf(root, old_db_host, new_db_host):
|
|
777
|
+
report(f"config/odoo.conf db_host updated to {new_db_host}.", "ok")
|
|
778
|
+
else:
|
|
779
|
+
message = "Could not read the renamed database container name; check db_host in config/odoo.conf."
|
|
780
|
+
report(message, "warn")
|
|
781
|
+
warnings.append(message)
|
|
782
|
+
leftovers = []
|
|
783
|
+
if (root / "docker-compose.override.yml").exists():
|
|
784
|
+
leftovers.append(
|
|
785
|
+
"docker-compose.override.yml still carries the Traefik labels of the original copy; review them."
|
|
786
|
+
)
|
|
787
|
+
if mailpit_is_enabled(root):
|
|
788
|
+
leftovers.append("Mailpit is enabled: ports 1025 and 8025 are not remapped and may clash with the other copy.")
|
|
789
|
+
for message in leftovers:
|
|
790
|
+
report(message, "warn")
|
|
791
|
+
warnings.append(message)
|
|
522
792
|
|
|
523
793
|
ssh_configured = False
|
|
524
794
|
if ssh_key:
|
|
@@ -535,6 +805,23 @@ def unpack(
|
|
|
535
805
|
warnings.append(message)
|
|
536
806
|
|
|
537
807
|
db_dump, filestore_tar = _find_backup_files(root)
|
|
808
|
+
if db_dump is not None and meta.get("has_db_backup") is False:
|
|
809
|
+
# The manifest states this environment was packed without a database,
|
|
810
|
+
# so the dump under rkd_backups/ is left over from an earlier pack of
|
|
811
|
+
# the same project and restoring it would hand the recipient data the
|
|
812
|
+
# sender never meant to send (#225). Packs from 3.8.1 on no longer
|
|
813
|
+
# ship it; this covers the ZIPs already in circulation.
|
|
814
|
+
#
|
|
815
|
+
# Only an explicit False counts. A manifest without the key is older
|
|
816
|
+
# or hand-made and has no opinion, and there the dump is trusted.
|
|
817
|
+
message = (
|
|
818
|
+
f"The manifest says this environment was packed without a database, so {db_dump.name} "
|
|
819
|
+
"is left over from an earlier pack and is not restored. Restore it by hand if you meant to receive it."
|
|
820
|
+
)
|
|
821
|
+
report(message, "warn")
|
|
822
|
+
warnings.append(message)
|
|
823
|
+
db_dump = None
|
|
824
|
+
|
|
538
825
|
db_restored = False
|
|
539
826
|
filestore_restored = False
|
|
540
827
|
|
|
@@ -590,6 +877,9 @@ def unpack(
|
|
|
590
877
|
return {
|
|
591
878
|
"ports": {"odoo_port": odoo_port, "vsc_port": vsc_port},
|
|
592
879
|
"ports_changed": ports_changed,
|
|
880
|
+
"project_name": _compose_project_name(root),
|
|
881
|
+
"project_renamed": renamed_from is not None,
|
|
882
|
+
"renamed_from": renamed_from,
|
|
593
883
|
"ssh_configured": ssh_configured,
|
|
594
884
|
"db_restored": db_restored,
|
|
595
885
|
"filestore_restored": filestore_restored,
|
|
@@ -37,6 +37,7 @@ def unpack_info():
|
|
|
37
37
|
return {
|
|
38
38
|
"meta": info["meta"],
|
|
39
39
|
"ssh_keys": info["ssh_keys"],
|
|
40
|
+
"project": info["project"],
|
|
40
41
|
# Plain existence, like /status reports it: the SPA gates the unpack
|
|
41
42
|
# button on that endpoint's flag, and two answers to the same
|
|
42
43
|
# question under the same key is a trap. `meta` already comes back
|
|
@@ -105,7 +106,7 @@ def unpack(body: UnpackRequest = UnpackRequest()):
|
|
|
105
106
|
Calls core.unpack.unpack() directly instead of shelling out to `rkd
|
|
106
107
|
unpack` (#143 T13), for the same reason `pack` above does: a `def` here
|
|
107
108
|
runs in FastAPI's threadpool, so a restore that takes minutes never
|
|
108
|
-
blocks the event loop. Port conflicts are auto-accepted -- the same
|
|
109
|
+
blocks the event loop. Port and project-name conflicts are auto-accepted -- the same
|
|
109
110
|
behaviour `--yes` gives the CLI -- since there is no terminal here to ask.
|
|
110
111
|
"""
|
|
111
112
|
info = core_unpack.inspect(Path.cwd())
|
|
@@ -118,6 +119,11 @@ def unpack(body: UnpackRequest = UnpackRequest()):
|
|
|
118
119
|
report = core_unpack.unpack(
|
|
119
120
|
Path.cwd(),
|
|
120
121
|
ports=info["suggested_ports"],
|
|
122
|
+
# Only when there is a conflict, like the CLI. Without one the
|
|
123
|
+
# suggestion IS the current name, and passing it put every unpack
|
|
124
|
+
# through the name validation -- so a compose whose `name:` the
|
|
125
|
+
# validator rejects stopped restoring at all.
|
|
126
|
+
project_name=(info["project"]["suggested_name"] if info["project"]["conflict"] else None),
|
|
121
127
|
ssh_key=body.ssh_key if body.use_ssh else None,
|
|
122
128
|
on_progress=_collect,
|
|
123
129
|
)
|