#!/usr/bin/env bash # # Void Linux package utilities # packagesFile="$DOTFILES/void-packages.txt" # Get user-installed xbps packages and strip version info. # # We could also list all installed packages with: # xbps-query -l | awk '{ print $2 }' | xargs -n1 xbps-uhelper getpkgname | fmt get() { xbps-query -m \ | xargs -n1 xbps-uhelper getpkgname \ | sed -r 's/(base-system|grub-x86_64-efi|slack-desktop|discord)//' \ | grep "\S" } # Write list of packages to disk. save() { get > "$packagesFile" } # Install package and write update package listing to disk. install() { sudo xbps-install $1 if [[ $? == 0 ]]; then save fi } # Remove a package and write updated package listing to disk. uninstall() { sudo xbps-remove $1 if [[ $? == 0 ]]; then save fi } # Uninstall alias remove() { uninstall $1 } # Install any missing packages from package file. ensure() { if [[ ! -f $packagesFile ]]; then printf "Error: package file %s not found\n" $packagesFile exit 1 fi sudo xbps-install -S $(cat "$packagesFile") } $1 $2