Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Pacman() syscall logic with libalpm #2787

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/pylint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ jobs:
- run: python --version
- run: pylint --version
- name: Lint with Pylint
run: pylint .
run: pylint --extension-pkg-allow-list=pyalpm .
2 changes: 1 addition & 1 deletion .github/workflows/python-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
pacman-key --init
pacman --noconfirm -Sy archlinux-keyring
pacman --noconfirm -Syyu
pacman --noconfirm -Sy python-pip python-pydantic python-pyparted python-simple-term-menu pkgconfig gcc
pacman --noconfirm -Sy pyalpm python-pip python-pydantic python-pyparted python-simple-term-menu pkgconfig gcc
- name: Install build dependencies
run: |
python -m pip install --break-system-packages --upgrade pip
Expand Down
1 change: 1 addition & 0 deletions PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ depends=(
'pciutils'
'procps-ng'
'python'
'pyalpm'
'python-pydantic'
'python-pyparted'
'python-simple-term-menu'
Expand Down
3 changes: 1 addition & 2 deletions archinstall/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ def define_arguments() -> None:
parser.print_help()
exit(0)
if os.getuid() != 0:
print(_("Archinstall requires root privileges to run. See --help for more."))
exit(1)
warn(_("Archinstall might require root privileges to run. See --help for more."))


def parse_unspecified_argument_list(unknowns: list, multiple: bool = False, err: bool = False) -> dict:
Expand Down
4 changes: 4 additions & 0 deletions archinstall/lib/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ class DownloadTimeout(Exception):
'''
Download timeout exception raised by DownloadTimer.
'''


class PacmanIssue(Exception):
pass
24 changes: 12 additions & 12 deletions archinstall/lib/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def __init__(
self._zram_enabled = False
self._disable_fstrim = False

self.pacman = Pacman(self.target, storage['arguments'].get('silent', False))
self.pacman = Pacman(silent=storage['arguments'].get('silent', False))

def __enter__(self) -> 'Installer':
return self
Expand Down Expand Up @@ -672,7 +672,7 @@ def post_install_enable_iwd_service(*args: str, **kwargs: str) -> None:
# Otherwise, we can go ahead and add the required package
# and enable it's service:
else:
self.pacman.strap('iwd')
self.pacman.strap(self.target, 'iwd')
self.enable_service('iwd')

for psk in psk_files:
Expand Down Expand Up @@ -768,7 +768,7 @@ def _handle_partition_installation(self) -> None:
if part in self._disk_encryption.partitions:
if self._disk_encryption.hsm_device:
# Required by mkinitcpio to add support for fido2-device options
self.pacman.strap('libfido2')
self.pacman.strap(self.target, 'libfido2')

if 'sd-encrypt' not in self._hooks:
self._hooks.insert(self._hooks.index('filesystems'), 'sd-encrypt')
Expand Down Expand Up @@ -804,7 +804,7 @@ def _handle_lvm_installation(self) -> None:
if self._disk_encryption.encryption_type in [disk.EncryptionType.LvmOnLuks, disk.EncryptionType.LuksOnLvm]:
if self._disk_encryption.hsm_device:
# Required by mkinitcpio to add support for fido2-device options
self.pacman.strap('libfido2')
self.pacman.strap(self.target, 'libfido2')

if 'sd-encrypt' not in self._hooks:
self._hooks.insert(self._hooks.index('lvm2'), 'sd-encrypt')
Expand Down Expand Up @@ -851,7 +851,7 @@ def minimal_installation(

pacman_conf.apply()

self.pacman.strap(self._base_packages)
self.pacman.strap(self.target, self._base_packages)
self.helper_flags['base-strapped'] = True

pacman_conf.persist()
Expand Down Expand Up @@ -894,7 +894,7 @@ def minimal_installation(
def setup_swap(self, kind: str = 'zram') -> None:
if kind == 'zram':
info("Setting up swap on zram")
self.pacman.strap('zram-generator')
self.pacman.strap(self.target, 'zram-generator')

# We could use the default example below, but maybe not the best idea: https://github.com/archlinux/archinstall/pull/678#issuecomment-962124813
# zram_example_location = '/usr/share/doc/zram-generator/zram-generator.conf.example'
Expand Down Expand Up @@ -1056,7 +1056,7 @@ def _add_systemd_bootloader(
) -> None:
debug('Installing systemd bootloader')

self.pacman.strap('efibootmgr')
self.pacman.strap(self.target, 'efibootmgr')

if not SysInfo.has_uefi():
raise HardwareIncompatibilityError
Expand Down Expand Up @@ -1154,7 +1154,7 @@ def _add_grub_bootloader(
) -> None:
debug('Installing grub bootloader')

self.pacman.strap('grub') # no need?
self.pacman.strap(self.target, 'grub') # no need?

grub_default = self.target / 'etc/default/grub'
config = grub_default.read_text()
Expand All @@ -1181,7 +1181,7 @@ def _add_grub_bootloader(

info(f"GRUB EFI partition: {efi_partition.dev_path}")

self.pacman.strap('efibootmgr') # TODO: Do we need? Yes, but remove from minimal_installation() instead?
self.pacman.strap(self.target, 'efibootmgr') # TODO: Do we need? Yes, but remove from minimal_installation() instead?

boot_dir_arg = []
if boot_partition.mountpoint and boot_partition.mountpoint != boot_dir:
Expand Down Expand Up @@ -1239,7 +1239,7 @@ def _add_limine_bootloader(
) -> None:
debug('Installing limine bootloader')

self.pacman.strap('limine')
self.pacman.strap(self.target, 'limine')

info(f"Limine boot partition: {boot_partition.dev_path}")

Expand Down Expand Up @@ -1329,7 +1329,7 @@ def _add_efistub_bootloader(
) -> None:
debug('Installing efistub bootloader')

self.pacman.strap('efibootmgr')
self.pacman.strap(self.target, 'efibootmgr')

if not SysInfo.has_uefi():
raise HardwareIncompatibilityError
Expand Down Expand Up @@ -1466,7 +1466,7 @@ def add_bootloader(self, bootloader: Bootloader, uki_enabled: bool = False):
self._add_limine_bootloader(boot_partition, efi_partition, root)

def add_additional_packages(self, packages: Union[str, List[str]]) -> None:
return self.pacman.strap(packages)
return self.pacman.strap(self.target, packages)

def enable_sudo(self, entity: str, group: bool = False):
info(f'Enabling sudo permissions for {entity}')
Expand Down
Loading