From 1e2a69b43cc9fd9621435e468aa3f5183f044b0c Mon Sep 17 00:00:00 2001
From: Htylol <dixperm909@yandex.ru>
Date: Fri, 27 Sep 2024 06:45:32 +0500
Subject: [PATCH] Added SKIP_CHECK_UPDATES_NEW

---
 data_from_portwine/scripts/functions_helper | 117 ++++++++++++++++++--
 data_from_portwine/scripts/start.sh         | 113 ++-----------------
 2 files changed, 116 insertions(+), 114 deletions(-)

diff --git a/data_from_portwine/scripts/functions_helper b/data_from_portwine/scripts/functions_helper
index c9dfdaca..305b5f9f 100755
--- a/data_from_portwine/scripts/functions_helper
+++ b/data_from_portwine/scripts/functions_helper
@@ -1668,14 +1668,8 @@ pw_init_db () {
         && [[ "${PW_WINE_CPU_TOPOLOGY}" == "disabled" ]] \
         && [[ $(grep -c "^processor" /proc/cpuinfo) -gt "8" ]]
         then
-                export PW_WINE_CPU_TOPOLOGY="8:0,1,2,3,4,5,6,7"
-                print_info "Automatic added fix for unity games: WINE_CPU_TOPOLOGY=8:0,1,2,3,4,5,6,7"
-        fi
-
-        if check_nvidia_rtx ; then
-            check_variables PW_USE_NVAPI_AND_DLSS "1"
-            check_variables PW_USE_FAKE_DLSS "0"
-            check_variables PW_USE_RAY_TRACING "1"
+            export PW_WINE_CPU_TOPOLOGY="8:0,1,2,3,4,5,6,7"
+            print_info "Automatic added fix for unity games: WINE_CPU_TOPOLOGY=8:0,1,2,3,4,5,6,7"
         fi
     fi
 
@@ -1899,6 +1893,110 @@ pw_port_update () {
     return 0
 }
 
+pw_skip_update () {
+    if command -v gamescope &>/dev/null ; then
+        if ! timeout 3 gamescope --help &> "${PW_TMPFS_PATH}/gamescope.tmp" ; then
+            print_error "gamescope - broken!"
+        fi
+    else
+        print_warning "gamescope - not found!"
+    fi
+
+    if command -v vulkaninfo &>/dev/null ; then
+        if ! timeout 3 vulkaninfo &> "${PW_TMPFS_PATH}/vulkaninfo.tmp" ; then
+            print_error "vulkaninfo - broken!"
+        fi
+    else
+        print_warning "use portable vulkaninfo"
+        "$PW_PLUGINS_PATH"/portable/bin/x86_64-linux-gnu-vulkaninfo &> "${PW_TMPFS_PATH}/vulkaninfo.tmp"
+    fi
+
+    if command -v lspci &>/dev/null ; then
+        if ! timeout 3 lspci -k &> "${PW_TMPFS_PATH}/lspci.tmp" ; then
+            print_error "lspci - broken!"
+        fi
+    else
+        print_warning "lspci - not found!"
+    fi
+
+    if command -v xrandr &>/dev/null ; then
+        if ! timeout 3 xrandr --current &> "${PW_TMPFS_PATH}/xrandr.tmp" ; then
+            print_error "xrandr - broken!"
+        fi
+    else
+        print_warning "xrandr - not found!"
+    fi
+
+    if command -v locale &>/dev/null ; then
+        if ! timeout 3 locale -a &> "${PW_TMPFS_PATH}/locale.tmp" ; then
+            print_error "locale - broken!"
+        fi
+    else
+        print_warning "locale - not found!"
+    fi
+}
+
+pw_skip_update_new () {
+    if [[ "${SKIP_CHECK_UPDATES_NEW}" != "1" ]] ; then
+        while true ; do
+            if [[ ! $(jobs -p) =~ $PID_SKIP_UPDATE ]] ; then
+                break
+            fi
+        done
+
+        if [[ -f "${PW_TMPFS_PATH}/gamescope.tmp" ]] ; then
+            export GAMESCOPE_INSTALLED="1"
+        fi
+
+        if [[ -f "${PW_TMPFS_PATH}/vulkaninfo.tmp" ]] ; then
+            VULKAN_DRIVER_NAME="$(grep -e 'driverName' "${PW_TMPFS_PATH}/vulkaninfo.tmp" | awk '{print$3}' | head -1)"
+            GET_GPU_NAMES=$(awk -F '=' '/deviceName/{print $2}' "${PW_TMPFS_PATH}/vulkaninfo.tmp" | sed '/llvm/d'| sort -u | sed 's/^ //' | paste -sd '!')
+            export VULKAN_DRIVER_NAME GET_GPU_NAMES
+        fi
+
+        if [[ -f "${PW_TMPFS_PATH}/lspci.tmp" ]] ; then
+            LSPCI_VGA="$(grep -e 'VGA|3D' "${PW_TMPFS_PATH}/lspci.tmp" | tr -d '\n')"
+            export LSPCI_VGA
+        fi
+
+        if check_nvidia_rtx ; then
+            check_variables PW_USE_NVAPI_AND_DLSS "1"
+            check_variables PW_USE_FAKE_DLSS "0"
+            check_variables PW_USE_RAY_TRACING "1"
+        fi
+
+        if [[ -f "${PW_TMPFS_PATH}/xrandr.tmp" ]] ; then
+            PW_SCREEN_RESOLUTION="$(<"${PW_TMPFS_PATH}/xrandr.tmp" sed -rn 's/^.*primary.* ([0-9]+x[0-9]+).*$/\1/p')"
+            PW_SCREEN_PRIMARY="$(grep -e 'primary' "${PW_TMPFS_PATH}/xrandr.tmp" | awk '{print $1}')"
+            export PW_SCREEN_PRIMARY PW_SCREEN_RESOLUTION
+        fi
+
+        if [[ -f "${PW_TMPFS_PATH}/locale.tmp" ]] ; then
+            GET_LOCALE_LIST="ru_RU.utf en_US.utf zh_CN.utf ja_JP.utf ko_KR.utf"
+            unset LOCALE_LIST
+            for LOCALE in $GET_LOCALE_LIST ; do
+                if [[ $(<"${PW_TMPFS_PATH}/locale.tmp") =~ $LOCALE ]] ; then
+                    if [[ -n "$LOCALE_LIST" ]]
+                    then LOCALE_LIST+="!$LOCALE"
+                    else LOCALE_LIST="$LOCALE"
+                    fi
+                fi
+            done
+            export LOCALE_LIST
+        fi
+
+        logical_cores=$(grep -c "^processor" /proc/cpuinfo)
+        if [[ "${logical_cores}" -le "4" ]] ; then
+            GET_LOGICAL_CORE="1!$(seq -s! 1 $(( logical_cores - 1 )))"
+        else
+            GET_LOGICAL_CORE="1!2!$(seq -s! 4 4 $(( logical_cores - 1 )))"
+        fi
+        export GET_LOGICAL_CORE
+
+        export SKIP_CHECK_UPDATES_NEW="1"
+    fi
+}
+
 update_winetricks () {
     W_TRX_URL="https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks"
     W_TRX_EXT_VER="$(curl -s --list-only ${W_TRX_URL} | grep -i 'WINETRICKS_VERSION=' | sed 's/WINETRICKS_VERSION=//')"
@@ -3356,6 +3454,7 @@ export -f pw_run
 
 pw_yad_set_form () {
     if [[ $(<"${PW_TMPFS_PATH}/tmp_yad_form") != "" ]] ; then
+        pw_skip_update_new
         PW_YAD_SET=$(head -n 1 "${PW_TMPFS_PATH}/tmp_yad_form" | awk '{print $1}')
         export PW_YAD_SET
     fi
@@ -3386,6 +3485,7 @@ pw_yad_form_vulkan () {
 }
 
 portwine_launch () {
+    pw_skip_update_new
     start_portwine
     unset PW_VD_TMP
     if [[ "${PW_VIRTUAL_DESKTOP}" == "1" ]] ; then
@@ -5434,6 +5534,7 @@ pw_prefix_manager () {
 }
 
 portwine_start_debug () {
+    pw_skip_update_new
     kill_portwine
     export PW_LOG=1
     if [[ -z "$VULKAN_DRIVER_NAME" ]] || [[ "$VULKAN_DRIVER_NAME" == "llvmpipe" ]] ; then
diff --git a/data_from_portwine/scripts/start.sh b/data_from_portwine/scripts/start.sh
index f82fe7ba..b0c4e69b 100755
--- a/data_from_portwine/scripts/start.sh
+++ b/data_from_portwine/scripts/start.sh
@@ -86,10 +86,10 @@ fi
 source "${PORT_SCRIPTS_PATH}/functions_helper"
 
 create_new_dir "${HOME}/.local/share/applications"
-if [[ "${PW_SILENT_RESTART}" == 1 ]] \
-|| [[ "${START_FROM_STEAM}" == 1 ]]
+if [[ "${PW_SILENT_RESTART}" == "1" ]] \
+|| [[ "${START_FROM_STEAM}" == "1" ]]
 then
-    export PW_GUI_DISABLED_CS=1
+    export PW_GUI_DISABLED_CS="1"
     unset PW_SILENT_RESTART
 else
     unset PW_GUI_DISABLED_CS
@@ -264,111 +264,12 @@ pw_check_and_download_plugins
 if [[ "${SKIP_CHECK_UPDATES}" != 1 ]] ; then
     pw_port_update
 
-    if command -v gamescope &>/dev/null ; then
-        if timeout 3 gamescope --help &> "${PW_TMPFS_PATH}/gamescope.tmp" ; then
-            export GAMESCOPE_INSTALLED="1"
-        else
-            print_error "gamescope - broken!"
-            if [[ -n "$PW_DEBUG" ]] ; then
-                debug_timer --start
-                timeout 5 gamescope --help
-                debug_timer --end "gamescope"
-            fi
-        fi
-    else
-        print_warning "gamescope - not found!"
-    fi
-
-    if command -v vulkaninfo &>/dev/null ; then
-        if timeout 3 vulkaninfo &> "${PW_TMPFS_PATH}/vulkaninfo.tmp" ; then
-            VULKAN_DRIVER_NAME="$(grep -e 'driverName' "${PW_TMPFS_PATH}/vulkaninfo.tmp" | awk '{print$3}' | head -1)"
-            GET_GPU_NAMES=$(awk -F '=' '/deviceName/{print $2}' "${PW_TMPFS_PATH}/vulkaninfo.tmp" | sed '/llvm/d'| sort -u | sed 's/^ //' | paste -sd '!')
-            export VULKAN_DRIVER_NAME GET_GPU_NAMES
-        else
-            print_error "vulkaninfo - broken!"
-            if [[ -n "$PW_DEBUG" ]] ; then
-                debug_timer --start
-                timeout 5 vulkaninfo
-                debug_timer --end "vulkaninfo"
-            fi
-        fi
-    else
-        print_warning "use portable vulkaninfo"
-        "$PW_PLUGINS_PATH"/portable/bin/x86_64-linux-gnu-vulkaninfo &> "${PW_TMPFS_PATH}/vulkaninfo.tmp"
-        VULKAN_DRIVER_NAME="$(grep -e 'driverName' "${PW_TMPFS_PATH}/vulkaninfo.tmp" | awk '{print$3}' | head -1)"
-        GET_GPU_NAMES=$(awk -F '=' '/deviceName/{print $2}' "${PW_TMPFS_PATH}/vulkaninfo.tmp" | sed '/llvm/d'| sort -u | sed 's/^ //' | paste -sd '!')
-        export VULKAN_DRIVER_NAME GET_GPU_NAMES
-    fi
-
-    if command -v lspci &>/dev/null ; then
-        if timeout 3 lspci -k &> "${PW_TMPFS_PATH}/lspci.tmp" ; then
-            LSPCI_VGA="$(grep -e 'VGA|3D' "${PW_TMPFS_PATH}/lspci.tmp" | tr -d '\n')"
-            export LSPCI_VGA
-        else
-            print_error "lspci - broken!"
-            if [[ -n "$PW_DEBUG" ]] ; then
-                debug_timer --start
-                timeout 5 lspci -vv
-                debug_timer --end "lspci"
-            fi
-        fi
-    else
-        print_warning "lspci - not found!"
-    fi
-
-    if command -v xrandr &>/dev/null ; then
-        if timeout 3 xrandr --current &> "${PW_TMPFS_PATH}/xrandr.tmp" ; then
-            PW_SCREEN_RESOLUTION="$(<"${PW_TMPFS_PATH}/xrandr.tmp" sed -rn 's/^.*primary.* ([0-9]+x[0-9]+).*$/\1/p')"
-            PW_SCREEN_PRIMARY="$(grep -e 'primary' "${PW_TMPFS_PATH}/xrandr.tmp" | awk '{print $1}')"
-            export PW_SCREEN_PRIMARY PW_SCREEN_RESOLUTION
-            print_var PW_SCREEN_RESOLUTION PW_SCREEN_PRIMARY
-        else
-            print_error "xrandr - broken!"
-            if [[ -n "$PW_DEBUG" ]] ; then
-                debug_timer --start
-                timeout 5 xrandr --verbose
-                debug_timer --end "xrandr"
-            fi
-        fi
-    else
-        print_warning "xrandr - not found!"
-    fi
-
-    logical_cores=$(grep -c "^processor" /proc/cpuinfo)
-    if [[ "${logical_cores}" -le "4" ]] ; then
-        GET_LOGICAL_CORE="1!$(seq -s! 1 $(( logical_cores - 1 )))"
-    else
-        GET_LOGICAL_CORE="1!2!$(seq -s! 4 4 $(( logical_cores - 1 )))"
-    fi
-    export GET_LOGICAL_CORE
-
-    if command -v locale &>/dev/null ; then
-        if timeout 3 locale -a &> "${PW_TMPFS_PATH}/locale.tmp" ; then
-            GET_LOCALE_LIST="ru_RU.utf en_US.utf zh_CN.utf ja_JP.utf ko_KR.utf"
-            unset LOCALE_LIST
-            for LOCALE in $GET_LOCALE_LIST ; do
-                if [[ $(<"${PW_TMPFS_PATH}/locale.tmp") =~ $LOCALE ]] ; then
-                    if [[ -n "$LOCALE_LIST" ]]
-                    then LOCALE_LIST+="!$LOCALE"
-                    else LOCALE_LIST="$LOCALE"
-                    fi
-                fi
-            done
-            export LOCALE_LIST
-        else
-            print_error "locale - broken!"
-            if [[ -n "$PW_DEBUG" ]] ; then
-                debug_timer --start
-                timeout 5 locale -a
-                debug_timer --end "locale"
-            fi
-        fi
-    else
-        print_warning "locale - not found!"
-    fi
-
     PW_FILESYSTEM=$(stat -f -c %T "${PORT_WINE_PATH}")
     export PW_FILESYSTEM
+
+    pw_skip_update &
+    PID_SKIP_UPDATE=$(jobs -p)
+    export PID_SKIP_UPDATE="${PID_SKIP_UPDATE//*[[:space:]]/}"
 fi
 
 # create lock file