Unverified Commit 3523b476 authored by Boria138's avatar Boria138

Update install script for flatpak support

parent 1a1eff62
#!/usr/bin/env bash #!/usr/bin/env bash
# Author: Mikhail Tergoev (linux-gaming.ru) # Author: Mikhail Tergoev (linux-gaming.ru)
# Adapted for Flatpak: Boris Yumankulov (Boria138)
# License MIT # License MIT
######################################################################## ########################################################################
unset PW_AUTOPLAY PW_SET_LANG PW_SILENT_INSTALL unset PW_AUTOPLAY PW_SET_LANG PW_SILENT_INSTALL
export portname="PortProton" export portname="PortProton"
export port_ver=1.5 export port_ver=1.6
######################################################################## ########################################################################
cd "$(dirname "$(readlink -f "$0")")" cd "$(dirname "$(readlink -f "$0")")"
script_path="$(pwd)" script_path="$(pwd)"
...@@ -15,20 +16,49 @@ fatal () { ...@@ -15,20 +16,49 @@ fatal () {
exit 1 exit 1
} }
######################################################################## ########################################################################
check_flatpak () {
if [[ ! -z "$FLATPAK_IN_USE" ]]
then [[ "$FLATPAK_IN_USE" == 1 ]] && return 0 || return 1
fi
if grep -i "flatpak" /etc/os-release &>/dev/null ; then
export FLATPAK_IN_USE=1
return 0
else
export FLATPAK_IN_USE=0
return 1
fi
}
########################################################################
if [ "$(id -u)" == "0" ] ; then if [ "$(id -u)" == "0" ] ; then
$yad_gui --error --text "\nDo not run ${portname} from the superuser!" 2>/dev/null
fatal "Do not run the script from the superuser!" fatal "Do not run the script from the superuser!"
fi fi
######################################################################## ########################################################################
unset PW_USE_NS
if command -v yad &>/dev/null ; then
yad_gui="$(command -v yad) --title=${portname} --window-icon=portproton.svg --borders=10 --center --text-align=center"
elif grep -i "SteamOS" /etc/os-release &>/dev/null ; then
yad_gui="$(command -v zenity) --title=${portname} --window-icon=portproton.svg --borders=10 --center --text-align=center"
else
PW_USE_NS=1
fi
########################################################################
if flatpak list | grep "${portname}" &>/dev/null ; then
$yad_gui --error --text "\nDo not use flatpak and the native version of ${portname} at the same time!" 2>/dev/null
fatal "Do not use flatpak and the native version of ${portname} at the same time!"
fi
########################################################################
[ -z "${XDG_DATA_HOME}" ] && export XDG_DATA_HOME="$HOME/.local/share" [ -z "${XDG_DATA_HOME}" ] && export XDG_DATA_HOME="$HOME/.local/share"
PP_CONFIG_FILE="${HOME}/.config/${portname}.conf" if ! check_flatpak ; then
if [ -f "${XDG_DATA_HOME}/PortWINE/PortProton/data/scripts/start.sh" ] ; then PP_CONFIG_FILE="${HOME}/.config/${portname}.conf"
if [ -f "${XDG_DATA_HOME}/PortWINE/PortProton/data/scripts/start.sh" ] ; then
echo "${XDG_DATA_HOME}/PortWINE/PortProton" > "${PP_CONFIG_FILE}" echo "${XDG_DATA_HOME}/PortWINE/PortProton" > "${PP_CONFIG_FILE}"
elif [ -f "${HOME}/PortWINE/PortProton/data/scripts/start.sh" ] ; then elif [ -f "${HOME}/PortWINE/PortProton/data/scripts/start.sh" ] ; then
echo "${XDG_DATA_HOME}/PortWINE/PortProton" > "${PP_CONFIG_FILE}" echo "${XDG_DATA_HOME}/PortWINE/PortProton" > "${PP_CONFIG_FILE}"
fi
fi fi
if [ "$script_path" == "/usr/bin" ] && [ -f "${PP_CONFIG_FILE}" ] ; then if ! check_flatpak ; then
if [ "$script_path" == "/usr/bin" ] && [ -f "${PP_CONFIG_FILE}" ] ; then
export PORT_WINE_PATH="$(cat "${PP_CONFIG_FILE}" | head -n 1)" export PORT_WINE_PATH="$(cat "${PP_CONFIG_FILE}" | head -n 1)"
if [ -f "${PORT_WINE_PATH}/data/scripts/start.sh" ] ; then if [ -f "${PORT_WINE_PATH}/data/scripts/start.sh" ] ; then
echo "${port_ver}" > "${PORT_WINE_PATH}/data/tmp/${portname}_ver" echo "${port_ver}" > "${PORT_WINE_PATH}/data/tmp/${portname}_ver"
...@@ -37,10 +67,23 @@ if [ "$script_path" == "/usr/bin" ] && [ -f "${PP_CONFIG_FILE}" ] ; then ...@@ -37,10 +67,23 @@ if [ "$script_path" == "/usr/bin" ] && [ -f "${PP_CONFIG_FILE}" ] ; then
else else
rm -f "${PP_CONFIG_FILE}" rm -f "${PP_CONFIG_FILE}"
fi fi
fi
else
if [ "$script_path" == "/app/bin" ] ; then
export PORT_WINE_PATH="${XDG_DATA_HOME}"
if [ -f "${PORT_WINE_PATH}/scripts/start.sh" ] ; then
echo "${port_ver}" > "${PORT_WINE_PATH}/tmp/${portname}_ver"
/usr/bin/env bash "${PORT_WINE_PATH}/scripts/start.sh" "$@"
exit 0
fi
fi
fi fi
if [[ "${LANG}" == "ru_RU.UTF-8" ]] if echo "$LANG" | grep -i "ru_RU.utf" &>/dev/null ; then
then PW_SET_LANG="Russian" PW_SET_LANG="Russian"
else PW_SET_LANG="English" elif echo "$LANG" | grep -i "es_ES.utf" &>/dev/null ; then
PW_SET_LANG="Spanish"
else
PW_SET_LANG="English"
fi fi
######################################################################## ########################################################################
pw_notify_send () { pw_notify_send () {
...@@ -52,33 +95,15 @@ pw_notify_send () { ...@@ -52,33 +95,15 @@ pw_notify_send () {
fi fi
} }
######################################################################## ########################################################################
unset PW_USE_NS
YAD_PORTABLE_VER="12_3"
if command -v yad &>/dev/null ; then
yad_gui="yad --window-icon=portproton.svg --borders=10 --center --text-align=center"
elif curl -f -# -A "Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)" \
-H 'Cache-Control: no-cache, no-store' -H 'Pragma: no-cache' \
-L "https://github.com/Castro-Fidel/PortWINE/releases/download/yad_portable_v${YAD_PORTABLE_VER}/yad_portable_v${YAD_PORTABLE_VER}.tar.xz" \
-o "${HOME}/yad_portable_v${YAD_PORTABLE_VER}.tar.xz"
then
mkdir -p "${HOME}/.local/bin/" &>/dev/null
tar -Jxhvf "${HOME}/yad_portable_v${YAD_PORTABLE_VER}.tar.xz" -C "${HOME}/.local/bin/"
if [[ -f "${HOME}/.local/bin/yad_portable_v${YAD_PORTABLE_VER}" ]]
then yad_gui="${HOME}/.local/bin/yad_portable_v${YAD_PORTABLE_VER} --borders=10 --center --text-align=center"
else PW_USE_NS=1
fi
else
PW_USE_NS=1
fi
########################################################################
export PW_SILENT_INSTALL=1 export PW_SILENT_INSTALL=1
export PW_AUTOPLAY=1 export PW_AUTOPLAY=1
export INSTALLING_PORT=1 export INSTALLING_PORT=1
######################################################################## ########################################################################
if [[ "${PW_USE_NS}" != "1" ]] ; then if ! check_flatpak ; then
if [[ "${PW_USE_NS}" != "1" ]] ; then
case $PW_SET_LANG in case $PW_SET_LANG in
"Russian") "Russian")
inst1=$($yad_gui --title "Install ${portname}" --text "Выберите путь для установки (обновления) ${portname},\nили оставьте его по умолчанию.\n\nВнимание:\nУстанавливать необходимо на файловую систему Linux (ext4, btrfs и прочие)." --list --radiolist --width=600 --height=200 \ inst1=$($yad_gui --title "Установкка ${portname}" --text "Выберите путь для установки (обновления) ${portname},\nили оставьте его по умолчанию.\n\nВнимание:\nУстанавливать необходимо на файловую систему Linux (ext4, btrfs и прочие)." --list --radiolist --width=600 --height=200 \
--column="Выбор" --column "Путь:" \ --column="Выбор" --column "Путь:" \
TRUE "${def_path}" \ TRUE "${def_path}" \
FALSE "Другой путь...") FALSE "Другой путь...")
...@@ -90,8 +115,21 @@ if [[ "${PW_USE_NS}" != "1" ]] ; then ...@@ -90,8 +115,21 @@ if [[ "${PW_USE_NS}" != "1" ]] ; then
"Другой путь...") "Другой путь...")
D_PATH="$($yad_gui --file --directory --title="Выберите путь..." --width=800 --height=800)" ;; D_PATH="$($yad_gui --file --directory --title="Выберите путь..." --width=800 --height=800)" ;;
esac ;; esac ;;
"Spanish")
inst1=$($yad_gui --title "Instalar ${portname}" --text "Selecciona la ruta de instalación (actualización) ${portname},\no déjalo en el valor predeterminado. \n\nAtención:\nInstala en un sistema de archivos Linux (ext4, btrfs, etc.)." --list --radiolist --width=600 --height=200 \
--column="Elección" --column "Camino" \
TRUE "${def_path}" \
FALSE "Otro camino...")
[ "$?" != "0" ] && exit 1
inst1="$(echo $inst1 | awk -F'|' '{print $2}')"
case $inst1 in
"${def_path}")
D_PATH="${def_path}" ;;
"Otro camino...")
D_PATH="$($yad_gui --file --directory --title="Selecciona el camino..." --width=800 --height=800)" ;;
esac ;;
"English") "English")
inst1=$($yad_gui --title "Install ${portname}" --text "Select the installation path (update) port,\nor leave it in default." --list --radiolist --width=600 --height=200 \ inst1=$($yad_gui --title "Install ${portname}" --text "Select the installation path (update) ${portname},\nor leave it in default. \n\nAttention:\nInstall on a Linux file system (ext4, btrfs, etc.)" --list --radiolist --width=600 --height=200 \
--column="Set..." --column "Path:" \ --column="Set..." --column "Path:" \
TRUE "${def_path}" \ TRUE "${def_path}" \
FALSE "Other path...") FALSE "Other path...")
...@@ -112,39 +150,57 @@ if [[ "${PW_USE_NS}" != "1" ]] ; then ...@@ -112,39 +150,57 @@ if [[ "${PW_USE_NS}" != "1" ]] ; then
progress_bar() { progress_bar() {
$yad_gui --progress --title="Установка..." --text="Настройка ${portname}" --pulsate --auto-close --auto-kill --width=500 $yad_gui --progress --title="Установка..." --text="Настройка ${portname}" --pulsate --auto-close --auto-kill --width=500
} ;; } ;;
"Spanish")
progress_bar() {
$yad_gui --progress --title="Instalar..." --text="Instalar ${portname}" --pulsate --auto-close --auto-kill --width=500
} ;;
"English") "English")
progress_bar() { progress_bar() {
$yad_gui --progress --title="Install..." --text="Install ${portname}" --pulsate --auto-close --auto-kill --width=500 $yad_gui --progress --title="Install..." --text="Install ${portname}" --pulsate --auto-close --auto-kill --width=500
} ;; } ;;
esac esac
else else
D_PATH="${def_path}" D_PATH="${def_path}"
PW_NOTIFY_TEXT="Installing PortProton..." PW_NOTIFY_TEXT="Installing PortProton..."
pw_notify_send pw_notify_send
fi
fi fi
######################################################################## ########################################################################
export PORT_WINE_PATH="${D_PATH}" if ! check_flatpak ; then
echo "${PORT_WINE_PATH}" > "${PP_CONFIG_FILE}" export PORT_WINE_DATA_PATH="${D_PATH}/data"
if [ ! -d "${PORT_WINE_PATH}" ] ; then export PORT_WINE_PATH="${D_PATH}"
mkdir -p "$PORT_WINE_PATH" || fatal "Cannot create a directory: $PORT_WINE_PATH" else
export PORT_WINE_DATA_PATH="${XDG_DATA_HOME}"
fi
if ! check_flatpak ; then
if [[ ! -z "$PORT_WINE_PATH" ]]
then echo "${PORT_WINE_PATH}" > "${PP_CONFIG_FILE}"
fi
fi
if [ ! -d "${PORT_WINE_DATA_PATH}" ] ; then
mkdir -p "$PORT_WINE_DATA_PATH" || fatal "Cannot create a directory: $PORT_WINE_PATH"
else else
rm -fr "${PORT_WINE_PATH}/data/tmp" rm -fr "${PORT_WINE_DATA_PATH}/tmp"
rm -f "${PORT_WINE_PATH}/data/scripts/"* 2>/dev/null rm -f "${PORT_WINE_DATA_PATH}/scripts/"* 2>/dev/null
fi fi
######################################################################## ########################################################################
mkdir -p "${PORT_WINE_PATH}/data/tmp" mkdir -p "${PORT_WINE_DATA_PATH}/tmp"
echo "${port_ver}" > "${PORT_WINE_PATH}/data/tmp/${portname}_ver" echo "${port_ver}" > "${PORT_WINE_DATA_PATH}/tmp/${portname}_ver"
case "${PW_SET_LANG}" in case "${PW_SET_LANG}" in
"Russian") echo "RUS" > "${PORT_WINE_PATH}/data/tmp/${portname}_loc" ;; "Russian") echo "ru" > "${PORT_WINE_DATA_PATH}/tmp/${portname}_loc" ;;
"English") echo "ENG" > "${PORT_WINE_PATH}/data/tmp/${portname}_loc" ;; "Spanish") echo "es" > "${PORT_WINE_DATA_PATH}/tmp/${portname}_loc" ;;
"English") echo "en" > "${PORT_WINE_DATA_PATH}/tmp/${portname}_loc" ;;
esac esac
######################################################################## ########################################################################
if [[ "${PW_USE_NS}" != "1" ]] ; then PW_NOTIFY_TEXT="Installing PortProton..."
PW_NOTIFY_TEXT="Installing PortProton..." pw_notify_send
pw_notify_send ########################################################################
export PORT_WINE_TMP_PATH="${PORT_WINE_DATA_PATH}/tmp"
if ! check_flatpak
then cd "${D_PATH}"
else cd "${PORT_WINE_DATA_PATH}"
fi fi
export PORT_WINE_TMP_PATH="${PORT_WINE_PATH}/data/tmp"
cd "${PORT_WINE_PATH}"
echo -e "\nTry download scripts from gitlab.eterfund.ru..." echo -e "\nTry download scripts from gitlab.eterfund.ru..."
if ! curl -f -# -A "Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)" -H 'Cache-Control: no-cache, no-store' -H 'Pragma: no-cache' \ if ! curl -f -# -A "Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)" -H 'Cache-Control: no-cache, no-store' -H 'Pragma: no-cache' \
-L "https://gitlab.eterfund.ru/Castro-Fidel/PortWINE/-/archive/master/PortWINE-master.tar.gz" \ -L "https://gitlab.eterfund.ru/Castro-Fidel/PortWINE/-/archive/master/PortWINE-master.tar.gz" \
...@@ -159,16 +215,16 @@ fi ...@@ -159,16 +215,16 @@ fi
echo "Try unpacking scripts..." echo "Try unpacking scripts..."
tar -xvzf "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz" -C "${PORT_WINE_TMP_PATH}" tar -xvzf "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz" -C "${PORT_WINE_TMP_PATH}"
if [ "$?" = "0" ] ; then if [ "$?" = "0" ] ; then
[ ! -d "${PORT_WINE_PATH}/data/" ] && mkdir "${PORT_WINE_PATH}/data/" [ ! -d "${PORT_WINE_DATA_PATH}" ] && mkdir "${PORT_WINE_DATA_PATH}"
cp -fr "${PORT_WINE_TMP_PATH}/PortWINE-master/data_from_portwine/"* "${PORT_WINE_PATH}/data/" cp -fr "${PORT_WINE_TMP_PATH}/PortWINE-master/data_from_portwine/"* "${PORT_WINE_DATA_PATH}"
rm -f "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz" rm -f "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz"
rm -fr "${PORT_WINE_TMP_PATH}/PortWINE-master/" rm -fr "${PORT_WINE_TMP_PATH}/PortWINE-master/"
export scripts_current_ver=$(cat "${PORT_WINE_PATH}/data/scripts/var" | grep SCRIPTS_NEXT_VERSION | awk -F "=" '{print $2}') export scripts_current_ver=$(cat "${PORT_WINE_DATA_PATH}/scripts/var" | grep SCRIPTS_NEXT_VERSION | awk -F "=" '{print $2}')
echo "${scripts_current_ver}" > "${PORT_WINE_TMP_PATH}/scripts_ver" echo "${scripts_current_ver}" > "${PORT_WINE_TMP_PATH}/scripts_ver"
else else
rm -f "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz" rm -f "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz"
[ "$?" != "0" ] && fatal "Critical error during file unpacking!" [ "$?" != "0" ] && fatal "Critical error during file unpacking!"
fi fi
######################################################################## ########################################################################
cd "${PORT_WINE_PATH}/data/scripts" cd "${PORT_WINE_DATA_PATH}/scripts"
/usr/bin/env bash "${PORT_WINE_PATH}/data/scripts/setup.sh" && exit 0 /usr/bin/env bash "${PORT_WINE_DATA_PATH}/scripts/setup.sh" && exit 0
...@@ -10,11 +10,14 @@ ...@@ -10,11 +10,14 @@
<name>Mikhail Tergoev</name> <name>Mikhail Tergoev</name>
</developer> </developer>
<developer_name>Mikhail Tergoev</developer_name>
<url type="homepage">https://linux-gaming.ru</url> <url type="homepage">https://linux-gaming.ru</url>
<url type="bugtracker">https://github.com/Castro-Fidel/PortWINE/issues</url> <url type="bugtracker">https://github.com/Castro-Fidel/PortWINE/issues</url>
<url type="donation">https://linux-gaming.ru/t/podderzhat-proekt/123/</url> <url type="donation">https://linux-gaming.ru/t/podderzhat-proekt/123/</url>
<url type="vcs-browser">https://github.com/Castro-Fidel/PortWINE</url> <url type="vcs-browser">https://github.com/Castro-Fidel/PortWINE</url>
<url type="help">https://linux-gaming.ru/c/portproton/4</url> <url type="help">https://discord.gg/FTaheP99wE</url>
<url type="faq">https://linux-gaming.ru/c/portproton/4</url>
<metadata_license>CC0-1.0</metadata_license> <metadata_license>CC0-1.0</metadata_license>
<project_license>MIT</project_license> <project_license>MIT</project_license>
...@@ -69,6 +72,11 @@ ...@@ -69,6 +72,11 @@
</screenshot> </screenshot>
</screenshots> </screenshots>
<branding>
<color type="primary" scheme_preference="light">#8e7dbb</color>
<color type="primary" scheme_preference="dark">#352d48</color>
</branding>
<categories> <categories>
<category>Game</category> <category>Game</category>
</categories> </categories>
...@@ -100,6 +108,15 @@ ...@@ -100,6 +108,15 @@
<content_rating type="oars-1.1"/> <content_rating type="oars-1.1"/>
<releases> <releases>
<release version="1.6" date="2024-04-01">
<description>
<ul>
<li>added flatpak support to install script</li>
<li>added branding to metainfo</li>
<li>added Spanish translation to installer</li>
</ul>
</description>
</release>
<release version="1.5.2" date="2024-03-31"> <release version="1.5.2" date="2024-03-31">
<description> <description>
<ul> <ul>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment