#!/usr/bin/env bash # # Void Linux package utilities # thisdir=$(dirname "$(realpath ~/.bashrc)") packagesFile="$thisdir/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/(slack-desktop|discord)//' \ | grep "\S" } # Write list of packages to disk write() { get > "$packagesFile" } # Install package and write package listing to disk install() { sudo xbps-install $1 if [[ $? == 0 ]]; then write_packages fi } remove() { sudo xbps-remove $1 if [[ $? == 0 ]]; then write_packages fi } # Install 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