Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions archinstall/lib/general/general_menu.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from enum import Enum
from pathlib import Path

from archinstall.lib.locale.utils import list_timezones
from archinstall.lib.menu.helpers import Confirmation, Input, Selection
from archinstall.lib.output import warn
from archinstall.lib.pathnames import PACMAN_CONF
from archinstall.lib.translationhandler import Language, tr
from archinstall.tui.ui.menu_item import MenuItem, MenuItemGroup
from archinstall.tui.ui.result import ResultType
Expand Down Expand Up @@ -162,11 +162,10 @@ def validator(s: str) -> str | None:
case ResultType.Selection:
downloads = int(result.get_value())

pacman_conf_path = Path('/etc/pacman.conf')
with pacman_conf_path.open() as f: # noqa: ASYNC230
with PACMAN_CONF.open() as f:
pacman_conf = f.read().split('\n')

with pacman_conf_path.open('w') as fwrite: # noqa: ASYNC230
with PACMAN_CONF.open('w') as fwrite:
for line in pacman_conf:
if 'ParallelDownloads' in line:
fwrite.write(f'ParallelDownloads = {downloads}\n')
Expand Down
3 changes: 2 additions & 1 deletion archinstall/lib/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
from archinstall.lib.packages.packages import installed_package
from archinstall.lib.pacman.config import PacmanConfig
from archinstall.lib.pacman.pacman import Pacman
from archinstall.lib.pathnames import PACMAN_CONF
from archinstall.lib.plugins import plugins
from archinstall.lib.translationhandler import tr

Expand Down Expand Up @@ -570,7 +571,7 @@ def set_mirrors(

root = self.target if on_target else Path('/')
mirrorlist_config = root / 'etc/pacman.d/mirrorlist'
pacman_config = root / 'etc/pacman.conf'
pacman_config = root / PACMAN_CONF.relative_to_root()

repositories_config = mirror_config.repositories_config()
if repositories_config:
Expand Down
11 changes: 11 additions & 0 deletions archinstall/lib/linux_path.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from pathlib import Path
from typing import Self


class LPath(Path):
@classmethod
def fs_root(cls) -> Self:
return cls('/')

def relative_to_root(self) -> Self:
return self.relative_to(self.fs_root())
10 changes: 5 additions & 5 deletions archinstall/lib/pacman/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
from shutil import copy2

from archinstall.lib.models.packages import Repository
from archinstall.lib.pathnames import PACMAN_CONF


class PacmanConfig:
def __init__(self, target: Path | None):
self._config_path = Path('/etc') / 'pacman.conf'
self._config_remote_path: Path | None = None

if target:
self._config_remote_path = target / 'etc' / 'pacman.conf'
self._config_remote_path = target / PACMAN_CONF.relative_to_root()

self._repositories: list[Repository] = []

Expand All @@ -32,7 +32,7 @@ def apply(self) -> None:
else:
repos_to_enable.append(repo.value)

content = self._config_path.read_text().splitlines(keepends=True)
content = PACMAN_CONF.read_text().splitlines(keepends=True)

for row, line in enumerate(content):
# Check if this is a commented repository section that needs to be enabled
Expand All @@ -47,9 +47,9 @@ def apply(self) -> None:
content[row + 1] = re.sub(r'^#\s*', '', content[row + 1])

# Write the modified content back to the file
with open(self._config_path, 'w') as f:
with PACMAN_CONF.open('w') as f:
f.writelines(content)

def persist(self) -> None:
if self._repositories and self._config_remote_path:
copy2(self._config_path, self._config_remote_path)
copy2(PACMAN_CONF, self._config_remote_path)
3 changes: 2 additions & 1 deletion archinstall/lib/pacman/pacman.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from archinstall.lib.command import SysCommand
from archinstall.lib.exceptions import RequirementError
from archinstall.lib.output import error, info, warn
from archinstall.lib.pathnames import PACMAN_CONF
from archinstall.lib.plugins import plugins
from archinstall.lib.translationhandler import tr

Expand Down Expand Up @@ -77,6 +78,6 @@ def strap(self, packages: str | list[str]) -> None:
'Could not strap in packages',
'Pacstrap failed. See /var/log/archinstall/install.log or above message for error details',
SysCommand,
f'pacstrap -C /etc/pacman.conf -K {self.target} {" ".join(packages)} --noconfirm --needed',
f'pacstrap -C {PACMAN_CONF} -K {self.target} {" ".join(packages)} --noconfirm --needed',
peek_output=True,
)
5 changes: 5 additions & 0 deletions archinstall/lib/pathnames.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from typing import Final

from archinstall.lib.linux_path import LPath

PACMAN_CONF: Final = LPath('/etc/pacman.conf')
Loading