Replace Pacman()
syscall logic with libalpm
#2787
Draft
+428
−34
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Description:
This PR will enable us to do three things:
pacman -XYZ
via system calls, and instead rely on libalpm directly, via pyalpm.archinstall/archinstall/lib/packages/packages.py
Lines 45 to 59 in 26cf046
Allowing us to do local searches, and let pacman deal with databases and searching.
This simplifies custom mirrors and allowing us to search against them too.
root
privilegesSome thoughts
I decided to use a context manager approach, as it allows us to choose between interacting against system-wide pacman data - but during context creation also decide if we want a temporary pacman data structure.
That way we can do:
To not collide with system-wide pacman, and perform searches and syncs independently and irregards if existing pacman is executing.
With this we can remove:
archinstall/archinstall/lib/pacman/__init__.py
Lines 32 to 43 in 26cf046
And if we want to interact with pacman system wide, we simply just do:
I'm sure we could achieve the same thing with using only
__init__
and some if/else.But for some reason this felt like a logical thing to do, especially since all pacman operations are "transaction based", meaning we need to create a lock file while doing operations - and then remove the lock file once we're done.
And if libalpm/pacman crashes during an operation, we need a way to do easy cleanup and remove said lock file.