Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 24 additions & 31 deletions archinstall/lib/hardware.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from dataclasses import dataclass
from enum import Enum, StrEnum
from functools import cached_property
from pathlib import Path
Expand Down Expand Up @@ -163,25 +164,6 @@ def cpu_info(self) -> dict[str, str]:

return cpu

@cached_property
def mem_info(self) -> dict[str, int]:
"""
Returns system memory information
"""
mem_info_path = Path('/proc/meminfo')
mem_info: dict[str, int] = {}

with mem_info_path.open() as file:
for line in file:
key, value = line.strip().split(':')
num = value.split()[0]
mem_info[key] = int(num)

return mem_info

def mem_info_by_key(self, key: str) -> int:
return self.mem_info[key]

@cached_property
def loaded_modules(self) -> list[str]:
"""
Expand Down Expand Up @@ -273,18 +255,6 @@ def product_name() -> str | None:
except FileNotFoundError:
return None

@staticmethod
def mem_available() -> int:
return _sys_info.mem_info_by_key('MemAvailable')

@staticmethod
def mem_free() -> int:
return _sys_info.mem_info_by_key('MemFree')

@staticmethod
def mem_total() -> int:
return _sys_info.mem_info_by_key('MemTotal')

@staticmethod
def virtualization() -> str | None:
try:
Expand Down Expand Up @@ -340,3 +310,26 @@ def requires_alsa_fw() -> bool:
return True

return False


@dataclass(frozen=True)
class MemInfo:
mem_total: int
mem_free: int
mem_available: int


def read_meminfo() -> MemInfo:
data: dict[str, int] = {}

with Path('/proc/meminfo').open() as file:
for line in file:
key, _, remainder = line.partition(':')
num, _, _ = remainder.strip().partition(' ')
data[key] = int(num)

return MemInfo(
mem_total=data['MemTotal'],
mem_free=data['MemFree'],
mem_available=data['MemAvailable'],
)
8 changes: 4 additions & 4 deletions archinstall/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from archinstall.lib.args import ArchConfigHandler, SubCommand
from archinstall.lib.disk.utils import disk_layouts
from archinstall.lib.hardware import SysInfo
from archinstall.lib.hardware import MemInfo, SysInfo, read_meminfo
from archinstall.lib.log import debug, error, info, logger, share_install_log, warn
from archinstall.lib.menu.helpers import Confirmation
from archinstall.lib.network.wifi_handler import WifiHandler
Expand All @@ -23,11 +23,11 @@
from archinstall.tui.menu_item import MenuItemGroup


def _log_sys_info() -> None:
def _log_sys_info(meminfo: MemInfo) -> None:
# Log various information about hardware before starting the installation. This might assist in troubleshooting
debug(f'Hardware model detected: {SysInfo.sys_vendor()} {SysInfo.product_name()}; UEFI mode: {SysInfo.has_uefi()}')
debug(f'Processor model detected: {SysInfo.cpu_model()}')
debug(f'Memory statistics: {SysInfo.mem_available()} available out of {SysInfo.mem_total()} total installed')
debug(f'Memory statistics: {meminfo.mem_available} kB available out of {meminfo.mem_total} kB total installed')
debug(f'Virtualization detected: {SysInfo.virtualization()}; is VM: {SysInfo.is_vm()}')
debug(f'Graphics devices detected: {SysInfo._graphics_devices().keys()}')

Expand Down Expand Up @@ -138,7 +138,7 @@ def run() -> int:

translation_handler.save_console_font()

_log_sys_info()
_log_sys_info(read_meminfo())

if not arch_config_handler.args.offline:
if not arch_config_handler.args.skip_wifi_check:
Expand Down