From 32dce852570c3e489f08549e8c0c453ce4184afe Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Tue, 1 Jun 2021 20:11:25 +0200 Subject: Introduces HTTP mirror selection --- archinstall/lib/mirrors.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/archinstall/lib/mirrors.py b/archinstall/lib/mirrors.py index ccfc2808..fad3b129 100644 --- a/archinstall/lib/mirrors.py +++ b/archinstall/lib/mirrors.py @@ -16,7 +16,7 @@ def filter_mirrors_by_region(regions, destination='/etc/pacman.d/mirrorlist', *a region_list = [] for region in regions.split(','): region_list.append(f'country={region}') - response = urllib.request.urlopen(urllib.request.Request(f"https://archlinux.org/mirrorlist/?{'&'.join(region_list)}&protocol=https&ip_version=4&ip_version=6&use_mirror_status=on'", headers={'User-Agent': 'ArchInstall'})) + response = urllib.request.urlopen(urllib.request.Request(f"https://archlinux.org/mirrorlist/?{'&'.join(region_list)}&protocol=https&protocol=http&ip_version=4&ip_version=6&use_mirror_status=on'", headers={'User-Agent': 'ArchInstall'})) new_list = response.read().replace(b"#Server", b"Server") with open(destination, "wb") as mirrorlist: mirrorlist.write(new_list) @@ -79,7 +79,7 @@ def re_rank_mirrors(top=10, *positionals, **kwargs): def list_mirrors(): - url = "https://archlinux.org/mirrorlist/?protocol=https&ip_version=4&ip_version=6&use_mirror_status=on" + url = "https://archlinux.org/mirrorlist/?protocol=https&protocol=http&ip_version=4&ip_version=6&use_mirror_status=on" regions = {} try: -- cgit v1.2.3-70-g09d2 From 0901723ff483867558fe49c892c0c825942e1ac3 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Tue, 1 Jun 2021 23:56:15 +0200 Subject: Windows fix + Sorting based on list This fix introduces changes so that development can be done (and tested) on other platforms than Linux. This is a convenience fix and shouldn't break anything (simply a few Linux-specific imports that have moved into the functions where they are used). This commit also introduces sorting based on a list of priorities (where the default will be last if not matched). --- archinstall/lib/general.py | 33 ++++++++++++++++-- archinstall/lib/mirrors.py | 68 +++++++++++++++++++++++++++++++++---- archinstall/lib/networking.py | 2 +- archinstall/lib/user_interaction.py | 4 +-- 4 files changed, 96 insertions(+), 11 deletions(-) diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py index 3b62c891..aefc7c89 100644 --- a/archinstall/lib/general.py +++ b/archinstall/lib/general.py @@ -2,14 +2,41 @@ import hashlib import json import logging import os -import pty import shlex import subprocess import sys import time from datetime import datetime, date -from select import epoll, EPOLLIN, EPOLLHUP from typing import Union +try: + from select import epoll, EPOLLIN, EPOLLHUP +except: + import select + EPOLLIN = 0 + EPOLLHUP = 0 + class epoll(): + """ #!if windows + Create a epoll() implementation that simulates the epoll() behavior. + This so that the rest of the code doesn't need to worry weither we're using select() or epoll(). + """ + def __init__(self): + self.sockets = {} + self.monitoring = {} + + def unregister(self, fileno, *args, **kwargs): + try: + del(self.monitoring[fileno]) + except: + pass + + def register(self, fileno, *args, **kwargs): + self.monitoring[fileno] = True + + def poll(self, timeout=0.05, *args, **kwargs): + try: + return [[fileno, 1] for fileno in select.select(list(self.monitoring.keys()), [], [], timeout)[0]] + except OSError: + return [] from .exceptions import * from .output import log @@ -252,6 +279,8 @@ class SysCommandWorker: self.exit_code = 1 def execute(self) -> bool: + import pty + if (old_dir := os.getcwd()) != self.working_directory: os.chdir(self.working_directory) diff --git a/archinstall/lib/mirrors.py b/archinstall/lib/mirrors.py index fad3b129..44c73132 100644 --- a/archinstall/lib/mirrors.py +++ b/archinstall/lib/mirrors.py @@ -4,8 +4,53 @@ import urllib.request from .general import * from .output import log +def sort_mirrorlist(raw_data :bytes, sort_order=["https", "http"]) -> bytes: + """ + This function can sort /etc/pacman.d/mirrorlist according to the + mirror's URL prefix. By default places HTTPS before HTTP but it also + preserves the country/rank-order. + + This assumes /etc/pacman.d/mirrorlist looks like the following: + + ## Comment + Server = url + + or + + ## Comment + #Server = url + + But the Comments need to start with double-hashmarks to be distringuished + from server url definitions (commented or uncommented). + """ + comments_and_whitespaces = b"" + + categories = {key: [] for key in sort_order+["Unknown"]} + for line in raw_data.split(b"\n"): + if line[0:2] in (b'##', b''): + comments_and_whitespaces += line + b'\n' + elif line[:6].lower() == b'server' or line[:7].lower() == b'#server': + opening, url = line.split(b'=', 1) + opening, url = opening.strip(), url.strip() + if (category := url.split(b'://',1)[0].decode('UTF-8')) in categories: + categories[category].append(comments_and_whitespaces) + categories[category].append(opening+b' = '+url+b'\n') + else: + categories["Unknown"].append(comments_and_whitespaces) + categories["Unknown"].append(opening+b' = '+url+b'\n') + + comments_and_whitespaces = b"" -def filter_mirrors_by_region(regions, destination='/etc/pacman.d/mirrorlist', *args, **kwargs): + + new_raw_data = b'' + for category in sort_order+["Unknown"]: + for line in categories[category]: + new_raw_data += line + + return new_raw_data + + +def filter_mirrors_by_region(regions, destination='/etc/pacman.d/mirrorlist', sort_order=["https", "http"], *args, **kwargs): """ This function will change the active mirrors on the live medium by filtering which regions are active based on `regions`. @@ -18,10 +63,17 @@ def filter_mirrors_by_region(regions, destination='/etc/pacman.d/mirrorlist', *a region_list.append(f'country={region}') response = urllib.request.urlopen(urllib.request.Request(f"https://archlinux.org/mirrorlist/?{'&'.join(region_list)}&protocol=https&protocol=http&ip_version=4&ip_version=6&use_mirror_status=on'", headers={'User-Agent': 'ArchInstall'})) new_list = response.read().replace(b"#Server", b"Server") - with open(destination, "wb") as mirrorlist: - mirrorlist.write(new_list) - return True + if sort_order: + new_list = sort_mirrorlist(new_list, sort_order=sort_order) + + if destination: + with open(destination, "wb") as mirrorlist: + mirrorlist.write(new_list) + + return True + else: + return new_list.decode('UTF-8') def add_custom_mirrors(mirrors: list, *args, **kwargs): @@ -78,7 +130,7 @@ def re_rank_mirrors(top=10, *positionals, **kwargs): return False -def list_mirrors(): +def list_mirrors(sort_order=["https", "http"]): url = "https://archlinux.org/mirrorlist/?protocol=https&protocol=http&ip_version=4&ip_version=6&use_mirror_status=on" regions = {} @@ -88,8 +140,12 @@ def list_mirrors(): log(f'Could not fetch an active mirror-list: {err}', level=logging.WARNING, fg="yellow") return regions + mirrorlist = response.read() + if sort_order: + mirrorlist = sort_mirrorlist(mirrorlist, sort_order=sort_order) + region = 'Unknown region' - for line in response.readlines(): + for line in mirrorlist.split(b'\n'): if len(line.strip()) == 0: continue diff --git a/archinstall/lib/networking.py b/archinstall/lib/networking.py index 0643c9cf..ac889528 100644 --- a/archinstall/lib/networking.py +++ b/archinstall/lib/networking.py @@ -1,4 +1,3 @@ -import fcntl import logging import os import socket @@ -12,6 +11,7 @@ from .storage import storage def get_hw_addr(ifname): + import fcntl s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) info = fcntl.ioctl(s.fileno(), 0x8927, struct.pack('256s', bytes(ifname, 'utf-8')[:15])) return ':'.join('%02x' % b for b in info[18:24]) diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 79919658..b66a942b 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -7,9 +7,7 @@ import select # Used for char by char polling of sys.stdin import shutil import signal import sys -import termios import time -import tty from .exceptions import * from .general import SysCommand @@ -269,6 +267,8 @@ class MiniCurses: def get_keyboard_input(self, strip_rowbreaks=True, end='\n'): assert end in ['\r', '\n', None] + import termios + import tty poller = select.epoll() response = '' -- cgit v1.2.3-70-g09d2 From 434ebb3419f6d614c753729498337abb738481be Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 2 Jun 2021 00:08:45 +0200 Subject: Added docstrings --- archinstall/lib/mirrors.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/archinstall/lib/mirrors.py b/archinstall/lib/mirrors.py index 44c73132..95fb5ac6 100644 --- a/archinstall/lib/mirrors.py +++ b/archinstall/lib/mirrors.py @@ -1,5 +1,6 @@ import urllib.error import urllib.request +from typing import Union from .general import * from .output import log @@ -50,7 +51,7 @@ def sort_mirrorlist(raw_data :bytes, sort_order=["https", "http"]) -> bytes: return new_raw_data -def filter_mirrors_by_region(regions, destination='/etc/pacman.d/mirrorlist', sort_order=["https", "http"], *args, **kwargs): +def filter_mirrors_by_region(regions, destination='/etc/pacman.d/mirrorlist', sort_order=["https", "http"], *args, **kwargs) -> Union[bool, bytes]: """ This function will change the active mirrors on the live medium by filtering which regions are active based on `regions`. -- cgit v1.2.3-70-g09d2 From 8bbc26ca593e4dbf5b3eca01837a01c2509f1432 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 2 Jun 2021 00:21:15 +0200 Subject: Attempt to fix issue regarding broken output Since pacman and some other commands these days write multiple lines and goes back and fourth, it's not reliable to say the "peaked" line is a single line. And if it's not, it will make the output look like garbage. So instead, we'll write any output - as is - and let the command deal with fancy printing. --- archinstall/lib/general.py | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py index 3b62c891..9711382f 100644 --- a/archinstall/lib/general.py +++ b/archinstall/lib/general.py @@ -202,27 +202,6 @@ class SysCommandWorker: except UnicodeDecodeError: return False - output = output.strip('\r\n ') - if len(output) <= 0: - return False - - from .user_interaction import get_terminal_width - - # Move back to the beginning of the terminal - sys.stdout.flush() - sys.stdout.write("\033[%dG" % 0) - sys.stdout.flush() - - # Clear the line - sys.stdout.write(" " * get_terminal_width()) - sys.stdout.flush() - - # Move back to the beginning again - sys.stdout.flush() - sys.stdout.write("\033[%dG" % 0) - sys.stdout.flush() - - # And print the new output we're peaking on: sys.stdout.write(output) sys.stdout.flush() return True -- cgit v1.2.3-70-g09d2 From f541df4e7bf94c45246f3f1e0edb6f3caeb6f7c9 Mon Sep 17 00:00:00 2001 From: m1ten <57693631+m1ten@users.noreply.github.com> Date: Sat, 5 Jun 2021 13:11:57 -0400 Subject: updated makedepends and added manual --- PKGBUILD | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/PKGBUILD b/PKGBUILD index 7a5da658..56e79112 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -10,16 +10,19 @@ arch=('any') url="https://github.com/archlinux/archinstall" license=('GPL') depends=('python') -makedepends=('python-setuptools') +makedepends=('python-setuptools' 'python-sphinx') provides=('python-archinstall') conflicts=('archinstall' 'python-archinstall' 'python-archinstall-git') +md5sums=('SKIP') build() { cd "$startdir" python setup.py build + make man -C docs } package() { cd "$startdir" python setup.py install --root="${pkgdir}" --optimize=1 --skip-build + install -vDm 644 docs/_build/man/archinstall.1 -t "${pkgdir}/usr/share/man/man1/" } -- cgit v1.2.3-70-g09d2 From 419b058b6f663e75f4df9a33b87d06f7722dc82a Mon Sep 17 00:00:00 2001 From: Yash Tripathi Date: Sun, 6 Jun 2021 08:18:34 +0530 Subject: added support for seperating credentials from config --- archinstall/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/archinstall/__init__.py b/archinstall/__init__.py index 0b799d5b..84cf24a2 100644 --- a/archinstall/__init__.py +++ b/archinstall/__init__.py @@ -30,6 +30,7 @@ storage['__version__'] = __version__ def initialize_arguments(): config = {} parser.add_argument("--config", nargs="?", help="JSON configuration file or URL") + parser.add_argument("--creds", nargs="?", help="JSON credentials configuration file or URL") parser.add_argument("--silent", action="store_true", help="Warning!!! No prompts, ignored if config is not passed") parser.add_argument("--script", default="guided", nargs="?", help="Script to run for installation", type=str) @@ -42,6 +43,9 @@ def initialize_arguments(): if not parsed_url.scheme: # The Profile was not a direct match on a remote URL, it must be a local file. with open(args.config) as file: config = json.load(file) + if args.creds is not None: + with open(args.creds) as file: + config.update(json.load(file)) else: # Attempt to load the configuration from the URL. with urllib.request.urlopen(urllib.request.Request(args.config, headers={'User-Agent': 'ArchInstall'})) as response: config = json.loads(response.read()) -- cgit v1.2.3-70-g09d2 From 158dbbf8f19b2a4528cd267e38a21297d93012dd Mon Sep 17 00:00:00 2001 From: Yash Tripathi Date: Sun, 6 Jun 2021 08:35:26 +0530 Subject: changed block location --- archinstall/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/archinstall/__init__.py b/archinstall/__init__.py index 84cf24a2..16de1876 100644 --- a/archinstall/__init__.py +++ b/archinstall/__init__.py @@ -43,14 +43,14 @@ def initialize_arguments(): if not parsed_url.scheme: # The Profile was not a direct match on a remote URL, it must be a local file. with open(args.config) as file: config = json.load(file) - if args.creds is not None: - with open(args.creds) as file: - config.update(json.load(file)) else: # Attempt to load the configuration from the URL. with urllib.request.urlopen(urllib.request.Request(args.config, headers={'User-Agent': 'ArchInstall'})) as response: config = json.loads(response.read()) except Exception as e: print(e) + if args.creds is not None: + with open(args.creds) as file: + config.update(json.load(file)) # Installation can't be silent if config is not passed config["silent"] = args.silent for arg in unknowns: -- cgit v1.2.3-70-g09d2 From 9bec42ad0835864eee47b6b17c486930b672f29f Mon Sep 17 00:00:00 2001 From: Yash Tripathi Date: Sun, 6 Jun 2021 08:41:37 +0530 Subject: updated creds help --- archinstall/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archinstall/__init__.py b/archinstall/__init__.py index 16de1876..bbad316d 100644 --- a/archinstall/__init__.py +++ b/archinstall/__init__.py @@ -30,7 +30,7 @@ storage['__version__'] = __version__ def initialize_arguments(): config = {} parser.add_argument("--config", nargs="?", help="JSON configuration file or URL") - parser.add_argument("--creds", nargs="?", help="JSON credentials configuration file or URL") + parser.add_argument("--creds", nargs="?", help="JSON credentials configuration file") parser.add_argument("--silent", action="store_true", help="Warning!!! No prompts, ignored if config is not passed") parser.add_argument("--script", default="guided", nargs="?", help="Script to run for installation", type=str) -- cgit v1.2.3-70-g09d2 From b8631f6bb6234b9788960ceb44696af0cd1ea48f Mon Sep 17 00:00:00 2001 From: m1ten <57693631+m1ten@users.noreply.github.com> Date: Sun, 6 Jun 2021 11:16:17 -0400 Subject: Remove source check (not required) --- PKGBUILD | 1 - 1 file changed, 1 deletion(-) diff --git a/PKGBUILD b/PKGBUILD index 56e79112..cc7a669f 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -13,7 +13,6 @@ depends=('python') makedepends=('python-setuptools' 'python-sphinx') provides=('python-archinstall') conflicts=('archinstall' 'python-archinstall' 'python-archinstall-git') -md5sums=('SKIP') build() { cd "$startdir" -- cgit v1.2.3-70-g09d2 From 453ff15371a2ee23a84bb0b83c8678158a6efbd8 Mon Sep 17 00:00:00 2001 From: m1ten <57693631+m1ten@users.noreply.github.com> Date: Sun, 6 Jun 2021 17:05:15 -0700 Subject: version bump v2.3.0.dev0 --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 375ff434..add1c5e7 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -41,7 +41,7 @@ copyright = '2020, Anton Hvornum' author = 'Anton Hvornum' # The full version, including alpha/beta/rc tags -release = 'v2.1.0' +release = 'v2.3.0.dev0' # -- General configuration --------------------------------------------------- -- cgit v1.2.3-70-g09d2 From e26a007ad97991a616b51af587d42a7156851a33 Mon Sep 17 00:00:00 2001 From: JakobDev Date: Mon, 7 Jun 2021 14:07:38 +0200 Subject: Add Cutefish profile --- profiles/cutefish.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ profiles/desktop.py | 1 + 2 files changed, 52 insertions(+) create mode 100644 profiles/cutefish.py diff --git a/profiles/cutefish.py b/profiles/cutefish.py new file mode 100644 index 00000000..b30dec27 --- /dev/null +++ b/profiles/cutefish.py @@ -0,0 +1,51 @@ +# A desktop environment using "Cutefish" + +import archinstall + +is_top_level_profile = False + +__packages__ = [ + "cutefish-core", + "cutefish-dock", + "cutefish-filemanager", + "cutefish-icons", + "cutefish-kwin-plugins", + "cutefish-launcher", + "cutefish-qt-plugins", + "cutefish-settings", + "cutefish-statusbar", + "cutefish-wallpapers", + "cutefish-calculator", + "konsole", + "sddm" +] + + +def _prep_function(*args, **kwargs): + """ + Magic function called by the importing installer + before continuing any further. It also avoids executing any + other code in this stage. So it's a safe way to ask the user + for more input before any other installer steps start. + """ + + # Cutefish requires a functional xorg installation. + profile = archinstall.Profile(None, "xorg") + with profile.load_instructions(namespace="xorg.py") as imported: + if hasattr(imported, "_prep_function"): + return imported._prep_function() + 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("cutefish", "/somewhere/cutefish.py") +# or through conventional import cutefish +if __name__ == "cutefish": + # Install dependency profiles + archinstall.storage["installation_session"].install_profile("xorg") + + # Install the Cutefish packages + archinstall.storage["installation_session"].add_additional_packages(__packages__) + + archinstall.storage["installation_session"].enable_service("sddm") diff --git a/profiles/desktop.py b/profiles/desktop.py index 73df9256..75440613 100644 --- a/profiles/desktop.py +++ b/profiles/desktop.py @@ -43,6 +43,7 @@ def _prep_function(*args, **kwargs): 'mate', 'deepin', 'enlightenment', + 'cutefish' ] desktop = archinstall.generic_select(supported_desktops, 'Select your desired desktop environment: ', allow_empty_input=False, sort=True) -- cgit v1.2.3-70-g09d2 From 17bf73ee822b8533a6215c7c5e325796300a852c Mon Sep 17 00:00:00 2001 From: JakobDev Date: Mon, 7 Jun 2021 14:42:06 +0200 Subject: Add noto-fonts to package list --- profiles/cutefish.py | 1 + 1 file changed, 1 insertion(+) diff --git a/profiles/cutefish.py b/profiles/cutefish.py index b30dec27..30b1c4b5 100644 --- a/profiles/cutefish.py +++ b/profiles/cutefish.py @@ -16,6 +16,7 @@ __packages__ = [ "cutefish-statusbar", "cutefish-wallpapers", "cutefish-calculator", + "noto-fonts", "konsole", "sddm" ] -- cgit v1.2.3-70-g09d2 From 3059fa6953481af64b626ea761446682f1c374b6 Mon Sep 17 00:00:00 2001 From: JakobDev Date: Mon, 7 Jun 2021 16:42:38 +0200 Subject: Use group instead of package list --- profiles/cutefish.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/profiles/cutefish.py b/profiles/cutefish.py index 30b1c4b5..1df2467a 100644 --- a/profiles/cutefish.py +++ b/profiles/cutefish.py @@ -5,17 +5,7 @@ import archinstall is_top_level_profile = False __packages__ = [ - "cutefish-core", - "cutefish-dock", - "cutefish-filemanager", - "cutefish-icons", - "cutefish-kwin-plugins", - "cutefish-launcher", - "cutefish-qt-plugins", - "cutefish-settings", - "cutefish-statusbar", - "cutefish-wallpapers", - "cutefish-calculator", + "cutefish", "noto-fonts", "konsole", "sddm" -- cgit v1.2.3-70-g09d2 From 53c2452098d22bacd3e5dd3bb6984c4494306deb Mon Sep 17 00:00:00 2001 From: JakobDev Date: Wed, 9 Jun 2021 18:04:36 +0200 Subject: Remove cutefish from desktop.py --- profiles/desktop.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/profiles/desktop.py b/profiles/desktop.py index 75440613..26da7cbd 100644 --- a/profiles/desktop.py +++ b/profiles/desktop.py @@ -42,8 +42,7 @@ def _prep_function(*args, **kwargs): 'budgie', 'mate', 'deepin', - 'enlightenment', - 'cutefish' + 'enlightenment' ] desktop = archinstall.generic_select(supported_desktops, 'Select your desired desktop environment: ', allow_empty_input=False, sort=True) -- cgit v1.2.3-70-g09d2 From 26c522969fac3436209cb6b4669b179f1ee13ab5 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 9 Jun 2021 20:53:23 +0200 Subject: Linter hates on us if there's no comma at the end --- profiles/desktop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/profiles/desktop.py b/profiles/desktop.py index 26da7cbd..73df9256 100644 --- a/profiles/desktop.py +++ b/profiles/desktop.py @@ -42,7 +42,7 @@ def _prep_function(*args, **kwargs): 'budgie', 'mate', 'deepin', - 'enlightenment' + 'enlightenment', ] desktop = archinstall.generic_select(supported_desktops, 'Select your desired desktop environment: ', allow_empty_input=False, sort=True) -- cgit v1.2.3-70-g09d2 From fe76c517e0c8e34e5100fcd451fe4f6d91570312 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 8 Jun 2021 10:11:41 -0400 Subject: Split Nvidia so that there are two options for it This makes selecting an Nvidia driver simpler and makes it apparent that we support both open-source and proprietary from the initial selection. --- archinstall/lib/hardware.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/archinstall/lib/hardware.py b/archinstall/lib/hardware.py index 45e042db..a63155f5 100644 --- a/archinstall/lib/hardware.py +++ b/archinstall/lib/hardware.py @@ -48,10 +48,12 @@ AVAILABLE_GFX_DRIVERS = { "intel-media-driver", "vulkan-intel", ], - "Nvidia": { - "open-source": ["mesa", "xf86-video-nouveau", "libva-mesa-driver"], - "proprietary": ["nvidia"], - }, + "Nvidia (open-source)": [ + "mesa", + "xf86-video-nouveau", + "libva-mesa-driver" + ], + "Nvidia (proprietary)": ["nvidia"], "VMware / VirtualBox (open-source)": ["mesa", "xf86-video-vmware"], } -- cgit v1.2.3-70-g09d2 From 65407b4054f3dfc2f383105707bf8fd4ab19a07f Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 8 Jun 2021 09:39:49 -0400 Subject: Try to unmount devices before attempting to run mklabel --- archinstall/lib/disk.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index d0e3f6a2..de39bafd 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -448,16 +448,16 @@ class Filesystem: if self.blockdevice.keep_partitions is False: log(f'Wiping {self.blockdevice} by using partition format {self.mode}', level=logging.DEBUG) if self.mode == GPT: - if self.raw_parted(f'{self.blockdevice.device} mklabel gpt').exit_code == 0: + if self.parted_mklabel(self.blockdevice.device, "gpt"): self.blockdevice.flush_cache() return self else: - raise DiskError('Problem setting the partition format to GPT:', f'/usr/bin/parted -s {self.blockdevice.device} mklabel gpt') + raise DiskError('Problem setting the disk label type to GPT:', f'/usr/bin/parted -s {self.blockdevice.device} mklabel gpt') elif self.mode == MBR: - if SysCommand(f'/usr/bin/parted -s {self.blockdevice.device} mklabel msdos').exit_code == 0: + if self.parted_mklabel(self.blockdevice.device, "msdos"): return self else: - raise DiskError('Problem setting the partition format to MBR:', f'/usr/bin/parted -s {self.blockdevice.device} mklabel msdos') + raise DiskError('Problem setting the disk label type to msdos:', f'/usr/bin/parted -s {self.blockdevice.device} mklabel msdos') else: raise DiskError(f'Unknown mode selected to format in: {self.mode}') @@ -552,6 +552,14 @@ class Filesystem: def set(self, partition: int, string: str): return self.parted(f'{self.blockdevice.device} set {partition + 1} {string}') == 0 + def parted_mklabel(self, device: str, disk_label: str): + # Try to unmount devices before attempting to run mklabel + try: + SysCommand(f'bash -c "umount {device}?"') + except: + pass + return self.raw_parted(f'{device} mklabel {disk_label}').exit_code == 0 + def device_state(name, *args, **kwargs): # Based out of: https://askubuntu.com/questions/528690/how-to-get-list-of-all-non-removable-disk-device-names-ssd-hdd-and-sata-ide-onl/528709#528709 -- cgit v1.2.3-70-g09d2 From 35b9cf43af71960a4b89f8608a55ff91f186bffa Mon Sep 17 00:00:00 2001 From: Dylan Taylor Date: Wed, 9 Jun 2021 22:31:05 -0400 Subject: Initial port of GitHub workspaces to GitLab CI/CD --- .gitlab-ci.yml | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..c57892db --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,83 @@ +# This file contains GitLab CI/CD configuration for the ArchInstall project. +# It defines several jobs that get run when a new commit is made, and is comparable to the GitHub workflows. +# All jons will be run in the official archlinux container image, so we will declare that here. +# There is an expectation that a runner exists that has the --privileged flag enabled for the build ISO job to run correctly. +# These jobs should leverage the same tag as that runner. If necessary, change the tag from 'docker' to the one it uses. + +image: archlinux:latest + +stages: + - lint + - test + - build + - publish + +mypy: + stage: lint + tags: + - docker + script: + - pacman --noconfirm -Syu python mypy + - mypy . --ignore-missing-imports || exit 0 + +flake8: + stage: lint + tags: + - docker + script: + - pacman --noconfirm -Syu python python-pip + - python -m pip install --upgrade pip + - pip install flake8 + - flake8 . --count --select=E9,F63,F7 --show-source --statistics + - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + +# We currently do not have unit tests implemented but this stage is written in anticipation of their future usage. +# When a stage name is preceeded with a '.' it's treated as "disabled" by GitLab and is not executed, so it's fine for it to be declared. +.pytest: + stage: test + tags: + - docker + script: + - pacman --noconfirm -Syu python python-pip + - python -m pip install --upgrade pip + - pip install pytest + - pytest + +# This stage might fail with exit code 137 on a shared runner. This is probably due to the CPU/memory consumption needed to run the build. +build_iso: + stage: build + tags: + - docker + script: + - pwd + - find . + - cat /etc/os-release + - mkdir -p /tmp/archlive/airootfs/root/archinstall-git; cp -r . /tmp/archlive/airootfs/root/archinstall-git + - echo "pip uninstall archinstall -y; cd archinstall-git; python setup.py install" > /tmp/archlive/airootfs/root/.zprofile + - echo "echo \"This is an unofficial ISO for development and testing of archinstall. No support will be provided.\"" >> /tmp/archlive/airootfs/root/.zprofile + - echo "echo \"This ISO was built from Git SHA $CI_COMMIT_SHA\"" >> /tmp/archlive/airootfs/root/.zprofile + - echo "echo \"Type archinstall to launch the installer.\"" >> /tmp/archlive/airootfs/root/.zprofile + - cat /tmp/archlive/airootfs/root/.zprofile + - pacman -Sy; pacman --noconfirm -S git archiso + - cp -r /usr/share/archiso/configs/releng/* /tmp/archlive + - echo -e "git\npython\npython-pip\npython-setuptools" >> /tmp/archlive/packages.x86_64 + - find /tmp/archlive + - cd /tmp/archlive; mkarchiso -v -w work/ -o out/ ./ + artifacts: + name: "Arch Live ISO" + paths: + - /tmp/archlive/out/*.iso + expire_in: 1 week + +## The following CI/CD variables need to be set to the PyPi username and password in the GitLab project's settings for this stage to work. +# * FLIT_USERNAME +# * FLIT_PASSWORD +publish_pypi: + stage: publish + tags: + - docker + script: + - pacman -Sy; pacman --noconfirm -S python python-pip + - python -m pip install --upgrade pip + - pip install setuptools wheel flit + - flit -- cgit v1.2.3-70-g09d2 From a8dda0716970d6ba9d5bef2cb8b0f4b0ad9fde57 Mon Sep 17 00:00:00 2001 From: Dylan Taylor Date: Wed, 9 Jun 2021 23:37:35 -0400 Subject: Only print requires root messages if effective user id is not root --- archinstall/lib/networking.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/archinstall/lib/networking.py b/archinstall/lib/networking.py index 0643c9cf..2c261334 100644 --- a/archinstall/lib/networking.py +++ b/archinstall/lib/networking.py @@ -32,7 +32,8 @@ def check_mirror_reachable(): if (exit_code := SysCommand("pacman -Sy").exit_code) == 0: return True elif exit_code == 256: - log("check_mirror_reachable() uses 'pacman -Sy' which requires root.", level=logging.ERROR, fg="red") + if os.geteuid() != 0: + log("check_mirror_reachable() uses 'pacman -Sy' which requires root.", level=logging.ERROR, fg="red") return False -- cgit v1.2.3-70-g09d2 From 0563d307e84498d124a34638d04d3fd5bc09878c Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Thu, 10 Jun 2021 06:53:05 -0400 Subject: Exit codes are an 8 bit value and could be 0 through 255 We also don't need to check the exit code - this message should just be displayed if we are not root --- archinstall/lib/networking.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/archinstall/lib/networking.py b/archinstall/lib/networking.py index 2c261334..49970ec4 100644 --- a/archinstall/lib/networking.py +++ b/archinstall/lib/networking.py @@ -31,9 +31,8 @@ def list_interfaces(skip_loopback=True): def check_mirror_reachable(): if (exit_code := SysCommand("pacman -Sy").exit_code) == 0: return True - elif exit_code == 256: - if os.geteuid() != 0: - log("check_mirror_reachable() uses 'pacman -Sy' which requires root.", level=logging.ERROR, fg="red") + elif os.geteuid() != 0: + log("check_mirror_reachable() uses 'pacman -Sy' which requires root.", level=logging.ERROR, fg="red") return False -- cgit v1.2.3-70-g09d2 From e5e818a52a30bc3d552b127455791107046e558b Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Thu, 10 Jun 2021 07:14:51 -0400 Subject: Only run publish_pypi when a tag is created on the master branch --- .gitlab-ci.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c57892db..ca54c552 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,11 +1,15 @@ # This file contains GitLab CI/CD configuration for the ArchInstall project. # It defines several jobs that get run when a new commit is made, and is comparable to the GitHub workflows. -# All jons will be run in the official archlinux container image, so we will declare that here. # There is an expectation that a runner exists that has the --privileged flag enabled for the build ISO job to run correctly. # These jobs should leverage the same tag as that runner. If necessary, change the tag from 'docker' to the one it uses. +# All jobs will be run in the official archlinux container image, so we will declare that here. image: archlinux:latest +# This can be used to handle common actions. In this case, we do a pacman -Sy to make sure repos are ready to use. +before_script: + - pacman -Sy + stages: - lint - test @@ -58,7 +62,7 @@ build_iso: - echo "echo \"This ISO was built from Git SHA $CI_COMMIT_SHA\"" >> /tmp/archlive/airootfs/root/.zprofile - echo "echo \"Type archinstall to launch the installer.\"" >> /tmp/archlive/airootfs/root/.zprofile - cat /tmp/archlive/airootfs/root/.zprofile - - pacman -Sy; pacman --noconfirm -S git archiso + - pacman --noconfirm -S git archiso - cp -r /usr/share/archiso/configs/releng/* /tmp/archlive - echo -e "git\npython\npython-pip\npython-setuptools" >> /tmp/archlive/packages.x86_64 - find /tmp/archlive @@ -69,6 +73,7 @@ build_iso: - /tmp/archlive/out/*.iso expire_in: 1 week +## This job only runs when a tag is created on the master branch. This is because we do not want to try to publish to PyPi every time we commit. ## The following CI/CD variables need to be set to the PyPi username and password in the GitLab project's settings for this stage to work. # * FLIT_USERNAME # * FLIT_PASSWORD @@ -77,7 +82,11 @@ publish_pypi: tags: - docker script: - - pacman -Sy; pacman --noconfirm -S python python-pip + - pacman --noconfirm -S python python-pip - python -m pip install --upgrade pip - pip install setuptools wheel flit - flit + only: + - tags + except: + - branches -- cgit v1.2.3-70-g09d2 From fcd0acfef261ad83f0d470957f94e6b046f66411 Mon Sep 17 00:00:00 2001 From: Yash Tripathi Date: Thu, 10 Jun 2021 18:36:15 +0530 Subject: added --dry-run flag (#570) * added --dry-run flag --- archinstall/__init__.py | 6 +++++- examples/guided.py | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/archinstall/__init__.py b/archinstall/__init__.py index bbad316d..84595528 100644 --- a/archinstall/__init__.py +++ b/archinstall/__init__.py @@ -32,7 +32,9 @@ def initialize_arguments(): parser.add_argument("--config", nargs="?", help="JSON configuration file or URL") parser.add_argument("--creds", nargs="?", help="JSON credentials configuration file") parser.add_argument("--silent", action="store_true", - help="Warning!!! No prompts, ignored if config is not passed") + help="WARNING: Disables all prompts for input and confirmation. If no configuration is provided, this is ignored") + parser.add_argument("--dry-run", action="store_true", + help="Generates a configuration file and then exits instead of performing an installation") parser.add_argument("--script", default="guided", nargs="?", help="Script to run for installation", type=str) args, unknowns = parser.parse_known_args() if args.config is not None: @@ -61,6 +63,8 @@ def initialize_arguments(): key, val = arg[2:], True config[key] = val config["script"] = args.script + if args.dry_run is not None: + config["dry_run"] = args.dry_run return config diff --git a/examples/guided.py b/examples/guided.py index 56c054fc..266efbd4 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -270,7 +270,10 @@ def perform_installation_steps(): with open("/var/log/archinstall/user_configuration.json", "w") as config_file: config_file.write(user_configuration) print() - + + if archinstall.arguments.get('dry_run'): + exit(0) + if not archinstall.arguments.get('silent'): input('Press Enter to continue.') -- cgit v1.2.3-70-g09d2