From d27fe9715f357d0a3d98ed166f480d27de3e920f Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sat, 1 May 2021 09:28:42 -0400 Subject: Attempt to fix #406 I think this should fix the comment Torxed made --- profiles/sway.py | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'profiles/sway.py') diff --git a/profiles/sway.py b/profiles/sway.py index db94ae2c..8e256a87 100644 --- a/profiles/sway.py +++ b/profiles/sway.py @@ -4,7 +4,19 @@ import archinstall is_top_level_profile = False -__packages__ = ["sway", "swaylock", "swayidle", "waybar", "dmenu", "light", "grim", "slurp", "pavucontrol", "alacritty"] +__packages__ = [ + "sway", + "swaylock", + "swayidle", + "waybar", + "dmenu", + "light", + "grim", + "slurp", + "pavucontrol", + "alacritty", +] + def _prep_function(*args, **kwargs): """ @@ -13,18 +25,26 @@ def _prep_function(*args, **kwargs): other code in this stage. So it's a safe way to ask the user for more input before any other installer steps start. """ - if "nvidia" in _gfx_driver_packages: - choice = input("The proprietary Nvidia driver is not supported by Sway. It is likely that you will run into issues. Continue anyways? [y/N] ") - if choice.lower() in ("n", ""): - raise archinstall.lib.exceptions.HardwareIncompatibilityError("Sway does not support the proprietary nvidia drivers.") - - __builtins__['_gfx_driver_packages'] = archinstall.select_driver() + __builtins__["_gfx_driver_packages"] = archinstall.select_driver() return True + # Ensures that this code only gets executed if executed # through importlib.util.spec_from_file_location("sway", "/somewhere/sway.py") # or through conventional import sway -if __name__ == 'sway': +if __name__ == "sway": + if "nvidia" in _gfx_driver_packages: + choice = input( + "The proprietary Nvidia driver is not supported by Sway. It is likely that you will run into issues. Continue anyways? [y/N] " + ) + if choice.lower() in ("n", ""): + raise archinstall.lib.exceptions.HardwareIncompatibilityError( + "Sway does not support the proprietary nvidia drivers." + ) + # Install the Sway packages installation.add_additional_packages(__packages__) + + # Install the graphics driver packages + installation.add_additional_packages(_gfx_driver_packages) -- cgit v1.2.3-70-g09d2 From 4ff35663b80e1bb40c44d4ceee85700ef428cab0 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 12 May 2021 13:55:41 +0200 Subject: Replaced the magic __builtin__ global variable. This should fix mypy complaints while still retaining the same functionality, kinda. It's less automatic but it's also less of dark magic, which makes sense for anyone but me. --- archinstall/lib/installer.py | 9 +-------- profiles/52-54-00-12-34-56.py | 2 +- profiles/applications/awesome.py | 8 ++++---- profiles/applications/cockpit.py | 4 ++-- profiles/applications/docker.py | 4 ++-- profiles/applications/httpd.py | 4 ++-- profiles/applications/lighttpd.py | 4 ++-- profiles/applications/mariadb.py | 6 +++--- profiles/applications/nginx.py | 4 ++-- profiles/applications/postgresql.py | 6 +++--- profiles/applications/sshd.py | 4 ++-- profiles/applications/tomcat.py | 4 ++-- profiles/awesome.py | 12 ++++++------ profiles/budgie.py | 6 +++--- profiles/cinnamon.py | 6 +++--- profiles/deepin.py | 6 +++--- profiles/desktop.py | 8 +++----- profiles/gnome.py | 6 +++--- profiles/i3.py | 10 +++++----- profiles/kde.py | 6 +++--- profiles/lxqt.py | 6 +++--- profiles/mate.py | 6 +++--- profiles/server.py | 2 +- profiles/sway.py | 4 ++-- profiles/xfce4.py | 6 +++--- profiles/xorg.py | 22 ++++++---------------- 26 files changed, 73 insertions(+), 92 deletions(-) (limited to 'profiles/sway.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 331762b4..e5120ff1 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -452,14 +452,7 @@ class Installer(): return self.pacstrap(*packages) def install_profile(self, profile): - # TODO: Replace this with a import archinstall.session instead in the profiles. - # The tricky thing with doing the import archinstall.session instead is that - # profiles might be run from a different chroot, and there's no way we can - # guarantee file-path safety when accessing the installer object that way. - # Doing the __builtins__ replacement, ensures that the global variable "installation" - # is always kept up to date. It's considered a nasty hack - but it's a safe way - # of ensuring 100% accuracy of archinstall session variables. - __builtins__['installation'] = self + storage['installation_session'] = self if type(profile) == str: profile = Profile(self, profile) diff --git a/profiles/52-54-00-12-34-56.py b/profiles/52-54-00-12-34-56.py index a3347760..28cd14f6 100644 --- a/profiles/52-54-00-12-34-56.py +++ b/profiles/52-54-00-12-34-56.py @@ -5,7 +5,7 @@ import urllib.request __packages__ = ['nano', 'wget', 'git'] if __name__ == '52-54-00-12-34-56': - awesome = archinstall.Application(installation, 'postgresql') + awesome = archinstall.Application(archinstall.storage['installation_session'], 'postgresql') awesome.install() """ diff --git a/profiles/applications/awesome.py b/profiles/applications/awesome.py index a63c707b..d5a8e793 100644 --- a/profiles/applications/awesome.py +++ b/profiles/applications/awesome.py @@ -2,11 +2,11 @@ import archinstall __packages__ = ["awesome", "xorg-xrandr", "xterm", "feh", "slock", "terminus-font", "gnu-free-fonts", "ttf-liberation", "xsel"] -installation.install_profile('xorg') +archinstall.storage['installation_session'].install_profile('xorg') -installation.add_additional_packages(__packages__) +archinstall.storage['installation_session'].add_additional_packages(__packages__) -with open(f'{installation.target}/etc/X11/xinit/xinitrc', 'r') as xinitrc: +with open(f"{archinstall.storage['installation_session'].target}/etc/X11/xinit/xinitrc", 'r') as xinitrc: xinitrc_data = xinitrc.read() for line in xinitrc_data.split('\n'): @@ -20,5 +20,5 @@ for line in xinitrc_data.split('\n'): xinitrc_data += '\n' xinitrc_data += 'exec awesome\n' -with open(f'{installation.target}/etc/X11/xinit/xinitrc', 'w') as xinitrc: +with open(f"{archinstall.storage['installation_session'].target}/etc/X11/xinit/xinitrc", 'w') as xinitrc: xinitrc.write(xinitrc_data) diff --git a/profiles/applications/cockpit.py b/profiles/applications/cockpit.py index f1cea1d2..8a0ede9d 100644 --- a/profiles/applications/cockpit.py +++ b/profiles/applications/cockpit.py @@ -4,6 +4,6 @@ import archinstall # which packages will be installed by this profile __packages__ = ["cockpit", "udisks2", "packagekit"] -installation.add_additional_packages(__packages__) +archinstall.storage['installation_session'].add_additional_packages(__packages__) -installation.enable_service('cockpit.socket') +archinstall.storage['installation_session'].enable_service('cockpit.socket') diff --git a/profiles/applications/docker.py b/profiles/applications/docker.py index afa3f8fb..afbde1a5 100644 --- a/profiles/applications/docker.py +++ b/profiles/applications/docker.py @@ -4,6 +4,6 @@ import archinstall # which packages will be installed by this profile __packages__ = ["docker"] -installation.add_additional_packages(__packages__) +archinstall.storage['installation_session'].add_additional_packages(__packages__) -installation.enable_service('docker') +archinstall.storage['installation_session'].enable_service('docker') diff --git a/profiles/applications/httpd.py b/profiles/applications/httpd.py index 00d64b6e..23b3fefa 100644 --- a/profiles/applications/httpd.py +++ b/profiles/applications/httpd.py @@ -4,6 +4,6 @@ import archinstall # which packages will be installed by this profile __packages__ = ["apache"] -installation.add_additional_packages(__packages__) +archinstall.storage['installation_session'].add_additional_packages(__packages__) -installation.enable_service('httpd') +archinstall.storage['installation_session'].enable_service('httpd') diff --git a/profiles/applications/lighttpd.py b/profiles/applications/lighttpd.py index a1e6a371..71158861 100644 --- a/profiles/applications/lighttpd.py +++ b/profiles/applications/lighttpd.py @@ -4,6 +4,6 @@ import archinstall # which packages will be installed by this profile __packages__ = ["lighttpd"] -installation.add_additional_packages(__packages__) +archinstall.storage['installation_session'].add_additional_packages(__packages__) -installation.enable_service('lighttpd') +archinstall.storage['installation_session'].enable_service('lighttpd') diff --git a/profiles/applications/mariadb.py b/profiles/applications/mariadb.py index e458a45a..bdde18b5 100644 --- a/profiles/applications/mariadb.py +++ b/profiles/applications/mariadb.py @@ -4,8 +4,8 @@ import archinstall # which packages will be installed by this profile __packages__ = ["mariadb"] -installation.add_additional_packages(__packages__) +archinstall.storage['installation_session'].add_additional_packages(__packages__) -installation.arch_chroot("mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql") +archinstall.storage['installation_session'].arch_chroot("mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql") -installation.enable_service('mariadb') +archinstall.storage['installation_session'].enable_service('mariadb') diff --git a/profiles/applications/nginx.py b/profiles/applications/nginx.py index 50eb0506..6f63b15c 100644 --- a/profiles/applications/nginx.py +++ b/profiles/applications/nginx.py @@ -4,6 +4,6 @@ import archinstall # which packages will be installed by this profile __packages__ = ["nginx"] -installation.add_additional_packages(__packages__) +archinstall.storage['installation_session'].add_additional_packages(__packages__) -installation.enable_service('nginx') +archinstall.storage['installation_session'].enable_service('nginx') diff --git a/profiles/applications/postgresql.py b/profiles/applications/postgresql.py index fcdce824..3f8c6950 100644 --- a/profiles/applications/postgresql.py +++ b/profiles/applications/postgresql.py @@ -4,8 +4,8 @@ import archinstall # which packages will be installed by this profile __packages__ = ["postgresql"] -installation.add_additional_packages(__packages__) +archinstall.storage['installation_session'].add_additional_packages(__packages__) -installation.arch_chroot("initdb -D /var/lib/postgres/data", runas='postgres') +archinstall.storage['installation_session'].arch_chroot("initdb -D /var/lib/postgres/data", runas='postgres') -installation.enable_service('postgresql') \ No newline at end of file +archinstall.storage['installation_session'].enable_service('postgresql') \ No newline at end of file diff --git a/profiles/applications/sshd.py b/profiles/applications/sshd.py index 234638d5..4199ecb0 100644 --- a/profiles/applications/sshd.py +++ b/profiles/applications/sshd.py @@ -4,6 +4,6 @@ import archinstall # which packages will be installed by this profile __packages__ = ["openssh"] -installation.add_additional_packages(__packages__) +archinstall.storage['installation_session'].add_additional_packages(__packages__) -installation.enable_service('sshd') +archinstall.storage['installation_session'].enable_service('sshd') diff --git a/profiles/applications/tomcat.py b/profiles/applications/tomcat.py index 9c521390..ae6d1c2a 100644 --- a/profiles/applications/tomcat.py +++ b/profiles/applications/tomcat.py @@ -7,6 +7,6 @@ import archinstall # which packages will be installed by this profile __packages__ = ["tomcat10"] -installation.add_additional_packages(__packages__) +archinstall.storage['installation_session'].add_additional_packages(__packages__) -installation.enable_service('tomcat10') +archinstall.storage['installation_session'].enable_service('tomcat10') diff --git a/profiles/awesome.py b/profiles/awesome.py index a5dedccd..8ee113f4 100644 --- a/profiles/awesome.py +++ b/profiles/awesome.py @@ -30,23 +30,23 @@ def _prep_function(*args, **kwargs): # or through conventional import awesome if __name__ == 'awesome': # Install the application awesome from the template under /applications/ - awesome = archinstall.Application(installation, 'awesome') + awesome = archinstall.Application(archinstall.storage['installation_session'], 'awesome') awesome.install() - installation.add_additional_packages(__packages__) + archinstall.storage['installation_session'].add_additional_packages(__packages__) # TODO: Copy a full configuration to ~/.config/awesome/rc.lua instead. - with open(f'{installation.target}/etc/xdg/awesome/rc.lua', 'r') as fh: + with open(f'{archinstall.storage['installation_session'].target}/etc/xdg/awesome/rc.lua', 'r') as fh: awesome_lua = fh.read() ## Replace xterm with alacritty for a smoother experience. awesome_lua = awesome_lua.replace('"xterm"', '"alacritty"') - with open(f'{installation.target}/etc/xdg/awesome/rc.lua', 'w') as fh: + with open(f'{archinstall.storage['installation_session'].target}/etc/xdg/awesome/rc.lua', 'w') as fh: fh.write(awesome_lua) ## TODO: Configure the right-click-menu to contain the above packages that were installed. (as a user config) ## Remove some interfering nemo settings - installation.arch_chroot("gsettings set org.nemo.desktop show-desktop-icons false") - installation.arch_chroot("xdg-mime default nemo.desktop inode/directory application/x-gnome-saved-search") + archinstall.storage['installation_session'].arch_chroot("gsettings set org.nemo.desktop show-desktop-icons false") + archinstall.storage['installation_session'].arch_chroot("xdg-mime default nemo.desktop inode/directory application/x-gnome-saved-search") diff --git a/profiles/budgie.py b/profiles/budgie.py index fc061cd2..dbbd3a9d 100644 --- a/profiles/budgie.py +++ b/profiles/budgie.py @@ -28,9 +28,9 @@ def _prep_function(*args, **kwargs): # or through conventional import budgie if __name__ == 'budgie': # Install dependency profiles - installation.install_profile('xorg') + archinstall.storage['installation_session'].install_profile('xorg') # Install the Budgie packages - installation.add_additional_packages(__packages__) + archinstall.storage['installation_session'].add_additional_packages(__packages__) - installation.enable_service('lightdm') # Light Display Manager + archinstall.storage['installation_session'].enable_service('lightdm') # Light Display Manager diff --git a/profiles/cinnamon.py b/profiles/cinnamon.py index 4ca9cfed..89798671 100644 --- a/profiles/cinnamon.py +++ b/profiles/cinnamon.py @@ -27,9 +27,9 @@ def _prep_function(*args, **kwargs): # or through conventional import cinnamon if __name__ == 'cinnamon': # Install dependency profiles - installation.install_profile('xorg') + archinstall.storage['installation_session'].install_profile('xorg') # Install the Cinnamon packages - installation.add_additional_packages(__packages__) + archinstall.storage['installation_session'].add_additional_packages(__packages__) - installation.enable_service('lightdm') # Light Display Manager + archinstall.storage['installation_session'].enable_service('lightdm') # Light Display Manager diff --git a/profiles/deepin.py b/profiles/deepin.py index ce59a699..47fbe13f 100644 --- a/profiles/deepin.py +++ b/profiles/deepin.py @@ -28,10 +28,10 @@ def _prep_function(*args, **kwargs): # or through conventional import deepin if __name__ == 'deepin': # Install dependency profiles - installation.install_profile('xorg') + archinstall.storage['installation_session'].install_profile('xorg') # Install the Deepin packages - installation.add_additional_packages(__packages__) + archinstall.storage['installation_session'].add_additional_packages(__packages__) # Enable autostart of Deepin for all users - installation.enable_service('lightdm') + archinstall.storage['installation_session'].enable_service('lightdm') diff --git a/profiles/desktop.py b/profiles/desktop.py index 2aea6d30..d4c13239 100644 --- a/profiles/desktop.py +++ b/profiles/desktop.py @@ -48,9 +48,7 @@ if __name__ == 'desktop': """ # Install common packages for all desktop environments - installation.add_additional_packages(__packages__) - - # TODO: Remove magic variable 'installation' and place it - # in archinstall.storage or archinstall.session/archinstall.installation - installation.install_profile(archinstall.storage['_desktop_profile']) + archinstall.storage['installation_session'].add_additional_packages(__packages__) + + archinstall.storage['installation_session'].install_profile(archinstall.storage['_desktop_profile']) diff --git a/profiles/gnome.py b/profiles/gnome.py index 77c90859..e6cc75c0 100644 --- a/profiles/gnome.py +++ b/profiles/gnome.py @@ -29,11 +29,11 @@ def _prep_function(*args, **kwargs): # or through conventional import gnome if __name__ == 'gnome': # Install dependency profiles - installation.install_profile('xorg') + archinstall.storage['installation_session'].install_profile('xorg') # Install the GNOME packages - installation.add_additional_packages(__packages__) + archinstall.storage['installation_session'].add_additional_packages(__packages__) - installation.enable_service('gdm') # Gnome Display Manager + 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. diff --git a/profiles/i3.py b/profiles/i3.py index 8492d36f..e99bc549 100644 --- a/profiles/i3.py +++ b/profiles/i3.py @@ -48,16 +48,16 @@ if __name__ == 'i3': """ # Install common packages for all i3 configurations - installation.add_additional_packages(__packages__[:4]) + archinstall.storage['installation_session'].add_additional_packages(__packages__[:4]) # Install dependency profiles - installation.install_profile('xorg') + archinstall.storage['installation_session'].install_profile('xorg') # gaps is installed by deafult so we are overriding it here with lightdm - installation.add_additional_packages(__packages__[4:]) + archinstall.storage['installation_session'].add_additional_packages(__packages__[4:]) # Auto start lightdm for all users - installation.enable_service('lightdm') + archinstall.storage['installation_session'].enable_service('lightdm') # install the i3 group now - installation.add_additional_packages(archinstall.storage['_i3_configuration']) + archinstall.storage['installation_session'].add_additional_packages(archinstall.storage['_i3_configuration']) diff --git a/profiles/kde.py b/profiles/kde.py index c8efdcde..aac5ade4 100644 --- a/profiles/kde.py +++ b/profiles/kde.py @@ -37,10 +37,10 @@ def _post_install(*args, **kwargs): # or through conventional import kde if __name__ == 'kde': # Install dependency profiles - installation.install_profile('xorg') + archinstall.storage['installation_session'].install_profile('xorg') # Install the KDE packages - installation.add_additional_packages(__packages__) + archinstall.storage['installation_session'].add_additional_packages(__packages__) # Enable autostart of KDE for all users - installation.enable_service('sddm') + archinstall.storage['installation_session'].enable_service('sddm') diff --git a/profiles/lxqt.py b/profiles/lxqt.py index d0727a90..025d033d 100644 --- a/profiles/lxqt.py +++ b/profiles/lxqt.py @@ -28,9 +28,9 @@ def _prep_function(*args, **kwargs): # or through conventional import lxqt if __name__ == 'lxqt': # Install dependency profiles - installation.install_profile('xorg') + archinstall.storage['installation_session'].install_profile('xorg') # Install the LXQt packages - installation.add_additional_packages(__packages__) + archinstall.storage['installation_session'].add_additional_packages(__packages__) - installation.enable_service('sddm') # SDDM Display Manager + archinstall.storage['installation_session'].enable_service('sddm') # SDDM Display Manager diff --git a/profiles/mate.py b/profiles/mate.py index 2cfe7305..e2421ed8 100644 --- a/profiles/mate.py +++ b/profiles/mate.py @@ -27,9 +27,9 @@ def _prep_function(*args, **kwargs): # or through conventional import mate if __name__ == 'mate': # Install dependency profiles - installation.install_profile('xorg') + archinstall.storage['installation_session'].install_profile('xorg') # Install the MATE packages - installation.add_additional_packages(__packages__) + archinstall.storage['installation_session'].add_additional_packages(__packages__) - installation.enable_service('lightdm') # Light Display Manager + archinstall.storage['installation_session'].enable_service('lightdm') # Light Display Manager diff --git a/profiles/server.py b/profiles/server.py index 9d28054d..d0346ace 100644 --- a/profiles/server.py +++ b/profiles/server.py @@ -24,7 +24,7 @@ if __name__ == 'server': archinstall.log(archinstall.storage['_selected_servers'], level=logging.DEBUG) for server in archinstall.storage['_selected_servers']: archinstall.log(f'Installing {server} ...', level=logging.INFO) - app = archinstall.Application(installation, server) + app = archinstall.Application(archinstall.storage['installation_session'], server) app.install() archinstall.log('If your selections included multiple servers with the same port, you may have to reconfigure them.', fg="yellow", level=logging.INFO) diff --git a/profiles/sway.py b/profiles/sway.py index 8e256a87..e90e5e8d 100644 --- a/profiles/sway.py +++ b/profiles/sway.py @@ -44,7 +44,7 @@ if __name__ == "sway": ) # Install the Sway packages - installation.add_additional_packages(__packages__) + archinstall.storage['installation_session'].add_additional_packages(__packages__) # Install the graphics driver packages - installation.add_additional_packages(_gfx_driver_packages) + archinstall.storage['installation_session'].add_additional_packages(_gfx_driver_packages) diff --git a/profiles/xfce4.py b/profiles/xfce4.py index 8102919b..43da23ac 100644 --- a/profiles/xfce4.py +++ b/profiles/xfce4.py @@ -28,9 +28,9 @@ def _prep_function(*args, **kwargs): # or through conventional import xfce4 if __name__ == 'xfce4': # Install dependency profiles - installation.install_profile('xorg') + archinstall.storage['installation_session'].install_profile('xorg') # Install the XFCE4 packages - installation.add_additional_packages(__packages__) + archinstall.storage['installation_session'].add_additional_packages(__packages__) - installation.enable_service('lightdm') # Light Display Manager + archinstall.storage['installation_session'].enable_service('lightdm') # Light Display Manager diff --git a/profiles/xorg.py b/profiles/xorg.py index 7546a01b..19ca92d7 100644 --- a/profiles/xorg.py +++ b/profiles/xorg.py @@ -28,22 +28,12 @@ def _prep_function(*args, **kwargs): if __name__ == 'xorg': try: if "nvidia" in _gfx_driver_packages: - if "linux-zen" in installation.base_packages or "linux-lts" in installation.base_packages: - installation.add_additional_packages("dkms")#I've had kernel regen fail if it wasn't installed before nvidia-dkms - installation.add_additional_packages("xorg-server xorg-xinit nvidia-dkms") + 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("xorg-server xorg-xinit nvidia-dkms") else: - installation.add_additional_packages(f"xorg-server xorg-xinit {' '.join(_gfx_driver_packages)}") + archinstall.storage['installation_session'].add_additional_packages(f"xorg-server xorg-xinit {' '.join(_gfx_driver_packages)}") else: - installation.add_additional_packages(f"xorg-server xorg-xinit {' '.join(_gfx_driver_packages)}") + archinstall.storage['installation_session'].add_additional_packages(f"xorg-server xorg-xinit {' '.join(_gfx_driver_packages)}") except: - installation.add_additional_packages(f"xorg-server xorg-xinit") # Prep didn't run, so there's no driver to install - - # with open(f'{installation.mountpoint}/etc/X11/xinit/xinitrc', 'a') as X11: - # X11.write('setxkbmap se\n') - - # with open(f'{installation.mountpoint}/etc/vconsole.conf', 'a') as vconsole: - # vconsole.write('KEYMAP={keyboard_layout}\n'.format(**arguments)) - # vconsole.write('FONT=lat9w-16\n') - - # awesome = archinstall.Application(installation, 'awesome') - # awesome.install() \ No newline at end of file + archinstall.storage['installation_session'].add_additional_packages(f"xorg-server xorg-xinit") # Prep didn't run, so there's no driver to install \ No newline at end of file -- cgit v1.2.3-70-g09d2 From ffd5b5f80453a609b76e050d6d4e8309c540c28e Mon Sep 17 00:00:00 2001 From: Dylan Taylor Date: Sat, 15 May 2021 11:35:18 -0400 Subject: Very selectively fix some PEP 8 issues with profiles --- profiles/52-54-00-12-34-56.py | 4 ++-- profiles/applications/postgresql.py | 2 +- profiles/awesome.py | 3 ++- profiles/budgie.py | 6 ++++-- profiles/cinnamon.py | 15 +++++++++++-- profiles/deepin.py | 1 + profiles/desktop.py | 42 ++++++++++++++++++++++++++++++------- profiles/enlightenment.py | 1 + profiles/gnome.py | 4 +++- profiles/i3.py | 9 +++++--- profiles/kde.py | 2 ++ profiles/lxqt.py | 5 +++-- profiles/mate.py | 4 +++- profiles/minimal.py | 4 +++- profiles/server.py | 4 +++- profiles/sway.py | 4 +--- profiles/xfce4.py | 5 +++-- profiles/xorg.py | 1 + 18 files changed, 86 insertions(+), 30 deletions(-) (limited to 'profiles/sway.py') diff --git a/profiles/52-54-00-12-34-56.py b/profiles/52-54-00-12-34-56.py index 28cd14f6..d4fc3d07 100644 --- a/profiles/52-54-00-12-34-56.py +++ b/profiles/52-54-00-12-34-56.py @@ -7,7 +7,7 @@ __packages__ = ['nano', 'wget', 'git'] if __name__ == '52-54-00-12-34-56': awesome = archinstall.Application(archinstall.storage['installation_session'], 'postgresql') awesome.install() - + """ # Unmount and close previous runs (Mainly only used for re-runs, but won't hurt.) archinstall.sys_command(f'umount -R /mnt', suppress_errors=True) @@ -57,4 +57,4 @@ with archinstall.Filesystem(harddrive) as fs: urllib.request.urlopen(req, timeout=5) except: pass -""" \ No newline at end of file +""" diff --git a/profiles/applications/postgresql.py b/profiles/applications/postgresql.py index 3f8c6950..29546d78 100644 --- a/profiles/applications/postgresql.py +++ b/profiles/applications/postgresql.py @@ -8,4 +8,4 @@ archinstall.storage['installation_session'].add_additional_packages(__packages__ archinstall.storage['installation_session'].arch_chroot("initdb -D /var/lib/postgres/data", runas='postgres') -archinstall.storage['installation_session'].enable_service('postgresql') \ No newline at end of file +archinstall.storage['installation_session'].enable_service('postgresql') diff --git a/profiles/awesome.py b/profiles/awesome.py index ee812eb3..62cb9e00 100644 --- a/profiles/awesome.py +++ b/profiles/awesome.py @@ -8,6 +8,7 @@ is_top_level_profile = False # of the profile to get a list of "what packages will be installed". __packages__ = ['nemo', 'gpicview', 'main', 'alacritty'] + def _prep_function(*args, **kwargs): """ Magic function called by the importing installer @@ -46,7 +47,7 @@ if __name__ == 'awesome': fh.write(awesome_lua) ## TODO: Configure the right-click-menu to contain the above packages that were installed. (as a user config) - + ## Remove some interfering nemo settings archinstall.storage['installation_session'].arch_chroot("gsettings set org.nemo.desktop show-desktop-icons false") archinstall.storage['installation_session'].arch_chroot("xdg-mime default nemo.desktop inode/directory application/x-gnome-saved-search") diff --git a/profiles/budgie.py b/profiles/budgie.py index dbbd3a9d..abaf87b0 100644 --- a/profiles/budgie.py +++ b/profiles/budgie.py @@ -4,9 +4,10 @@ import archinstall is_top_level_profile = False -# "It is recommended also to install the gnome group, which contains applications required for the standard GNOME experience." - Arch Wiki +# "It is recommended also to install the gnome group, which contains applications required for the standard GNOME experience." - Arch Wiki __packages__ = ["budgie-desktop", "lightdm", "lightdm-gtk-greeter", "gnome"] + def _prep_function(*args, **kwargs): """ Magic function called by the importing installer @@ -23,6 +24,7 @@ def _prep_function(*args, **kwargs): else: print('Deprecated (??): xorg profile has no _prep_function() anymore') + # Ensures that this code only gets executed if executed # through importlib.util.spec_from_file_location("budgie", "/somewhere/budgie.py") # or through conventional import budgie @@ -33,4 +35,4 @@ if __name__ == 'budgie': # Install the Budgie packages archinstall.storage['installation_session'].add_additional_packages(__packages__) - archinstall.storage['installation_session'].enable_service('lightdm') # Light Display Manager + archinstall.storage['installation_session'].enable_service('lightdm') # Light Display Manager diff --git a/profiles/cinnamon.py b/profiles/cinnamon.py index 89798671..0122677a 100644 --- a/profiles/cinnamon.py +++ b/profiles/cinnamon.py @@ -4,7 +4,17 @@ import archinstall is_top_level_profile = False -__packages__ = ["cinnamon", "system-config-printer", "gnome-keyring", "gnome-terminal", "blueberry", "metacity", "lightdm", "lightdm-gtk-greeter"] +__packages__ = [ + "cinnamon", + "system-config-printer", + "gnome-keyring", + "gnome-terminal", + "blueberry", + "metacity", + "lightdm", + "lightdm-gtk-greeter", +] + def _prep_function(*args, **kwargs): """ @@ -22,6 +32,7 @@ def _prep_function(*args, **kwargs): else: print('Deprecated (??): xorg profile has no _prep_function() anymore') + # Ensures that this code only gets executed if executed # through importlib.util.spec_from_file_location("cinnamon", "/somewhere/cinnamon.py") # or through conventional import cinnamon @@ -32,4 +43,4 @@ if __name__ == 'cinnamon': # Install the Cinnamon packages archinstall.storage['installation_session'].add_additional_packages(__packages__) - archinstall.storage['installation_session'].enable_service('lightdm') # Light Display Manager + archinstall.storage['installation_session'].enable_service('lightdm') # Light Display Manager diff --git a/profiles/deepin.py b/profiles/deepin.py index 757597f3..a4778b0d 100644 --- a/profiles/deepin.py +++ b/profiles/deepin.py @@ -6,6 +6,7 @@ is_top_level_profile = False __packages__ = ["deepin", "deepin-terminal", "deepin-editor", "lightdm", "lightdm-gtk-greeter"] + def _prep_function(*args, **kwargs): """ Magic function called by the importing installer diff --git a/profiles/desktop.py b/profiles/desktop.py index 9e1d8b4c..84c1ac06 100644 --- a/profiles/desktop.py +++ b/profiles/desktop.py @@ -6,7 +6,19 @@ is_top_level_profile = True # New way of defining packages for a profile, which is iterable and can be used out side # of the profile to get a list of "what packages will be installed". -__packages__ = ['nano', 'vim', 'openssh', 'htop', 'wget', 'iwd', 'wireless_tools', 'wpa_supplicant', 'smartmontools', 'xdg-utils'] +__packages__ = [ + 'nano', + 'vim', + 'openssh', + 'htop', + 'wget', + 'iwd', + 'wireless_tools', + 'wpa_supplicant', + 'smartmontools', + 'xdg-utils', +] + def _prep_function(*args, **kwargs): """ @@ -16,11 +28,25 @@ def _prep_function(*args, **kwargs): for more input before any other installer steps start. """ - supported_desktops = ['gnome', 'kde', 'awesome', 'sway', 'cinnamon', 'xfce4', 'lxqt', 'i3', 'budgie', 'mate', 'deepin', 'enlightenment'] + supported_desktops = [ + 'gnome', + 'kde', + 'awesome', + 'sway', + 'cinnamon', + 'xfce4', + 'lxqt', + 'i3', + 'budgie', + 'mate', + 'deepin', + 'enlightenment', + ] + + desktop = archinstall.generic_select( + supported_desktops, 'Select your desired desktop environment: ', allow_empty_input=False, sort=True + ) - desktop = archinstall.generic_select(supported_desktops, 'Select your desired desktop environment: ', - allow_empty_input=False, sort=True) - # Temporarily store the selected desktop profile # in a session-safe location, since this module will get reloaded # the next time it gets executed. @@ -34,6 +60,7 @@ def _prep_function(*args, **kwargs): else: print(f"Deprecated (??): {desktop} profile has no _prep_function() anymore") + if __name__ == 'desktop': """ This "profile" is a meta-profile. @@ -47,9 +74,8 @@ if __name__ == 'desktop': There are plenty of desktop-turn-key-solutions based on Arch Linux, this is therefore just a helper to get started """ - + # Install common packages for all desktop environments archinstall.storage['installation_session'].add_additional_packages(__packages__) - - archinstall.storage['installation_session'].install_profile(archinstall.storage['_desktop_profile']) + archinstall.storage['installation_session'].install_profile(archinstall.storage['_desktop_profile']) diff --git a/profiles/enlightenment.py b/profiles/enlightenment.py index 6ff334de..4c5a7999 100644 --- a/profiles/enlightenment.py +++ b/profiles/enlightenment.py @@ -6,6 +6,7 @@ is_top_level_profile = False __packages__ = ["enlightenment", "terminology", "lightdm", "lightdm-gtk-greeter"] + def _prep_function(*args, **kwargs): """ Magic function called by the importing installer diff --git a/profiles/gnome.py b/profiles/gnome.py index e6cc75c0..09fac1bb 100644 --- a/profiles/gnome.py +++ b/profiles/gnome.py @@ -7,6 +7,7 @@ is_top_level_profile = False # Note: GDM should be part of the gnome group, but adding it here for clarity __packages__ = ["gnome", "gnome-tweaks", "gdm"] + def _prep_function(*args, **kwargs): """ Magic function called by the importing installer @@ -24,6 +25,7 @@ def _prep_function(*args, **kwargs): else: print('Deprecated (??): xorg profile has no _prep_function() anymore') + # Ensures that this code only gets executed if executed # through importlib.util.spec_from_file_location("gnome", "/somewhere/gnome.py") # or through conventional import gnome @@ -34,6 +36,6 @@ if __name__ == 'gnome': # Install the GNOME packages archinstall.storage['installation_session'].add_additional_packages(__packages__) - archinstall.storage['installation_session'].enable_service('gdm') # Gnome Display Manager + 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. diff --git a/profiles/i3.py b/profiles/i3.py index e99bc549..1972ba59 100644 --- a/profiles/i3.py +++ b/profiles/i3.py @@ -8,6 +8,7 @@ is_top_level_profile = False # of the profile to get a list of "what packages will be installed". __packages__ = ['i3lock', 'i3status', 'i3blocks', 'xterm', 'lightdm-gtk-greeter', 'lightdm', 'dmenu'] + def _prep_function(*args, **kwargs): """ Magic function called by the importing installer @@ -17,8 +18,9 @@ def _prep_function(*args, **kwargs): """ supported_configurations = ['i3-wm', 'i3-gaps'] - desktop = archinstall.generic_select(supported_configurations, 'Select your desired configuration: ', - allow_empty_input=False, sort=True) + desktop = archinstall.generic_select( + supported_configurations, 'Select your desired configuration: ', allow_empty_input=False, sort=True + ) # Temporarily store the selected desktop profile # in a session-safe location, since this module will get reloaded @@ -33,6 +35,7 @@ def _prep_function(*args, **kwargs): else: print('Deprecated (??): xorg profile has no _prep_function() anymore') + if __name__ == 'i3': """ This "profile" is a meta-profile. @@ -46,7 +49,7 @@ if __name__ == 'i3': There are plenty of desktop-turn-key-solutions based on Arch Linux, this is therefore just a helper to get started """ - + # Install common packages for all i3 configurations archinstall.storage['installation_session'].add_additional_packages(__packages__[:4]) diff --git a/profiles/kde.py b/profiles/kde.py index aac5ade4..66625074 100644 --- a/profiles/kde.py +++ b/profiles/kde.py @@ -8,6 +8,7 @@ __packages__ = ["plasma-meta", "konsole", "kate", "dolphin", "sddm", "plasma-way # TODO: Remove hard dependency of bash (due to .bash_profile) + def _prep_function(*args, **kwargs): """ Magic function called by the importing installer @@ -24,6 +25,7 @@ def _prep_function(*args, **kwargs): else: print('Deprecated (??): xorg profile has no _prep_function() anymore') + """ def _post_install(*args, **kwargs): if "nvidia" in _gfx_driver_packages: diff --git a/profiles/lxqt.py b/profiles/lxqt.py index 025d033d..af6337e6 100644 --- a/profiles/lxqt.py +++ b/profiles/lxqt.py @@ -1,4 +1,3 @@ - # A desktop environment using "LXQt" import archinstall @@ -7,6 +6,7 @@ is_top_level_profile = False __packages__ = ["lxqt", "breeze-icons", "oxygen-icons", "xdg-utils", "ttf-freefont", "leafpad", "slock", "sddm"] + def _prep_function(*args, **kwargs): """ Magic function called by the importing installer @@ -23,6 +23,7 @@ def _prep_function(*args, **kwargs): else: print('Deprecated (??): xorg profile has no _prep_function() anymore') + # Ensures that this code only gets executed if executed # through importlib.util.spec_from_file_location("lxqt", "/somewhere/lxqt.py") # or through conventional import lxqt @@ -33,4 +34,4 @@ if __name__ == 'lxqt': # Install the LXQt packages archinstall.storage['installation_session'].add_additional_packages(__packages__) - archinstall.storage['installation_session'].enable_service('sddm') # SDDM Display Manager + archinstall.storage['installation_session'].enable_service('sddm') # SDDM Display Manager diff --git a/profiles/mate.py b/profiles/mate.py index e2421ed8..351f2250 100644 --- a/profiles/mate.py +++ b/profiles/mate.py @@ -6,6 +6,7 @@ is_top_level_profile = False __packages__ = ["mate", "mate-extra", "lightdm", "lightdm-gtk-greeter"] + def _prep_function(*args, **kwargs): """ Magic function called by the importing installer @@ -22,6 +23,7 @@ def _prep_function(*args, **kwargs): else: print('Deprecated (??): xorg profile has no _prep_function() anymore') + # Ensures that this code only gets executed if executed # through importlib.util.spec_from_file_location("mate", "/somewhere/mate.py") # or through conventional import mate @@ -32,4 +34,4 @@ if __name__ == 'mate': # Install the MATE packages archinstall.storage['installation_session'].add_additional_packages(__packages__) - archinstall.storage['installation_session'].enable_service('lightdm') # Light Display Manager + archinstall.storage['installation_session'].enable_service('lightdm') # Light Display Manager diff --git a/profiles/minimal.py b/profiles/minimal.py index 79821a89..8af06a3a 100644 --- a/profiles/minimal.py +++ b/profiles/minimal.py @@ -4,6 +4,7 @@ import archinstall, os is_top_level_profile = True + def _prep_function(*args, **kwargs): """ Magic function called by the importing installer @@ -11,7 +12,8 @@ def _prep_function(*args, **kwargs): we don't need to do anything special here, but it needs to exist and return True. """ - return True # Do nothing and just return True + return True # Do nothing and just return True + if __name__ == 'minimal': """ diff --git a/profiles/server.py b/profiles/server.py index d0346ace..36bfd3ab 100644 --- a/profiles/server.py +++ b/profiles/server.py @@ -6,6 +6,7 @@ is_top_level_profile = True available_servers = ["cockpit", "docker", "httpd", "lighttpd", "mariadb", "nginx", "postgresql", "sshd", "tomcat"] + def _prep_function(*args, **kwargs): """ Magic function called by the importing installer @@ -13,9 +14,10 @@ def _prep_function(*args, **kwargs): """ selected_servers = archinstall.generic_multi_select(available_servers, f"Choose which servers to install and enable (leave blank for a minimal installation): ") archinstall.storage['_selected_servers'] = selected_servers - + return True + if __name__ == 'server': """ This "profile" is a meta-profile. diff --git a/profiles/sway.py b/profiles/sway.py index e90e5e8d..686fe868 100644 --- a/profiles/sway.py +++ b/profiles/sway.py @@ -39,9 +39,7 @@ if __name__ == "sway": "The proprietary Nvidia driver is not supported by Sway. It is likely that you will run into issues. Continue anyways? [y/N] " ) if choice.lower() in ("n", ""): - raise archinstall.lib.exceptions.HardwareIncompatibilityError( - "Sway does not support the proprietary nvidia drivers." - ) + raise archinstall.lib.exceptions.HardwareIncompatibilityError("Sway does not support the proprietary nvidia drivers.") # Install the Sway packages archinstall.storage['installation_session'].add_additional_packages(__packages__) diff --git a/profiles/xfce4.py b/profiles/xfce4.py index 43da23ac..ad00c461 100644 --- a/profiles/xfce4.py +++ b/profiles/xfce4.py @@ -1,4 +1,3 @@ - # A desktop environment using "Xfce4" import archinstall @@ -7,6 +6,7 @@ is_top_level_profile = False __packages__ = ["xfce4", "xfce4-goodies", "lightdm", "lightdm-gtk-greeter"] + def _prep_function(*args, **kwargs): """ Magic function called by the importing installer @@ -23,6 +23,7 @@ def _prep_function(*args, **kwargs): else: print('Deprecated (??): xorg profile has no _prep_function() anymore') + # Ensures that this code only gets executed if executed # through importlib.util.spec_from_file_location("xfce4", "/somewhere/xfce4.py") # or through conventional import xfce4 @@ -33,4 +34,4 @@ if __name__ == 'xfce4': # Install the XFCE4 packages archinstall.storage['installation_session'].add_additional_packages(__packages__) - archinstall.storage['installation_session'].enable_service('lightdm') # Light Display Manager + archinstall.storage['installation_session'].enable_service('lightdm') # Light Display Manager diff --git a/profiles/xorg.py b/profiles/xorg.py index 19ca92d7..e7cf00d0 100644 --- a/profiles/xorg.py +++ b/profiles/xorg.py @@ -7,6 +7,7 @@ is_top_level_profile = True __packages__ = ['dkms', 'xorg-server', 'xorg-xinit', 'nvidia-dkms', 'xorg-server', *archinstall.lib.hardware.__packages__] + def _prep_function(*args, **kwargs): """ Magic function called by the importing installer -- cgit v1.2.3-70-g09d2 From 126c7ebfca16156d4e1c738a5f562ba99a4ab5f2 Mon Sep 17 00:00:00 2001 From: Dylan Taylor Date: Sat, 15 May 2021 14:46:40 -0400 Subject: More formatting fixes to satisfy PEP 8 --- archinstall/__init__.py | 3 ++- archinstall/lib/disk.py | 28 ++++++++++++++++------------ archinstall/lib/general.py | 6 +++--- archinstall/lib/installer.py | 19 +++++++++++-------- archinstall/lib/luks.py | 3 ++- archinstall/lib/networking.py | 1 + archinstall/lib/profiles.py | 4 ++-- archinstall/lib/storage.py | 2 +- archinstall/lib/user_interaction.py | 27 ++++++++++++--------------- docs/conf.py | 5 +---- examples/guided.py | 8 ++------ profiles/desktop.py | 4 +--- profiles/i3.py | 4 +--- profiles/sway.py | 4 +--- 14 files changed, 56 insertions(+), 62 deletions(-) (limited to 'profiles/sway.py') diff --git a/archinstall/__init__.py b/archinstall/__init__.py index f1d8341e..58012a21 100644 --- a/archinstall/__init__.py +++ b/archinstall/__init__.py @@ -34,7 +34,8 @@ for arg in sys.argv[1:]: # TODO: Learn the dark arts of argparse... -# (I summon thee dark spawn of cPython) +# (I summon thee dark spawn of cPython) + def run_as_a_module(): """ diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index 65d1599b..85e8a402 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -17,7 +17,8 @@ MBR = 0b00000010 # libc = ctypes.CDLL(ctypes.util.find_library('c'), use_errno=True) # libc.mount.argtypes = (ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_ulong, ctypes.c_char_p) -class BlockDevice(): + +class BlockDevice: def __init__(self, path, info=None): if not info: # If we don't give any information, we need to auto-fill it. @@ -76,7 +77,8 @@ class BlockDevice(): if self.info['type'] == 'loop': for drive in json.loads(b''.join(sys_command(['losetup', '--json'], hide_from_log=True)).decode('UTF_8'))['loopdevices']: - if not drive['name'] == self.path: continue + if not drive['name'] == self.path: + continue return drive['back-file'] elif self.info['type'] == 'disk': @@ -91,8 +93,8 @@ class BlockDevice(): else: log(f"Unknown blockdevice type for {self.path}: {self.info['type']}", level=logging.DEBUG) - # if not stat.S_ISBLK(os.stat(full_path).st_mode): - # raise DiskError(f'Selected disk "{full_path}" is not a block device.') + # if not stat.S_ISBLK(os.stat(full_path).st_mode): + # raise DiskError(f'Selected disk "{full_path}" is not a block device.') @property def partitions(self): @@ -153,7 +155,7 @@ class BlockDevice(): self.part_cache = OrderedDict() -class Partition(): +class Partition: 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) @@ -236,7 +238,7 @@ class Partition(): for blockdevice in json.loads(b''.join(sys_command('lsblk -J')).decode('UTF-8'))['blockdevices']: if (parent := self.find_parent_of(blockdevice, os.path.basename(self.path))): return f"/dev/{parent}" - # raise DiskError(f'Could not find appropriate parent for encrypted partition {self}') + # raise DiskError(f'Could not find appropriate parent for encrypted partition {self}') return self.path def detect_inner_filesystem(self, password): @@ -351,9 +353,9 @@ class Partition(): self.filesystem = 'f2fs' elif filesystem == 'crypto_LUKS': - # from .luks import luks2 - # encrypted_partition = luks2(self, None, None) - # encrypted_partition.format(path) + # from .luks import luks2 + # encrypted_partition = luks2(self, None, None) + # encrypted_partition.format(path) self.filesystem = 'crypto_LUKS' else: @@ -378,7 +380,8 @@ class Partition(): if not self.mountpoint: log(f'Mounting {self} to {target}', level=logging.INFO) if not fs: - if not self.filesystem: raise DiskError(f'Need to format (or define) the filesystem on {self} before mounting.') + if not self.filesystem: + raise DiskError(f'Need to format (or define) the filesystem on {self} before mounting.') fs = self.filesystem pathlib.Path(target).mkdir(parents=True, exist_ok=True) @@ -425,7 +428,7 @@ class Partition(): return True -class Filesystem(): +class Filesystem: # TODO: # When instance of a HDD is selected, check all usages and gracefully unmount them # as well as close any crypto handles. @@ -566,7 +569,8 @@ def all_disks(*args, **kwargs): 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(b''.join(sys_command('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 + if not kwargs['partitions'] and drive['type'] == 'part': + continue drives[drive['path']] = BlockDevice(drive['path'], drive) return drives diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py index b65e2593..816fa755 100644 --- a/archinstall/lib/general.py +++ b/archinstall/lib/general.py @@ -170,7 +170,7 @@ class sys_command: 'ended': self.ended, 'started_pprint': '{}-{}-{} {}:{}:{}'.format(*time.localtime(self.started)), 'ended_pprint': '{}-{}-{} {}:{}:{}'.format(*time.localtime(self.ended)) if self.ended else None, - 'exit_code': self.exit_code + 'exit_code': self.exit_code, } def peak(self, output: Union[str, bytes]) -> bool: @@ -256,7 +256,7 @@ class sys_command: original = trigger trigger = bytes(original, 'UTF-8') self.kwargs['events'][trigger] = self.kwargs['events'][original] - del (self.kwargs['events'][original]) + del self.kwargs['events'][original] if type(self.kwargs['events'][trigger]) != bytes: self.kwargs['events'][trigger] = bytes(self.kwargs['events'][trigger], 'UTF-8') @@ -269,7 +269,7 @@ class sys_command: last_trigger_pos = trigger_pos os.write(child_fd, self.kwargs['events'][trigger]) - del (self.kwargs['events'][trigger]) + del self.kwargs['events'][trigger] broke = True break diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index bac19007..139d9d33 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -9,7 +9,7 @@ from .user_interaction import * __packages__ = ["base", "base-devel", "linux-firmware", "linux", "linux-lts", "linux-zen", "linux-hardened"] -class Installer(): +class Installer: """ `Installer()` is the wrapper for most basic installation steps. It also wraps :py:func:`~archinstall.Installer.pacstrap` among other things. @@ -127,7 +127,8 @@ class Installer(): return [step for step, flag in self.helper_flags.items() if flag is False] def pacstrap(self, *packages, **kwargs): - if type(packages[0]) in (list, tuple): packages = packages[0] + if type(packages[0]) in (list, tuple): + packages = packages[0] self.log(f'Installing packages: {packages}', level=logging.INFO) if (sync_mirrors := sys_command('/usr/bin/pacman -Syy')).exit_code == 0: @@ -158,7 +159,8 @@ class Installer(): fh.write(hostname + '\n') def set_locale(self, locale, encoding='UTF-8', *args, **kwargs): - if not len(locale): return True + if not len(locale): + return True with open(f'{self.target}/etc/locale.gen', 'a') as fh: fh.write(f'{locale}.{encoding} {encoding}\n') @@ -168,8 +170,10 @@ class Installer(): return True if sys_command(f'/usr/bin/arch-chroot {self.target} locale-gen').exit_code == 0 else False def set_timezone(self, zone, *args, **kwargs): - if not zone: return True - if not len(zone): return True # Redundant + if not zone: + return True + if not len(zone): + return True # Redundant if (pathlib.Path("/usr") / "share" / "zoneinfo" / zone).exists(): (pathlib.Path(self.target) / "etc" / "localtime").unlink(missing_ok=True) @@ -263,6 +267,7 @@ class Installer(): if enable_services: # If we haven't installed the base yet (function called pre-maturely) if self.helper_flags.get('base', False) is False: + def post_install_enable_networkd_resolved(*args, **kwargs): self.enable_service('systemd-networkd', 'systemd-resolved') @@ -332,9 +337,7 @@ class Installer(): self.helper_flags['base-strapped'] = True with open(f"{self.target}/etc/fstab", "a") as fstab: - fstab.write( - "\ntmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0\n" - ) # Redundant \n at the start? who knows? + fstab.write("\ntmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0\n") # Redundant \n at the start? who knows? ## TODO: Support locale and timezone # os.remove(f'{self.target}/etc/localtime') diff --git a/archinstall/lib/luks.py b/archinstall/lib/luks.py index e6e1c897..1cb6777f 100644 --- a/archinstall/lib/luks.py +++ b/archinstall/lib/luks.py @@ -5,7 +5,7 @@ from .general import * from .output import log -class luks2(): +class luks2: def __init__(self, partition, mountpoint, password, key_file=None, auto_unmount=False, *args, **kwargs): self.password = password self.partition = partition @@ -120,6 +120,7 @@ class luks2(): :type mountpoint: str """ from .disk import get_filesystem_type + if '/' in mountpoint: os.path.basename(mountpoint) # TODO: Raise exception instead? diff --git a/archinstall/lib/networking.py b/archinstall/lib/networking.py index 3e5ed4e7..e12d9cc3 100644 --- a/archinstall/lib/networking.py +++ b/archinstall/lib/networking.py @@ -68,6 +68,7 @@ def get_wireless_networks(interface): # TODO: Make this oneliner pritter to check if the interface is scanning or not. if not '_WIFI' in storage or interface not in storage['_WIFI'] or storage['_WIFI'][interface].get('scanning', False) is False: import time + wireless_scan(interface) time.sleep(5) diff --git a/archinstall/lib/profiles.py b/archinstall/lib/profiles.py index 2f97231c..894b8fcb 100644 --- a/archinstall/lib/profiles.py +++ b/archinstall/lib/profiles.py @@ -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 @@ -75,7 +75,7 @@ def list_profiles(filter_irrelevant_macs=True, subpath='', filter_top_level_prof if filter_top_level_profiles: for profile in list(cache.keys()): if Profile(None, profile).is_top_level_profile() is False: - del (cache[profile]) + del cache[profile] return cache diff --git a/archinstall/lib/storage.py b/archinstall/lib/storage.py index 53d5e938..42214572 100644 --- a/archinstall/lib/storage.py +++ b/archinstall/lib/storage.py @@ -18,5 +18,5 @@ storage = { 'PROFILE_DB': None, # Used in cases when listing profiles is desired, not mandatory for direct profile grabing. 'LOG_PATH': '/var/log/archinstall', 'LOG_FILE': 'install.log', - 'MOUNT_POINT': '/mnt' + 'MOUNT_POINT': '/mnt', } diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 69689479..f39eea1c 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -23,6 +23,7 @@ from .profiles import Profile # TODO: Some inconsistencies between the selection processes. # Some return the keys from the options, some the values? + def get_terminal_height(): return shutil.get_terminal_size().lines @@ -104,7 +105,7 @@ def print_large_list(options, padding=5, margin_bottom=0, separator=': '): max_num_of_columns = get_terminal_width() // longest_line max_options_in_cells = max_num_of_columns * (get_terminal_height() - margin_bottom) - if (len(options) > max_options_in_cells): + if len(options) > max_options_in_cells: for index, option in enumerate(options): print(f"{index}: {option}") return 1, index @@ -214,8 +215,10 @@ class MiniCurses: self._cursor_x += len(text) def clear(self, x, y): - if x < 0: x = 0 - if y < 0: y = 0 + if x < 0: + x = 0 + if y < 0: + y = 0 # import time # sys.stdout.write(f"Clearing from: {x, y}") @@ -401,8 +404,7 @@ def ask_to_configure_network(): for index, mode in enumerate(modes): print(f"{index}: {mode}") - mode = generic_select(['DHCP', 'IP'], f"Select which mode to configure for {nic} or leave blank for DHCP: ", - options_output=False) + mode = generic_select(['DHCP', 'IP'], f"Select which mode to configure for {nic} or leave blank for DHCP: ", options_output=False) if mode == 'IP': while 1: ip = input(f"Enter the IP and subnet for {nic} (example: 192.168.0.5/24): ").strip() @@ -450,11 +452,10 @@ def ask_for_disk_layout(): options = { 'keep-existing': 'Keep existing partition layout and select which ones to use where', 'format-all': 'Format entire drive and setup a basic partition scheme', - 'abort': 'Abort the installation' + 'abort': 'Abort the installation', } - value = generic_select(options, "Found partitions on the selected drive, (select by number) what you want to do: ", - allow_empty_input=False, sort=True) + value = generic_select(options, "Found partitions on the selected drive, (select by number) what you want to do: ", allow_empty_input=False, sort=True) return next((key for key, val in options.items() if val == value), None) @@ -466,8 +467,7 @@ def ask_for_main_filesystem_format(): 'f2fs': 'f2fs' } - value = generic_select(options, "Select which filesystem your main partition should use (by number or name): ", - allow_empty_input=False) + value = generic_select(options, "Select which filesystem your main partition should use (by number or name): ", allow_empty_input=False) return next((key for key, val in options.items() if val == value), None) @@ -584,8 +584,7 @@ def select_profile(options): print(' -- They might make it easier to install things like desktop environments. --') print(' -- (Leave blank and hit enter to skip this step and continue) --') - selected_profile = generic_select(profiles, 'Enter a pre-programmed profile name if you want to install one: ', - options_output=False) + selected_profile = generic_select(profiles, 'Enter a pre-programmed profile name if you want to install one: ', options_output=False) if selected_profile: return Profile(None, selected_profile) else: @@ -675,9 +674,7 @@ def select_mirror_regions(mirrors, show_top_mirrors=True): print_large_list(regions, margin_bottom=4) print(' -- You can skip this step by leaving the option blank --') - selected_mirror = generic_select(regions, - 'Select one of the above regions to download packages from (by number or full name): ', - options_output=False) + selected_mirror = generic_select(regions, 'Select one of the above regions to download packages from (by number or full name): ', options_output=False) if not selected_mirror: # Returning back empty options which can be both used to # do "if x:" logic as well as do `x.get('mirror', {}).get('sub', None)` chaining diff --git a/docs/conf.py b/docs/conf.py index 9d23f979..88a55e02 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -123,8 +123,5 @@ man_pages = [("index", "archinstall", u"archinstall Documentation", [u"Anton Hvo # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ( - "index", "archinstall", u"archinstall Documentation", - u"Anton Hvornum", "archinstall", "Simple and minimal HTTP server." - ), + ("index", "archinstall", u"archinstall Documentation", u"Anton Hvornum", "archinstall", "Simple and minimal HTTP server."), ] diff --git a/examples/guided.py b/examples/guided.py index 0ddca5a2..f5da9265 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -84,8 +84,7 @@ def ask_user_questions(): # Select a partition # 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): ") + partition = archinstall.generic_select(mountpoints_list, "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 @@ -373,10 +372,7 @@ def perform_installation(mountpoint): if archinstall.arguments['profile'] and archinstall.arguments['profile'].has_post_install(): with archinstall.arguments['profile'].load_instructions(namespace=f"{archinstall.arguments['profile'].namespace}.py") as imported: if not imported._post_install(): - archinstall.log( - ' * Profile\'s post configuration requirements was not fulfilled.', - fg='red' - ) + archinstall.log(' * Profile\'s post configuration requirements was not fulfilled.', fg='red') exit(1) installation.log("For post-installation tips, see https://wiki.archlinux.org/index.php/Installation_guide#Post-installation", fg="yellow") diff --git a/profiles/desktop.py b/profiles/desktop.py index 67514a97..30bb9a6a 100644 --- a/profiles/desktop.py +++ b/profiles/desktop.py @@ -43,9 +43,7 @@ def _prep_function(*args, **kwargs): 'enlightenment', ] - desktop = archinstall.generic_select( - supported_desktops, 'Select your desired desktop environment: ', allow_empty_input=False, sort=True - ) + desktop = archinstall.generic_select(supported_desktops, 'Select your desired desktop environment: ', allow_empty_input=False, sort=True) # Temporarily store the selected desktop profile # in a session-safe location, since this module will get reloaded diff --git a/profiles/i3.py b/profiles/i3.py index 418749c0..c25003f9 100644 --- a/profiles/i3.py +++ b/profiles/i3.py @@ -18,9 +18,7 @@ def _prep_function(*args, **kwargs): """ supported_configurations = ['i3-wm', 'i3-gaps'] - desktop = archinstall.generic_select( - supported_configurations, 'Select your desired configuration: ', allow_empty_input=False, sort=True - ) + desktop = archinstall.generic_select(supported_configurations, 'Select your desired configuration: ', allow_empty_input=False, sort=True) # Temporarily store the selected desktop profile # in a session-safe location, since this module will get reloaded diff --git a/profiles/sway.py b/profiles/sway.py index 686fe868..9afc047d 100644 --- a/profiles/sway.py +++ b/profiles/sway.py @@ -35,9 +35,7 @@ def _prep_function(*args, **kwargs): # or through conventional import sway if __name__ == "sway": if "nvidia" in _gfx_driver_packages: - choice = input( - "The proprietary Nvidia driver is not supported by Sway. It is likely that you will run into issues. Continue anyways? [y/N] " - ) + choice = input("The proprietary Nvidia driver is not supported by Sway. It is likely that you will run into issues. Continue anyways? [y/N] ") if choice.lower() in ("n", ""): raise archinstall.lib.exceptions.HardwareIncompatibilityError("Sway does not support the proprietary nvidia drivers.") -- cgit v1.2.3-70-g09d2