-
-
Notifications
You must be signed in to change notification settings - Fork 930
Description
Operating System
Linux
Description of bug
When launching the wrapper script on a system that does not have zenity installed (for example, a KDE or LXQt-based system), it fails. If launched from the applications menu rather than from a terminal, the failure is silent.
Steps to reproduce
- If you are using a Gnome or similar desktop and have zenity available, temporarily hide it (e.g. sudo mv /usr/bin/zenity /usr/bin/zenity.doesntexist)
- Run the launcher script
The launcher will fail with the following output:
/opt/multimc/run.sh: line 16: zenity: command not found
tar (child): mmc-stable-lin64.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
rm: cannot remove 'mmc-stable-lin64.tar.gz': No such file or directory
chmod: cannot access 'MultiMC': No such file or directory
/opt/multimc/run.sh: line 25: ./MultiMC: No such file or directory
Suspected cause
The script uses zenity to display a progress bar. If zenity is unavailable, the pipe on the output of wget fails.
As MultiMC is a Qt program and will therefore pull in Qt dependencies, it would make sense to use qarma in preference to zenity if it is available to avoid pulling in additional GTK dependencies unnecessarily in Qt-based environments. Unfortunately, although it appears to be intended as a drop-in replacement (the command line args are identical), its behaviour is sufficiently different that simply dropping it in (e.g. by symlinking it) doesn't work - it doesn't understand numbers suffixed with a '%' character (!) and it doesn't auto-close when its input pipe closes. Because the final line of wget's output differs slightly from previous lines, the sed regexp never outputs 100%, the --auto-close option is never triggered and, while zenity closes when its standard input is closed, qarma waits until it is cancelled by the user. (Both of these behavioural differences probably warrant a qarma bug report, really.)
I propose the following patch for the launcher to address both these issues. Firstly, it checks for the existence of qarma and zenity and chooses one. It also adds a minimal fallback if neither exists (as was the case on my Xfce system). It also amends the sed regexp to output the progress numbers without the percentage sign and match the final line of wget output so that "100" gets printed on completion.
--- run.sh.orig 2021-12-12 09:37:26.807786775 +0000
+++ run.sh 2021-12-12 09:48:43.858240576 +0000
@@ -9,11 +9,23 @@
PACKAGE="mmc-stable-lin32.tar.gz"
fi
+PROGRESS_ARGS="--progress --auto-close --auto-kill --title=\"Downloading MultiMC...\""
+if which qarma
+then
+ PROGRESS="qarma"
+elif which zenity
+then
+ PROGRESS="zenity"
+else
+ PROGRESS="cat"
+ PROGRESS_ARGS=""
+fi
+
deploy() {
mkdir -p $INSTDIR
cd ${INSTDIR}
- wget --progress=dot:force "https://files.multimc.org/downloads/${PACKAGE}" 2>&1 | sed -u 's/.* \([0-9]\+%\)\ \+\([0-9.]\+.\) \(.*\)/\1\n# Downloading at \2\/s, ETA \3/' | zenity --progress --auto-close --auto-kill --title="Downloading MultiMC..."
+ wget --progress=dot:force "https://files.multimc.org/downloads/${PACKAGE}" 2>&1 | sed -u 's/.* \([0-9]\+\)%\ \+\([0-9.]\+.\)[ =]\(.*\)/\1\n# Downloading at \2\/s, ETA \3/' | ${PROGRESS} ${PROGRESS_ARGS}
tar -xzf ${PACKAGE} --transform='s,MultiMC/,,'
rm ${PACKAGE}
(It's worth mentioning that my wget, GNU Wget 1.21.2, doesn't accept 'force' as a suboption of '--progress=dot', but this only triggers a warning and, assuming that some other version does require it in order to behave as expected, it may as well stay because it's harmless.)
This issue is unique
- I have searched the issue tracker and did not find an issue describing my bug.