Fixes for prev PR (#2175)

* Fixes for prev PR

* Update

---------

Co-authored-by: Daniel Girtler <girtler.daniel@gmail.com>
This commit is contained in:
Daniel Girtler 2023-10-18 16:57:44 +11:00 committed by GitHub
parent 8117c0eed8
commit ce9828c293
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 56 deletions

View File

@ -89,6 +89,8 @@ def define_arguments():
parser.add_argument("--no-pkg-lookups", action="store_true", default=False,
help="Disabled package validation specifically prior to starting installation.")
parser.add_argument("--plugin", nargs="?", type=str)
parser.add_argument("--skip-version-check", action="store_true",
help="Skip the version check when running archinstall")
def parse_unspecified_argument_list(unknowns: list, multiple: bool = False, err: bool = False) -> dict:
@ -280,8 +282,20 @@ def plugin(f, *args, **kwargs):
def _check_new_version():
info("Checking version...")
Pacman.run("-Sy")
upgrade = Pacman.run("-Qu archinstall").decode()
try:
Pacman.run("-Sy")
except Exception as e:
debug(f'Failed to perform version check: {e}')
info(f'Arch Linux mirrors are not reachable. Please check your internet connection')
exit(1)
upgrade = None
try:
upgrade = Pacman.run("-Qu archinstall").decode()
except Exception as e:
debug(f'Failed determine pacman version: {e}')
if upgrade:
text = f'New version available: {upgrade}'
@ -295,7 +309,8 @@ def main():
OR straight as a module: python -m archinstall
In any case we will be attempting to load the provided script to be run from the scripts/ folder
"""
_check_new_version()
if not arguments.get('skip_version_check', False):
_check_new_version()
script = arguments.get('script', None)

View File

@ -4,19 +4,19 @@ if TYPE_CHECKING:
from .general import SysCommandWorker
class RequirementError(BaseException):
class RequirementError(Exception):
pass
class DiskError(BaseException):
class DiskError(Exception):
pass
class UnknownFilesystemFormat(BaseException):
class UnknownFilesystemFormat(Exception):
pass
class SysCallError(BaseException):
class SysCallError(Exception):
def __init__(self, message :str, exit_code :Optional[int] = None, worker :Optional['SysCommandWorker'] = None) -> None:
super(SysCallError, self).__init__(message)
self.message = message
@ -24,17 +24,17 @@ class SysCallError(BaseException):
self.worker = worker
class HardwareIncompatibilityError(BaseException):
class HardwareIncompatibilityError(Exception):
pass
class ServiceException(BaseException):
class ServiceException(Exception):
pass
class PackageError(BaseException):
class PackageError(Exception):
pass
class Deprecated(BaseException):
class Deprecated(Exception):
pass

View File

@ -8,7 +8,7 @@ from urllib.parse import urlencode
from urllib.request import urlopen
from .exceptions import SysCallError
from .output import error, info, debug
from .output import error, info
from .pacman import Pacman
@ -32,19 +32,6 @@ def list_interfaces(skip_loopback :bool = True) -> Dict[str, str]:
return interfaces
def check_mirror_reachable() -> bool:
info("Testing connectivity to the Arch Linux mirrors...")
try:
Pacman.run("-Sy")
return True
except SysCallError as err:
if os.geteuid() != 0:
error("check_mirror_reachable() uses 'pacman -Sy' which requires root.")
debug(f'exit_code: {err.exit_code}, Error: {err.message}')
return False
def update_keyring() -> bool:
info("Updating archlinux-keyring ...")
try:

View File

@ -1,4 +1,3 @@
import os
from pathlib import Path
from typing import Any, TYPE_CHECKING, Optional
@ -15,7 +14,6 @@ from archinstall.lib.mirrors import use_mirrors, add_custom_mirrors
from archinstall.lib.models import AudioConfiguration
from archinstall.lib.models.bootloader import Bootloader
from archinstall.lib.models.network_configuration import NetworkConfiguration
from archinstall.lib.networking import check_mirror_reachable
from archinstall.lib.profile.profiles_handler import profile_handler
if TYPE_CHECKING:
@ -232,11 +230,6 @@ def perform_installation(mountpoint: Path):
debug(f"Disk states after installing: {disk.disk_layouts()}")
if archinstall.arguments.get('skip-mirror-check', False) is False and check_mirror_reachable() is False:
log_file = os.path.join(archinstall.storage.get('LOG_PATH', None), archinstall.storage.get('LOG_FILE', None))
info(f"Arch Linux mirrors are not reachable. Please check your internet connection and the log file '{log_file}'.")
exit(1)
if not archinstall.arguments.get('silent'):
ask_user_questions()

View File

@ -1,16 +1,10 @@
import os
from pathlib import Path
import archinstall
from archinstall import info, debug
from archinstall import debug
from archinstall.lib.installer import Installer
from archinstall.lib.configuration import ConfigurationOutput
from archinstall.lib import disk
from archinstall.lib.networking import check_mirror_reachable
if archinstall.arguments.get('help'):
print("See `man archinstall` for help.")
exit(0)
def ask_user_questions():
@ -58,11 +52,6 @@ def perform_installation(mountpoint: Path):
debug(f"Disk states after installing: {disk.disk_layouts()}")
if archinstall.arguments.get('skip-mirror-check', False) is False and check_mirror_reachable() is False:
log_file = os.path.join(archinstall.storage.get('LOG_PATH', None), archinstall.storage.get('LOG_FILE', None))
info(f"Arch Linux mirrors are not reachable. Please check your internet connection and the log file '{log_file}'")
exit(1)
if not archinstall.arguments.get('silent'):
ask_user_questions()

View File

@ -1,4 +1,3 @@
import os
from enum import Enum
from pathlib import Path
from typing import TYPE_CHECKING, Any, Dict, Optional
@ -10,7 +9,6 @@ from archinstall.lib import models
from archinstall.lib import disk
from archinstall.lib import locale
from archinstall.lib.models import AudioConfiguration
from archinstall.lib.networking import check_mirror_reachable
from archinstall.lib.profile.profiles_handler import profile_handler
from archinstall.lib import menu
from archinstall.lib.global_menu import GlobalMenu
@ -21,11 +19,6 @@ if TYPE_CHECKING:
_: Any
if archinstall.arguments.get('help'):
print("See `man archinstall` for help.")
exit(0)
class ExecutionMode(Enum):
Full = 'full'
Lineal = 'lineal'
@ -290,11 +283,6 @@ def perform_installation(mountpoint: Path, exec_mode: ExecutionMode):
debug(f"Disk states after installing: {disk.disk_layouts()}")
if not check_mirror_reachable():
log_file = os.path.join(archinstall.storage.get('LOG_PATH', None), archinstall.storage.get('LOG_FILE', None))
info(f"Arch Linux mirrors are not reachable. Please check your internet connection and the log file '{log_file}'")
exit(1)
param_mode = archinstall.arguments.get('mode', ExecutionMode.Full.value).lower()
try: