make install.sh script compatible for running on non-arch systems

This commit is contained in:
Zechert, Frank (EXTERN: Capgemini)
2026-05-19 11:19:06 +02:00
parent 83891fa61c
commit 0e9f9cf418
+19 -6
View File
@@ -1,16 +1,19 @@
#!/bin/bash
packagefile="packages.txt"
PACKAGEFILE="packages.txt"
# Ensure we are in the correct directory
pushd "$(dirname "$(realpath "$0")")" &> /dev/null
# Check if commands are available
command -v yay &> /dev/null && CMD_YAY=true || CMD_YAY=false
# Read packages.txt and install packages on system using yay
function install_packages {
local install
for pkg in $(sed -E -e 's/\s*#.*$//g' -e 's/^\s+//g' "$packagefile" | sed -E ':a;N;$!ba;s/\s+/\n/g'); do
for pkg in $(sed -E -e 's/\s*#.*$//g' -e 's/^\s+//g' "$PACKAGEFILE" | sed -E ':a;N;$!ba;s/\s+/\n/g'); do
# check if package is installed
local installed
yay -Q "$(echo "$pkg")" &> /dev/null && installed=1 || installed=0
$CMD_YAY && yay -Q "$(echo "$pkg")" &> /dev/null && installed=1 || installed=0
if [ $installed -eq 0 ]; then
# needs to be installed
install="$install"$'\n'"$pkg"
@@ -18,9 +21,19 @@ function install_packages {
done
[ -z "$install" ] || {
echo "Packages to be installed: "
echo "$install"
yay -S $install
if $CMD_YAY; then
echo "Packages to be installed: "
echo "$install"
yay -S $install
else
echo "Yay package manager is not available"
echo "Please make sure that the following tools"
echo "are available in your system"
echo ""
echo "$install"
echo ""
read -p "Press Enter to continue" < /dev/tty
fi
}
}