From a967849d1d16d6530fd6cea9da47fcae5fea71ba Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Sun, 31 Jul 2022 19:19:32 -0400 Subject: [PATCH] REF split installation into deps file and pacman/yay scripts --- install_deps | 64 --------------------------------------------- make_pkgs | 7 +++++ scripts/.query_pkgs | 22 ++++++++++++++++ scripts/aur_deps | 12 +++++++++ scripts/pacman_deps | 16 ++++++++++++ 5 files changed, 57 insertions(+), 64 deletions(-) delete mode 100755 install_deps create mode 100644 make_pkgs create mode 100755 scripts/.query_pkgs create mode 100755 scripts/aur_deps create mode 100755 scripts/pacman_deps diff --git a/install_deps b/install_deps deleted file mode 100755 index 0f7cf35..0000000 --- a/install_deps +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash - -## Build xmonad and install packages to make it run at full capacity - -prebuild () { - # TODO this can be integrated into stack with nix - # for x11 - make_pkgs=(libx11 libxrandr libxss) - # for alsa - make_pkgs=(alsa-lib) - # for iwlib - make_pkgs=(wireless_tools) - # for x11-xft - make_pkgs+=(libxft) - # for xmobar - make_pkgs+=(libxpm) - - sudo pacman --noconfirm -S "${make_pkgs[@]}" -} - -build () { - stack install -} - -query='.[].success | -objects | -.root.tree | -..|.left?.data, ..|.right?.data, .data? | -select(. != null) | -.fulfillment | -select(. != null) | -add | select(. != null)' - -jq_type () { - echo "$1" | jq --raw-output "select(.type==\"$2\") | .name" | sort | uniq -} - -postbuild () { - # these are extra packages that pertain to processes outside xmonad but are - # still required/desired to make it work correctly - xmonad_pkgs=(xinit autorandr picom) - - raw=$(xmonad --deps | jq "$query") - - mapfile -t official < <(jq_type "$raw" "Official") - mapfile -t local < <(jq_type "$raw" "AUR") - - if ! pacman -Si "${official[@]}" > /dev/null; then - echo "At least one official package doesn't exist." - exit 1 - fi - - if ! yay -Si "${local[@]}"; then - echo "At least one local package doesn't exist." - exit 1 - fi - - sudo pacman --noconfirm -S "${xmonad_pkgs[@]}" "${official[@]}" - yay --needed --noconfirm --norebuild --removemake -S "${local[@]}" -} - -prebuild -build -postbuild diff --git a/make_pkgs b/make_pkgs new file mode 100644 index 0000000..d048614 --- /dev/null +++ b/make_pkgs @@ -0,0 +1,7 @@ +libx11 +libxrandr +libxss +alsa-lib +wireless_tools +libxft +libxpm \ No newline at end of file diff --git a/scripts/.query_pkgs b/scripts/.query_pkgs new file mode 100755 index 0000000..769b864 --- /dev/null +++ b/scripts/.query_pkgs @@ -0,0 +1,22 @@ +#!/bin/bash + +# Query the current xmonad configuration for packages to install + +# usage: .query_pkgs "Official"|"AUR" + +query='.[].success | +objects | +.root.tree | +..|.left?.data, ..|.right?.data, .data? | +select(. != null) | +.fulfillment | +select(. != null) | +add | select(. != null)' + +jq_type () { + echo "$1" | jq --raw-output "select(.type==\"$2\") | .name" | sort | uniq +} + +raw=$(xmonad --deps | jq "$query") + +jq_type "$raw" "$1" diff --git a/scripts/aur_deps b/scripts/aur_deps new file mode 100755 index 0000000..a410aeb --- /dev/null +++ b/scripts/aur_deps @@ -0,0 +1,12 @@ +#!/bin/bash + +# Print list of packages to be installed via yay + +mapfile -t local < <(./.query_pkgs "AUR") + +if ! yay -Si "${local[@]}" > /dev/null; then + echo "At least one local package doesn't exist." + exit 1 +fi + +echo "${local[@]}" diff --git a/scripts/pacman_deps b/scripts/pacman_deps new file mode 100755 index 0000000..30431b8 --- /dev/null +++ b/scripts/pacman_deps @@ -0,0 +1,16 @@ +#!/bin/bash + +# Print list of packages to be installed via pacman + +# these are extra packages that pertain to processes outside xmonad but are +# still required/desired to make it work correctly +xmonad_pkgs=(xinit autorandr picom) + +mapfile -t official < <(./.query_pkgs "Official") + +if ! pacman -Si "${official[@]}" > /dev/null; then + echo "At least one official package doesn't exist." + exit 1 +fi + +echo "${xmonad_pkgs[@]}" "${official[@]}"