ripytide / pacdef

Fork of https://github.com/steven-omaha/pacdef
GNU General Public License v3.0
3 stars 1 forks source link

Arch Package Dependencies #27

Open ripytide opened 6 days ago

ripytide commented 6 days ago

I realized when migrating my group files to the new format and attepmting to run pacdef clean that it fails due to trying to remove packages which were dependencies of packages in the group files. This happens because the method we were using to decide which packages were unmanaged was not taking dependencies into account. Therefore we will need to get more information from the backends that support dependencies, like Arch.

Getting an arch packages dependencies from just the pacman cli tool seems non-feasible since it can also list .so files which are not packages but are instead extra files in the Provides: section of other packages (like libalpm.so provided by pacman and required as a dependency by paru).

Therefore, I think we need to revert the change to remove the alpm dependency so we can get dependency information again and make the unmanaged package resolution algorithm dependency-aware.

The original issue we had with the backend-specific dependencies (rust-apt and alpm) made building the project fail unless the dependencies were both installed, unless we feature gate each backend which makes the code more complicated.

Ideally, there would exist pure-rust crates that would provide the same functionality as rust-apt and alpm but unfortunately it does appear that any exist (apart from https://users.rust-lang.org/t/half-baked-alpm-arch-linux-package-manager-implementation/18969 but it looks like it did not take off)

Overall, I now believe such that adding back the dependencies and feature-gating them now seems like the best option.

We might be able to handle feature-gating in a better way than originally though by not disabling/hiding an entire backend when it's feature is disabled but instead just making it report zero packages in the query_installed_packages() trait method. We could also throw a warning when users have backend packages in their group files but are using pacdef without that backend feature enabled.

ripytide commented 6 days ago

Or we can use the pactree command.

ripytide commented 4 days ago

An even easier and faster idea! We can just mark all the explicit packages that are not in the group files as a dependency with pacman and them just get pacman to remove all non-required dependencies with pacman -Qqd | pacman -Rsu - from the ArchWiki