From d650079127b562e6f959710b810dd75b777f18b0 Mon Sep 17 00:00:00 2001 From: "Kevin Veen-Birkenbach [aka. Frantz]" Date: Wed, 6 May 2020 12:11:15 +0200 Subject: [PATCH] Implemented game installation logic --- configuration/packages/client/yay/games.txt | 3 ++ scripts/base.sh | 8 --- scripts/client/setup.sh | 54 ++++++++++++++++----- 3 files changed, 44 insertions(+), 21 deletions(-) create mode 100644 configuration/packages/client/yay/games.txt diff --git a/configuration/packages/client/yay/games.txt b/configuration/packages/client/yay/games.txt new file mode 100644 index 0000000..ca246e2 --- /dev/null +++ b/configuration/packages/client/yay/games.txt @@ -0,0 +1,3 @@ +# flightgear +flightgear-data-git +flightgear-git diff --git a/scripts/base.sh b/scripts/base.sh index 44b8164..79ad41b 100644 --- a/scripts/base.sh +++ b/scripts/base.sh @@ -70,14 +70,6 @@ error(){ exit 1; } -# @todo May this should be moved to another place -get_packages(){ - for package_collection in "$@" - do - sed -e "/^#/d" -e "s/#.*//" "$PACKAGE_PATH""$package_collection.txt" || error "Loading package wasn't possible." - done -} - HEADER(){ echo echo "${COLOR_YELLOW}The" diff --git a/scripts/client/setup.sh b/scripts/client/setup.sh index 9d87793..827eef3 100644 --- a/scripts/client/setup.sh +++ b/scripts/client/setup.sh @@ -2,10 +2,28 @@ # @author Kevin Veen-Birkenbach # shellcheck disable=SC2015 # Deactivating bool hint # shellcheck source=/dev/null # Deactivate SC1090 - +# shellcheck disable=SC2086 # Deactivating escaping warning, because it's wrong concerning pacman_packages source "$(dirname "$(readlink -f "${0}")")/../base.sh" || (echo "Loading base.sh failed." && exit 1) -SYSTEM_MEMORY_KB="$(grep MemTotal /proc/meminfo | awk '{print $2}')" +get_packages(){ + for package_collection in "$@" + do + echo "$(sed -e "/^#/d" -e "s/#.*//" "$PACKAGE_PATH""$package_collection.txt" | tr '\n' ' ')" || error "Loading package wasn't possible." + done +} + +install_yay_packages_if_needed(){ + info "Checking yay packages [ $1 ]..." + for package in $1; do + if [ "$(pacman -Qi "$package" 2> /dev/null)" ]; then + info "Package \"$package\" is allready installed. Skipped installation." + else + info "Install package \"$package\" with yay..." && + yay -S "$package" || error "Failed to install package \"$package\"." + fi + done +} + info "Start setup of customized core software..." info "Copying templates to home folder..." && @@ -14,18 +32,12 @@ cp -rfv "$TEMPLATE_PATH/." "$HOME" || error "Copy templates failed." info "Update packages..." && sudo pacman -Syyu || error "Package syncronisation failed." -info "Synchronizing pacman packages..." && -get_packages "general" "client/pacman/general" "client/pacman/games" | sudo pacman -S --needed - || error "Syncronisation failed." +pacman_packages="$(get_packages "general" "client/pacman/general")" +info "Synchronizing pacman packages [$pacman_packages]..." && +sudo pacman -S --needed $pacman_packages || error "Syncronisation failed." -info "Synchronizing yay packages..." -for package in $(get_packages "client/yay/general"); do - if [ "$(pacman -Qi "$package" 2> /dev/null)" ]; then - info "Package \"$package\" is allready installed. Skipped installation." - else - info "Install package \"$package\" with yay..." - get_packages "client/yay/general" | yay -S "package" - fi -done +info "Synchronizing yay packages..." && +install_yay_packages_if_needed "$(get_packages "client/yay/general")"; FSTAB_SWAP_ENTRY="/swapfile none swap defaults 0 0" SWAP_FILE="/swapfile" @@ -165,6 +177,22 @@ if [ "$DESKTOP_SESSION" == "gnome" ]; then fi +info "Testing if computer has more then 4GB of memory to process games..." && +if [ "$(echo "( $(grep MemTotal /proc/meminfo | awk '{print $2}') / (1024 ^ 2) ) > 4" | bc -l)" = "1" ]; + then + pacman_game_packages="$(get_packages "client/pacman/games")" + yay_game_packages="$(get_packages "client/yay/games")" + success "Ok" && + info "Installing games..." && + info "Installing yay packages [ $yay_game_packages ]..." && + install_yay_packages_if_needed "$yay_game_packages" && + info "Installing pacman packages [ $pacman_game_packages ]..." && + sudo pacman -S --needed "$(get_packages "client/pacman/games")" || error "Syncronisation failed."; + else + warning "Not enough ressources." && + info "Skipping game installation"; +fi + info "Removing all software from user startup..." autostart_folder="$HOME/.config/autostart/" if [ "$(ls -A "$autostart_folder")" ]