Skip to content
/ pipac Public

pipac - Prune and Install PACkages

License

Notifications You must be signed in to change notification settings

j4kub5/pipac

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

pipac - Prune and Install PACkages

About

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).

Features

  • maintains system packages based on package lists
  • supports multiple package managers (yay, paru, pacman)
  • handles optional dependencies
  • accepts .txt, .md and .org as list formats

Why was pipac created?

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%.

Alternatives

Installation

Manual

git clone https://github.com/j4kub5/pipac
cd pipac
sudo install -Dm755 pipac.py /usr/bin/pipac

AUR

yay -S pipac

Usage

pipac [COMMAND]... [PACKAGE_LIST]...

Commands

-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

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).

Example package lists

txt

package1
package2 # comment
&optional_dependency_for_package2

# comment
package3 package4
package5 &optional_dependency_for_package5

md

# base
linux

# network
iwd

org-mode

* base
linux

* network
iwd

Create a package list

pacman -Qeq > packages.txt

Default package lists

If 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/hostname

Configuration

Configuration 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

Examples

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

TO-DOs

  • [ ] feature: when no lists are present and -n should 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 (-o flag)
  • [X] documentation: explain ¿why?
  • [X] documentation: document alternative software
  • [X] feature: ask for confirmation before -D operations
  • [X] feature: accept .org and .md as 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

About

pipac - Prune and Install PACkages

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages