Skip to main content Declarative package management : r/voidlinux

Declarative package management

How can I manage packages installed with xbps and xbps-src from say a text file?

As example there is an arch package that does that for pacman - pacmanfile

Can I provide a packages.txt file with a package on every new line and have xbps and xbps-src uninstall everything that is not there and then install any missing package on my system?

Learn by doing - Cloud, Kubernetes, Python, and more. Get your teams up to speed faster with interactive labs and sandboxes to gain hands-on experience. No environment to set up, no software to install.
  • O'Reilly builds AI-ready teams
  • O'Reilly builds AI-ready teams
  • O'Reilly builds AI-ready teams
  • O'Reilly builds AI-ready teams
  • O'Reilly builds AI-ready teams
  • O'Reilly builds AI-ready teams
  • Best
    Open comment sort options

    If I do move to void, I will try to make a script and will add a link to it here.

    If you're going to recreate this script, at least learn the comm command. diff is not the right tool for this task.

    Thanks for the tip!

    More replies
    More replies

    List all the packages that you want installed in a file and then just run

    xbps-install -Sy $(cat packages.txt)

    With xbps-src you can do it with a script but it’s not as simple by no means is it hard though.

    And about removing all explicitly installed packages which are not on the list?

    Same thing, use a little script or a one line bash command. This is the basic idea of what it would do:

    1. List your installed packages, probably to a temporary text file.

    2. Compare the two files probably using diff. Or any tool to find the differences, could even use grep as someone else mentioned.

    3. Uninstall any files that don’t match.

    Also can I ask why you would be uninstalling packages that aren’t on the list if your installing packages on the list, especially on Void where you get a minimal install from the beginning? Just curious as to how or why someone would want to do that.

    More replies

    I think you can compare package lists using grep.

    Do you perhaps mean installed packages that aren't deps of explicitly installed packages?

    More replies
    More replies