Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall
diff options
context:
space:
mode:
authorDaniel Girtler <blackrabbit256@gmail.com>2023-10-18 16:57:44 +1100
committerGitHub <noreply@github.com>2023-10-18 16:57:44 +1100
commitce9828c2934937217daee6ba178dafedf6cabe6d (patch)
tree0c9540f07c6756426e50786a04b4436ef3b51577 /archinstall
parent8117c0eed8cdeffc542026a82a51cb10fd6c1ec4 (diff)
Fixes for prev PR (#2175)
* Fixes for prev PR * Update --------- Co-authored-by: Daniel Girtler <girtler.daniel@gmail.com>
Diffstat (limited to 'archinstall')
-rw-r--r--archinstall/__init__.py21
-rw-r--r--archinstall/lib/exceptions.py16
-rw-r--r--archinstall/lib/networking.py15
-rw-r--r--archinstall/scripts/guided.py7
-rw-r--r--archinstall/scripts/only_hd.py13
-rw-r--r--archinstall/scripts/swiss.py12
6 files changed, 28 insertions, 56 deletions
diff --git a/archinstall/__init__.py b/archinstall/__init__.py
index 3949d38a..b9a0c2fb 100644
--- a/archinstall/__init__.py
+++ b/archinstall/__init__.py
@@ -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)
diff --git a/archinstall/lib/exceptions.py b/archinstall/lib/exceptions.py
index 53458d2c..80926e0b 100644
--- a/archinstall/lib/exceptions.py
+++ b/archinstall/lib/exceptions.py
@@ -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
diff --git a/archinstall/lib/networking.py b/archinstall/lib/networking.py
index 2a086f39..fb26bd3d 100644
--- a/archinstall/lib/networking.py
+++ b/archinstall/lib/networking.py
@@ -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:
diff --git a/archinstall/scripts/guided.py b/archinstall/scripts/guided.py
index fdf05c99..6acbdbf3 100644
--- a/archinstall/scripts/guided.py
+++ b/archinstall/scripts/guided.py
@@ -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()
diff --git a/archinstall/scripts/only_hd.py b/archinstall/scripts/only_hd.py
index d0ee1e39..2293cbee 100644
--- a/archinstall/scripts/only_hd.py
+++ b/archinstall/scripts/only_hd.py
@@ -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()
diff --git a/archinstall/scripts/swiss.py b/archinstall/scripts/swiss.py
index c04ccca4..1db304a8 100644
--- a/archinstall/scripts/swiss.py
+++ b/archinstall/scripts/swiss.py
@@ -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: