make install.sh script compatible for running on non-arch systems
This commit is contained in:
+16
-3
@@ -1,16 +1,19 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
packagefile="packages.txt"
|
PACKAGEFILE="packages.txt"
|
||||||
|
|
||||||
# Ensure we are in the correct directory
|
# Ensure we are in the correct directory
|
||||||
pushd "$(dirname "$(realpath "$0")")" &> /dev/null
|
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
|
# Read packages.txt and install packages on system using yay
|
||||||
function install_packages {
|
function install_packages {
|
||||||
local install
|
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
|
# check if package is installed
|
||||||
local 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
|
if [ $installed -eq 0 ]; then
|
||||||
# needs to be installed
|
# needs to be installed
|
||||||
install="$install"$'\n'"$pkg"
|
install="$install"$'\n'"$pkg"
|
||||||
@@ -18,9 +21,19 @@ function install_packages {
|
|||||||
done
|
done
|
||||||
|
|
||||||
[ -z "$install" ] || {
|
[ -z "$install" ] || {
|
||||||
|
if $CMD_YAY; then
|
||||||
echo "Packages to be installed: "
|
echo "Packages to be installed: "
|
||||||
echo "$install"
|
echo "$install"
|
||||||
yay -S $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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user