polygamma / aurman

AUR Helper
MIT License
567 stars 35 forks source link

[Question] Package installation rules #275

Closed GrabbenD closed 1 year ago

GrabbenD commented 1 year ago

Is there any way to force a package to be installed from a specific repository?

For instance, with Pacfree it's possible to do:

sudo pacfree add-rule <repo_name>/<pkg_name> <repo_name>/<pkg_name> <repo_name>/<pkg_name> 
sudo pacfree update
sudo pacfree upgrade
polygamma commented 1 year ago

Hey :)

See: https://github.com/polygamma/aurman#choose-between-multiple-package-sources

GrabbenD commented 1 year ago

@polygamma Amazing, thank you a ton 🙂

I have a odd question as a followup to package installation rules. For context, there's folks using alternative init systems like OpenRC and dinit (which is crazy fast) on Arch Linux and one problem with this is that some packages depend on SystemD (meaning you have to create rules to point to non-systemd repos like Artix for particular packages). Would it be possible to inspect a package's dependency tree and automatically use a different repository if it has a particular dependency like systemd?

polygamma commented 1 year ago

Would it be possible to inspect a package's dependency tree and automatically use a different repository if it has a particular dependency like systemd?

Possible - sure, why not? If you want to look at dependencies of packages, I suggest you use pactree: https://man.archlinux.org/man/pactree.8 It's part of pacman-contrib: https://archlinux.org/packages/extra/x86_64/pacman-contrib/

The real question is, what you mean with "automatically". If you want to know, if it could be included in aurman, sure, it's possible, but I guess I wouldn't do it, and I don't even know, if I'd accept a merge request implementing this feature. It really depends on what exactly your idea is.

GrabbenD commented 1 year ago

I was thinking that one way could be to use a regex based hook which runs prior to installation of a package. It would check package's dependencies and determinate the right repository similar to how post installation scripts works in Pacman with e.g. Dracut: https://wiki.archlinux.org/title/Dracut#Generate_a_new_initramfs_on_kernel_upgrade

If it was natively supported in Aurman it could look like this:

[rules]
depends=systemd=repo_name

There's currently no package manager that I know of which supports this and it's a major problem for users who would like to use a alternative init system with Arch Linux - this would be a game changer.

Nonetheless I understand if this is outside of the scope of this project.

polygamma commented 1 year ago

Why not use pactree to detect the packages you want to install from a different repo, and generate the regarding aurman config? I feel like this is a problem that shouldn't be solved by aurman, or any other AUR helper.

If you write a script, that allows to detect packages to install from another repo, you just need to generate the regarding configs for tools like aurman and that's it.

GrabbenD commented 1 year ago

That's definitely a better approach, I'm probably overcomplicating this @polygamma 🙂

Are you thinking about something along these lines in a bash script (./install.sh pkg1 pkg2 pkg3)?

  1. Check for *systemd* dependency via pactree -u -s pkg
    • Determinate which repository the package is available in: pacman --config /etc/artix_repos.conf -Ss ^pkg$
    • Append the detected repository name and pkg under [repo_packages] in aurman config:
      [repo_packages]
      pkg=artix_repo
  2. Call aurman to perform installation
polygamma commented 1 year ago

Yeah, exactly. It's really not too much you need. Integrating all of that into aurman is far more complicated :)

GrabbenD commented 1 year ago

Thanks a ton for the help @polygamma ! This will take me time to make as I'm not really a programmer but atleast now it's doable as there's a plan 🙂

polygamma commented 1 year ago

You're welcome :)