Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib
diff options
context:
space:
mode:
authorDylan M. Taylor <dylan@dylanmtaylor.com>2022-02-12 12:11:34 -0500
committerGitHub <noreply@github.com>2022-02-12 18:11:34 +0100
commit1df17eb987241d0f190df1081d242bbdb248c423 (patch)
tree39d91d85c48855d524d9168c6d3425fccd73d4cf /archinstall/lib
parent003a35be3d908431c25f7fa9d7a7dd6beb8e0fe1 (diff)
Add a flag to install testing repositories (#967)
* Add a boolean to install testing repos, default to false * More work on adding structure * Add logic to enable testing repos. * Corrections * Make flake8 happy about regex escapes * Flake8 doesn't like whitespace around equals * Fix trailing whitespace character
Diffstat (limited to 'archinstall/lib')
-rw-r--r--archinstall/lib/installer.py37
1 files changed, 36 insertions, 1 deletions
diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py
index 1ead46c7..e22883cb 100644
--- a/archinstall/lib/installer.py
+++ b/archinstall/lib/installer.py
@@ -1,6 +1,7 @@
import time
import logging
import os
+import re
import shutil
import shlex
import pathlib
@@ -288,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_testing_repositories(self):
+ # Set up a regular expression pattern of a commented line containing 'testing' within []
+ pattern = re.compile("^#\\[.*testing.*\\]$")
+
+ # 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 'testing', uncomment it and set the matched tracking boolean.
+ pacman_conf.write(line.lstrip('#'))
+ matched = True
+ elif matched:
+ # The previous line was a match for [.*testing.*].
+ # 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 pacstrap(self, *packages :str, **kwargs :str) -> bool:
if type(packages[0]) in (list, tuple):
packages = packages[0]
@@ -533,7 +560,7 @@ class Installer:
return SysCommand(f'/usr/bin/arch-chroot {self.target} mkinitcpio {" ".join(flags)}').exit_code == 0
- def minimal_installation(self) -> bool:
+ def minimal_installation(self, testing=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
@@ -582,6 +609,14 @@ 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.
+ # This action takes place on the host system as pacstrap copies over package repository lists.
+ if testing:
+ self.log("The testing flag is set. This system will be installed with testing repositories enabled.")
+ self.enable_testing_repositories()
+ 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