Merge pull request #448 from dylanmtaylor/whitespace
More minor whitespace changes
This commit is contained in:
commit
85fa833a8a
|
|
@ -152,8 +152,9 @@ class BlockDevice():
|
|||
def flush_cache(self):
|
||||
self.part_cache = OrderedDict()
|
||||
|
||||
|
||||
class Partition():
|
||||
def __init__(self, path :str, block_device :BlockDevice, part_id=None, size=-1, filesystem=None, mountpoint=None, encrypted=False, autodetect_filesystem=True):
|
||||
def __init__(self, path: str, block_device: BlockDevice, part_id=None, size=-1, filesystem=None, mountpoint=None, encrypted=False, autodetect_filesystem=True):
|
||||
if not part_id:
|
||||
part_id = os.path.basename(path)
|
||||
|
||||
|
|
@ -506,9 +507,9 @@ class Filesystem():
|
|||
self.blockdevice.partition[0].allow_formatting = True
|
||||
self.blockdevice.partition[1].allow_formatting = True
|
||||
else:
|
||||
#we don't need a seprate boot partition it would be a waste of space
|
||||
# we don't need a seprate boot partition it would be a waste of space
|
||||
self.add_partition('primary', start='1MB', end='100%')
|
||||
self.blockdevice.partition[0].filesystem=root_filesystem_type
|
||||
self.blockdevice.partition[0].filesystem = root_filesystem_type
|
||||
log(f"Set the root partition {self.blockdevice.partition[0]} to use filesystem {root_filesystem_type}.", level=logging.DEBUG)
|
||||
self.blockdevice.partition[0].target_mountpoint = '/'
|
||||
self.blockdevice.partition[0].allow_formatting = True
|
||||
|
|
@ -558,28 +559,31 @@ def device_state(name, *args, **kwargs):
|
|||
return
|
||||
return True
|
||||
|
||||
|
||||
# lsblk --json -l -n -o path
|
||||
def all_disks(*args, **kwargs):
|
||||
kwargs.setdefault("partitions", False)
|
||||
drives = OrderedDict()
|
||||
#for drive in json.loads(sys_command(f'losetup --json', *args, **lkwargs, hide_from_log=True)).decode('UTF_8')['loopdevices']:
|
||||
# for drive in json.loads(sys_command(f'losetup --json', *args, **lkwargs, hide_from_log=True)).decode('UTF_8')['loopdevices']:
|
||||
for drive in json.loads(b''.join(sys_command(f'lsblk --json -l -n -o path,size,type,mountpoint,label,pkname,model', *args, **kwargs, hide_from_log=True)).decode('UTF_8'))['blockdevices']:
|
||||
if not kwargs['partitions'] and drive['type'] == 'part': continue
|
||||
|
||||
drives[drive['path']] = BlockDevice(drive['path'], drive)
|
||||
return drives
|
||||
|
||||
|
||||
def convert_to_gigabytes(string):
|
||||
unit = string.strip()[-1]
|
||||
size = float(string.strip()[:-1])
|
||||
|
||||
if unit == 'M':
|
||||
size = size/1024
|
||||
size = size / 1024
|
||||
elif unit == 'T':
|
||||
size = size*1024
|
||||
size = size * 1024
|
||||
|
||||
return size
|
||||
|
||||
|
||||
def harddrive(size=None, model=None, fuzzy=False):
|
||||
collection = all_disks()
|
||||
for drive in collection:
|
||||
|
|
|
|||
|
|
@ -83,10 +83,12 @@ class JSON(json.JSONEncoder, json.JSONDecoder):
|
|||
def encode(self, obj):
|
||||
return super(JSON, self).encode(self._encode(obj))
|
||||
|
||||
|
||||
class sys_command:
|
||||
"""
|
||||
Stolen from archinstall_gui
|
||||
"""
|
||||
|
||||
def __init__(self, cmd, callback=None, start_callback=None, peak_output=False, environment_vars={}, *args, **kwargs):
|
||||
kwargs.setdefault("worker_id", gen_uid())
|
||||
kwargs.setdefault("emulate", False)
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ def cpuVendor() -> Optional[str]:
|
|||
|
||||
def isVM() -> bool:
|
||||
try:
|
||||
subprocess.check_call(["systemd-detect-virt"]) # systemd-detect-virt issues a non-zero exit code if it is not on a virtual machine
|
||||
subprocess.check_call(["systemd-detect-virt"]) # systemd-detect-virt issues a non-zero exit code if it is not on a virtual machine
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ class Installer():
|
|||
|
||||
return True
|
||||
|
||||
def set_hostname(self, hostname :str, *args, **kwargs):
|
||||
def set_hostname(self, hostname: str, *args, **kwargs):
|
||||
with open(f'{self.target}/etc/hostname', 'w') as fh:
|
||||
fh.write(hostname + '\n')
|
||||
|
||||
|
|
@ -423,7 +423,6 @@ class Installer():
|
|||
## blkid doesn't trigger on loopback devices really well,
|
||||
## so we'll use the old manual method until we get that sorted out.
|
||||
|
||||
|
||||
if (real_device := self.detect_encryption(root_partition)):
|
||||
# TODO: We need to detect if the encrypted device is a whole disk encryption,
|
||||
# or simply a partition encryption. Right now we assume it's a partition (and we always have)
|
||||
|
|
@ -446,7 +445,7 @@ class Installer():
|
|||
sys_command('/usr/bin/arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg')
|
||||
return True
|
||||
else:
|
||||
root_device = subprocess.check_output(f'basename "$(readlink -f /sys/class/block/{root_partition.path.replace("/dev/","")}/..)"', shell=True).decode().strip()
|
||||
root_device = subprocess.check_output(f'basename "$(readlink -f /sys/class/block/{root_partition.path.replace("/dev/", "")}/..)"', shell=True).decode().strip()
|
||||
if root_device == "block":
|
||||
root_device = f"{root_partition.path}"
|
||||
o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.target} grub-install --target=i386-pc /dev/{root_device}'))
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ def filter_mirrors_by_region(regions, destination='/etc/pacman.d/mirrorlist', tm
|
|||
return True
|
||||
|
||||
|
||||
def add_custom_mirrors(mirrors:list, *args, **kwargs):
|
||||
def add_custom_mirrors(mirrors: list, *args, **kwargs):
|
||||
"""
|
||||
This will append custom mirror definitions in pacman.conf
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ from .storage import storage
|
|||
|
||||
|
||||
def grab_url_data(path):
|
||||
safe_path = path[:path.find(':')+1]+''.join([item if item in ('/', '?', '=', '&') else urllib.parse.quote(item) for item in multisplit(path[path.find(':')+1:], ('/', '?', '=', '&'))])
|
||||
safe_path = path[:path.find(':') + 1] + ''.join([item if item in ('/', '?', '=', '&') else urllib.parse.quote(item) for item in multisplit(path[path.find(':') + 1:], ('/', '?', '=', '&'))])
|
||||
ssl_context = ssl.create_default_context()
|
||||
ssl_context.check_hostname = False
|
||||
ssl_context.verify_mode = ssl.CERT_NONE
|
||||
|
|
@ -47,7 +47,7 @@ def list_profiles(filter_irrelevant_macs=True, subpath='', filter_top_level_prof
|
|||
if len(first_line) and first_line[0] == '#':
|
||||
description = first_line[1:].strip()
|
||||
|
||||
cache[file[:-3]] = {'path' : os.path.join(root, file), 'description' : description, 'tailored' : tailored}
|
||||
cache[file[:-3]] = {'path': os.path.join(root, file), 'description': description, 'tailored': tailored}
|
||||
break
|
||||
|
||||
# Grab profiles from upstream URL
|
||||
|
|
@ -70,7 +70,7 @@ def list_profiles(filter_irrelevant_macs=True, subpath='', filter_top_level_prof
|
|||
continue
|
||||
tailored = True
|
||||
|
||||
cache[profile[:-3]] = {'path' : os.path.join(storage["UPSTREAM_URL"]+subpath, profile), 'description' : profile_list[profile], 'tailored' : tailored}
|
||||
cache[profile[:-3]] = {'path': os.path.join(storage["UPSTREAM_URL"] + subpath, profile), 'description': profile_list[profile], 'tailored': tailored}
|
||||
|
||||
if filter_top_level_profiles:
|
||||
for profile in list(cache.keys()):
|
||||
|
|
|
|||
|
|
@ -5,6 +5,6 @@ def service_state(service_name: str):
|
|||
if os.path.splitext(service_name)[1] != '.service':
|
||||
service_name += '.service' # Just to be safe
|
||||
|
||||
state = b''.join(sys_command(f'systemctl show --no-pager -p SubState --value {service_name}', environment_vars={'SYSTEMD_COLORS' : '0'}))
|
||||
state = b''.join(sys_command(f'systemctl show --no-pager -p SubState --value {service_name}', environment_vars={'SYSTEMD_COLORS': '0'}))
|
||||
|
||||
return state.strip().decode('UTF-8')
|
||||
|
|
|
|||
|
|
@ -12,5 +12,4 @@ If the PR is larger than ~20 lines, please describe it here unless described in
|
|||
|
||||
# Testing
|
||||
|
||||
Any new feature or stability improvement should be tested if possible. Please follow the test instructions at the bottom
|
||||
of the README or use the ISO built on each PR.
|
||||
Any new feature or stability improvement should be tested if possible. Please follow the test instructions at the bottom of the README or use the ISO built on each PR.
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ def ask_user_questions():
|
|||
# If we provide keys as options, it's better to convert them to list and sort before passing
|
||||
mountpoints_list = sorted(list(partition_mountpoints.keys()))
|
||||
partition = archinstall.generic_select(mountpoints_list,
|
||||
"Select a partition by number that you want to set a mount-point for (leave blank when done): ")
|
||||
"Select a partition by number that you want to set a mount-point for (leave blank when done): ")
|
||||
if not partition:
|
||||
if set(mountpoints_set) & {'/', '/boot'} == {'/', '/boot'}:
|
||||
break
|
||||
|
|
@ -119,8 +119,9 @@ def ask_user_questions():
|
|||
try:
|
||||
partition.format(new_filesystem, path='/dev/null', log_formatting=False, allow_formatting=True)
|
||||
except archinstall.UnknownFilesystemFormat:
|
||||
archinstall.log(f"Selected filesystem is not supported yet. If you want archinstall to support '{new_filesystem}', please create a issue-ticket suggesting it on github at https://github.com/archlinux/archinstall/issues.")
|
||||
archinstall.log(f"Until then, please enter another supported filesystem.")
|
||||
archinstall.log(f"Selected filesystem is not supported yet. If you want archinstall to support '{new_filesystem}',")
|
||||
archinstall.log("please create a issue-ticket suggesting it on github at https://github.com/archlinux/archinstall/issues.")
|
||||
archinstall.log("Until then, please enter another supported filesystem.")
|
||||
continue
|
||||
except archinstall.SysCallError:
|
||||
pass # Expected exception since mkfs.<format> can not format /dev/null. But that means our .format() function supported it.
|
||||
|
|
@ -316,12 +317,12 @@ def perform_installation(mountpoint):
|
|||
time.sleep(1)
|
||||
# Set mirrors used by pacstrap (outside of installation)
|
||||
if archinstall.arguments.get('mirror-region', None):
|
||||
archinstall.use_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors for the live medium
|
||||
archinstall.use_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors for the live medium
|
||||
if installation.minimal_installation():
|
||||
installation.set_hostname(archinstall.arguments['hostname'])
|
||||
if archinstall.arguments['mirror-region'].get("mirrors", None) is not None:
|
||||
installation.set_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors in the installation medium
|
||||
if archinstall.arguments["bootloader"]=="grub-install" and hasUEFI()==True:
|
||||
installation.set_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors in the installation medium
|
||||
if archinstall.arguments["bootloader"] == "grub-install" and hasUEFI() == True:
|
||||
installation.add_additional_packages("grub")
|
||||
installation.set_keyboard_language(archinstall.arguments['keyboard-language'])
|
||||
installation.add_bootloader(archinstall.arguments["bootloader"])
|
||||
|
|
@ -329,8 +330,8 @@ def perform_installation(mountpoint):
|
|||
# If user selected to copy the current ISO network configuration
|
||||
# Perform a copy of the config
|
||||
if archinstall.arguments.get('nic', {}) == 'Copy ISO network configuration to installation':
|
||||
installation.copy_ISO_network_config(enable_services=True) # Sources the ISO network configuration to the install medium.
|
||||
elif archinstall.arguments.get('nic', {}).get('NetworkManager',False):
|
||||
installation.copy_ISO_network_config(enable_services=True) # Sources the ISO network configuration to the install medium.
|
||||
elif archinstall.arguments.get('nic', {}).get('NetworkManager', False):
|
||||
installation.add_additional_packages("networkmanager")
|
||||
installation.enable_service('NetworkManager.service')
|
||||
# Otherwise, if a interface was selected, configure that interface
|
||||
|
|
|
|||
|
|
@ -37,5 +37,5 @@ if __name__ == 'gnome':
|
|||
archinstall.storage['installation_session'].add_additional_packages(__packages__)
|
||||
|
||||
archinstall.storage['installation_session'].enable_service('gdm') # Gnome Display Manager
|
||||
# We could also start it via xinitrc since we do have Xorg,
|
||||
# but for gnome that's deprecated and wayland is preferred.
|
||||
# We could also start it via xinitrc since we do have Xorg,
|
||||
# but for gnome that's deprecated and wayland is preferred.
|
||||
|
|
|
|||
|
|
@ -30,11 +30,11 @@ if __name__ == 'xorg':
|
|||
try:
|
||||
if "nvidia" in _gfx_driver_packages:
|
||||
if "linux-zen" in archinstall.storage['installation_session'].base_packages or "linux-lts" in archinstall.storage['installation_session'].base_packages:
|
||||
archinstall.storage['installation_session'].add_additional_packages("dkms")#I've had kernel regen fail if it wasn't installed before nvidia-dkms
|
||||
archinstall.storage['installation_session'].add_additional_packages("dkms") # I've had kernel regen fail if it wasn't installed before nvidia-dkms
|
||||
archinstall.storage['installation_session'].add_additional_packages("xorg-server xorg-xinit nvidia-dkms")
|
||||
else:
|
||||
archinstall.storage['installation_session'].add_additional_packages(f"xorg-server xorg-xinit {' '.join(_gfx_driver_packages)}")
|
||||
else:
|
||||
archinstall.storage['installation_session'].add_additional_packages(f"xorg-server xorg-xinit {' '.join(_gfx_driver_packages)}")
|
||||
except:
|
||||
archinstall.storage['installation_session'].add_additional_packages("xorg-server xorg-xinit") # Prep didn't run, so there's no driver to install
|
||||
archinstall.storage['installation_session'].add_additional_packages("xorg-server xorg-xinit") # Prep didn't run, so there's no driver to install
|
||||
|
|
|
|||
Loading…
Reference in New Issue