-
Notifications
You must be signed in to change notification settings - Fork 185
add clang and ubuntu versions warnings #502
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -45,11 +45,14 @@ | |||||||
| from mytonctrl.console_cmd import add_command, check_usage_one_arg, check_usage_args_min_max_len | ||||||||
| from mytonctrl.migrate import run_migrations | ||||||||
| from mytonctrl.utils import GetItemFromList, timestamp2utcdatetime, fix_git_config, is_hex, GetColorInt, \ | ||||||||
| pop_user_from_args, pop_arg_from_args | ||||||||
| pop_user_from_args, pop_arg_from_args, get_clang_major_version, get_os_version | ||||||||
| from mytoninstaller.archive_blocks import download_blocks | ||||||||
| from mytoninstaller.utils import get_ton_storage_port | ||||||||
|
|
||||||||
|
|
||||||||
| CLANG_VERSION_REQUIRED = 21 | ||||||||
|
|
||||||||
|
|
||||||||
| def Init(local, ton, console, argv): | ||||||||
| # Load translate table | ||||||||
| with get_package_resource_path('mytonctrl', 'resources/translate.json') as translate_path: | ||||||||
|
|
@@ -370,8 +373,8 @@ def Upgrade(local, ton, args: list): | |||||||
| ton.SetSettings("validatorConsole", validatorConsole) | ||||||||
|
|
||||||||
| clang_version = get_clang_major_version() | ||||||||
| if clang_version is None or clang_version < 16: | ||||||||
| text = f"{{red}}WARNING: THIS UPGRADE WILL MOST PROBABLY FAIL DUE TO A WRONG CLANG VERSION: {clang_version}, REQUIRED VERSION IS 16. RECOMMENDED TO EXIT NOW AND UPGRADE CLANG AS PER INSTRUCTIONS: https://gist.github.com/neodix42/e4b1b68d2d5dd3dec75b5221657f05d7{{endc}}\n" | ||||||||
| if clang_version is None or clang_version < CLANG_VERSION_REQUIRED: | ||||||||
| text = f"{{red}}WARNING: THIS UPGRADE WILL MOST PROBABLY FAIL DUE TO A WRONG CLANG VERSION: {clang_version}, REQUIRED VERSION IS {CLANG_VERSION_REQUIRED}. RECOMMENDED TO EXIT NOW AND UPGRADE CLANG AS PER INSTRUCTIONS: https://gist.github.com/neodix42/24d6a401e928f7e895fcc8e7b7c5c24a{{endc}}\n" | ||||||||
| color_print(text) | ||||||||
| if input("Continue with upgrade anyway? [Y/n]\n").strip().lower() not in ('y', ''): | ||||||||
| print('aborted.') | ||||||||
|
|
@@ -400,37 +403,6 @@ def upgrade_btc_teleport(local, ton, reinstall=False, branch: str = 'master', us | |||||||
| local.try_function(module.init, args=[reinstall, branch, user]) | ||||||||
|
|
||||||||
|
|
||||||||
| def get_clang_major_version(): | ||||||||
| try: | ||||||||
| process = subprocess.run(["clang", "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, | ||||||||
| text=True, timeout=3) | ||||||||
| if process.returncode != 0: | ||||||||
| return None | ||||||||
|
|
||||||||
| output = process.stdout | ||||||||
|
|
||||||||
| lines = output.strip().split('\n') | ||||||||
| if not lines: | ||||||||
| return None | ||||||||
|
|
||||||||
| first_line = lines[0] | ||||||||
| if "clang version" not in first_line: | ||||||||
| return None | ||||||||
|
|
||||||||
| version_part = first_line.split("clang version")[1].strip() | ||||||||
| major_version = version_part.split('.')[0] | ||||||||
|
|
||||||||
| major_version = ''.join(c for c in major_version if c.isdigit()) | ||||||||
|
|
||||||||
| if not major_version: | ||||||||
| return None | ||||||||
|
|
||||||||
| return int(major_version) | ||||||||
| except Exception as e: | ||||||||
| print(f"Error checking clang version: {type(e)}: {e}") | ||||||||
| return None | ||||||||
|
|
||||||||
|
|
||||||||
| def rollback_to_mtc1(local, ton, args): | ||||||||
| color_print("{red}Warning: this is dangerous, please make sure you've backed up mytoncore's db.{endc}") | ||||||||
| a = input("Do you want to continue? [Y/n]\n") | ||||||||
|
|
@@ -555,16 +527,22 @@ def check_adnl(local, ton): | |||||||
| print_warning(local, error) | ||||||||
| #end define | ||||||||
|
|
||||||||
| def warnings(local, ton): | ||||||||
| def check_ubuntu_version(local: MyPyClass): | ||||||||
| distro, ver = get_os_version() | ||||||||
| if distro == 'ubuntu': | ||||||||
| if ver not in ['22.04', '24.04']: | ||||||||
| warning = local.translate("ubuntu_version_warning").format(ver) | ||||||||
| print_warning(local, warning) | ||||||||
|
|
||||||||
| def warnings(local: MyPyClass, ton: MyTonCore): | ||||||||
| local.try_function(check_disk_usage, args=[local, ton]) | ||||||||
| local.try_function(check_sync, args=[local, ton]) | ||||||||
| local.try_function(check_adnl, args=[local, ton]) | ||||||||
| local.try_function(check_validator_balance, args=[local, ton]) | ||||||||
| local.try_function(check_vps, args=[local, ton]) | ||||||||
| local.try_function(check_tg_channel, args=[local, ton]) | ||||||||
| local.try_function(check_slashed, args=[local, ton]) | ||||||||
| #end define | ||||||||
|
|
||||||||
| local.try_function(check_ubuntu_version, args=[local]) | ||||||||
|
||||||||
| local.try_function(check_ubuntu_version, args=[local]) | |
| local.try_function(check_ubuntu_version, args=[local]) | |
| #end define |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| from pytest_mock import MockerFixture | ||
|
|
||
| from mytonctrl import mytonctrl | ||
|
|
||
|
|
||
| def test_warnings(cli, monkeypatch, mocker: MockerFixture): | ||
| monkeypatch.setattr(mytonctrl, 'CheckMytonctrlUpdate', lambda *_: None) | ||
| monkeypatch.setattr(mytonctrl, 'check_installer_user', lambda *_: None) | ||
| monkeypatch.setattr(mytonctrl, 'check_vport', lambda *_: None) | ||
|
|
||
| # test check_ubuntu_version | ||
|
|
||
| monkeypatch.setattr(mytonctrl.os.path, 'exists', lambda _: True) | ||
| res = ''' | ||
| PRETTY_NAME="Ubuntu 22.04.4 LTS" | ||
| NAME="Ubuntu" | ||
| VERSION_ID="22.04" | ||
| VERSION="22.04.4 LTS (Jammy Jellyfish)" | ||
| VERSION_CODENAME=jammy | ||
| ID=ubuntu | ||
| ''' | ||
| mock = mocker.mock_open(read_data=res) | ||
| monkeypatch.setattr('builtins.open', mock) | ||
| output = cli.run_pre_up() | ||
| assert 'Ubuntu' not in output | ||
|
|
||
| monkeypatch.setattr(mytonctrl.os.path, 'exists', lambda _: True) | ||
| res = ''' | ||
| PRETTY_NAME="Ubuntu 24.04.4 LTS" | ||
| NAME="Ubuntu" | ||
| VERSION_ID="24.04" | ||
| VERSION="24.04.3 LTS (Noble Numbat)" | ||
| VERSION_CODENAME=noble | ||
| ID=ubuntu | ||
| ''' | ||
| mock = mocker.mock_open(read_data=res) | ||
| monkeypatch.setattr('builtins.open', mock) | ||
| output = cli.run_pre_up() | ||
| assert 'Ubuntu' not in output | ||
|
|
||
| res = ''' | ||
| PRETTY_NAME="Ubuntu 20.04.4 LTS" | ||
| NAME="Ubuntu" | ||
| VERSION_ID="20.04" | ||
| VERSION="20.04.4 LTS (Focal Fossa)" | ||
| VERSION_CODENAME=focal | ||
| ID=ubuntu | ||
| ''' | ||
| mock = mocker.mock_open(read_data=res) | ||
| monkeypatch.setattr('builtins.open', mock) | ||
| output = cli.run_pre_up() | ||
| assert 'Ubuntu version must be 22.04 or 24.04. Found 20.04.' in output | ||
|
|
||
| res = ''' | ||
| PRETTY_NAME="Debian GNU/Linux 12 (bookworm)" | ||
| NAME="Debian GNU/Linux" | ||
| VERSION_ID="12" | ||
| VERSION="12 (bookworm)" | ||
| VERSION_CODENAME=bookworm | ||
| ID=debian | ||
| ''' | ||
| mock = mocker.mock_open(read_data=res) | ||
| monkeypatch.setattr('builtins.open', mock) | ||
| output = cli.run_pre_up() | ||
| assert 'Ubuntu' not in output | ||
|
|
||
| # todo: other warnings |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The 'check_ubuntu_version' function is missing an #end define comment that is used consistently throughout the rest of the file. For consistency, it should be added.