|
46 | 46 | MSG_ERR_LIVE: str = 'The system is in live-boot mode. Please use "install image" instead.'
|
47 | 47 | MSG_ERR_NO_DISK: str = 'No suitable disk was found. There must be at least one disk of 2GB or greater size.'
|
48 | 48 | MSG_ERR_IMPROPER_IMAGE: str = 'Missing sha256sum.txt.\nEither this image is corrupted, or of era 1.2.x (md5sum) and would downgrade image tools;\ndisallowed in either case.'
|
49 |
| -MSG_ERR_ARCHITECTURE_MISMATCH: str = 'Upgrading to a different image architecture will break your system.' |
| 49 | +MSG_ERR_INCOMPATIBLE_IMAGE: str = 'Image compatibility check failed, aborting installation.' |
| 50 | +MSG_ERR_ARCHITECTURE_MISMATCH: str = 'The current architecture is "{0}", the new image is for "{1}". Upgrading to a different image architecture will break your system.' |
50 | 51 | MSG_ERR_FLAVOR_MISMATCH: str = 'The current image flavor is "{0}", the new image is "{1}". Upgrading to a non-matching flavor can have unpredictable consequences.'
|
| 52 | +MSG_ERR_MISSING_ARCHITECTURE: str = 'The new image version data does not specify architecture, cannot check compatibility (is it a legacy release image?)' |
| 53 | +MSG_ERR_MISSING_FLAVOR: str = 'The new image version data does not specify flavor, cannot check compatibility (is it a legacy release image?)' |
| 54 | +MSG_ERR_CORRUPT_CURRENT_IMAGE: str = 'Version data in the current image is malformed: missing flavor and/or architecture fields. Upgrade compatibility cannot be checked.' |
51 | 55 | MSG_INFO_INSTALL_WELCOME: str = 'Welcome to VyOS installation!\nThis command will install VyOS to your permanent storage.'
|
52 | 56 | MSG_INFO_INSTALL_EXIT: str = 'Exiting from VyOS installation'
|
53 | 57 | MSG_INFO_INSTALL_SUCCESS: str = 'The image installed successfully; please reboot now.'
|
@@ -707,25 +711,42 @@ def validate_compatibility(iso_path: str) -> None:
|
707 | 711 | Args:
|
708 | 712 | iso_path (str): a path to the mounted ISO image
|
709 | 713 | """
|
710 |
| - old_data = get_version_data() |
711 |
| - old_flavor = old_data.get('flavor', '') |
712 |
| - old_architecture = old_data.get('architecture') or cmd('dpkg --print-architecture') |
| 714 | + current_data = get_version_data() |
| 715 | + current_flavor = current_data.get('flavor') |
| 716 | + current_architecture = current_data.get('architecture') or cmd('dpkg --print-architecture') |
713 | 717 |
|
714 | 718 | new_data = get_version_data(f'{iso_path}/version.json')
|
715 |
| - new_flavor = new_data.get('flavor', '') |
716 |
| - new_architecture = new_data.get('architecture', '') |
| 719 | + new_flavor = new_data.get('flavor') |
| 720 | + new_architecture = new_data.get('architecture') |
717 | 721 |
|
718 |
| - if not old_architecture == new_architecture: |
719 |
| - print(MSG_ERR_ARCHITECTURE_MISMATCH) |
| 722 | + if not current_flavor or not current_architecture: |
| 723 | + # This may only happen if someone modified the version file. |
| 724 | + # Unlikely but not impossible. |
| 725 | + print(MSG_ERR_CORRUPT_CURRENT_IMAGE) |
720 | 726 | cleanup()
|
721 | 727 | exit(MSG_INFO_INSTALL_EXIT)
|
722 | 728 |
|
723 |
| - if not old_flavor == new_flavor: |
724 |
| - print(MSG_ERR_FLAVOR_MISMATCH.format(old_flavor, new_flavor)) |
| 729 | + success = True |
| 730 | + |
| 731 | + if current_architecture != new_architecture: |
| 732 | + success = False |
| 733 | + if not new_architecture: |
| 734 | + print(MSG_ERR_MISSING_ARCHITECTURE) |
| 735 | + else: |
| 736 | + print(MSG_ERR_ARCHITECTURE_MISMATCH.format(current_architecture, new_architecture)) |
| 737 | + |
| 738 | + if current_flavor != new_flavor: |
| 739 | + success = False |
| 740 | + if not new_flavor: |
| 741 | + print(MSG_ERR_MISSING_FLAVOR) |
| 742 | + else: |
| 743 | + print(MSG_ERR_FLAVOR_MISMATCH.format(current_flavor, new_flavor)) |
| 744 | + |
| 745 | + if not success: |
| 746 | + print(MSG_ERR_INCOMPATIBLE_IMAGE) |
725 | 747 | cleanup()
|
726 | 748 | exit(MSG_INFO_INSTALL_EXIT)
|
727 | 749 |
|
728 |
| - |
729 | 750 | def install_image() -> None:
|
730 | 751 | """Install an image to a disk
|
731 | 752 | """
|
|
0 commit comments