-
Notifications
You must be signed in to change notification settings - Fork 8
Improve convert #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Improve convert #83
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| otools-convert: give better instructions of what is left to do after the conversion has run |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| otools-conversion: handle the conversion of the ADDONS_PATH environment variable in Dockerfile |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,17 +17,6 @@ | |||||||||||||||||||||||
| import sys | ||||||||||||||||||||||||
| from dataclasses import dataclass | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||
| import odoorpc | ||||||||||||||||||||||||
| except ImportError: | ||||||||||||||||||||||||
| print( | ||||||||||||||||||||||||
| "WARNING: odoorpc is not available, you will not be able to fetch " | ||||||||||||||||||||||||
| "the list of installed modules from a running instance. " | ||||||||||||||||||||||||
| "To fix this, run `pip install odoorpc`.", | ||||||||||||||||||||||||
| file=sys.stderr, | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
| odoorpc = None | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| from ..config import get_conf_key | ||||||||||||||||||||||||
| from ..utils.path import root_path | ||||||||||||||||||||||||
| from ..utils.proj import get_current_version | ||||||||||||||||||||||||
|
|
@@ -62,16 +51,16 @@ def generate_report(): | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| 1. check the diff between Dockerfile and Dockerfile.bak. | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| * update the ADDONS_PATH environment variable (`odoo/src` and | ||||||||||||||||||||||||
| `odoo/external-src/enterprise` have moved, | ||||||||||||||||||||||||
| `odoo-cloud-platform` must be removed) | ||||||||||||||||||||||||
| * check the ADDONS_PATH environment variable: the paths have changed and the script may not know of | ||||||||||||||||||||||||
| the specificities of your project (esp. paid addons) | ||||||||||||||||||||||||
| * check other environment variables which could have been set | ||||||||||||||||||||||||
| * check the differences introduced by an ongoing migration process | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| meld Dockerfile Dockerfile.bak | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| 2. check the diff between docker-compose.yml and docker-compose.yml.bak | ||||||||||||||||||||||||
| 2. check the diff between docker-compose.yml and docker-compose.yml.bak and restore any customizations | ||||||||||||||||||||||||
| you could have done (environment variables...) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| meld docker-compose.yml docker-compose.yml.bak | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
@@ -82,7 +71,18 @@ def generate_report(): | |||||||||||||||||||||||
| files for these that are placed in patches/odoo and patches/enterprise/ | ||||||||||||||||||||||||
| respectively. They will be processed by alphabetical order. | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| 5. run `docker build .` and fix any build issues | ||||||||||||||||||||||||
| * if you have patch files in the `patches/` directory that don't match any pending merge in | ||||||||||||||||||||||||
| `pending-merges.d/src.yml` or `pending-merges.d/enterprise.yml`, remove them | ||||||||||||||||||||||||
| * if you have pending merges in `pending-merges.d/src.yml` (resp. `pending-merges.d/enterprise.yml`) | ||||||||||||||||||||||||
| and you have the matching patch files in the `patches/` directory, move the patch files to `patches/odoo/` | ||||||||||||||||||||||||
| (resp. `patches/enterprise/`) | ||||||||||||||||||||||||
| * if you have pending merges in `pending-merges.d/src.yml` (resp. `pending-merges.d/enterprise.yml`) | ||||||||||||||||||||||||
| but you don't have the matching patch files in the `patches/`, you can regenerate them with | ||||||||||||||||||||||||
| `otools-pending add <url-to-commit>` | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| 5. run `docker build .` and fix any build issues. The base Python version may have changed, so you | ||||||||||||||||||||||||
| could need to update the version of some dependencies that were frozen to be compatible with Python 3.9 | ||||||||||||||||||||||||
| for instance. | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| 6. configure github actions on your repository -> see | ||||||||||||||||||||||||
| https://confluence.camptocamp.com/confluence/display/DEV/How+to+deploy+Github+Actions+on+odoo+projects | ||||||||||||||||||||||||
|
|
@@ -281,9 +281,52 @@ def remove_files(): | |||||||||||||||||||||||
| raise ValueError(f"unexpected file {name}. Is it a symlink?") | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| def convert_env_lines(old_env_lines): | ||||||||||||||||||||||||
| new_env_lines = [] | ||||||||||||||||||||||||
| for line in old_env_lines: | ||||||||||||||||||||||||
| new_line = ( | ||||||||||||||||||||||||
| line.replace( | ||||||||||||||||||||||||
| "/odoo/src/addons", "/odoo/src/odoo/odoo/addons, /odoo/src/odoo/addons" | ||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The replace seems strange. I may be missing something. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there is 1 directory in the "old style" image, and I had to replace it with the 2 addons directories of Odoo ( |
||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
| .replace("/odoo/external-src/paid-modules", "/odoo/odoo/paid-modules") | ||||||||||||||||||||||||
| .replace("/odoo/external-src/enterprise", "/odoo/src/enterprise") | ||||||||||||||||||||||||
| .replace("/odoo/external-src", "/odoo/odoo/external-src") | ||||||||||||||||||||||||
| .replace("/odoo/local-src", "/odoo/odoo/addons") | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
| if "odoo-cloud-platform" in new_line: | ||||||||||||||||||||||||
| continue | ||||||||||||||||||||||||
| new_env_lines.append(new_line) | ||||||||||||||||||||||||
| return new_env_lines | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| def copy_dockerfile(): | ||||||||||||||||||||||||
| shutil.move("odoo/Dockerfile", "Dockerfile.bak") | ||||||||||||||||||||||||
| old_env_lines = [] | ||||||||||||||||||||||||
| with open("Dockerfile.bak") as old_dockerfile: | ||||||||||||||||||||||||
| found_env = False | ||||||||||||||||||||||||
| for line in old_dockerfile: | ||||||||||||||||||||||||
|
Comment on lines
303
to
+307
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now pathlib is mandatory for this repo.
Suggested change
|
||||||||||||||||||||||||
| if line.strip().startswith("ENV ADDONS"): | ||||||||||||||||||||||||
| found_env = True | ||||||||||||||||||||||||
| if found_env: | ||||||||||||||||||||||||
| old_env_lines.append(line) | ||||||||||||||||||||||||
| if not line.strip().endswith("\\"): | ||||||||||||||||||||||||
| found_env = False | ||||||||||||||||||||||||
| subprocess.run(["git", "rm", "-f", "odoo/Dockerfile"], check=False) | ||||||||||||||||||||||||
| new_env_lines = convert_env_lines(old_env_lines) | ||||||||||||||||||||||||
| new_docker_file_lines = [] | ||||||||||||||||||||||||
| with open("Dockerfile") as new_dockerfile: | ||||||||||||||||||||||||
| found_env = False | ||||||||||||||||||||||||
| for line in new_dockerfile: | ||||||||||||||||||||||||
|
Comment on lines
+317
to
+319
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||
| if line.strip().startswith("ENV ADDONS"): | ||||||||||||||||||||||||
| found_env = True | ||||||||||||||||||||||||
| new_docker_file_lines += new_env_lines | ||||||||||||||||||||||||
| if found_env: | ||||||||||||||||||||||||
| if not line.strip().endswith("\\"): | ||||||||||||||||||||||||
| found_env = False | ||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||
| new_docker_file_lines.append(line) | ||||||||||||||||||||||||
| with open("Dockerfile", "w") as new_dockerfile: | ||||||||||||||||||||||||
| new_dockerfile.writelines(new_docker_file_lines) | ||||||||||||||||||||||||
|
Comment on lines
+328
to
+329
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| def parse_args(): | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/odoo/src/odoo/odoo/addonsI don't remember seeing it. It exists or is it a typo?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's the path of the base addons. Not sure why I had issues without this. I'll double check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/odoo/src/addons+/odoo/src/odoo/addonsshould be enough IMO, the other one doesn't exist