pipac (Prune and Install PACkages) is a very simple Python tool that helps maintain a clean system (Arch Linux or similar) by ensuring that explicitly installed packages match user-provided package lists (declarative package management).
- maintains system packages based on package lists
- supports multiple package managers (yay, paru, pacman)
- handles optional dependencies
- accepts
.txt,.mdand.orgas list formats
The goal was to create a simple tool that does one thing well: make sure that installed packages in a system are those and only those on user’s specified lists. I tried using alternative software (see below) but found them too complex (but still great and an inspiration to create pipac).
pipac is written in python because of it’s widespread use (https://pkgstats.archlinux.de/packages/python). I was considering bash but it surpasses python popularity only by 0.2%.
- metapac: https://github.com/ripytide/metapac
- aconfmgr: https://github.com/CyberShadow/aconfmgr
- declaro: https://github.com/mantinhas/declaro
- pacdef: https://github.com/steven-omaha/pacdef
git clone https://github.com/j4kub5/pipac
cd pipac
sudo install -Dm755 pipac.py /usr/bin/pipacyay -S pipacpipac [COMMAND]... [PACKAGE_LIST]...
-h,--help- display help message
-p,--prune- prune packages not in lists (mark them as dependencies)
-o,--orphans- remove orphans
-i,--install- install packages from lists that are not currently installed
-n,--new- print installed explicit packages missing from the lists
-p, -o and -i can be used together. The order of operations is always: prune, orphans, install.
Package lists are text files; packages are line or space separated. Optional dependencies should be prefixed with &. Everything in a line after #, *, ; is a comment (ignored by the program).
package1 package2 # comment &optional_dependency_for_package2 # comment package3 package4 package5 &optional_dependency_for_package5
# base
linux
# network
iwd* base
linux
* network
iwd
pacman -Qeq > packages.txtIf no package lists are specified as arguments pipac will use default package lists:
packages[.txt,.md,.org]$HOSTNAME[.txt,.md,.org]
located in in $XDG_CONFIG_HOME/pipac/ or ~/.config/pipac/.
Replace $HOSTNAME with the actual name given by:
cat /proc/sys/kernel/hostnameConfiguration is done with a config file. Configuration is optional.
pipac searches for a config file in $XDG_CONFIG_HOME/pipac/pipac.ini and falls back to ~/.config/pipac/pipac.ini.
Example config file:
[default] # Preffered package manager (yay, paru, pacman). Defaults to yay package_manager = yay # Use defaults lists (see [Default pagkage lists] section) use_default_lists = true [lists] # Additional package lists temporary_packages = ~/.config/pipac/temp.txt work_packages = /home/user/work-packages.md gaming_packages = ~/.config/pipac/games.org
After you manually edit the package list(s) you may:
# Install missing packages in default lists
pipac -i
# Prune packages not in default lists (mark them as dependencies)
# and then remove orphans
pipac -po
# Install missing packages in lists
pipac -i packages.txt $HOSTNAME.txt
# Prune packages not in lists
pipac -p packages.txt $HOSTNAME.txt
# Combine prune and install
pipac -ip packages.txt $HOSTNAME.txt
# Add packages you installed manually to a list
pipac -n >> ~/.config/pipac/packages.txt- [ ] feature: when no lists are present and
-nshould ask to create.config/pipac/packages.txt - [X] fix: respect XDG_CONFIG_HOME
- [X] feature: configuration file (select package manager, select custom lists, use default lists y/n)
- [X] feature: run yay -Yc (or equivalent) after pruning (
-oflag) - [X] documentation: explain ¿why?
- [X] documentation: document alternative software
- [X] feature: ask for confirmation before
-Doperations - [X] feature: accept
.organd.mdas package lists - [X] feature: print out a list of newly installed packages (not yes added to lists)
- [X] add license
- [X] make $HOSTNAME.txt in config directory optional
- [X] more examples (use with scripts)
- [X] create an AUR package
- [X] feature: update system while installing
- [X] feature: read default package lists
- [X] feature: default behavior when no arguments are passed