ambevar-dotfiles/.local/bin/package-lister

57 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
## Create lists of system- and TeX Live packages.
## Variables
PKG_ROOT="$HOME/.package-lists"
mkdir -p "$PKG_ROOT"
GREEN='\033[0;32m\033[1m'
YELLOW='\033[0;33m\033[1m'
BOLD='\033[0m\033[1m'
NORMAL='\033[0m'
section() {
echo -e "$GREEN==> $@$NORMAL"
}
message() {
echo -e "$YELLOW:: $@$NORMAL"
}
status() {
local title=$1
local body=$2
[ -z "$body" ] && return
message "$title"
echo "$body"
}
## Arch Linux
if command -v pacman >/dev/null 2>&1; then
pacman -Qneq | LC_ALL=C sort >"$PKG_ROOT/arch-official"
pacman -Qmeq | LC_ALL=C sort >"$PKG_ROOT/arch-aur"
fi
## TeXlive
if ! command -v guix >/dev/null 2>&1; then
if command -v tlmgr >/dev/null 2>&1; then
tlctl l >"$PKG_ROOT/texlive"
fi
fi
## Guix
if command -v guix >/dev/null 2>&1; then
section "Listing Guix default profile"
guile --no-auto-compile -s ~/.config/guix/profile-to-manifest.scm ~/.guix-profile >"$PKG_ROOT/guix-manifest.scm"
for i in ~/.guix-extra-profiles/*; do
profile=$i/$(basename "$i")
section "Listing Guix profile" $(basename "$i")
if [ -d "$profile" ]; then
guile --no-auto-compile -s ~/.config/guix/profile-to-manifest.scm "$profile" >"$PKG_ROOT/guix-$(basename "$i")-manifest.scm"
fi
unset profile
done
fi
status "Unpushed files:" "$(git -C "$PKG_ROOT" diff --cached --name-only .)"
status "Unstaged files:" "$(git -C "$PKG_ROOT" diff --name-only .)"