Skip to content

Commit ca4dbe3

Browse files
author
Live System User
committed
Prepare for appupdateimagegui
1 parent b2a2187 commit ca4dbe3

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

AppImageUpdate.AppDir/usr/bin/appimageupdate

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
set -e
44

5+
# This script is supposed to be run either on the command line
6+
# or though the appimageupdate GUI. The GUI is purely optional.
7+
# It displays stdout and stderr, as well as a progress indicator.
8+
59
# A simple dependency check
610
which zsync_curl >/dev/null
711
which curl >/dev/null
@@ -32,31 +36,31 @@ gpg_check()
3236
ASC_URL=$( echo "${ZSYNC_URL}" | sed -e 's|.zsync|.asc|g' )
3337
curl -k -L -O -# "${ASC_URL}" && gpg --verify $(basename "${ASC_URL}")
3438
else
35-
echo "GPG is not installed; hence skipping signature verification"
39+
echo "GPG is not installed; hence skipping signature verification" >&2
3640
fi
3741
}
3842

3943
USAGE="Usage:
4044
$0 /path/to/AppImage -
4145
Updates the AppImage using the update information embedded in the AppImage
4246
"
43-
MSG="This updater has no GUI yet. \n
44-
Run it from the command line and supply
45-
the AppImage to be updated as an argument. \n
46-
Create a pull request on
47-
https://github.com/probonopd/AppImageKit
48-
to contribute a proper GUI."
47+
48+
MSG="GUI not installed or not working on this system, please use this tool from the command line instead"
4949

5050
if [ $# -lt 1 ] ; then
51-
if [ -x /usr/bin/zenity ] ; then
52-
zenity --error --text "${MSG}" 2>/dev/null
53-
elif [ -x /usr/bin/kdialog ] ; then
54-
kdialog --msgbox "${MSG}" 2>/dev/null
55-
elif [ -x /usr/bin/Xdialog ] ; then
56-
Xdialog --msgbox "${MSG}" 2>/dev/null
51+
set +e
52+
appimageupdategui "${1}"
53+
RESULT=$?
54+
set -e
55+
if [ $RESULT != 0 ] ; then
56+
if [ -x /usr/bin/zenity ] ; then
57+
zenity --error --text "${MSG}" 2>/dev/null
58+
elif [ -x /usr/bin/kdialog ] ; then
59+
kdialog --msgbox "${MSG}" 2>/dev/null
60+
elif [ -x /usr/bin/Xdialog ] ; then
61+
Xdialog --msgbox "${MSG}" 2>/dev/null
62+
fi
5763
fi
58-
echo $USAGE
59-
exit 1
6064
fi
6165

6266
if [ -e "${1}" ] ; then
@@ -100,8 +104,7 @@ fi
100104
if [ "${2}" == "set" ] ; then
101105
dd if=/dev/zero of="${ISO}" bs=1 seek=33651 count=512 conv=notrunc 2>/dev/null
102106
echo "${3}" | dd of="${ISO}" bs=1 seek=33651 count=512 conv=notrunc 2>/dev/null
103-
echo "Changed ${APPLICATION_USED}"
104-
echo "to ${3}"
107+
echo "Changed ${APPLICATION_USED} to ${3}"
105108
exit 0
106109
fi
107110

@@ -137,10 +140,11 @@ elif [ "$TYPE" == "bintray-zsync" ] ; then
137140
DUMMY_URL="https://bintray.com/artifact/download/$USERNAME/$REPO/$ZSYNCDUMMYNAME"
138141
VERSION=$(curl -k -r 0-0 -Ls -o /dev/null -w %{url_effective} "${REDIRECTOR_URL}" | cut -d "/" -f 7)
139142
if [ "$VERSION" == "_latestVersion" ] ; then
140-
echo "Could not get the latest version"
143+
echo "Error"
144+
echo "Could not get the latest version from Bintray" >&2
141145
exit 1
142146
else
143-
echo "$VERSION"
147+
echo "Latest version: ${VERSION}"
144148
fi
145149
ZSYNC_URL=$(echo "${DUMMY_URL}" | sed -e "s|_latestVersion|$VERSION|g" )
146150
zsync_curl -I -i "${ISO}" "${ZSYNC_URL}" # Get the file with zsync using $1 as an input file
@@ -149,13 +153,12 @@ elif [ "$TYPE" == "bintray-zsync" ] ; then
149153
gpg_check
150154

151155
elif [ "$TYPE" == "" ] ; then
152-
echo "Cannot update this file."
153-
echo "This file has no update information embedded"
154-
echo "or you need to update the updater."
156+
echo "Cannot update this file"
157+
echo "This file contains no update information or you need to update the updater" >&2
155158
update_myself
156159
else
157-
echo "I do not know how to handle this file."
158-
echo "You need to update to an updater that can handle $TYPE."
160+
echo "Cannot update this file"
161+
echo "You need to an updater that can handle $TYPE" >&2
159162
update_myself
160163
fi
161164

0 commit comments

Comments
 (0)