#!/bin/sh

#-----------------------------------
# Name:     install-yay
# Version:  1.0.0
# Author:   Solomon Laing
# Description:
# Installs the AUR helper yay on the
# system.
#-----------------------------------

clear

if command -v yay &> /dev/null; then
    echo "yay is already installed on the system."
    exit 0
fi

echo "This script is going to attempt install yay and it's dependencies. As such it will ask for root privilages."

read -r -p "Are You Sure? [y/N] " input

case $input in
[yY][eE][sS] | [yY])
    echo "The program will continue..."
    ;;
[nN][oO] | [nN])
    exit 0
    ;;
*)
    echo "Invalid input..."
    exit 1
    ;;
esac

if ! command -v fakeroot &> /dev/null; then
    sudo pacman -S --noconfirm base-devel
fi

cd /opt
sudo -S git clone https://aur.archlinux.org/yay.git
sudo -S chown -R $USER:users ./yay
cd yay
makepkg -si