testing additional repo code needs update for new repository format
This is going to likely break the existing code for repo enablement:
https://archlinux.org/news/git-migration-announcement/
Existing code:
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.*\\]$")
# 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) and (enable_multilib_testing or 'multilib' not in 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)
Looks like the regex ^#\\[.*testing.*\\]$ will match the new testing repositories [core-testing] and [extra-testing], which are replacing [testing], and so no changes would be needed. Let us see.
import re
lines = [
'[core]\n',
'#[core-testing]\n',
'#[extra-testing]\n',
'#[mutlilib-testing]\n',
'#[custom]\n'
]
pattern = re.compile("^#\\[.*testing.*\\]$")
for line in lines:
if pattern.match(line):
print('match: ' + line, end='')
else:
print('no match: ' + line, end='')
Output
no match: [core]
match: #[core-testing]
match: #[extra-testing]
match: #[mutlilib-testing]
no match: #[custom]
Looks good since we would not want to match the lines [core] or #[custom].
You could use a link like https://github.com/archlinux/archinstall/blob/5276d95339368210e75791e2b88c1bf5aca4517b/archinstall/lib/installer.py#L325-L349 to create a link to the code, see: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-a-permanent-link-to-a-code-snippet
https://github.com/archlinux/archinstall/blob/5276d95339368210e75791e2b88c1bf5aca4517b/archinstall/lib/installer.py#L325-L349
I think we need to split it from one selection to multiple to match upstream arch though.
With the logic built in a way to match both #[testing] and #[community-testing] as well as #[multilib-testing] when enable_multilib_testing is True, it will also catch #[core-testing] and #[extra-testing] and uncomment them. If the bottom of the new /etc/pacman.conf looks like the following then no change would be needed.
# The testing repositories are disabled by default. To enable, uncomment the
# repo name header and Include lines. You can add preferred servers immediately
# after the header, and they will be used before the default mirrors.
#[core-testing]
#Include = /etc/pacman.d/mirrorlist
[core]
Include = /etc/pacman.d/mirrorlist
#[extra-testing]
#Include = /etc/pacman.d/mirrorlist
[extra]
Include = /etc/pacman.d/mirrorlist
# If you want to run 32 bit applications on your x86_64 system,
# enable the multilib repositories as required here.
#[multilib-testing]
#Include = /etc/pacman.d/mirrorlist
#[multilib]
#Include = /etc/pacman.d/mirrorlist
# An example of a custom package repository. See the pacman manpage for
# tips on creating your own repositories.
#[custom]
#SigLevel = Optional TrustAll
#Server = file:///home/custompkgs
The pacman.conf has been updated in the git packages repository.
https://gitlab.archlinux.org/archlinux/packaging/packages/pacman/-/commit/e0929b97e8363ba9eff51b53072a4b9dbda46c80
https://gitlab.archlinux.org/archlinux/packaging/packages/pacman/-/blob/main/pacman.conf
I think we need to split it from one selection to multiple to match upstream arch though.
There is nothing that needs to be split. Either both core-testing and extra-testing are enable or neither. If multilib-testing is enabled then core-testing and extra-testing must be too. See the second bullet of the following.
Warning
- Be careful when enabling the testing repositories. Your system may break after performing an update. Only experienced users who know how to deal with potential system breakage should use it.
- If you enable core-testing, you must also enable extra-testing, and vice versa. If you enable any other testing repository listed in the following subsections, you must also enable both core-testing and extra-testing.
https://wiki.archlinux.org/title/Official_repositories#Testing_repositories
If anything the option to enable the testing repositories should be moved under the --advanced flag because of that first bullet in the warning from the ArchWiki article given above.
Enabling of the testing repositories functions properly with the changes to the pacman.conf that are now live.