Skip to content

Commit

Permalink
Update system fully implemented for both Epichrome and apps.
Browse files Browse the repository at this point in the history
  • Loading branch information
David Marmor committed Oct 7, 2016
1 parent 5eea5e3 commit a308aaa
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 26 deletions.
4 changes: 3 additions & 1 deletion README.md
Expand Up @@ -19,7 +19,9 @@ See [CHANGELOG.md](https://github.com/dmarmor/epichrome/blob/master/app/CHANGELO

**If you're running any version earlier than 2.1.10, please update to the latest version as soon as possible. Prior versions have a potentially serious bug where updates to Chrome could break Epichrome apps permanently, so they'd have to be deleted and recreated.**

This version adds a check in the icon-conversion code to point out that it can't handle images with no alpha channel. Thanks to [io41](https://github.com/io41 "io41") and [freewind](https://github.com/freewind "freewind") for helping diagnose this. Sorry I don't have time to actually make the code handle non-alpha images right now.
Starting with this version, Epichrome (and all Epichrome apps) will automatically check Github once a week for a new version of Epichrome. If one is found, a dialog is displayed giving the user the option to go to the download page for the new release, check again later or ignore this version. Thanks to [Zettt](https://github.com/Zettt "Zettt") for proposing an update-checking system.

This version also adds a check in the icon-conversion code to point out that it can't handle images with no alpha channel. Thanks to [io41](https://github.com/io41 "io41") and [freewind](https://github.com/freewind "freewind") for helping diagnose this. Sorry I don't have time to actually make the code handle non-alpha images right now.

See [CHANGELOG.md](https://github.com/dmarmor/epichrome/blob/master/app/CHANGELOG.md "CHANGELOG") for more details.

Expand Down
5 changes: 4 additions & 1 deletion app/CHANGELOG.md
@@ -1,7 +1,10 @@
# Epichrome.app Change Log
This project adheres to [Semantic Versioning](http://semver.org/).

## [2.1.13] - ?????
## [2.1.13] - 2016-10-07
### Changed
- Added code to automatically check Github once a week for a new version of Epichrome. If one is found, a dialog is displayed giving the user the option to go to the download page for the new release, check again later or ignore this version. Thanks to [Zettt](https://github.com/Zettt "Zettt") for proposing an update-checking system.

### Fixed
- Added a check in the icon-conversion code to point out that it can't handle images with no alpha channel. Thanks to [io41](https://github.com/io41 "io41") and [freewind](https://github.com/freewind "freewind") for helping diagnose this. Sorry I don't have time to actually make the code handle non-alpha images right now.

Expand Down
84 changes: 79 additions & 5 deletions app/src/epichrome
Expand Up @@ -44,7 +44,7 @@ function unsudo {

# DIALOG -- display a dialog and return the button pressed
function dialog { # VAR MESSAGE TITLE ICON (if starts with | try app icon first) BUTTON1 BUTTON2 BUTTON3 (+ = default, - = cancel)

if [[ "$ok" ]] ; then

local var="$1" ; shift ; [[ "$var" ]] || var=var # if not capturing, just save dialog text to this local
Expand Down Expand Up @@ -78,7 +78,8 @@ end tell"
local try_start=
local try_end=
local numbuttons=0
for button in "${@:1:3}" ; do

for button in $@ ; do
# increment button count
numbuttons=$((${numbuttons} + 1))

Expand All @@ -98,7 +99,7 @@ end try"
# add to button list
buttonlist="$buttonlist, \"$button\""
done

# if no buttons specified, make one default OK button
if [[ "$numbuttons" -eq 0 ]]; then
numbuttons=1
Expand All @@ -109,7 +110,7 @@ end try"

# close button list
buttonlist="{ ${buttonlist:2} }"

# run the dialog

try "${var}=" osascript -e "$icon_set
Expand Down Expand Up @@ -372,7 +373,7 @@ if [ "$SSBChromeVersion" != "$chromeVersion" ] ; then
fi


# CHECK FOR NEW VERSION OF MAKECHROMESSB AND UPDATE
# CHECK FOR NEW VERSION OF EPICHROME AND UPDATE

if [[ "$(newversion "$SSBVersion" "$mcssbVersion")" ]] ; then

Expand Down Expand Up @@ -430,6 +431,79 @@ if [[ "$(newversion "$SSBVersion" "$mcssbVersion")" ]] ; then
fi


# CHECK FOR A NEW VERSION OF EPICHROME ON GITHUB

try 'curDate=' /bin/date '+%s' 'Unable to get date for Epichrome update check.'
if [[ "$ok" ]] ; then

# check for updates if we've never run a check, or if the next check date is in the past
if [[ ( ! "$SSBUpdateCheckDate" ) || ( "$SSBUpdateCheckDate" -lt "$curDate" ) ]] ; then

# set next update for 7 days from now
SSBUpdateCheckDate=$(($curDate + (7 * 24 * 60 * 60)))
updateconfig=1

# if we haven't set a version to check against, use the current version
[[ "$SSBUpdateCheckVersion" ]] || SSBUpdateCheckVersion="$mcssbVersion"

# check if there's a new version on Github
try 'updateResult=' checkmcssbversion "$myContents" "$SSBUpdateCheckVersion" 'Unable to check for a new version of Epichrome on Github.'
if [[ ! "$ok" ]] ; then
alert "Warning: $errmsg" 'Checking For Update' '|caution'
ok=1
else

# if there's an update available, display a dialog
if [[ "$updateResult" ]] ; then
# set separator to newline
oldifs="$IFS"
IFS=$'\n'

# convert result into an array
updateResult=( $(echo "$updateResult") )

# display dialog
dialog doEpichromeUpdate \
"A new version of Epichrome (${updateResult[0]}) is available on GitHub." \
"Update Available" \
"|caution" \
"+Download" \
"-Later" \
"Ignore This Version"

# act based on dialog
if [[ "$ok" ]] ; then

case "$doEpichromeUpdate" in
Download)
# open the update URL
open "${updateResult[1]}"
;;

Later)
# do nothing
doEpichromeUpdate=
;;
*)
# pretend we're already at the new version
SSBUpdateCheckVersion="${updateResult[0]}"
;;
esac
fi

# alert the user to any error, but don't abort
if [[ ! "$ok" ]] ; then
alert "Warning: $errmsg" 'Checking For Update' '|caution'
ok=1
fi

IFS="$oldifs"
fi
fi
fi
fi


# HANDLE FIRST-RUN SETUP

newprofile=
Expand Down
16 changes: 7 additions & 9 deletions app/src/main.applescript
Expand Up @@ -109,33 +109,35 @@ set ssbURLs to {}


-- CHECK FOR UPDATES TO EPICHROME

set curDate to current date
display alert "TEMPORARY: updateCheckDate is " & (updateCheckDate as text) & ", updateCheckVersion is " & updateCheckVersion
if updateCheckDate < curDate then
-- set next update for 24 hours from now
set updateCheckDate to (curDate + (1 * day))
-- set next update for 1 week from now
set updateCheckDate to (curDate + (7 * days))

-- if updateCheckVersion isn't set, set it to the current version of Epichrome
if updateCheckVersion is false then
set updateCheckVersion to do shell script "source " & versionScript & " ; echo $mcssbVersion"
end if

-- run the actual update check script
try
set updateCheckResult to do shell script updateCheckScript & " " & (quoted form of updateCheckVersion)
on error errStr number errNum
set updateCheckResult to false
display dialog errStr with title "Error" with icon stop buttons {"OK"} default button "OK"
end try

-- parse update check results
if updateCheckResult is not false then
if updateCheckResult is not "" then
set newVersion to paragraph 1 of updateCheckResult
set updateURL to paragraph 2 of updateCheckResult
try
set dlgResult to button returned of (display dialog "A new version of Epichrome (" & newVersion & ") is available on GitHub." with title "Update Available" buttons {"Download", "Later", "Ignore This Version"} default button "Download" cancel button "Later" with icon myIcon)
on error number -128
-- Later: do nothing
set dlgResult to false
set updateCheckDate to (curDate + (7 * days))
end try

-- Download or Ignore
Expand All @@ -144,16 +146,12 @@ if updateCheckDate < curDate then
else if dlgResult is "Ignore This Version" then
set updateCheckVersion to newVersion
end if
else
display alert "TEMPORARY: No update at this time (my version is " & updateCheckVersion & "). Will check again in 24 hours."
end if
end if
end if

--display alert ((current date) as number)

--display alert "updateCheck result: '" & updateCheckResult & "'"
-- "A new version of Epichrome ($newVersion) is available on GitHub."
-- BUILD THE APP

repeat
-- FIRST STEP: SELECT APPLICATION NAME & LOCATION
Expand Down
10 changes: 2 additions & 8 deletions app/src/runtime.sh
Expand Up @@ -481,13 +481,6 @@ function mcssbinfo { # (optional)MCSSB-PATH
# get current value for mcssbVersion
try source "${mcssbPath}/Contents/Resources/Scripts/version.sh" 'Unable to load Epichrome version.'

# set up SSBNextUpdateCheck if not already set
if [[ "$ok" ]] ; then
if [[ ! "$SSBNextUpdateCheck" ]] ; then
try 'SSBNextUpdateCheck=' /bin/date '+%s' 'Unable to get date for Epichrome update check.'
SSBNextUpdateCheck=$(($SSBNextUpdateCheck + (24 * 60 * 60))) # set first check in 24 hrs
fi
fi
fi

[[ "$ok" ]] && return 0
Expand Down Expand Up @@ -851,7 +844,8 @@ function writeconfig { # $1 = destination app bundle Contents directory
CFBundleName \
CFBundleIdentifier \
SSBVersion \
SSBNextUpdateCheck \
SSBUpdateCheckDate \
SSBUpdateCheckVersion \
SSBProfilePath \
SSBChromePath \
SSBChromeVersion \
Expand Down
2 changes: 0 additions & 2 deletions app/src/updatecheck.sh
Expand Up @@ -55,5 +55,3 @@ mcssbinfo "$myPath"
checkmcssbversion "$myRuntimePath" "$1"

[[ "$ok" ]] || abort "$errmsg" 1

# IFS=$'\n' y=($x)

0 comments on commit a308aaa

Please sign in to comment.