Project Procyon: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
(Created page with "== Description == The auto-updater used in [http://procyon.surrealearth.info/ Project Procyon]. This work is licensed under a [http://creativecommons.org/licenses/by-nc/3.0/ Cre...")
 
m (line formatting)
 
(One intermediate revision by one other user not shown)
Line 31: Line 31:
Section "MainSection" SEC01
Section "MainSection" SEC01


IfFileExists "$AppData\Procyon\*.*" +2  ; Procyon goes into AppData for ease
        IfFileExists "$AppData\Procyon\*.*" +2  ; Procyon goes into AppData for ease
CreateDirectory "$AppData\Procyon"      ; of launching and updating.
        CreateDirectory "$AppData\Procyon"      ; of launching and updating.
 
       
; Future revisions may include launcher auto-update. Code is written, but no
        ; Future revisions may include launcher auto-update. Code is written, but no
; launcher update files are on the Procyon server yet.
        ; launcher update files are on the Procyon server yet.
 
       
; You can always add "Call DetectLauncherUpdate" here, but the code in that
        ; You can always add "Call DetectLauncherUpdate" here, but the code in that
; function and related functions are not tested.
        ; function and related functions are not tested.
 
       
Call DetectProcyonUpdate  ; All the code for the launcher is function-based.
        Call DetectProcyonUpdate  ; All the code for the launcher is function-based.


SectionEnd
SectionEnd
Line 137: Line 137:
</highlight-nsis>
</highlight-nsis>
{{PageAuthor|Kazinsal}}
{{PageAuthor|Kazinsal}}
[[Category:Real_World_Installers]]

Latest revision as of 23:32, 8 May 2012

Description

The auto-updater used in Project Procyon.

This work is licensed under a Creative Commons Attribution-NonCommercial 3.0 Unported License.

The Script

; NSIS script for Project Procyon Alpha Launcher
; Written in 2010 by Troy Martin for Project Procyon.
; Project Procyon site: http://procyon.surrealearth.info/
; Licensed under a Creative Commons Attribution-NonCommercial 3.0 License.
; See http://creativecommons.org/licenses/by-nc/3.0/ for license details.
 
; String defines
!define PRODUCT_NAME "Project Procyon"
!define PRODUCT_VERSION "Alpha"
!define PRODUCT_PUBLISHER "Surreal Earth Studios"
!define PRODUCT_WEB_SITE "http://procyon.surrealearth.info/"
 
RequestExecutionLevel user  ; It works better without wanting admin privs.
Icon "procyon.ico"
BrandingText " "            ; Remove the NSIS branding text
 
!include "UAC.nsh"  ; I don't know why this is included.
 
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "procyon.exe"
InstallDir "$PROGRAMFILES\Project Procyon"
ShowInstDetails show
 
Section "MainSection" SEC01
 
        IfFileExists "$AppData\Procyon\*.*" +2  ; Procyon goes into AppData for ease
        CreateDirectory "$AppData\Procyon"      ; of launching and updating.
 
        ; Future revisions may include launcher auto-update. Code is written, but no
        ; launcher update files are on the Procyon server yet.
 
        ; You can always add "Call DetectLauncherUpdate" here, but the code in that
        ; function and related functions are not tested.
 
        Call DetectProcyonUpdate  ; All the code for the launcher is function-based.
 
SectionEnd
 
Section -Post
SectionEnd
 
Function RunProcyon
        IfFileExists "$AppData\Procyon\procyon.exe" +4
                Delete "$AppData\Procyon\version.txt"
                Call DetectProcyonUpdate
                Quit
        Exec '"$AppData\Procyon\procyon.exe"'
        Quit
FunctionEnd
 
 
Function GetProcyon
        FileOpen $0 "$AppData\Procyon\version.txt" r
        FileRead $0 $3
        FileClose $0
        StrCpy $3 $3 -2
        StrCpy $2 "$AppData\Procyon\procyon.exe"
        Rename $2 "$AppData\Procyon\procyonold.exe"
        nsisdl::download /TIMEOUT=30000 "${PRODUCT_WEB_SITE}updater/procyon-$3.zip" "$AppData\Procyon\procyon.zip"
        Pop $R0 ;Get the return value
                StrCmp $R0 "success" +4
                MessageBox MB_OK "Download failed: $R0 - $3.zip"
                Rename "$AppData\Procyon\procyonold.exe" $2
                Quit
        nsisunz::UnzipToLog "$AppData\Procyon\procyon.zip" "$AppData\Procyon"
        Delete "$AppData\Procyon\procyon.zip"
        Call RunProcyon
FunctionEnd
 
Function DetectProcyonUpdate
        StrCpy $2 "$TEMP\procyonupdate.txt"
 
        nsisdl::download /TIMEOUT=30000 "${PRODUCT_WEB_SITE}updater/procyonupdate.txt" $2
        Pop $R0 ;Get the return value
                StrCmp $R0 "success" +3
                MessageBox MB_OK "Download failed: $R0"
                Call RunProcyon
        FileOpen $0 "$TEMP\procyonupdate.txt" r
        FileRead $0 $1
        FileClose $0
        IfFileExists "$AppData\Procyon\*.*" 0 +5
        FileOpen $0 "$AppData\Procyon\version.txt" r
        FileRead $0 $3
        FileClose $0
        StrCmp $1 $3 +5
        FileOpen $0 "$AppData\Procyon\version.txt" w
        FileWrite $0 $1
        FileClose $0
        Call GetProcyon
        Call RunProcyon
FunctionEnd
 
Function RunLauncher    ; Never actually called
        Exec $EXEPATH
        Quit
FunctionEnd
 
 
Function GetLauncher    ; Never actually called
        nsisdl::download /TIMEOUT=30000 "${PRODUCT_WEB_SITE}procyon.exe" $EXEPATH
        Pop $R0 ;Get the return value
                StrCmp $R0 "success" +4
                MessageBox MB_OK "Download failed: $R0 - $3.exe"
                Quit
        Call RunLauncher
FunctionEnd
 
Function DetectLauncherUpdate   ; Never actually called
        StrCpy $2 "$TEMP\launcherupdate.txt"
 
        nsisdl::download /TIMEOUT=30000 "${PRODUCT_WEB_SITE}updater/launcherupdate.txt" $2
        Pop $R0 ;Get the return value
                StrCmp $R0 "success" +3
                MessageBox MB_OK "Download failed: $R0"
                Return
        FileOpen $0 "$TEMP\launcherupdate.txt" r
        FileRead $0 $1
        FileClose $0
        IfFileExists "$AppData\Procyon\*.*" 0 +5
        FileOpen $0 "$AppData\Procyon\launcher.txt" r
        FileRead $0 $3
        FileClose $0
        StrCmp $1 $3 +5
        FileOpen $0 "$AppData\Procyon\launcher.txt" w
        FileWrite $0 $1
        FileClose $0
        Call GetLauncher
        Call RunLauncher
FunctionEnd
Author: Kazinsal (talk, contrib)