#!/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 you want to continue? [Y/n] " input
case $input in
[nN][oO] | [nN])
    exit 0
    ;;
*)
    echo "The program will continue..."
    ;;
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

exit 0
