Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/installer.py
diff options
context:
space:
mode:
authorDylan M. Taylor <dylan@dylanmtaylor.com>2022-02-13 04:10:35 -0500
committerGitHub <noreply@github.com>2022-02-13 10:10:35 +0100
commitfb72cc42044b32f237bdde256be2900228bfd367 (patch)
treee28f213e60918b5f308bb91302ee9844f23104c6 /archinstall/lib/installer.py
parent8457aa5660553faa811f26246059fa4cd84852cd (diff)
Add multilib flag and enable multilib-testing if testing flag is also passed (#975)
* Add multilib flag to enable this repository and enable multi-lib testing if testing flag is also passed * Fix comments * Attempt to force pacman to use the config file from the host * Make sure the pacman configuration is copied to target * flake8
Diffstat (limited to 'archinstall/lib/installer.py')
-rw-r--r--archinstall/lib/installer.py44
1 files changed, 40 insertions, 4 deletions
diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py
index c8ff612c..2a7b158a 100644
--- a/archinstall/lib/installer.py
+++ b/archinstall/lib/installer.py
@@ -289,6 +289,32 @@ class Installer:
def post_install_check(self, *args :str, **kwargs :str) -> List[str]:
return [step for step, flag in self.helper_flags.items() if flag is False]
+ def enable_multilib_repository(self):
+ # Set up a regular expression pattern of a commented line containing 'multilib' within []
+ pattern = re.compile("^#\\[.*multilib.*\\]$")
+
+ # This is used to track if the previous line is a match, so we end up uncommenting the line after the block.
+ matched = False
+
+ # Read in the lines from the original file
+ with open("/etc/pacman.conf", "r") as pacman_conf:
+ lines = pacman_conf.readlines()
+
+ # Open the file again in write mode, to replace the contents
+ with open("/etc/pacman.conf", "w") as pacman_conf:
+ for line in lines:
+ if pattern.match(line):
+ # If this is the [] block containing 'multilib', uncomment it and set the matched tracking boolean.
+ pacman_conf.write(line.lstrip('#'))
+ matched = True
+ elif matched:
+ # The previous line was a match for [.*multilib.*].
+ # This means we're on a line that looks like '#Include = /etc/pacman.d/mirrorlist'
+ pacman_conf.write(line.lstrip('#'))
+ matched = False # Reset the state of matched to False.
+ else:
+ pacman_conf.write(line)
+
def enable_testing_repositories(self, enable_multilib_testing=False):
# Set up a regular expression pattern of a commented line containing 'testing' within []
pattern = re.compile("^#\\[.*testing.*\\]$")
@@ -327,7 +353,7 @@ class Installer:
self.log(f'Installing packages: {packages}', level=logging.INFO)
if (sync_mirrors := SysCommand('/usr/bin/pacman -Syy')).exit_code == 0:
- if (pacstrap := SysCommand(f'/usr/bin/pacstrap {self.target} {" ".join(packages)} --noconfirm', peak_output=True)).exit_code == 0:
+ if (pacstrap := SysCommand(f'/usr/bin/pacstrap -C /etc/pacman.conf {self.target} {" ".join(packages)} --noconfirm', peak_output=True)).exit_code == 0:
return True
else:
self.log(f'Could not strap in packages: {pacstrap}', level=logging.ERROR, fg="red")
@@ -560,7 +586,7 @@ class Installer:
return SysCommand(f'/usr/bin/arch-chroot {self.target} mkinitcpio {" ".join(flags)}').exit_code == 0
- def minimal_installation(self, testing=False) -> bool:
+ def minimal_installation(self, testing=False, multilib=False) -> bool:
# Add necessary packages if encrypting the drive
# (encrypted partitions default to btrfs for now, so we need btrfs-progs)
# TODO: Perhaps this should be living in the function which dictates
@@ -609,17 +635,27 @@ class Installer:
else:
self.log(f"Unknown CPU vendor '{vendor}' detected. Archinstall won't install any ucode.", level=logging.DEBUG)
- # Determine whether to enable testing repositories before running pacstrap if testing flag is set.
+ # Determine whether to enable multilib/testing repositories before running pacstrap if testing flag is set.
# This action takes place on the host system as pacstrap copies over package repository lists.
+ if multilib:
+ self.log("The multilib flag is set. This system will be installed with the multilib repository enabled.")
+ self.enable_multilib_repository()
+ else:
+ self.log("The testing flag is not set. This system will be installed without testing repositories enabled.")
+
if testing:
self.log("The testing flag is set. This system will be installed with testing repositories enabled.")
- self.enable_testing_repositories()
+ self.enable_testing_repositories(multilib)
else:
self.log("The testing flag is not set. This system will be installed without testing repositories enabled.")
self.pacstrap(self.base_packages)
self.helper_flags['base-strapped'] = True
+ # This handles making sure that the repositories we enabled persist on the installed system
+ if multilib or testing:
+ shutil.copy2("/etc/pacman.conf", f"{self.target}/etc/pacman.conf")
+
# Periodic TRIM may improve the performance and longevity of SSDs whilst
# having no adverse effect on other devices. Most distributions enable
# periodic TRIM by default.