Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall
diff options
context:
space:
mode:
authoradvaithm <advaith.madhukar@gmail.com>2021-03-12 11:30:32 +0530
committeradvaithm <advaith.madhukar@gmail.com>2021-03-12 11:30:32 +0530
commit850fd2efa812508e2df67aa2b50cff8820389a0d (patch)
tree172e2a1be18feeaccff3b9ee2cde10c045951259 /archinstall
parente2aeb3a32faa397db899f4105a16f31a095387be (diff)
Started work on BIOS support
Diffstat (limited to 'archinstall')
-rw-r--r--archinstall/lib/disk.py16
-rw-r--r--archinstall/lib/installer.py23
2 files changed, 32 insertions, 7 deletions
diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py
index c05ba757..16ee72e7 100644
--- a/archinstall/lib/disk.py
+++ b/archinstall/lib/disk.py
@@ -5,6 +5,7 @@ from .exceptions import DiskError
from .general import *
from .output import log, LOG_LEVELS
from .storage import storage
+from .hardware import hasUEFI
ROOT_DIR_PATTERN = re.compile('^.*?/devices')
GPT = 0b00000001
@@ -331,9 +332,12 @@ class Filesystem():
# TODO:
# When instance of a HDD is selected, check all usages and gracefully unmount them
# as well as close any crypto handles.
- def __init__(self, blockdevice, mode=GPT):
+ def __init__(self, blockdevice):
self.blockdevice = blockdevice
- self.mode = mode
+ if hasUEFI():
+ self.mode = GPT
+ else:
+ self.mode = MBR
def __enter__(self, *args, **kwargs):
if self.blockdevice.keep_partitions is False:
@@ -343,6 +347,11 @@ class Filesystem():
return self
else:
raise DiskError(f'Problem setting the partition format to GPT:', f'/usr/bin/parted -s {self.blockdevice.device} mklabel gpt')
+ elif self.mode == MBR:
+ if sys_command(f'/usr/bin/parted -s {self.blockdevice.} mklabel msdos').exit_code == 0:
+ return self
+ else:
+ raise DiskError(f'Problem setting the partition format to GPT:', f'/usr/bin/parted -s {self.blockdevice.device} mklabel msdos')
else:
raise DiskError(f'Unknown mode selected to format in: {self.mode}')
@@ -405,6 +414,9 @@ class Filesystem():
log(f'Adding partition to {self.blockdevice}', level=LOG_LEVELS.Info)
previous_partitions = self.blockdevice.partitions
+ if self.mode == MBR:
+ if len(self.blockdevice.partitions())>3:
+ DiskError("Too many partitions on disk, MBR disks can only have 3 parimary partitions")
if format:
partitioning = self.parted(f'{self.blockdevice.device} mkpart {type} {format} {start} {end}') == 0
else:
diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py
index 06bdd05a..ecc3c9c9 100644
--- a/archinstall/lib/installer.py
+++ b/archinstall/lib/installer.py
@@ -1,4 +1,4 @@
-import os, stat, time, shutil
+import os, stat, time, shutil, subprocess
from .exceptions import *
from .disk import *
@@ -53,6 +53,8 @@ class Installer():
}
self.base_packages = base_packages.split(' ')
+ if not hasUEFI():
+ base_packages.append('grub') # if it isn't uefi is must be bios therefore we need grub as systemd-boot is uefi only
self.post_base_install = []
storage['session'] = self
@@ -332,8 +334,10 @@ class Installer():
for uid in uids:
real_path = os.path.realpath(os.path.join(root, uid))
if not os.path.basename(real_path) == os.path.basename(self.partition.real_device): continue
-
- entry.write(f'options cryptdevice=UUID={uid}:luksdev root=/dev/mapper/luksdev rw intel_pstate=no_hwp\n')
+ if subprocess.check_output("lscpu | grep AMD", shell=True).strip().decode(): # intel_paste is intel only, it's redudant on AMD systens
+ entry.write(f'options cryptdevice=UUID={uid}:luksdev root=/dev/mapper/luksdev rw\n')
+ else:
+ entry.write(f'options cryptdevice=UUID={uid}:luksdev root=/dev/mapper/luksdev rw intel_pstate=no_hwp\n')
self.helper_flags['bootloader'] = bootloader
return True
@@ -343,13 +347,22 @@ class Installer():
for uid in uids:
real_path = os.path.realpath(os.path.join(root, uid))
if not os.path.basename(real_path) == os.path.basename(self.partition.path): continue
-
- entry.write(f'options root=PARTUUID={uid} rw intel_pstate=no_hwp\n')
+ if subprocess.check_output("lscpu | grep AMD", shell=True).strip().decode():
+ entry.write(f'options root=PARTUUID={uid} rw\n')
+ else:
+ entry.write(f'options root=PARTUUID={uid} rw intel_pstate=no_hwp\n')
self.helper_flags['bootloader'] = bootloader
return True
break
raise RequirementError(f"Could not identify the UUID of {self.partition}, there for {self.mountpoint}/boot/loader/entries/arch.conf will be broken until fixed.")
+ elif bootloader == 'grub-install':
+ if hasUEFI():
+ o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.mountpoint} grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB'))
+ sys_command('/usr/bin/arch-chroot grub-mkconfig -o /boot/grub/grub.cfg')
+ else:
+ o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.mountpoint} grub-install --target=--target=i386-pc {self}'))
+ sys_command('/usr/bin/arch-chroot grub-mkconfig -o /boot/grub/grub.cfg')
else:
raise RequirementError(f"Unknown (or not yet implemented) bootloader added to add_bootloader(): {bootloader}")