Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archinstall/__init__.py4
-rw-r--r--archinstall/lib/general.py4
-rw-r--r--archinstall/lib/hardware.py51
-rw-r--r--examples/guided.py9
4 files changed, 61 insertions, 7 deletions
diff --git a/archinstall/__init__.py b/archinstall/__init__.py
index fcd9a706..0b799d5b 100644
--- a/archinstall/__init__.py
+++ b/archinstall/__init__.py
@@ -61,6 +61,10 @@ def initialize_arguments():
arguments = initialize_arguments()
+storage['arguments'] = arguments
+if arguments.get('debug'):
+ log(f"Warning: --debug mode will write certain credentials to {storage['LOG_PATH']}/{storage['LOG_FILE']}!", fg="red", level=logging.WARNING)
+
from .lib.plugins import plugins, load_plugin # This initiates the plugin loading ceremony
if arguments.get('plugin', None):
diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py
index 3b62c891..f72311c9 100644
--- a/archinstall/lib/general.py
+++ b/archinstall/lib/general.py
@@ -13,7 +13,7 @@ from typing import Union
from .exceptions import *
from .output import log
-
+from .storage import storage
def gen_uid(entropy_length=256):
return hashlib.sha512(os.urandom(entropy_length)).hexdigest()
@@ -265,6 +265,8 @@ class SysCommandWorker:
if not self.pid:
try:
os.execve(self.cmd[0], self.cmd, {**os.environ, **self.environment_vars})
+ if storage['arguments'].get('debug'):
+ log(f"Executing: {self.cmd}", level=logging.DEBUG)
except FileNotFoundError:
log(f"{self.cmd[0]} does not exist.", level=logging.ERROR, fg="red")
self.exit_code = 1
diff --git a/archinstall/lib/hardware.py b/archinstall/lib/hardware.py
index 6a3b166d..45e042db 100644
--- a/archinstall/lib/hardware.py
+++ b/archinstall/lib/hardware.py
@@ -79,22 +79,22 @@ def has_uefi() -> bool:
def graphics_devices() -> dict:
cards = {}
for line in SysCommand("lspci"):
- if b' VGA ' in line:
+ if b' VGA ' in line or b' 3D ' in line:
_, identifier = line.split(b': ', 1)
- cards[identifier.strip().lower().decode('UTF-8')] = line
+ cards[identifier.strip().decode('UTF-8')] = line
return cards
def has_nvidia_graphics() -> bool:
- return any('nvidia' in x for x in graphics_devices())
+ return any('nvidia' in x.lower() for x in graphics_devices())
def has_amd_graphics() -> bool:
- return any('amd' in x for x in graphics_devices())
+ return any('amd' in x.lower() for x in graphics_devices())
def has_intel_graphics() -> bool:
- return any('intel' in x for x in graphics_devices())
+ return any('intel' in x.lower() for x in graphics_devices())
def cpu_vendor() -> Optional[str]:
@@ -107,6 +107,47 @@ def cpu_vendor() -> Optional[str]:
return None
+def cpu_model() -> Optional[str]:
+ cpu_info_raw = SysCommand("lscpu -J")
+ cpu_info = json.loads(b"".join(cpu_info_raw).decode('UTF-8'))['lscpu']
+
+ for info in cpu_info:
+ if info.get('field', None) == "Model name:":
+ return info.get('data', None)
+ return None
+
+
+def sys_vendor() -> Optional[str]:
+ with open(f"/sys/devices/virtual/dmi/id/sys_vendor") as vendor:
+ return vendor.read().strip()
+
+
+def product_name() -> Optional[str]:
+ with open(f"/sys/devices/virtual/dmi/id/product_name") as product:
+ return product.read().strip()
+
+
+def mem_info():
+ # This implementation is from https://stackoverflow.com/a/28161352
+ return dict((i.split()[0].rstrip(':'), int(i.split()[1])) for i in open('/proc/meminfo').readlines())
+
+
+def mem_available() -> Optional[str]:
+ return mem_info()['MemAvailable']
+
+
+def mem_free() -> Optional[str]:
+ return mem_info()['MemFree']
+
+
+def mem_total() -> Optional[str]:
+ return mem_info()['MemTotal']
+
+
+def virtualization() -> Optional[str]:
+ return str(SysCommand("systemd-detect-virt")).strip('\r\n')
+
+
def is_vm() -> bool:
try:
# systemd-detect-virt issues a non-zero exit code if it is not on a virtual machine
diff --git a/examples/guided.py b/examples/guided.py
index 42429370..56c054fc 100644
--- a/examples/guided.py
+++ b/examples/guided.py
@@ -5,7 +5,7 @@ import time
import archinstall
from archinstall.lib.general import run_custom_user_commands
-from archinstall.lib.hardware import has_uefi, AVAILABLE_GFX_DRIVERS
+from archinstall.lib.hardware import *
from archinstall.lib.networking import check_mirror_reachable
from archinstall.lib.profiles import Profile
@@ -16,6 +16,13 @@ if os.getuid() != 0:
print("Archinstall requires root privileges to run. See --help for more.")
exit(1)
+# Log various information about hardware before starting the installation. This might assist in troubleshooting
+archinstall.log(f"Hardware model detected: {archinstall.sys_vendor()} {archinstall.product_name()}; UEFI mode: {archinstall.has_uefi()}", level=logging.DEBUG)
+archinstall.log(f"Processor model detected: {archinstall.cpu_model()}", level=logging.DEBUG)
+archinstall.log(f"Memory statistics: {archinstall.mem_available()} available out of {archinstall.mem_total()} total installed", level=logging.DEBUG)
+archinstall.log(f"Virtualization detected: {archinstall.virtualization()}; is VM: {archinstall.is_vm()}", level=logging.DEBUG)
+archinstall.log(f"Graphics devices detected: {archinstall.graphics_devices().keys()}", level=logging.DEBUG)
+
# For support reasons, we'll log the disk layout pre installation to match against post-installation layout
archinstall.log(f"Disk states before installing: {archinstall.disk_layouts()}", level=logging.DEBUG)