diff options
-rwxr-xr-x | packages.sh | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/packages.sh b/packages.sh index 8296644..c79d58c 100755 --- a/packages.sh +++ b/packages.sh @@ -2,18 +2,31 @@ all=($(< packages.txt sed 's/#.*//' | xargs printf -- '%s\n' | sort -u)) grps=($(printf -- '%s\n' "${all[@]}" | sed -n 's/^g://p')) pkgs=($(printf -- '%s\n' "${all[@]}" | sed -n 's/^p://p')) -igns=($(printf -- '%s\n' "${all[@]}" | sed -n 's/^i://p')) +excl=($(printf -- '%s\n' "${all[@]}" | sed -n 's/^x://p')) +bads=($(printf -- '%s\n' "${all[@]}" | grep -v '^[gpx]:')) +if [[ ${#bads[@]} -gt 0 ]]; then + echo ' => Invalid entries in packages.txt' + printf ' -> %s\n' "${bads[@]}" + exit 1 +fi + +packages_txt() { + { + pacman -Sgq -- "${grps[@]}"|grep -vFx -f <(printf '%s\n' "${excl[@]}") + printf '%s\n' "${pkgs[@]}" + } | sort -u +} echo ' => In packages.txt, but not installed' comm -13 \ <(pacman -Qq|sort -u) \ - <({ pacman -Sgq -- "${grps[@]}"; printf '%s\n' "${pkgs[@]}"; }|sort -u) | + <(packages_txt) | sed 's|^| -> |' echo ' => Installed explicitly and not depended on, but not in packages.txt' comm -23 \ <(pacman -Qetq |sort -u) \ - <({ pacman -Sgq -- "${grps[@]}"; printf '%s\n' "${pkgs[@]}"; }|sort -u) | + <(packages_txt) | sed 's|^| -> |' echo ' => Installed explicitly and only optionally depended on, but not in packages.txt' @@ -21,7 +34,7 @@ comm -23 \ <(comm -23 \ <(pacman -Qettq|sort -u) \ <(pacman -Qetq |sort -u)) \ - <({ pacman -Sgq -- "${grps[@]}"; printf '%s\n' "${pkgs[@]}"; }|sort -u) | + <(packages_txt) | sed 's|^| -> |' echo ' => Installed as dependencies, but only optionally depended on' |