Skip to content

Commit 820a139

Browse files
committed
Added umu zipapp functionality.
1 parent 309358e commit 820a139

File tree

1 file changed

+52
-2
lines changed

1 file changed

+52
-2
lines changed

src.sh

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@ REPO_PATH="https://github.com/ZOOM-Platform/zoom-platform.sh"
1414
INNOEXT_BIN="/tmp/innoextract_zoom"
1515
LAUNCH_SCRIPTS_PATH="$HOME"/.local/share/zoom-platform
1616
UMU_BIN=umu-run
17+
CACHE_DIR="$HOME"/.cache/zoom-platform
1718

1819
# Check if dialogs can be used and set tool
1920
CAN_USE_DIALOGS=0
2021
USE_ZENITY=1
2122
(command -v kdialog >/dev/null || command -v zenity >/dev/null) && [ -n "$DISPLAY" ] && CAN_USE_DIALOGS=1
2223
[ $CAN_USE_DIALOGS -eq 1 ] && ! command -v zenity >/dev/null && USE_ZENITY=0
2324

25+
# Create cahce directory
26+
mkdir -p "$CACHE_DIR"
27+
2428
# .shellcheck will consume ram trying to parse INNOEXTRACT_BINARY_B64
2529
# when developing, just load the bin from working dir
2630
get_innoext_string() {
@@ -115,6 +119,46 @@ trim_string() {
115119
awk '{$1=$1;print}'
116120
}
117121

122+
# Download the umu-launcher zipapp
123+
download_umu_zipapp() {
124+
_url="$1"
125+
_url_resp=$(curl -o "$CACHE_DIR"/umu-launcher.tar.xz "$_url" -Ls -H "User-Agent: zoom-platform.sh/$INSTALLER_VERSION (+https://zoom-platform.sh/)")
126+
_url_exit=$?
127+
if [ $_url_exit -ne 0 ]; then
128+
fatal_error "Could not download umu-launcher. Please install it manually."
129+
fi
130+
131+
if ! command -v tar > /dev/null; then
132+
fatal_error "tar was not found on this system."
133+
fi
134+
135+
tar --overwrite-dir -C "$CACHE_DIR" -xf "$CACHE_DIR"/umu-launcher.tar.xz umu/umu-run
136+
rm -f "$CACHE_DIR"/umu-launcher.tar.xz
137+
chmod +x "$CACHE_DIR"/umu/umu-run
138+
UMU_BIN="$CACHE_DIR"/umu/umu-run
139+
}
140+
141+
# Get umu-launcher's url from lutris' runtime api
142+
get_umu_url() {
143+
_api_resp=$(curl -Ls -H "User-Agent: zoom-platform.sh/$INSTALLER_VERSION (+https://zoom-platform.sh/)" \
144+
'https://lutris.net/api/runtimes?format=json')
145+
_api_exit=$?
146+
if [ $_api_exit -eq 0 ]; then
147+
_parsed_str="$(printf '%s' "$_api_resp" | awk -F'"' '/"name":"umu"/ {for(i=1; i<=NF; i++) if($i=="url") {print $(i+2); exit}}')"
148+
# Validate parsed output
149+
case $_parsed_str in
150+
"https://"*)
151+
printf '%s' "$_parsed_str"
152+
exit 0
153+
;;
154+
*)
155+
exit 1
156+
;;
157+
esac
158+
fi
159+
exit 1
160+
}
161+
118162
get_umu_id() {
119163
_guid="$1"
120164
_api_resp=$(curl -Ls -H "User-Agent: zoom-platform.sh/$INSTALLER_VERSION (+https://zoom-platform.sh/)" \
@@ -456,15 +500,20 @@ fi
456500
# Check if UWU is installed
457501
if command -v umu-run > /dev/null; then
458502
UMU_BIN=umu-run
503+
log_info "Using umu native"
459504
elif command -v "$HOME"/.local/share/umu/umu-run > /dev/null; then
460505
UMU_BIN="$HOME"/.local/share/umu/umu-run
506+
log_info "Using $HOME/.local/share/umu/umu-run"
461507
elif command -v /usr/bin/umu-run > /dev/null; then
462508
UMU_BIN=/usr/bin/umu-run
509+
log_info "Using /usr/bin/umu-run"
463510
elif flatpak info org.openwinecomponents.umu.umu-launcher >/dev/null 2>&1; then
464511
UMU_BIN="FLATPAK"
465512
log_info "Using umu Flatpak"
466513
else
467-
fatal_error "umu is not installed"
514+
_umu_url="$(get_umu_url)"
515+
download_umu_zipapp "$_umu_url"
516+
# fatal_error "umu is not installed"
468517
fi
469518

470519
# If dialogs are usable and installer wasn't specified, show a dialog
@@ -651,7 +700,8 @@ umu_launch "$INPUT_INSTALLER" \
651700

652701
# Watch the install log
653702
_currentfile=0
654-
_filecount=$(("$(get_header_val 'file_count')"+"$(get_header_val 'icon_count')"))
703+
# _filecount=$(("$(get_header_val 'file_count')"+"$(get_header_val 'icon_count')"))
704+
_filecount=219
655705
_readlog=1
656706
while [ $_readlog -eq 1 ]; do
657707
sleep 0.010

0 commit comments

Comments
 (0)