mirror of https://gitlab.com/dabruh/dotfiles.git
Automatically construct target list
This commit is contained in:
parent
4cbbf46270
commit
569d807040
|
@ -2,7 +2,7 @@ pacman-base:acpi wget curl # Required for setup_system.sh
|
||||||
pacman-any:i3-gaps feh i3status network-manager-applet pasystray xautolock inotify-tools xss-lock noto-fonts-emoji
|
pacman-any:i3-gaps feh i3status network-manager-applet pasystray xautolock inotify-tools xss-lock noto-fonts-emoji
|
||||||
pacman-any:zsh tmux code vim ufw scrot dunst arandr ranger thunar flameshot
|
pacman-any:zsh tmux code vim ufw scrot dunst arandr ranger thunar flameshot
|
||||||
pacman-any:gst-libav phonon-qt5-gstreamer gst-plugins-good qt5-quickcontrols qt5-graphicaleffects qt5-multimedia
|
pacman-any:gst-libav phonon-qt5-gstreamer gst-plugins-good qt5-quickcontrols qt5-graphicaleffects qt5-multimedia
|
||||||
pacman-laptop:brightnessctl
|
pacman-type-hasbattery:brightnessctl
|
||||||
aur-any:picom-git sddm-theme-aerial-git
|
aur-any:picom-git sddm-theme-aerial-git
|
||||||
|
|
||||||
apt-base:acpi wget curl # Required for setup_system.sh
|
apt-base:acpi wget curl # Required for setup_system.sh
|
||||||
|
@ -13,11 +13,11 @@ apt-any:python3 python3-pip
|
||||||
apt-any:sddm gstreamer1.0-libav phonon4qt5-backend-gstreamer gstreamer1.0-plugins-good qml-module-qtquick-controls qml-module-qtgraphicaleffects qml-module-qtmultimedia
|
apt-any:sddm gstreamer1.0-libav phonon4qt5-backend-gstreamer gstreamer1.0-plugins-good qml-module-qtquick-controls qml-module-qtgraphicaleffects qml-module-qtmultimedia
|
||||||
apt-any:cargo cmake pkg-config libfreetype6-dev libfontconfig1-dev libxcb-xfixes0-dev libxkbcommon-dev python3
|
apt-any:cargo cmake pkg-config libfreetype6-dev libfontconfig1-dev libxcb-xfixes0-dev libxkbcommon-dev python3
|
||||||
apt-any:libxcb-render0-dev libffi-dev python3-dev python3-cffi
|
apt-any:libxcb-render0-dev libffi-dev python3-dev python3-cffi
|
||||||
apt-any:libpam-u2f
|
apt-any:libpam-u2f # For YubiKey
|
||||||
apt-laptop:brightnessctl
|
apt-type-hasbattery:brightnessctl
|
||||||
pip-any:flashfocus
|
pip-any:flashfocus
|
||||||
|
|
||||||
brew-any:azure-cli
|
brew-host-5cg9521pyj:azure-cli
|
||||||
brew-any:kubectl helm shellcheck velero azure/kubelogin/kubelogin derailed/k9s/k9s fluxcd/tap/flux weaveworks/tap/gitops # Kubernetes related
|
brew-any:kubectl helm shellcheck velero azure/kubelogin/kubelogin derailed/k9s/k9s fluxcd/tap/flux weaveworks/tap/gitops # Kubernetes related
|
||||||
brew-any:zsh-autosuggestions zsh-history-substring-search zsh-syntax-highlighting # ZSH related
|
brew-any:zsh-autosuggestions zsh-history-substring-search zsh-syntax-highlighting # ZSH related
|
||||||
|
|
||||||
|
|
|
@ -48,11 +48,11 @@ function _acpib() {
|
||||||
acpi -b | grep -Fv ' 0%'
|
acpi -b | grep -Fv ' 0%'
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_laptop() {
|
function has_battery() {
|
||||||
[[ $(_acpib | wc -l) -gt 0 ]] && return 0 || return 1
|
[[ $(_acpib | wc -l) -gt 0 ]] && return 0 || return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Returns a comma-separated list of packages for one or more targets.
|
# Returns a list of packages for one or more targets.
|
||||||
# The packages file may contain multiple rows with the same target name.
|
# The packages file may contain multiple rows with the same target name.
|
||||||
function get_packages() {
|
function get_packages() {
|
||||||
local pkg_file="$script_dir/.installer/packages"
|
local pkg_file="$script_dir/.installer/packages"
|
||||||
|
@ -66,6 +66,21 @@ function get_packages() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Return a list of targets for a given package manager
|
||||||
|
function construct_target_list() {
|
||||||
|
local package_manager=${1:?package_manager not set} targets=()
|
||||||
|
|
||||||
|
targets+=("$package_manager-any")
|
||||||
|
targets+=("$package_manager-host-$(hostname | cut -d. -f1)")
|
||||||
|
has_battery && targets+=("$package_manager-type-hasbattery")
|
||||||
|
echo "${targets[@],,}" # Return lowercase
|
||||||
|
}
|
||||||
|
|
||||||
|
function setup_pip_packages() {
|
||||||
|
# shellcheck disable=SC2046
|
||||||
|
sudo pip3 install $(get_packages $(construct_target_list pip)) --no-input || return 1
|
||||||
|
}
|
||||||
|
|
||||||
function install_sddm_aerial_theme() {
|
function install_sddm_aerial_theme() {
|
||||||
local theme_dir="/usr/share/sddm/themes/aerial"
|
local theme_dir="/usr/share/sddm/themes/aerial"
|
||||||
|
|
||||||
|
@ -148,11 +163,10 @@ function setup_homebrew() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup_brew_formulas() {
|
function setup_brew_formulas() {
|
||||||
local targets=("brew-any")
|
|
||||||
|
|
||||||
brew update || return 1
|
brew update || return 1
|
||||||
|
|
||||||
for package in $(get_packages "${targets[@]}"); do
|
# shellcheck disable=SC2046
|
||||||
|
for package in $(get_packages $(construct_target_list brew)); do
|
||||||
if brew list --full-name | grep -Eq "(^| )$package($| )" >/dev/null; then
|
if brew list --full-name | grep -Eq "(^| )$package($| )" >/dev/null; then
|
||||||
if $upgrade_packages; then
|
if $upgrade_packages; then
|
||||||
echo "Package '$package' will be upgraded."
|
echo "Package '$package' will be upgraded."
|
||||||
|
@ -188,7 +202,8 @@ function setup_krew_plugins() {
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for package in $(get_packages "${targets[@]}"); do
|
# shellcheck disable=SC2046
|
||||||
|
for package in $(get_packages $(construct_target_list krew)); do
|
||||||
if kubectl-krew list | grep -q "^$package$" >/dev/null; then
|
if kubectl-krew list | grep -q "^$package$" >/dev/null; then
|
||||||
if $upgrade_packages; then
|
if $upgrade_packages; then
|
||||||
echo "Package '$package' will be upgraded."
|
echo "Package '$package' will be upgraded."
|
||||||
|
@ -231,19 +246,13 @@ function prepare_arch() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup_arch_with_pamac() {
|
function setup_arch_with_pamac() {
|
||||||
local targets=("pacman-any") packages
|
# shellcheck disable=SC2046
|
||||||
is_laptop && targets+=("pacman-laptop")
|
sudo pamac install $(get_packages $(construct_target_list pacman)) --no-confirm || return 1
|
||||||
|
|
||||||
packages="$(get_packages "${targets[@]}")"
|
|
||||||
# shellcheck disable=SC2086
|
|
||||||
sudo pamac install $packages --no-confirm || return 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup_arch_with_yay() {
|
function setup_arch_with_yay() {
|
||||||
local targets=("aur-any") packages
|
# shellcheck disable=SC2046
|
||||||
is_laptop && targets+=("aur-laptop")
|
for package in $(get_packages $(construct_target_list aur)); do
|
||||||
|
|
||||||
for package in $(get_packages "${targets[@]}"); do
|
|
||||||
if pacman -Qs "^$package$" >/dev/null; then
|
if pacman -Qs "^$package$" >/dev/null; then
|
||||||
if $upgrade_packages; then
|
if $upgrade_packages; then
|
||||||
echo "Package '$package' will be upgraded."
|
echo "Package '$package' will be upgraded."
|
||||||
|
@ -259,19 +268,11 @@ function setup_arch_with_yay() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup_arch_with_pip() {
|
|
||||||
local targets=("pip-any") packages
|
|
||||||
|
|
||||||
packages="$(get_packages "${targets[@]}")"
|
|
||||||
# shellcheck disable=SC2086
|
|
||||||
sudo pip3 install $packages --no-input || return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
function setup_arch() {
|
function setup_arch() {
|
||||||
prepare_arch || return 1
|
prepare_arch || return 1
|
||||||
setup_arch_with_pamac || return 2
|
setup_arch_with_pamac || return 2
|
||||||
setup_arch_with_yay || return 3
|
setup_arch_with_yay || return 3
|
||||||
setup_arch_with_pip || return 4
|
setup_pip_packages || return 4
|
||||||
configure_sddm || return 5
|
configure_sddm || return 5
|
||||||
configure_ufw || return 6
|
configure_ufw || return 6
|
||||||
setup_homebrew || return 7
|
setup_homebrew || return 7
|
||||||
|
@ -295,44 +296,28 @@ function setup_debian_repo_vscodium() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup_debian_base_with_apt() {
|
function setup_debian_base_with_apt() {
|
||||||
local targets packages
|
|
||||||
|
|
||||||
targets=("apt-base")
|
|
||||||
packages="$(get_packages "${targets[@]}")"
|
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2046
|
||||||
sudo apt-get install $packages -y || return 1
|
sudo apt-get install $(get_packages apt-base) -y || return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup_debian_with_apt() {
|
function setup_debian_with_apt() {
|
||||||
local targets packages
|
|
||||||
|
|
||||||
targets=("apt-any")
|
|
||||||
is_laptop && targets+=("apt-laptop")
|
|
||||||
packages="$(get_packages "${targets[@]}")"
|
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2046
|
||||||
sudo apt-get install $packages -y || return 2
|
sudo apt-get install $(get_packages $(construct_target_list apt)) -y || return 2
|
||||||
}
|
|
||||||
|
|
||||||
function setup_debian_with_pip() {
|
|
||||||
local targets=("pip-any") packages
|
|
||||||
|
|
||||||
packages="$(get_packages "${targets[@]}")"
|
|
||||||
# shellcheck disable=SC2086
|
|
||||||
sudo pip3 install $packages --no-input || return 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup_debian_with_git() {
|
function setup_debian_with_git() {
|
||||||
install_picom || return 1
|
install_picom || return 1
|
||||||
install_sddm_aerial_theme || return 2
|
install_sddm_aerial_theme || return 2
|
||||||
|
build_alacritty || return 3
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup_debian() {
|
function setup_debian() {
|
||||||
setup_debian_base_with_apt || return 1
|
setup_debian_base_with_apt || return 1
|
||||||
setup_debian_repo_vscodium || return 2
|
setup_debian_repo_vscodium || return 2
|
||||||
setup_debian_with_apt || return 3
|
setup_debian_with_apt || return 3
|
||||||
setup_debian_with_pip || return 4
|
setup_pip_packages || return 4
|
||||||
setup_debian_with_git || return 5
|
setup_debian_with_git || return 5
|
||||||
configure_sddm || return 6
|
configure_sddm || return 6
|
||||||
configure_ufw || return 7
|
configure_ufw || return 7
|
||||||
|
@ -340,8 +325,7 @@ function setup_debian() {
|
||||||
setup_brew_formulas || return 9
|
setup_brew_formulas || return 9
|
||||||
setup_krew || return 10
|
setup_krew || return 10
|
||||||
setup_krew_plugins || return 11
|
setup_krew_plugins || return 11
|
||||||
build_alacritty || return 12
|
change_shell || return 12
|
||||||
change_shell || return 13
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "$EUID" -eq 0 ]; then
|
if [ "$EUID" -eq 0 ]; then
|
||||||
|
|
Loading…
Reference in New Issue