diff --git a/Kaju Admin App/Build Automation.xojo_code b/Kaju Admin App/Build Automation.xojo_code index f9b6aee..475c785 100644 --- a/Kaju Admin App/Build Automation.xojo_code +++ b/Kaju Admin App/Build Automation.xojo_code @@ -1,13 +1,25 @@ #tag BuildAutomation Begin BuildStepList Linux + Begin ExternalIDEScriptStep UpdateAppVersionLinux + AppliesTo = 0 + FolderItem = Li4AQnVpbGQgU2NyaXB0cwBVcGRhdGUgQXBwIFZlcnNpb24ueG9qb19zY3JpcHQ= + End Begin BuildProjectStep Build End End Begin BuildStepList Mac OS X + Begin ExternalIDEScriptStep UpdateAppVersionMac + AppliesTo = 0 + FolderItem = Li4AQnVpbGQgU2NyaXB0cwBVcGRhdGUgQXBwIFZlcnNpb24ueG9qb19zY3JpcHQ= + End Begin BuildProjectStep Build End End Begin BuildStepList Windows + Begin ExternalIDEScriptStep UpdateAppVersionWin + AppliesTo = 0 + FolderItem = Li4AQnVpbGQgU2NyaXB0cwBVcGRhdGUgQXBwIFZlcnNpb24ueG9qb19zY3JpcHQ= + End Begin BuildProjectStep Build End End diff --git a/Kaju Admin App/Build Scripts/Update App Version.xojo_script b/Kaju Admin App/Build Scripts/Update App Version.xojo_script new file mode 100644 index 0000000..b049762 --- /dev/null +++ b/Kaju Admin App/Build Scripts/Update App Version.xojo_script @@ -0,0 +1,23 @@ +dim kajuVersion as string +kajuVersion = ConstantValue( "Kaju.Version" ) + +dim parts() as string +parts = kajuVersion.Split( "." ) + +if parts.Ubound < 2 then +redim parts( 2 ) +end if + +for i as integer = 0 to 2 +if parts( i ) = "" then +parts( i ) = "0" +end if +next i + +PropertyValue( "App.MajorVersion" ) = parts( 0 ) +PropertyValue( "App.MinorVersion" ) = parts( 1 ) +PropertyValue( "App.BugVersion" ) = parts( 2 ) + +PropertyValue( "App.ShortVersion" ) = kajuVersion +PropertyValue( "App.LongVersion" ) = "v." + kajuVersion + diff --git a/Kaju Admin App/Kaju Admin.xojo_project b/Kaju Admin App/Kaju Admin.xojo_project index 621d651..3c80306 100644 --- a/Kaju Admin App/Kaju Admin.xojo_project +++ b/Kaju Admin App/Kaju Admin.xojo_project @@ -1,5 +1,5 @@ Type=Desktop -RBProjectVersion=2014.032 +RBProjectVersion=2015.01 MinIDEVersion=20070100 Folder=Kaju Classes;../Kaju Classes;&h2570CF64;&h0;false Class=App;App.xojo_code;&h7955649;&h0;false @@ -26,13 +26,13 @@ Class=FolderItemAlias;Other Classes/FolderItemAlias.xojo_code;&h53EF1AE5;&h6AF5D Class=HTTPSSocket;../Kaju Classes/Kaju/HTTPSSocket.xojo_code;&h5ACDFAEB;&h11400316;false AppMenuBar=MainMenuBar MajorVersion=1 -MinorVersion=3 -SubVersion=3 +MinorVersion=4 +SubVersion=0 NonRelease=0 Release=3 InfoVersion=Kaju Admin -LongVersion=v.1.3.3 -ShortVersion=1.3.3 +LongVersion=v.1.4 +ShortVersion=1.4 WinCompanyName=MacTechnologies Consulting WinInternalName= WinProductName= diff --git a/Kaju Classes/Kaju.xojo_code b/Kaju Classes/Kaju.xojo_code index a5c3c21..f94a631 100644 --- a/Kaju Classes/Kaju.xojo_code +++ b/Kaju Classes/Kaju.xojo_code @@ -85,6 +85,33 @@ Protected Module Kaju End Sub #tag EndMethod + #tag Method, Flags = &h1 + Protected Function DidLastUpdateFail() As Boolean + dim marker as string = kSwitchUpdateFailed + dim args as string = System.CommandLine + dim pos as integer = args.InStrB( marker ) + return pos <> 0 + + End Function + #tag EndMethod + + #tag Method, Flags = &h1 + Protected Function DidLastUpdateSucceed(ByRef fromVersion As String) As Boolean + dim marker as string = kSwitchUpdateSucceeded + dim args as string = System.CommandLine + dim pos as integer = args.InStrB( marker ) + + if pos <> 0 then + fromVersion = args.MidB( pos + marker.LenB + 1 ) + fromVersion = fromVersion.Trim + return true + else + return false + end if + + End Function + #tag EndMethod + #tag Method, Flags = &h1 Protected Function GetTemporaryFolder() As FolderItem dim f as FolderItem = GetTemporaryFolderItem @@ -346,9 +373,18 @@ Protected Module Kaju #tag EndNote + #tag Constant, Name = kSwitchUpdateFailed, Type = String, Dynamic = False, Default = \"--kaju-fail", Scope = Private + #tag EndConstant + + #tag Constant, Name = kSwitchUpdateSucceeded, Type = String, Dynamic = False, Default = \"--kaju-success", Scope = Private + #tag EndConstant + #tag Constant, Name = kUpdatePacketMarker, Type = String, Dynamic = False, Default = \"KAJU ", Scope = Protected #tag EndConstant + #tag Constant, Name = Version, Type = String, Dynamic = False, Default = \"1.4", Scope = Protected + #tag EndConstant + #tag ViewBehavior #tag ViewProperty diff --git a/Kaju Classes/Kaju/HTTPSSocket.xojo_code b/Kaju Classes/Kaju/HTTPSSocket.xojo_code index 828e89f..fe036a6 100644 --- a/Kaju Classes/Kaju/HTTPSSocket.xojo_code +++ b/Kaju Classes/Kaju/HTTPSSocket.xojo_code @@ -1,6 +1,23 @@ #tag Class Protected Class HTTPSSocket Inherits HTTPSecureSocket + #tag Event + Function AuthenticationRequired(Realm As String, Headers As InternetHeaders, ByRef Name As String, ByRef Password As String) As Boolean + if RaiseEvent AuthenticationRequired( Realm, Headers, Name, Password ) then + return true + end if + + if Username <> "" then + Name = Username + Password = self.Password + return true + else + return false + end if + End Function + #tag EndEvent + + #tag Method, Flags = &h0 Sub Get(url As String) SetSecure( url ) @@ -107,7 +124,7 @@ Inherits HTTPSecureSocket #tag EndMethod #tag Method, Flags = &h21 - Private Sub SetSecure(url As String) + Private Sub SetSecure(ByRef url As String) if ForceSecure or url.Trim.Left( 8 ) = "https://" then self.Secure = true self.Port = 443 @@ -115,14 +132,44 @@ Inherits HTTPSecureSocket self.Secure = false self.Port = 80 end if + + // + // See if the username and password has been specified + // + dim rx as new RegEx + rx.SearchPattern = "^(?:https?://)([^:/\x20@]+):([^:/\x20@]*)@(.*)" + + dim match as RegExMatch = rx.Search( url ) + if match is nil then + Username = "" + Password = "" + else + Username = DecodeURLComponent( match.SubExpressionString( 1 ) ) + Password = DecodeURLComponent( match.SubExpressionString( 2 ) ) + url = match.SubExpressionString( 3 ) + end if + End Sub #tag EndMethod + #tag Hook, Flags = &h0 + Event AuthenticationRequired(Realm As String, Headers As InternetHeaders, ByRef Name As String, ByRef Password As String) As Boolean + #tag EndHook + + #tag Property, Flags = &h0 ForceSecure As Boolean #tag EndProperty + #tag Property, Flags = &h21 + Private Password As String + #tag EndProperty + + #tag Property, Flags = &h21 + Private Username As String + #tag EndProperty + #tag Constant, Name = kDefaultMaximumIterations, Type = Double, Dynamic = False, Default = \"5", Scope = Private #tag EndConstant diff --git a/Kaju Classes/Kaju/UpdateInitiater.xojo_code b/Kaju Classes/Kaju/UpdateInitiater.xojo_code index f6c6206..fcf4c2b 100644 --- a/Kaju Classes/Kaju/UpdateInitiater.xojo_code +++ b/Kaju Classes/Kaju/UpdateInitiater.xojo_code @@ -129,6 +129,7 @@ Protected Class UpdateInitiater script = script.ReplaceAll( kMarkerAppName, ShellQuote( executable.Name ) ) script = script.ReplaceAll( kMarkerAppParent, ShellPathQuote( executable.Parent ) ) + script = script.ReplaceAll( kMarkerAppVersion, ShellQuote( Kaju.AppVersionString ) ) script = script.ReplaceAll( kMarkerNewAppName, ShellQuote( ReplacementExecutableName ) ) script = script.ReplaceAll( kMarkerNewAppParent, ShellPathQuote( ReplacementAppFolder ) ) script = script.ReplaceAll( kMarkerTempFolder, ShellPathQuote( TempFolder ) ) @@ -209,6 +210,7 @@ Protected Class UpdateInitiater script = script.ReplaceAll( kMarkerAppName, ShellQuote( appFolderItem.Name ) ) script = script.ReplaceAll( kMarkerAppParent, ShellPathQuote( appFolderItem.Parent ) ) + script = script.ReplaceAll( kMarkerAppVersion, ShellQuote( Kaju.AppVersionString ) ) script = script.ReplaceAll( kMarkerNewAppName, ShellQuote( ReplacementAppFolder.Name ) ) script = script.ReplaceAll( kMarkerNewAppParent, ShellPathQuote( ReplacementAppFolder.Parent ) ) script = script.ReplaceAll( kMarkerTempFolder, ShellPathQuote( TempFolder ) ) @@ -267,6 +269,7 @@ Protected Class UpdateInitiater script = script.ReplaceAll( kMarkerAppName, executable.Name ) script = script.ReplaceAll( kMarkerAppParent, ShellPathQuote( executable.Parent ) ) + script = script.ReplaceAll( kMarkerAppVersion, Kaju.AppVersionString ) script = script.ReplaceAll( kMarkerNewAppName, ReplacementExecutableName ) script = script.ReplaceAll( kMarkerNewAppParent, ShellPathQuote( ReplacementAppFolder ) ) script = script.ReplaceAll( kMarkerTempFolder, ShellPathQuote( TempFolder ) ) @@ -408,6 +411,9 @@ Protected Class UpdateInitiater #tag Constant, Name = kMarkerAppParent, Type = String, Dynamic = False, Default = \"@@APP_PARENT@@", Scope = Private #tag EndConstant + #tag Constant, Name = kMarkerAppVersion, Type = String, Dynamic = False, Default = \"@@APP_VERSION@@", Scope = Private + #tag EndConstant + #tag Constant, Name = kMarkerDecompressedFolderPath, Type = String, Dynamic = False, Default = \"@@DECOMPRESSED_FOLDER@@", Scope = Private #tag EndConstant @@ -449,9 +455,9 @@ Protected Class UpdateInitiater #tag EndConstant #tag Constant, Name = kUpdaterScript, Type = String, Dynamic = False, Default = \"", Scope = Private - #Tag Instance, Platform = Mac OS, Language = Default, Definition = \"#!/bin/bash\n\n#\n# FUNCTIONS\n#\n\nfunction log_cmd {\n /usr/bin/logger -t \"Kaju Update Script\" $@\n}\n\n# END FUNCTIONS\n\n#\n# These will be filled in by the calling app\n#\n\nAPP_NAME\x3D@@APP_NAME@@\nAPP_PARENT\x3D@@APP_PARENT@@\nNEW_APP_NAME\x3D@@NEW_APP_NAME@@\nNEW_APP_PARENT\x3D@@NEW_APP_PARENT@@\nTEMP_FOLDER_PATH\x3D@@TEMP_FOLDER@@\nPID_FILE\x3D@@PID_FILE_PATH@@\n\n#\n# -----------------\n#\n\nreadonly true\x3D1\nreadonly false\x3D0\n\nAPP_PATH\x3D$APP_PARENT/$APP_NAME\nNEW_APP_PATH\x3D$NEW_APP_PARENT/$NEW_APP_NAME\n\nRENAMED_APP_NAME\x3D`echo \"$APP_NAME\" | /usr/bin/sed -E s/\\.[aA][pP]{2}//`-`date +%Y%m%d%H%M%S`.app\nRENAMED_APP_PATH\x3D$APP_PARENT/$RENAMED_APP_NAME\n\nlog_cmd \"STARTING UPDATE OF $APP_NAME\"\n\ncounter\x3D10\nwhile [ -f \"$PID_FILE\" ]\ndo\n log_cmd \"Checking to see if $PIDFILE exists\x2C $counter\"\n sleep 1\n \n let counter\x3Dcounter-1\n \n if [ $counter \x3D\x3D 0 ]\n then\n \tlog_cmd \'ERROR: Could not update app\x2C it never quit\'\n \texit 1\n fi\ndone\n\nPROCEED\x3D$true\n\n#\n# Rename the old application\n#\nlog_cmd \"Renaming old application $APP_NAME to $RENAMED_APP_NAME\"\nmv \"$APP_PATH\" \"$RENAMED_APP_PATH\"\n\n#\n# Make sure that succeeded\n#\nif [ $\? \x3D\x3D 0 ]\nthen\n log_cmd \'...confirmed\'\nelse\n log_cmd \"Could not rename old application to $RENAMED_APP_PATH\"\n PROCEED\x3D0\nfi\n\n#\n# Move in the replacement app\n#\nif [ $PROCEED \x3D\x3D $true ]\nthen\n log_cmd \"Moving new application $NEW_APP_PATH to folder $APP_PARENT\"\n mv \"$NEW_APP_PATH\" \"$APP_PARENT\"\n\n #\n # Make sure that worked\n #\n if [ $\? \x3D\x3D 0 ]\n then\n log_cmd \'...confirmed\'\n else\n log_cmd \"Could not move in new application\"\n log_cmd \"Attempting to restore old application and launch it\"\n mv \"$RENAMED_APP_PATH\" \"$APP_PATH\"\n open \"$APP_PATH\"\n PROCEED\x3D$false\n fi\nfi\n\nif [ $PROCEED \x3D\x3D $true ]\nthen\n log_cmd \"Removing old application $RENAMED_APP_NAME\"\n rm -fr \"$RENAMED_APP_PATH\"\n \n APP_PATH\x3D$APP_PARENT/$NEW_APP_NAME\n log_cmd \"Starting new application at $APP_PATH\"\n \n open \"$APP_PATH\"\nfi\n\nif [ $PROCEED \x3D\x3D $true ]\nthen\n log_cmd \'Removing temp folder\'\n rm -fr \"$TEMP_FOLDER_PATH\"\nfi\n" - #Tag Instance, Platform = Linux, Language = Default, Definition = \"#!/bin/bash\n\n#\n# FUNCTIONS\n#\n\nfunction log_cmd {\n\t/usr/bin/logger -t \"Kaju Update Script\" $@\n}\n\n# END FUNCTIONS\n\n#\n# These will be filled in by the calling app\n#\n\nAPP_NAME\x3D@@APP_NAME@@\nAPP_PARENT\x3D@@APP_PARENT@@\nNEW_APP_NAME\x3D@@NEW_APP_NAME@@\nNEW_APP_PARENT\x3D@@NEW_APP_PARENT@@\nTEMP_FOLDER_PATH\x3D@@TEMP_FOLDER@@\nPID_FILE\x3D@@PID_FILE_PATH@@\n\n#\n# This array will store the names of the items next to the executable\n# under the variable NEW_APP_OTHER_NAME\n#\nNEW_APP_OTHER_UB\x3D@@NEW_APP_OTHER_UB@@\n\n@@NEW_APP_OTHER_ARRAY@@\n\n#\n# -----------------\n#\n\nreadonly true\x3D1\nreadonly false\x3D0\n\nAPP_PATH\x3D$APP_PARENT/$APP_NAME\n\nBACKUP_PARENT\x3D$APP_PARENT/${APP_NAME}-`date +%Y%m%d%H%M%S`\nmkdir \"$BACKUP_PARENT\"\n\nlog_cmd \"STARTING UPDATE OF $APP_NAME\"\n\ncounter\x3D10\nwhile [ -f \"$PID_FILE\" ]\ndo\n\tlog_cmd \"Checking to see if $PIDFILE exists\x2C $counter\"\n\tsleep 1\n\t\n\tlet counter\x3Dcounter-1\n\t\n\tif [ $counter \x3D\x3D 0 ]\n\tthen\n\t\tlog_cmd \'ERROR: Could not update app\x2C it never quit\'\n\t\texit 1\n\tfi\ndone\n\nPROCEED\x3D$true\n\n#\n# Move the other items\n#\nlog_cmd \"Copying other items to backup $BACKUP_PARENT\"\n\ncounter\x3D0\nwhile [ $counter -le $NEW_APP_OTHER_UB ]\ndo\n\tthis_item\x3D${NEW_APP_OTHER_NAME[$counter]}\n\tlog_cmd \"Looking for item $this_item in $APP_PARENT\"\n\t\n\tthis_path\x3D$APP_PARENT/$this_item\n\tif [ -d \"$this_path\" ] || [ -f \"$this_path\" ]\n\tthen\n\t\tlog_cmd \"...found\x2C copying\"\n\t\tcp -pr \"$this_path\" \"$BACKUP_PARENT\"\n\t\tif [ $\? \x3D\x3D 0 ]\n\t\tthen\n\t\t\tlog_cmd \"...confirmed\"\n\t\telse\n\t\t\t log_cmd \"...FAILED!\"\n\t\t\t PROCEED\x3D$false\n\t\t\t break\n\t\tfi\n\tfi\n\t(( counter++ ))\ndone\n\n#\n# Move the executable\n#\nif [ $PROCEED \x3D\x3D $true ]\nthen\n\tlog_cmd \"Moving the executable $APP_NAME to backup\"\n\tmv \"$APP_PARENT/$APP_NAME\" \"$BACKUP_PARENT\"\n\tif [ $\? \x3D\x3D 0 ]\n\tthen\n\t\tlog_cmd \"...confirmed\"\n\telse\n\t\tlog_cmd \"...FAILED! (Error $\?)\"\n\t\tPROCEED\x3D$false\n\tfi\nfi\n\n#\n# Make sure there wasn\'t an error during the backup\n#\nif [ $PROCEED \x3D\x3D $true ]\nthen\n\tlog_cmd \'All items backed up\'\nelse\n\tlog_cmd \'Attempting to copy items back to parent\'\n\trsync -a --exclude\x3D\'.DS_Store\' \"${BACKUP_PARENT}/\" \"$APP_PARENT\"\nfi\n\n#\n# Move in the replacement files\n#\nif [ $PROCEED \x3D\x3D $true ]\nthen\n\tlog_cmd \"Copying files from $NEW_APP_PARENT to folder $APP_PARENT\"\n\trsync -a --exclude\x3D\'.DS_Store\' \"${NEW_APP_PARENT}/\" \"$APP_PARENT\"\n\t\n\tif [ $\? \x3D\x3D 0 ]\n\tthen\n\t\tlog_cmd \'...confirmed\'\n\telse\n\t\tlog_cmd \"...FAILED! (Error $\?)\"\n\t\tlog_cmd \"Attempting to restore old application\"\n\t\trsync -a --exclude\x3D\'.DS_Store\' \"${BACKUP_PARENT}/\" \"$APP_PARENT\"\n\t\tPROCEED\x3D$false\n\t\tbreak\n\tfi\nfi\n\n#\n# Removed the backup folder if everything has gone swimmingly so\n#\nif [ $PROCEED \x3D\x3D $true ]\nthen\n\tlog_cmd \'Removing backup\'\n\trm -r \"$BACKUP_PARENT\"\nfi\n\n#\n# Launch the application\n#\nif [ $PROCEED \x3D $true ]\nthen\n\tlog_cmd \'Making the new app executable\'\n\tchmod +x \"$APP_PARENT/$NEW_APP_NAME\"\n\tlog_cmd \'Launching new app\'\n\t\"$APP_PARENT/$NEW_APP_NAME\"\nelse\n\tlog_cmd \'Launching old app\'\n\t\"$APP_PARENT/$APP_NAME\"\nfi\n\nlog_cmd \'Removing temp folder\'\nrm -fr \"$TEMP_FOLDER_PATH\"\n" - #Tag Instance, Platform = Windows, Language = Default, Definition = \"@ECHO OFF \n\nREM\nREM These will be filled in by the calling app\nREM\n\nSET APP_NAME\x3D@@APP_NAME@@\nSET APP_PARENT\x3D@@APP_PARENT@@\nSET NEW_APP_NAME\x3D@@NEW_APP_NAME@@\nSET NEW_APP_PARENT\x3D@@NEW_APP_PARENT@@\nSET TEMP_FOLDER_PATH\x3D@@TEMP_FOLDER@@\nSET DECOMPRESSED_FOLDER_PATH\x3D@@DECOMPRESSED_FOLDER@@\nSET PID_FILE\x3D@@PID_FILE_PATH@@\n\nREM\nREM -----------------\nREM\n\nSET TODAY_DATE\x3D%DATE:~10\x2C4%-%DATE:~4\x2C2%-%DATE:~7\x2C2% %TIME:~0\x2C2%:%TIME:~3\x2C2%:%TIME:~6\x2C2%\nSET APP_PATH\x3D%APP_PARENT%\\%APP_NAME%\n\nSET BACKUP_PARENT\x3D%APP_PATH%-%DATE:~10\x2C4%%DATE:~4\x2C2%%DATE:~7\x2C2%%TIME:~0\x2C2%%TIME:~3\x2C2%%TIME:~6\x2C2%\n\nSET LOGGER\x3D%APP_PARENT%\\%NEW_APP_NAME% Update Log.txt\nECHO \"STARTED ON %TODAY_DATE%\" >> \"%LOGGER%\" 2>&1\n\nFOR /L %%i IN (1\x2C1\x2C10) DO (\n\tIF NOT EXIST \"%PID_FILE%\" (\n\t\tGOTO :program_exited\n\t)\n\n\tREM Windows version of sleep 1. Starting in Windows Vista\x2C the sleep command was removed.\n\tping -n 2 127.0.0.1 >nul\n\n\tIF %%i \x3D\x3D 10 (\n\t\tECHO ERROR: Could not update app\x2C it never quit >> \"%LOGGER%\" 2>&1\n\t\tEXIT /B 1\n\t)\n)\n:program_exited\n\nmkdir \"%BACKUP_PARENT%\"\n\nSET PROCEED\x3D1\n\nREM\nREM Move the other items\nREM\nECHO \"Copying items to backup %BACKUP_PARENT%\" >> \"%LOGGER%\" 2>&1\n\nREM We will need to manually populate these move commands. Windows Batch doesn\'t really handle arrays\x2C\nREM only looping through space delimited elements of a string. Below is a template for moving one such file.\n\nREM BEGIN PSEUDO-ARRAY\nSET THIS_ITEM\x3D@@OTHER_NAME@@\nSET THIS_PATH\x3D%APP_PARENT%\\%THIS_ITEM%\nECHO \"Looking for item %THIS_PATH%\" >> \"%LOGGER%\" 2>&1\nIF EXIST \"%THIS_PATH%\" (\n\tGOTO :copy_@@OTHER_NAME_WO_SPACES@@\n)\nECHO \"...not found as file\x2C trying as directory\" >> \"%LOGGER%\" 2>&1\nIF EXIST \"%THIS_PATH%\\NUL\" (\n\tGOTO :copy_@@OTHER_NAME_WO_SPACES@@\n) ELSE (\n\tECHO \"...NOT FOUND!\" >> \"%LOGGER%\" 2>&1\n\tGOTO :finished_with_@@OTHER_NAME_WO_SPACES@@\n)\n\n:copy_@@OTHER_NAME_WO_SPACES@@\n\nECHO \"...found\x2C copying\" >> \"%LOGGER%\" 2>&1\nCOPY \"%THIS_PATH%\" \"%BACKUP_PARENT%\" >> \"%LOGGER%\" 2>&1\nIF %ERRORLEVEL% NEQ 0 (\n\tECHO \"...FAILED! (Error %ERRORLEVEL%)\" >> \"%LOGGER%\" 2>&1\n\tSET PROCEED\x3D0\n\tGOTO :restore_from_backup\n) ELSE (\n\tECHO \"...confirmed\" >> \"%LOGGER%\" 2>&1\n)\n\n:finished_with_@@OTHER_NAME_WO_SPACES@@\n\nREM END PSEUDO-ARRAY\n\nREM\nREM Move the executable to backup\nREM\nIF %PROCEED% \x3D\x3D 1 (\n\tECHO \"Moving the executable %APP_NAME% to backup\" >> \"%LOGGER%\" 2>&1\n\tMOVE \"%APP_PATH%\" \"%BACKUP_PARENT%\" >> \"%LOGGER%\" 2>&1\n\tIF %ERRORLEVEL% NEQ 0 (\n\t\tECHO \"...FAILED! (Error %ERRORLEVEL%)\" >> \"%LOGGER%\" 2>&1\n\t\tSET PROCEED\x3D0\n\t\tGOTO :restore_from_backup\n\t) ELSE (\n\t\tECHO \"...confirmed\" >> \"%LOGGER%\" 2>&1\n\t)\n)\n\nREM\nREM Make sure there wasn\'t an error during the move\nREM\nIF %PROCEED% \x3D\x3D 1 (\n\tECHO \"All items moved to backup\" >> \"%LOGGER%\" 2>&1\n)\n\nREM\nREM Copy in the replacement files\nREM\n\nIF %PROCEED% \x3D\x3D 1 (\n\tECHO \"Copying files from %NEW_APP_PARENT% to folder %APP_PARENT%\" >> \"%LOGGER%\" 2>&1\n\tXCOPY /y /e /k \"%NEW_APP_PARENT%\" \"%APP_PARENT%\" >> \"%LOGGER%\" 2>&1\n\tIF %ERRORLEVEL% NEQ 0 (\n\t\tECHO \"...FAILED! (Error %ERRORLEVEL%)\" >> \"%LOGGER%\" 2>&1\n\t\tSET PROCEED\x3D0\n\t\tGOTO :restore_from_backup\n\t) ELSE (\n\t\tECHO \"...confirmed\" >> \"%LOGGER%\" 2>&1\n\t)\n)\n\nREM\nREM If we get here\x2C it all worked\nREM\nIF %PROCEED% \x3D\x3D 1 (\n\tGOTO :all_succeeded\n)\n\n:restore_from_backup\nIF %PROCEED% \x3D\x3D 0 (\n\tECHO \"Attempting to restore old application\" >> \"%LOGGER%\" 2>&1\n\n\tXCOPY /y /e /k \"%BACKUP_PARENT%\" \"%APP_PARENT%\" >> \"%LOGGER%\" 2>&1\n\tIF %ERRORLEVEL% EQU 0 (\n\t\tRMDIR /S /Q \"%BACKUP_PARENT%\" >> \"%LOGGER%\" 2>&1\n\t)\n)\nGOTO :launch_application\n\n:all_succeeded\nREM\nREM Remove the backup and decompressed folders if everything has gone swimmingly so far\nREM\nIF %PROCEED% \x3D\x3D 1 (\n\tECHO \"Removing backup\" >> \"%LOGGER%\" 2>&1\n\tRMDIR /S /Q \"%BACKUP_PARENT%\" >> \"%LOGGER%\" 2>&1\n\tECHO \"Removing decompressed folder\" >> \"%LOGGER%\" 2>&1\n\tRMDIR /S /Q \"%DECOMPRESSED_FOLDER_PATH%\" >> \"%LOGGER%\" 2>&1\n)\n\nREM\nREM Launch the application\nREM\n:launch_application\nIF %PROCEED% \x3D\x3D 1 (\n\tECHO \"Launching new app\" >> \"%LOGGER%\" 2>&1\n\tSTART \"\" \"%APP_PARENT%\\%NEW_APP_NAME%\"\n) ELSE (\n\tECHO \"Launching old app\" >> \"%LOGGER%\" 2>&1\n\tSTART \"\" \"%APP_PATH%\"\n)\n\nECHO \"Removing temp folder\" >> \"%LOGGER%\" 2>&1\nRMDIR /S /Q \"%TEMP_FOLDER_PATH%\" >> \"%LOGGER%\" 2>&1\n" + #Tag Instance, Platform = Mac OS, Language = Default, Definition = \"#!/bin/bash\n\n#\n# FUNCTIONS\n#\n\nfunction log_cmd {\n /usr/bin/logger -t \"Kaju Update Script\" $@\n}\n\n# END FUNCTIONS\n\n#\n# These will be filled in by the calling app\n#\n\nAPP_NAME\x3D@@APP_NAME@@\nAPP_PARENT\x3D@@APP_PARENT@@\nAPP_VERSION\x3D@@APP_VERSION@@\nNEW_APP_NAME\x3D@@NEW_APP_NAME@@\nNEW_APP_PARENT\x3D@@NEW_APP_PARENT@@\nTEMP_FOLDER_PATH\x3D@@TEMP_FOLDER@@\nPID_FILE\x3D@@PID_FILE_PATH@@\n\n#\n# -----------------\n#\n\nreadonly true\x3D1\nreadonly false\x3D0\n\nAPP_PATH\x3D$APP_PARENT/$APP_NAME\nNEW_APP_PATH\x3D$NEW_APP_PARENT/$NEW_APP_NAME\n\nRENAMED_APP_NAME\x3D`echo \"$APP_NAME\" | /usr/bin/sed -E s/\\.[aA][pP]{2}//`-`date +%Y%m%d%H%M%S`.app\nRENAMED_APP_PATH\x3D$APP_PARENT/$RENAMED_APP_NAME\n\nlog_cmd \"STARTING UPDATE OF $APP_NAME\"\n\ncounter\x3D10\nwhile [ -f \"$PID_FILE\" ]\ndo\n log_cmd \"Checking to see if $PIDFILE exists\x2C $counter\"\n sleep 1\n \n let counter\x3Dcounter-1\n \n if [ $counter \x3D\x3D 0 ]\n then\n \tlog_cmd \'ERROR: Could not update app\x2C it never quit\'\n \texit 1\n fi\ndone\n\nPROCEED\x3D$true\n\n#\n# Rename the old application\n#\nlog_cmd \"Renaming old application $APP_NAME to $RENAMED_APP_NAME\"\nmv \"$APP_PATH\" \"$RENAMED_APP_PATH\"\n\n#\n# Make sure that succeeded\n#\nif [ $\? \x3D\x3D 0 ]\nthen\n log_cmd \'...confirmed\'\nelse\n log_cmd \"Could not rename old application to $RENAMED_APP_PATH\"\n PROCEED\x3D0\nfi\n\n#\n# Move in the replacement app\n#\nif [ $PROCEED \x3D\x3D $true ]\nthen\n log_cmd \"Moving new application $NEW_APP_PATH to folder $APP_PARENT\"\n mv \"$NEW_APP_PATH\" \"$APP_PARENT\"\n\n #\n # Make sure that worked\n #\n if [ $\? \x3D\x3D 0 ]\n then\n log_cmd \'...confirmed\'\n else\n log_cmd \"Could not move in new application\"\n log_cmd \"Attempting to restore old application and launch it\"\n mv \"$RENAMED_APP_PATH\" \"$APP_PATH\"\n open \"$APP_PATH\" --args --kaju-fail\n PROCEED\x3D$false\n fi\nfi\n\nif [ $PROCEED \x3D\x3D $true ]\nthen\n log_cmd \"Removing old application $RENAMED_APP_NAME\"\n rm -fr \"$RENAMED_APP_PATH\"\n \n APP_PATH\x3D$APP_PARENT/$NEW_APP_NAME\n log_cmd \"Starting new application at $APP_PATH\"\n \n open \"$APP_PATH\" --args --kaju-success \"$APP_VERSION\"\nfi\n\nif [ $PROCEED \x3D\x3D $true ]\nthen\n log_cmd \'Removing temp folder\'\n rm -fr \"$TEMP_FOLDER_PATH\"\nfi\n" + #Tag Instance, Platform = Linux, Language = Default, Definition = \"#!/bin/bash\n\n#\n# FUNCTIONS\n#\n\nfunction log_cmd {\n\t/usr/bin/logger -t \"Kaju Update Script\" $@\n}\n\n# END FUNCTIONS\n\n#\n# These will be filled in by the calling app\n#\n\nAPP_NAME\x3D@@APP_NAME@@\nAPP_PARENT\x3D@@APP_PARENT@@\nAPP_VERSION\x3D@@APP_VERSION@@\nNEW_APP_NAME\x3D@@NEW_APP_NAME@@\nNEW_APP_PARENT\x3D@@NEW_APP_PARENT@@\nTEMP_FOLDER_PATH\x3D@@TEMP_FOLDER@@\nPID_FILE\x3D@@PID_FILE_PATH@@\n\n#\n# This array will store the names of the items next to the executable\n# under the variable NEW_APP_OTHER_NAME\n#\nNEW_APP_OTHER_UB\x3D@@NEW_APP_OTHER_UB@@\n\n@@NEW_APP_OTHER_ARRAY@@\n\n#\n# -----------------\n#\n\nreadonly true\x3D1\nreadonly false\x3D0\n\nAPP_PATH\x3D$APP_PARENT/$APP_NAME\n\nBACKUP_PARENT\x3D$APP_PARENT/${APP_NAME}-`date +%Y%m%d%H%M%S`\nmkdir \"$BACKUP_PARENT\"\n\nlog_cmd \"STARTING UPDATE OF $APP_NAME\"\n\ncounter\x3D10\nwhile [ -f \"$PID_FILE\" ]\ndo\n\tlog_cmd \"Checking to see if $PIDFILE exists\x2C $counter\"\n\tsleep 1\n\t\n\tlet counter\x3Dcounter-1\n\t\n\tif [ $counter \x3D\x3D 0 ]\n\tthen\n\t\tlog_cmd \'ERROR: Could not update app\x2C it never quit\'\n\t\texit 1\n\tfi\ndone\n\nPROCEED\x3D$true\n\n#\n# Move the other items\n#\nlog_cmd \"Copying other items to backup $BACKUP_PARENT\"\n\ncounter\x3D0\nwhile [ $counter -le $NEW_APP_OTHER_UB ]\ndo\n\tthis_item\x3D${NEW_APP_OTHER_NAME[$counter]}\n\tlog_cmd \"Looking for item $this_item in $APP_PARENT\"\n\t\n\tthis_path\x3D$APP_PARENT/$this_item\n\tif [ -d \"$this_path\" ] || [ -f \"$this_path\" ]\n\tthen\n\t\tlog_cmd \"...found\x2C copying\"\n\t\tcp -pr \"$this_path\" \"$BACKUP_PARENT\"\n\t\tif [ $\? \x3D\x3D 0 ]\n\t\tthen\n\t\t\tlog_cmd \"...confirmed\"\n\t\telse\n\t\t\t log_cmd \"...FAILED!\"\n\t\t\t PROCEED\x3D$false\n\t\t\t break\n\t\tfi\n\tfi\n\t(( counter++ ))\ndone\n\n#\n# Move the executable\n#\nif [ $PROCEED \x3D\x3D $true ]\nthen\n\tlog_cmd \"Moving the executable $APP_NAME to backup\"\n\tmv \"$APP_PARENT/$APP_NAME\" \"$BACKUP_PARENT\"\n\tif [ $\? \x3D\x3D 0 ]\n\tthen\n\t\tlog_cmd \"...confirmed\"\n\telse\n\t\tlog_cmd \"...FAILED! (Error $\?)\"\n\t\tPROCEED\x3D$false\n\tfi\nfi\n\n#\n# Make sure there wasn\'t an error during the backup\n#\nif [ $PROCEED \x3D\x3D $true ]\nthen\n\tlog_cmd \'All items backed up\'\nelse\n\tlog_cmd \'Attempting to copy items back to parent\'\n\trsync -a --exclude\x3D\'.DS_Store\' \"${BACKUP_PARENT}/\" \"$APP_PARENT\"\nfi\n\n#\n# Move in the replacement files\n#\nif [ $PROCEED \x3D\x3D $true ]\nthen\n\tlog_cmd \"Copying files from $NEW_APP_PARENT to folder $APP_PARENT\"\n\trsync -a --exclude\x3D\'.DS_Store\' \"${NEW_APP_PARENT}/\" \"$APP_PARENT\"\n\t\n\tif [ $\? \x3D\x3D 0 ]\n\tthen\n\t\tlog_cmd \'...confirmed\'\n\telse\n\t\tlog_cmd \"...FAILED! (Error $\?)\"\n\t\tlog_cmd \"Attempting to restore old application\"\n\t\trsync -a --exclude\x3D\'.DS_Store\' \"${BACKUP_PARENT}/\" \"$APP_PARENT\"\n\t\tPROCEED\x3D$false\n\t\tbreak\n\tfi\nfi\n\n#\n# Removed the backup folder if everything has gone swimmingly so\n#\nif [ $PROCEED \x3D\x3D $true ]\nthen\n\tlog_cmd \'Removing backup\'\n\trm -r \"$BACKUP_PARENT\"\nfi\n\n#\n# Launch the application\n#\nif [ $PROCEED \x3D $true ]\nthen\n\tlog_cmd \'Making the new app executable\'\n\tchmod +x \"$APP_PARENT/$NEW_APP_NAME\"\n\tlog_cmd \'Launching new app\'\n\t\"$APP_PARENT/$NEW_APP_NAME\" --kaju-success \"$APP_VERSION\"\nelse\n\tlog_cmd \'Launching old app\'\n\t\"$APP_PARENT/$APP_NAME\" --kaju-fail\nfi\n\nlog_cmd \'Removing temp folder\'\nrm -fr \"$TEMP_FOLDER_PATH\"\n" + #Tag Instance, Platform = Windows, Language = Default, Definition = \"@ECHO OFF \n\nREM\nREM These will be filled in by the calling app\nREM\n\nSET APP_NAME\x3D@@APP_NAME@@\nSET APP_PARENT\x3D@@APP_PARENT@@\nSET APP_VERSION\x3D@@APP_VERSION@@\nSET NEW_APP_NAME\x3D@@NEW_APP_NAME@@\nSET NEW_APP_PARENT\x3D@@NEW_APP_PARENT@@\nSET TEMP_FOLDER_PATH\x3D@@TEMP_FOLDER@@\nSET DECOMPRESSED_FOLDER_PATH\x3D@@DECOMPRESSED_FOLDER@@\nSET PID_FILE\x3D@@PID_FILE_PATH@@\n\nREM\nREM -----------------\nREM\n\nSET TODAY_DATE\x3D%DATE:~10\x2C4%-%DATE:~4\x2C2%-%DATE:~7\x2C2% %TIME:~0\x2C2%:%TIME:~3\x2C2%:%TIME:~6\x2C2%\nSET APP_PATH\x3D%APP_PARENT%\\%APP_NAME%\n\nSET BACKUP_PARENT\x3D%APP_PATH%-%DATE:~10\x2C4%%DATE:~4\x2C2%%DATE:~7\x2C2%%TIME:~0\x2C2%%TIME:~3\x2C2%%TIME:~6\x2C2%\n\nSET LOGGER\x3D%APP_PARENT%\\%NEW_APP_NAME% Update Log.txt\nECHO \"STARTED ON %TODAY_DATE%\" >> \"%LOGGER%\" 2>&1\n\nFOR /L %%i IN (1\x2C1\x2C10) DO (\n\tIF NOT EXIST \"%PID_FILE%\" (\n\t\tGOTO :program_exited\n\t)\n\n\tREM Windows version of sleep 1. Starting in Windows Vista\x2C the sleep command was removed.\n\tping -n 2 127.0.0.1 >nul\n\n\tIF %%i \x3D\x3D 10 (\n\t\tECHO ERROR: Could not update app\x2C it never quit >> \"%LOGGER%\" 2>&1\n\t\tEXIT /B 1\n\t)\n)\n:program_exited\n\nmkdir \"%BACKUP_PARENT%\"\n\nSET PROCEED\x3D1\n\nREM\nREM Move the other items\nREM\nECHO \"Copying items to backup %BACKUP_PARENT%\" >> \"%LOGGER%\" 2>&1\n\nREM We will need to manually populate these move commands. Windows Batch doesn\'t really handle arrays\x2C\nREM only looping through space delimited elements of a string. Below is a template for moving one such file.\n\nREM BEGIN PSEUDO-ARRAY\nSET THIS_ITEM\x3D@@OTHER_NAME@@\nSET THIS_PATH\x3D%APP_PARENT%\\%THIS_ITEM%\nECHO \"Looking for item %THIS_PATH%\" >> \"%LOGGER%\" 2>&1\nIF EXIST \"%THIS_PATH%\" (\n\tGOTO :copy_@@OTHER_NAME_WO_SPACES@@\n)\nECHO \"...not found as file\x2C trying as directory\" >> \"%LOGGER%\" 2>&1\nIF EXIST \"%THIS_PATH%\\NUL\" (\n\tGOTO :copy_@@OTHER_NAME_WO_SPACES@@\n) ELSE (\n\tECHO \"...NOT FOUND!\" >> \"%LOGGER%\" 2>&1\n\tGOTO :finished_with_@@OTHER_NAME_WO_SPACES@@\n)\n\n:copy_@@OTHER_NAME_WO_SPACES@@\n\nECHO \"...found\x2C copying\" >> \"%LOGGER%\" 2>&1\nCOPY \"%THIS_PATH%\" \"%BACKUP_PARENT%\" >> \"%LOGGER%\" 2>&1\nIF %ERRORLEVEL% NEQ 0 (\n\tECHO \"...FAILED! (Error %ERRORLEVEL%)\" >> \"%LOGGER%\" 2>&1\n\tSET PROCEED\x3D0\n\tGOTO :restore_from_backup\n) ELSE (\n\tECHO \"...confirmed\" >> \"%LOGGER%\" 2>&1\n)\n\n:finished_with_@@OTHER_NAME_WO_SPACES@@\n\nREM END PSEUDO-ARRAY\n\nREM\nREM Move the executable to backup\nREM\nIF %PROCEED% \x3D\x3D 1 (\n\tECHO \"Moving the executable %APP_NAME% to backup\" >> \"%LOGGER%\" 2>&1\n\tMOVE \"%APP_PATH%\" \"%BACKUP_PARENT%\" >> \"%LOGGER%\" 2>&1\n\tIF %ERRORLEVEL% NEQ 0 (\n\t\tECHO \"...FAILED! (Error %ERRORLEVEL%)\" >> \"%LOGGER%\" 2>&1\n\t\tSET PROCEED\x3D0\n\t\tGOTO :restore_from_backup\n\t) ELSE (\n\t\tECHO \"...confirmed\" >> \"%LOGGER%\" 2>&1\n\t)\n)\n\nREM\nREM Make sure there wasn\'t an error during the move\nREM\nIF %PROCEED% \x3D\x3D 1 (\n\tECHO \"All items moved to backup\" >> \"%LOGGER%\" 2>&1\n)\n\nREM\nREM Copy in the replacement files\nREM\n\nIF %PROCEED% \x3D\x3D 1 (\n\tECHO \"Copying files from %NEW_APP_PARENT% to folder %APP_PARENT%\" >> \"%LOGGER%\" 2>&1\n\tXCOPY /g /y /e /k \"%NEW_APP_PARENT%\" \"%APP_PARENT%\" >> \"%LOGGER%\" 2>&1\n\tIF %ERRORLEVEL% NEQ 0 (\n\t\tECHO \"...FAILED! (Error %ERRORLEVEL%)\" >> \"%LOGGER%\" 2>&1\n\t\tSET PROCEED\x3D0\n\t\tGOTO :restore_from_backup\n\t) ELSE (\n\t\tECHO \"...confirmed\" >> \"%LOGGER%\" 2>&1\n\t)\n)\n\nREM\nREM If we get here\x2C it all worked\nREM\nIF %PROCEED% \x3D\x3D 1 (\n\tGOTO :all_succeeded\n)\n\n:restore_from_backup\nIF %PROCEED% \x3D\x3D 0 (\n\tECHO \"Attempting to restore old application\" >> \"%LOGGER%\" 2>&1\n\n\tXCOPY /g /y /e /k \"%BACKUP_PARENT%\" \"%APP_PARENT%\" >> \"%LOGGER%\" 2>&1\n\tIF %ERRORLEVEL% EQU 0 (\n\t\tRMDIR /S /Q \"%BACKUP_PARENT%\" >> \"%LOGGER%\" 2>&1\n\t)\n)\nGOTO :launch_application\n\n:all_succeeded\nREM\nREM Remove the backup and decompressed folders if everything has gone swimmingly so far\nREM\nIF %PROCEED% \x3D\x3D 1 (\n\tECHO \"Removing backup\" >> \"%LOGGER%\" 2>&1\n\tRMDIR /S /Q \"%BACKUP_PARENT%\" >> \"%LOGGER%\" 2>&1\n\tECHO \"Removing decompressed folder\" >> \"%LOGGER%\" 2>&1\n\tRMDIR /S /Q \"%DECOMPRESSED_FOLDER_PATH%\" >> \"%LOGGER%\" 2>&1\n)\n\nREM\nREM Launch the application\nREM\n:launch_application\nIF %PROCEED% \x3D\x3D 1 (\n\tECHO \"Launching new app\" >> \"%LOGGER%\" 2>&1\n\tSTART \"\" \"%APP_PARENT%\\%NEW_APP_NAME%\" --kaju-success %APP_VERSION%\n) ELSE (\n\tECHO \"Launching old app\" >> \"%LOGGER%\" 2>&1\n\tSTART \"\" \"%APP_PATH%\" --kaju-fail\n)\n\nECHO \"Removing temp folder\" >> \"%LOGGER%\" 2>&1\nRMDIR /S /Q \"%TEMP_FOLDER_PATH%\" >> \"%LOGGER%\" 2>&1\n" #tag EndConstant diff --git a/Kaju Update Test v1.kaju b/Kaju Update Test v1.kaju index 7563efd..6bc8cde 100644 --- a/Kaju Update Test v1.kaju +++ b/Kaju Update Test v1.kaju @@ -11,16 +11,16 @@ "AppName":"Kaju Update Test", "RequiresPayment":true, "MacBinary":{ - "Hash":"BFE30DC356D2E07B3D374F2F52488E11", + "Hash":"15E549C8B93F772297432036A12D79AB", "URL":"http:\/\/www.mactechnologies.com\/Kaju_Test\/Kaju_Update_Test_Mac.zip" }, "WindowsBinary":{ - "Hash":"9FC851106F43834D337E4BA3ED214828", + "Hash":"F271D52E8706E02FB65CCBA8A5579F68", "URL":"http:\/\/www.mactechnologies.com\/Kaju_Test\/Kaju_Update_Test_Win.zip", "ExecutableName":"Kaju Update Test.exe" }, "LinuxBinary":{ - "Hash":"434BF5B763B5674305D7F6C2401DC9C8", + "Hash":"3DECC7DA38869B1B83BF798CB524382C", "URL":"http:\/\/www.mactechnologies.com\/Kaju_Test\/Kaju_Update_Test_Linux.zip", "ExecutableName":"Kaju Update Test" } @@ -34,16 +34,16 @@ "AppName":"New Kaju Update Test", "RequiresPayment":false, "MacBinary":{ - "Hash":"BFE30DC356D2E07B3D374F2F52488E11", + "Hash":"15E549C8B93F772297432036A12D79AB", "URL":"http:\/\/www.mactechnologies.com\/Kaju_Test\/Kaju_Update_Test_Mac.zip" }, "WindowsBinary":{ - "Hash":"9FC851106F43834D337E4BA3ED214828", + "Hash":"F271D52E8706E02FB65CCBA8A5579F68", "URL":"http:\/\/www.mactechnologies.com\/Kaju_Test\/Kaju_Update_Test_Win.zip", "ExecutableName":"Kaju Update Test.exe" }, "LinuxBinary":{ - "Hash":"434BF5B763B5674305D7F6C2401DC9C8", + "Hash":"3DECC7DA38869B1B83BF798CB524382C", "URL":"http:\/\/www.mactechnologies.com\/Kaju_Test\/Kaju_Update_Test_Linux.zip", "ExecutableName":"Kaju Update Test" } @@ -57,16 +57,16 @@ "AppName":"Kaju Update Test", "RequiresPayment":false, "MacBinary":{ - "Hash":"BFE30DC356D2E07B3D374F2F52488E11", + "Hash":"15E549C8B93F772297432036A12D79AB", "URL":"http:\/\/www.mactechnologies.com\/Kaju_Test\/Kaju_Update_Test_Mac.zip" }, "WindowsBinary":{ - "Hash":"9FC851106F43834D337E4BA3ED214828", + "Hash":"F271D52E8706E02FB65CCBA8A5579F68", "URL":"http:\/\/www.mactechnologies.com\/Kaju_Test\/Kaju_Update_Test_Win.zip", "ExecutableName":"Kaju Update Test.exe" }, "LinuxBinary":{ - "Hash":"434BF5B763B5674305D7F6C2401DC9C8", + "Hash":"3DECC7DA38869B1B83BF798CB524382C", "URL":"http:\/\/www.mactechnologies.com\/Kaju_Test\/Kaju_Update_Test_Linux.zip", "ExecutableName":"Kaju Update Test" } @@ -103,16 +103,16 @@ "AppName":"Kaju Update Test", "RequiresPayment":false, "MacBinary":{ - "Hash":"BFE30DC356D2E07B3D374F2F52488E11", + "Hash":"15E549C8B93F772297432036A12D79AB", "URL":"http:\/\/www.mactechnologies.com\/Kaju_Test\/Kaju_Update_Test_Mac.zip" }, "WindowsBinary":{ - "Hash":"9FC851106F43834D337E4BA3ED214828", + "Hash":"F271D52E8706E02FB65CCBA8A5579F68", "URL":"http:\/\/www.mactechnologies.com\/Kaju_Test\/Kaju_Update_Test_Win.zip", "ExecutableName":"Kaju Update Test.exe" }, "LinuxBinary":{ - "Hash":"434BF5B763B5674305D7F6C2401DC9C8", + "Hash":"3DECC7DA38869B1B83BF798CB524382C", "URL":"http:\/\/www.mactechnologies.com\/Kaju_Test\/Kaju_Update_Test_Linux.zip", "ExecutableName":"Kaju Update Test" } diff --git a/Platform Scripts/Kaju Linux Script.sh b/Platform Scripts/Kaju Linux Script.sh index 54d08f7..9147c71 100755 --- a/Platform Scripts/Kaju Linux Script.sh +++ b/Platform Scripts/Kaju Linux Script.sh @@ -16,6 +16,7 @@ function log_cmd { APP_NAME=@@APP_NAME@@ APP_PARENT=@@APP_PARENT@@ +APP_VERSION=@@APP_VERSION@@ NEW_APP_NAME=@@NEW_APP_NAME@@ NEW_APP_PARENT=@@NEW_APP_PARENT@@ TEMP_FOLDER_PATH=@@TEMP_FOLDER@@ @@ -152,10 +153,10 @@ then log_cmd 'Making the new app executable' chmod +x "$APP_PARENT/$NEW_APP_NAME" log_cmd 'Launching new app' - "$APP_PARENT/$NEW_APP_NAME" + "$APP_PARENT/$NEW_APP_NAME" --kaju-success "$APP_VERSION" else log_cmd 'Launching old app' - "$APP_PARENT/$APP_NAME" + "$APP_PARENT/$APP_NAME" --kaju-fail fi log_cmd 'Removing temp folder' diff --git a/Platform Scripts/Kaju Mac Script.sh b/Platform Scripts/Kaju Mac Script.sh index ccef3ed..8f1bda6 100755 --- a/Platform Scripts/Kaju Mac Script.sh +++ b/Platform Scripts/Kaju Mac Script.sh @@ -16,6 +16,7 @@ function log_cmd { APP_NAME=@@APP_NAME@@ APP_PARENT=@@APP_PARENT@@ +APP_VERSION=@@APP_VERSION@@ NEW_APP_NAME=@@NEW_APP_NAME@@ NEW_APP_PARENT=@@NEW_APP_PARENT@@ TEMP_FOLDER_PATH=@@TEMP_FOLDER@@ @@ -88,7 +89,7 @@ then log_cmd "Could not move in new application" log_cmd "Attempting to restore old application and launch it" mv "$RENAMED_APP_PATH" "$APP_PATH" - open "$APP_PATH" + open "$APP_PATH" --args --kaju-fail PROCEED=$false fi fi @@ -101,7 +102,7 @@ then APP_PATH=$APP_PARENT/$NEW_APP_NAME log_cmd "Starting new application at $APP_PATH" - open "$APP_PATH" + open "$APP_PATH" --args --kaju-success "$APP_VERSION" fi if [ $PROCEED == $true ] diff --git a/Platform Scripts/Kaju Windows Script.txt b/Platform Scripts/Kaju Windows Script.txt index f721ced..1b88cd4 100644 --- a/Platform Scripts/Kaju Windows Script.txt +++ b/Platform Scripts/Kaju Windows Script.txt @@ -6,6 +6,7 @@ REM SET APP_NAME=@@APP_NAME@@ SET APP_PARENT=@@APP_PARENT@@ +SET APP_VERSION=@@APP_VERSION@@ SET NEW_APP_NAME=@@NEW_APP_NAME@@ SET NEW_APP_PARENT=@@NEW_APP_PARENT@@ SET TEMP_FOLDER_PATH=@@TEMP_FOLDER@@ @@ -110,7 +111,7 @@ REM IF %PROCEED% == 1 ( ECHO "Copying files from %NEW_APP_PARENT% to folder %APP_PARENT%" >> "%LOGGER%" 2>&1 - XCOPY /y /e /k "%NEW_APP_PARENT%" "%APP_PARENT%" >> "%LOGGER%" 2>&1 + XCOPY /g /y /e /k "%NEW_APP_PARENT%" "%APP_PARENT%" >> "%LOGGER%" 2>&1 IF %ERRORLEVEL% NEQ 0 ( ECHO "...FAILED! (Error %ERRORLEVEL%)" >> "%LOGGER%" 2>&1 SET PROCEED=0 @@ -131,7 +132,7 @@ IF %PROCEED% == 1 ( IF %PROCEED% == 0 ( ECHO "Attempting to restore old application" >> "%LOGGER%" 2>&1 - XCOPY /y /e /k "%BACKUP_PARENT%" "%APP_PARENT%" >> "%LOGGER%" 2>&1 + XCOPY /g /y /e /k "%BACKUP_PARENT%" "%APP_PARENT%" >> "%LOGGER%" 2>&1 IF %ERRORLEVEL% EQU 0 ( RMDIR /S /Q "%BACKUP_PARENT%" >> "%LOGGER%" 2>&1 ) @@ -155,10 +156,10 @@ REM :launch_application IF %PROCEED% == 1 ( ECHO "Launching new app" >> "%LOGGER%" 2>&1 - START "" "%APP_PARENT%\%NEW_APP_NAME%" + START "" "%APP_PARENT%\%NEW_APP_NAME%" --kaju-success %APP_VERSION% ) ELSE ( ECHO "Launching old app" >> "%LOGGER%" 2>&1 - START "" "%APP_PATH%" + START "" "%APP_PATH%" --kaju-fail ) ECHO "Removing temp folder" >> "%LOGGER%" 2>&1 diff --git a/README.md b/README.md index 8124cbf..855d456 100644 --- a/README.md +++ b/README.md @@ -225,7 +225,9 @@ We recommend that the latest version of any line use a static URL. For example, ## The Classes -There is only one class (`Kaju.UpdateChecker`) and one method in the Kaju module (`CancelUpdate`) that are of concern. The other classes and methods support these. +There is only one class (`Kaju.UpdateChecker`) and one method in the Kaju module (`CancelUpdate`) that are of real concern. The other classes and methods support these. + +There is also a `Kaju.Version` constant (introduced in v.1.4) that will let you keep track of the Kaju version in your project. **Class:** `Kaju.UpdateChecker` @@ -258,6 +260,8 @@ There is only one class (`Kaju.UpdateChecker`) and one method in the Kaju module |Method|Description| |:---|:---| |CancelUpdate|Cancels any pending update; use in your windows' CancelClose event| +|DidLastUpdateFail As Boolean|Returns `True` if this launch is a result of a failed update| +|DidLastUpdateSucceed(ByRef fromVersion As String) As Boolean|Returns `True` and supplies the old version if this launch is the result of a successful update| There are other methods in the Kaju module that you might find useful but we are not documenting them. @@ -362,3 +366,10 @@ Add a translation for each, then submit a pull request as outlined above. 1.3.3 (Jan. 22, 2015) - Fixed bug in conversion of release version to double. + +1.4 (Feb. 14, 2015) + +- Added /g switch to XCOPY in Windows script. +- When the app relaunches after an update or failed update, will get command-line switches telling it what happened. Added Kaju methods to report. +- URL's for both the update information and the downloads can specify a username and password in the form "http://un:pw@theurl.com". +- Added Kaju.Version constant. diff --git a/Update Test App/App.xojo_code b/Update Test App/App.xojo_code index 3c86942..d54a8ad 100644 --- a/Update Test App/App.xojo_code +++ b/Update Test App/App.xojo_code @@ -8,6 +8,16 @@ Inherits Application mPrefFolder.CreateAsFolder end if + // + // See if this was a launch after an attempted update + // + dim fromVersion as string + if Kaju.DidLastUpdateSucceed( fromVersion ) then + MsgBox "You have successfully updated from version " + fromVersion + "." + elseif Kaju.DidLastUpdateFail then + MsgBox "The last update failed. Please try again." + end if + End Sub #tag EndEvent diff --git a/Update Test App/Kaju Update Test.xojo_project b/Update Test App/Kaju Update Test.xojo_project index 054e6bd..a5a25b5 100644 --- a/Update Test App/Kaju Update Test.xojo_project +++ b/Update Test App/Kaju Update Test.xojo_project @@ -1,5 +1,5 @@ Type=Desktop -RBProjectVersion=2014.031 +RBProjectVersion=2015.01 MinIDEVersion=20070100 Class=App;App.xojo_code;&h503AC7A0;&h0;false Window=Window1;Window1.xojo_window;&h4308442C;&h0;false diff --git a/Update Test App/Window1.xojo_window b/Update Test App/Window1.xojo_window index 5242bf3..f38856d 100644 --- a/Update Test App/Window1.xojo_window +++ b/Update Test App/Window1.xojo_window @@ -48,7 +48,6 @@ Begin Window Window1 Selectable = False TabIndex = 0 TabPanelIndex = 0 - TabStop = True Text = "This will check a predefined web site for an update. It will always show an update for 1.1 and offer to download it, but the download is, in fact, v.1.0. In other words, the app will replace itself (sometimes with an older version) just so the process can be repeated." TextAlign = 0 TextColor = &c00000000 @@ -146,7 +145,6 @@ Begin Window Window1 Selectable = False TabIndex = 3 TabPanelIndex = 0 - TabStop = True Text = "Press check to get a result" TextAlign = 0 TextColor = &c00000000 @@ -307,7 +305,6 @@ Begin Window Window1 Selectable = False TabIndex = 8 TabPanelIndex = 0 - TabStop = True Text = "Min. Stage Allowed:" TextAlign = 0 TextColor = &c00000000 @@ -320,6 +317,40 @@ Begin Window Window1 Visible = True Width = 152 End + Begin Label lblVersion + AutoDeactivate = True + Bold = False + DataField = "" + DataSource = "" + Enabled = True + Height = 20 + HelpTag = "" + Index = -2147483648 + InitialParent = "" + Italic = False + Left = 374 + LockBottom = True + LockedInPosition= False + LockLeft = False + LockRight = True + LockTop = False + Multiline = False + Scope = 0 + Selectable = False + TabIndex = 9 + TabPanelIndex = 0 + Text = "Version" + TextAlign = 2 + TextColor = &c00000000 + TextFont = "SmallSystem" + TextSize = 0.0 + TextUnit = 0 + Top = 359 + Transparent = False + Underline = False + Visible = True + Width = 206 + End End #tag EndWindow @@ -418,6 +449,13 @@ End End Sub #tag EndEvent #tag EndEvents +#tag Events lblVersion + #tag Event + Sub Open() + me.Text = "Kaju Version " + Kaju.Version + End Sub + #tag EndEvent +#tag EndEvents #tag ViewBehavior #tag ViewProperty Name="BackColor" diff --git a/Update Test Files (Upload These)/Kaju_Update_Test_Linux.zip b/Update Test Files (Upload These)/Kaju_Update_Test_Linux.zip index 8a5d8b0..2608b8d 100644 Binary files a/Update Test Files (Upload These)/Kaju_Update_Test_Linux.zip and b/Update Test Files (Upload These)/Kaju_Update_Test_Linux.zip differ diff --git a/Update Test Files (Upload These)/Kaju_Update_Test_Mac.zip b/Update Test Files (Upload These)/Kaju_Update_Test_Mac.zip index 98d1d5a..ecbf54d 100644 Binary files a/Update Test Files (Upload These)/Kaju_Update_Test_Mac.zip and b/Update Test Files (Upload These)/Kaju_Update_Test_Mac.zip differ diff --git a/Update Test Files (Upload These)/Kaju_Update_Test_Win.zip b/Update Test Files (Upload These)/Kaju_Update_Test_Win.zip index 18d8897..b6e0ddb 100644 Binary files a/Update Test Files (Upload These)/Kaju_Update_Test_Win.zip and b/Update Test Files (Upload These)/Kaju_Update_Test_Win.zip differ diff --git a/Update Test Files (Upload These)/UpdateInformation.html b/Update Test Files (Upload These)/UpdateInformation.html index 5ef5690..49ef6c8 100644 --- a/Update Test Files (Upload These)/UpdateInformation.html +++ b/Update Test Files (Upload These)/UpdateInformation.html @@ -1,4 +1,4 @@ -KAJU 492CF16928C03DBB8732E4F0E5396BF91A109B6192BD67D29F24C868A1B7A1872427C95ACB1122881754271033242EA390BAB71047323D919B81D0D9E509A394917F48E6B91D2A7B956969017EDC50F098A9FA82E67D0A3C3044F6E4A2C6678135173DD7076C80730D6AD275E68E9AB3100F4BECE477AE107882A35656153A26B632F097216B1625560A7801106FAEED300B452F22301764336A5C7123E11709A6FDB607DA306CFDA0D9F394A9BA61E2308478B9BA0CED06AE65F1562FE050D8A59A69A49C25375C557CA814C220B36A76AD342EB3A628198C2995613FA5A639F8FF64622917C738A0D249ED77DE6157E58F9A9FA5FA41835BFD383E28203996 +KAJU 41CAD0C482A93C17E67D953A08BBB5575F798AE3C03364DC5B5C699D5F7DAAB37F89A8D179F786AA846AF25C243E0F9341151A517A1B7EBFDDC41056F1358156FDC50B963CCEFAC97BD51E2E01C825CA56F1E19131FEFB9A973C0A9E62F469C67C4CD45B80184A8352CD23FE5771350E7D38CD02993974A14C89C7E2144C9FF8E92C406EE074FFCE9B7FA9A0D7B0CDB9CA43DFF7E81CC8216ED1F6D7CC268F1EE0A76C8C9FCBE5E99557869005FBEB02E6DD713FD6FAB0BFABC73648E52533AA5FD9C7451D3ADC2D4EEC170D60BB14105EEC058B7E4AD433FA7CEF74508DDFE56791221CF039E7E570A1B02C85B1912DA06381961688DA033EFD6B051AE8E433 [ { "Version":"1.1 (10)", @@ -9,16 +9,16 @@ "AppName":"Kaju Update Test", "RequiresPayment":true, "MacBinary":{ - "Hash":"BFE30DC356D2E07B3D374F2F52488E11", + "Hash":"15E549C8B93F772297432036A12D79AB", "URL":"http://www.mactechnologies.com/Kaju_Test/Kaju_Update_Test_Mac.zip" }, "WindowsBinary":{ - "Hash":"9FC851106F43834D337E4BA3ED214828", + "Hash":"F271D52E8706E02FB65CCBA8A5579F68", "URL":"http://www.mactechnologies.com/Kaju_Test/Kaju_Update_Test_Win.zip", "ExecutableName":"Kaju Update Test.exe" }, "LinuxBinary":{ - "Hash":"434BF5B763B5674305D7F6C2401DC9C8", + "Hash":"3DECC7DA38869B1B83BF798CB524382C", "URL":"http://www.mactechnologies.com/Kaju_Test/Kaju_Update_Test_Linux.zip", "ExecutableName":"Kaju Update Test" } @@ -32,16 +32,16 @@ "AppName":"New Kaju Update Test", "RequiresPayment":false, "MacBinary":{ - "Hash":"BFE30DC356D2E07B3D374F2F52488E11", + "Hash":"15E549C8B93F772297432036A12D79AB", "URL":"http://www.mactechnologies.com/Kaju_Test/Kaju_Update_Test_Mac.zip" }, "WindowsBinary":{ - "Hash":"9FC851106F43834D337E4BA3ED214828", + "Hash":"F271D52E8706E02FB65CCBA8A5579F68", "URL":"http://www.mactechnologies.com/Kaju_Test/Kaju_Update_Test_Win.zip", "ExecutableName":"Kaju Update Test.exe" }, "LinuxBinary":{ - "Hash":"434BF5B763B5674305D7F6C2401DC9C8", + "Hash":"3DECC7DA38869B1B83BF798CB524382C", "URL":"http://www.mactechnologies.com/Kaju_Test/Kaju_Update_Test_Linux.zip", "ExecutableName":"Kaju Update Test" } @@ -55,16 +55,16 @@ "AppName":"Kaju Update Test", "RequiresPayment":false, "MacBinary":{ - "Hash":"BFE30DC356D2E07B3D374F2F52488E11", + "Hash":"15E549C8B93F772297432036A12D79AB", "URL":"http://www.mactechnologies.com/Kaju_Test/Kaju_Update_Test_Mac.zip" }, "WindowsBinary":{ - "Hash":"9FC851106F43834D337E4BA3ED214828", + "Hash":"F271D52E8706E02FB65CCBA8A5579F68", "URL":"http://www.mactechnologies.com/Kaju_Test/Kaju_Update_Test_Win.zip", "ExecutableName":"Kaju Update Test.exe" }, "LinuxBinary":{ - "Hash":"434BF5B763B5674305D7F6C2401DC9C8", + "Hash":"3DECC7DA38869B1B83BF798CB524382C", "URL":"http://www.mactechnologies.com/Kaju_Test/Kaju_Update_Test_Linux.zip", "ExecutableName":"Kaju Update Test" } @@ -101,16 +101,16 @@ "AppName":"Kaju Update Test", "RequiresPayment":false, "MacBinary":{ - "Hash":"BFE30DC356D2E07B3D374F2F52488E11", + "Hash":"15E549C8B93F772297432036A12D79AB", "URL":"http://www.mactechnologies.com/Kaju_Test/Kaju_Update_Test_Mac.zip" }, "WindowsBinary":{ - "Hash":"9FC851106F43834D337E4BA3ED214828", + "Hash":"F271D52E8706E02FB65CCBA8A5579F68", "URL":"http://www.mactechnologies.com/Kaju_Test/Kaju_Update_Test_Win.zip", "ExecutableName":"Kaju Update Test.exe" }, "LinuxBinary":{ - "Hash":"434BF5B763B5674305D7F6C2401DC9C8", + "Hash":"3DECC7DA38869B1B83BF798CB524382C", "URL":"http://www.mactechnologies.com/Kaju_Test/Kaju_Update_Test_Linux.zip", "ExecutableName":"Kaju Update Test" }