|
|
@ -18,62 +18,6 @@ |
|
|
|
|
|
|
|
########################################################### |
|
|
|
|
|
|
|
if [[ $UID -ne 0 ]]; then |
|
|
|
echo "Run as root or sudo" |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
|
|
|
|
########################################################### |
|
|
|
|
|
|
|
# Your system username (who has PoL profile // existing Wine prefixes) |
|
|
|
# Get it by running 'whoami' |
|
|
|
|
|
|
|
read -r -p "Who has PoL profiles // existing Wine prefixes on the system? [username] " username |
|
|
|
|
|
|
|
function check_username { |
|
|
|
|
|
|
|
if [[ $username == "" ]]; then |
|
|
|
echo "Empty username is invalid. Aborting." |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
|
|
|
|
if [[ $username == "root" ]]; then |
|
|
|
echo "Can't use 'root' user. Aborting." |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
|
|
|
|
local IFS=$'\n' |
|
|
|
for validname in $(cat /etc/passwd | awk -F : '{print $1}'); do |
|
|
|
if [[ $validname == $username ]]; then |
|
|
|
USERNAME=$username |
|
|
|
fi |
|
|
|
done |
|
|
|
|
|
|
|
if [[ ! -n $USERNAME ]]; then |
|
|
|
echo "Couldn't find user $username. Please check the name and try again." |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
function check_pol { |
|
|
|
|
|
|
|
# Check existence of PoL default folder in user's homedir |
|
|
|
|
|
|
|
local USERHOME=$(grep $USERNAME /etc/passwd | awk -F : '{print $(NF-1)}') |
|
|
|
|
|
|
|
if [[ ! -d "$USERHOME/PlayOnLinux's virtual drives" ]]; then |
|
|
|
echo "Warning. Couldn't find PoL directories in the homedir of user $USERNAME." |
|
|
|
NOPOL= |
|
|
|
fi |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
check_username |
|
|
|
check_pol |
|
|
|
|
|
|
|
########################################################### |
|
|
|
|
|
|
|
# REQUIREMENTS: |
|
|
|
|
|
|
|
# - Arch Linux or equivalent (uses pacman) |
|
|
@ -135,6 +79,129 @@ WINE_VERSION= |
|
|
|
|
|
|
|
########################################################### |
|
|
|
|
|
|
|
if [[ $UID -ne 0 ]]; then |
|
|
|
echo "Run as root or sudo. This permission is required only for package installation." |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
|
|
|
|
########################################################### |
|
|
|
|
|
|
|
# Your system username (who has PoL profile // existing Wine prefixes) |
|
|
|
# Get it by running 'whoami' |
|
|
|
|
|
|
|
unset USERNAME ERRPKGS |
|
|
|
|
|
|
|
read -r -p "Who has PoL profiles // existing Wine prefixes on the system? [username] " username |
|
|
|
echo "" |
|
|
|
function check_username { |
|
|
|
|
|
|
|
if [[ $(printf '%s' $username | sed 's/[[:blank:]]//g') == "" ]]; then |
|
|
|
echo "Empty username is invalid. Aborting." |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
|
|
|
|
if [[ $username == "root" ]]; then |
|
|
|
echo "Can't use 'root' user. Aborting." |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
|
|
|
|
local IFS=$'\n' |
|
|
|
for validname in $(cat /etc/passwd | awk -F : '{print $1}'); do |
|
|
|
if [[ $validname == $username ]]; then |
|
|
|
USERNAME=$username |
|
|
|
fi |
|
|
|
done |
|
|
|
|
|
|
|
if [[ ! -n $USERNAME ]]; then |
|
|
|
echo "Couldn't find user '$username'. Please check the name and try again." |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
function check_pol { |
|
|
|
|
|
|
|
# Check existence of PoL default folder in user's homedir |
|
|
|
|
|
|
|
local USERHOME=$(grep $USERNAME /etc/passwd | awk -F : '{print $(NF-1)}') |
|
|
|
|
|
|
|
if [[ ! -d "$USERHOME/PlayOnLinux's virtual drives" ]]; then |
|
|
|
echo "Warning. Couldn't find PoL directories in the homedir of user $USERNAME." |
|
|
|
NOPOL= |
|
|
|
fi |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
check_username |
|
|
|
check_pol |
|
|
|
|
|
|
|
########################################################### |
|
|
|
|
|
|
|
# Check package dependencies beforehand, just to avoid |
|
|
|
# annoying situations which could occur later while the script |
|
|
|
# is already running. |
|
|
|
|
|
|
|
# Just for "packages which are not found" array <=> ERRPKGS |
|
|
|
# We need to set it outside of checkDepends function |
|
|
|
# because it is a global variable for all checked packages |
|
|
|
l=0 |
|
|
|
|
|
|
|
function checkDepends { |
|
|
|
|
|
|
|
# The first and the second argument |
|
|
|
local packagedir=${1} |
|
|
|
local package=${2} |
|
|
|
|
|
|
|
# We get necessary variables to check from this file |
|
|
|
local file="./${packagedir}/PKGBUILD" |
|
|
|
|
|
|
|
# All but the (zero), the first and the second argument |
|
|
|
# We check the value of these file variables |
|
|
|
local file_vars=${@:3} |
|
|
|
|
|
|
|
for var in ${file_vars[*]}; do |
|
|
|
# Get the variable and set it as a new variable in the current shell |
|
|
|
# This is applicable only to variable arrays! Do not use if the variable is not an array. |
|
|
|
local field=$(awk "/^${var}/,/)/" ${file} | sed -r "s/^${var}=|[)|(|']//g") |
|
|
|
|
|
|
|
local i=0 |
|
|
|
for parse in ${field[*]}; do |
|
|
|
if [[ ! $parse =~ ^# ]]; then |
|
|
|
local PKGS[$i]=$(printf '%s' $parse | sed 's/[=|>|<].*$//') |
|
|
|
let i++ |
|
|
|
fi |
|
|
|
done |
|
|
|
|
|
|
|
# Sort list and delete duplicate index values |
|
|
|
# https://stackoverflow.com/questions/13648410/how-can-i-get-unique-values-from-an-array-in-bash |
|
|
|
local PKGS_sort=($(printf "${PKGS[*]}" | tr ' ' '\n' | sort -u | tr '\n' ' ')) |
|
|
|
|
|
|
|
for pkg in ${PKGS_sort[*]}; do |
|
|
|
|
|
|
|
if [[ $(printf $(pacman -Q ${pkg} &>/dev/null)$?) -ne 0 ]]; then |
|
|
|
ERRPKGS[$l]=${pkg} |
|
|
|
echo -e "\e[91mError:\e[0m Dependency '${pkg}' not found, required by '${package}' (${file} => ${var})" |
|
|
|
let l++ |
|
|
|
fi |
|
|
|
|
|
|
|
done |
|
|
|
|
|
|
|
unset PKGS PKGS_sort var i |
|
|
|
|
|
|
|
done |
|
|
|
echo -e " \e[92m=>\e[0m Dependency check for ${package} done.\n" |
|
|
|
} |
|
|
|
|
|
|
|
checkDepends "0-wine-staging-git" "wine-staging-git" _depends makedepends |
|
|
|
checkDepends "0-dxvk-git" "dxvk-git" depends makedepends |
|
|
|
|
|
|
|
if [[ -v ERRPKGS ]]; then |
|
|
|
echo -e "The following dependencies are missing:\n\e[91m$(for o in ${ERRPKGS[@]}; do printf '%s\n' ${o}; done)\e[0m\n" |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
|
|
|
|
########################################################### |
|
|
|
|
|
|
|
# Switches |
|
|
|
|
|
|
|
if [[ "${1}" == "--refresh" ]]; then |
|
|
@ -181,6 +248,7 @@ function netCheck() { |
|
|
|
echo -e "\nInternet connection failed (GitHub). Please check your connection and try again.\n" |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
rm ./index.html.tmp |
|
|
|
} |
|
|
|
|
|
|
|
########################################################### |
|
|
@ -349,6 +417,4 @@ if [[ ! -v CHECK ]]; then |
|
|
|
fi |
|
|
|
|
|
|
|
# Unset various env vars |
|
|
|
unset CHECK |
|
|
|
unset WINE_INSTALL |
|
|
|
unset FORCE_INSTALL |
|
|
|
unset CHECK WINE_INSTALL FORCE_INSTALL l |