1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-17 14:55:09 -05:00
filebot/installer/nsis/filebot.nsi

393 lines
12 KiB
Plaintext
Raw Normal View History

2013-08-04 09:18:07 -04:00
; OpenCandySample.nsi
;
; This is a fairly simple example of an NSIS installer that walks through
; the basic functionality a typical installer provides and also shows the
; required OpenCandy integration points.
;
; You should be able to build this installer without any modification
; and see a sample offer from the OpenCandy network. The unmodified installer
; is safe to run, it just drops a copy of this .nsi file in the installation
; folder.
;
; Everything specific to OpenCandy in this script is encapsulated like this:
;
; # [OpenCandy]
; ; OpenCandy stuff here
; # [/OpenCandy]
;
; If you already have your own .nsi script the accompanying SDK notes highlight
; the steps necessary for integration and this sample will provide a good
; reference implementation. For advanced support please contact the OpenCandy
; partner support team.
;
; Copyright (c) 2008 - 2013 SweetLabs, Inc.
;
; You may use and modify this .nsi file for your product installer so long as
; you abide by the terms of the OpenCandy SDK EULA.
;
2013-08-04 09:18:07 -04:00
;--------------------------------
; Definitions
;--------------------------------
# [OpenCandy]
; The following values get passed to the OpenCandy API. Once you've signed up
; for OpenCandy you'll be provided with a customized set of values specific to
; your product that you must set here before releasing your installer.
;
; These values must be defined before including OCSetupHlp.nsh.
;
; For internal purposes it's okay to use the sample values that are preset
; below. If everything is working properly you'll see a sample offer screen
; display in your installer. When you compile your installer with these
; sample values some warnings will be displayed in the compiler output
; window to remind you to make changes before your public release.
; Please change the key and secret to the ones assigned for your specific products
; Product key and secret for first offer
!define OC_STR_KEY "c759b81f33a64385655ad567bc5e4ddf"
!define OC_STR_SECRET "a292a0295f1fb9ca183b9fd48f472b6e"
; Product key and secret for second offer screen if showing two offers, otherwise
; set these to empty strings.
!define OC_STR_KEY2 "61ae9369917e275d4ec4182f23f6bfeb"
!define OC_STR_SECRET2 "f3f52c88720a1f42c9ec232abae94517"
; Optionally change the path to OCSetupHlp.dll here if it's not in the same folder
; as your .nsi file. You must specify the relative path from your .nsi file location.
!define OC_OCSETUPHLP_FILE_PATH ".\OCSetupHlp.dll"
# [/OpenCandy]
# [OpenCandy]
; The following values customize the UI for the OpenCandy loading screen.
; The loading screen is displayed only for a limited time when there has not
; been sufficient time between loading the OpenCandy client and end user navigation
; to the OpenCandy offer screen to finish checking for available offers.
; You may use LangStrings to localize messages.
;
; These values must be defined before including OCSetupHlp.nsh.
;
!define OC_LOADING_SCREEN_CAPTION " "
!define OC_LOADING_SCREEN_DESCRIPTION " "
!define OC_LOADING_SCREEN_MESSAGE "Loading..."
!define OC_LOADING_SCREEN_FONTFACE "Arial"
!define OC_LOADING_SCREEN_FONTSIZE 100
# [/OpenCandy]
!define PRODUCT_PROPER_NAME "FileBot"
; !define PRODUCT_FILESYSTEM_NAME "My Product"
; !define PRODUCT_PUBLISHER_PROPER_NAME "My Company, Inc."
; !define PRODUCT_PUBLISHER_FILESYSTEM_NAME "My Company"
!define INSTALLER_EXE_NAME "FileBot-setup.exe"
; !define PRODUCT_DIR_REGKEY "Software\${PRODUCT_PUBLISHER_FILESYSTEM_NAME}\${PRODUCT_FILESYSTEM_NAME}"
; Uncomment this definition to use Modern UI 2 instead of Modern UI. It's best
; to use Modern UI 2 if you're starting fresh with the latest version of NSIS
; and you don't have many custom dialogs created with InstallOptions. By default
; this sample installer uses Modern UI for maximum compatibility.
!define OPTION_USE_MUI_2
;--------------------------------
; Installer Configuration
;--------------------------------
# [OpenCandy]
; OpenCandy requires RequestExecutionLevel admin
# [/OpenCandy]
; Request admin privileges for Windows Vista, 7.
RequestExecutionLevel admin
; Name (shown in various places in the installer UI)
Name "${PRODUCT_PROPER_NAME}"
; Output file generated by NSIS compiler
OutFile "${INSTALLER_EXE_NAME}"
; Default installation folder
; InstallDir "$PROGRAMFILES\${PRODUCT_PUBLISHER_FILESYSTEM_NAME}\${PRODUCT_FILESYSTEM_NAME}"
; Automatically remember any user-customized installation path
; InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
; Use lzma compression
SetCompressor lzma
; Optimize Data Block
SetDatablockOptimize on
; Restore last write datestamp of files
; SetDateSave on
; Show un/installation details
ShowInstDetails show
ShowUnInstDetails show
;--------------------------------
; Includes
;--------------------------------
!include "x64.nsh"
2013-08-04 09:18:07 -04:00
; Use Modern UI to make the installer look nice
!ifdef OPTION_USE_MUI_2
!include "MUI2.nsh"
!else
!include "MUI.nsh"
!endif
; Include Sections header so that we can manipulate
; section properties in .onInit
!include "Sections.nsh"
# [OpenCandy]
; Include the OpenCandy Setup Helper header
; This provides all the OpenCandy helper macros, functions
; and definitions that are used by this install script.
!include "OCSetupHlp.nsh"
# [/OpenCandy]
;--------------------------------
; Reserve files
;--------------------------------
!insertmacro MUI_RESERVEFILE_LANGDLL
# [/OpenCandy]
; Improve performance by reserving an early place in
; the file data block for OpenCandy DLL.
!insertmacro OpenCandyReserveFile
# [/OpenCandy]
!ifndef OPTION_USE_MUI_2
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
!endif
;--------------------------------
; Variables
;--------------------------------
; Create any globals here
; Var MyGlobalVariable
;--------------------------------
; Modern UI Configuration
;--------------------------------
; MUI Settings
!define MUI_ABORTWARNING
; MUI Settings / Icons
2013-08-04 09:18:07 -04:00
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\orange-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall.ico"
; MUI Settings / Header
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_RIGHT
2013-08-04 09:18:07 -04:00
!define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\orange-r.bmp"
!define MUI_HEADERIMAGE_UNBITMAP "${NSISDIR}\Contrib\Graphics\Header\orange-uninstall-r.bmp"
; MUI Settings / Wizard
2013-08-04 09:18:07 -04:00
!define MUI_WELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\orange.bmp"
!define MUI_UNWELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\orange-uninstall.bmp"
2013-08-04 09:18:07 -04:00
;--------------------------------
; Installer pages
;--------------------------------
2013-08-04 09:18:07 -04:00
; Welcome page
!insertmacro MUI_PAGE_WELCOME
2013-08-04 09:18:07 -04:00
# [OpenCandy]
; You must display the OpenCandy EULA during installation. We recommend
; that you append the OpenCandy EULA to your own license agreement,
; and that you provide clearly visible notice of the presence of the
; OpenCandy EULA using a table of contents at the top of the
; combined presentation.
# [/OpenCandy]
; End user license agreement
!insertmacro MUI_PAGE_LICENSE "FileBot_OpenCandy_EULA.txt"
# [OpenCandy]
; This placeholder page supports deferred extraction and loading of the
; OpenCandy Network Client library when using OC_INIT_PERFORM_BYPAGEORDER.
; It will typically be inserted immediately after the license page. No
; page is actually displayed to the end user. Inserting this page later in
; the page list may reduce offer rate and increase the likelihood that end
; users will see the OpenCandy loading page.
!insertmacro OpenCandyLoadDLLPage
# [/OpenCandy]
# [OpenCandy]
; This placeholder page connects to the OpenCandy Network to check for
; recommendations after deferred loading using OpenCandyLoadDLLPage. It will
; typically be inserted immediately after OpenCandyLoadDLLPage. No page is
; actually displayed to the end user. Inserting this page later in the page
; list may reduce offer rate and increase the likelihood that end users will
; see the OpenCandy loading page.
!insertmacro OpenCandyConnectPage
# [/OpenCandy]
; Component selection (you might want to omit this in a simpler setup)
; !insertmacro MUI_PAGE_COMPONENTS
; Choose directory (you might want to omit this in a simpler setup)
; !insertmacro MUI_PAGE_DIRECTORY
# [OpenCandy]
; Insert a loading screen before the OpenCandy offer page. This screen
; will be displayed only if the OpenCandy client is still determining
; offer availability and for a limited period of time. Omitting this
; page may reduce offer rate. This page must be inserted after
; OpenCandyConnectPage and before OpenCandyOfferPage.
!insertmacro OpenCandyLoadingPage
# [/OpenCandy]
# [OpenCandy]
; Insert the OpenCandy offer page
!insertmacro OpenCandyOfferPage
# [/OpenCandy]
# [OpenCandy]
; Insert the second OpenCandy offer page
!insertmacro OpenCandyOfferPage2
# [/OpenCandy]
; Perform installation (executes each enabled Section)
!insertmacro MUI_PAGE_INSTFILES
2013-08-04 09:18:07 -04:00
; Finish page
!insertmacro MUI_PAGE_FINISH
;--------------------------------
; Language support
;--------------------------------
!insertmacro MUI_LANGUAGE "English"
2013-08-04 09:18:07 -04:00
LangString Section_Name_MainProduct ${LANG_ENGLISH} "${PRODUCT_PROPER_NAME}"
LangString Section_Name_MainProductExt ${LANG_ENGLISH} "${PRODUCT_PROPER_NAME} extensions"
2013-08-04 09:18:07 -04:00
;---------------------------
; Install sections
;---------------------------
Var MSI_STATUS
Section "$(Section_Name_MainProduct)" SECTIONID_MAINPRODUCT
; Put your own product installation code here!
;
; Notice that because this is the main product section
; there's some code in the .onInit callback that prevents
; the user from disabling this section on the components
; selection screen.
DetailPrint "Downloading latest version..."
;Install latest FileBot
${if} ${RunningX64}
inetc::get /USERAGENT "nsis" /caption "Downloading FileBot (64-bit)" "http://www.filebot.net/download.php?mode=nsis&type=msi&arch=x64" "$PLUGINSDIR\FileBot.msi" /end
${else}
inetc::get /USERAGENT "nsis" /caption "Downloading FileBot (32-bit)" "http://www.filebot.net/download.php?mode=nsis&type=msi&arch=x86" "$PLUGINSDIR\FileBot.msi" /end
${endif}
DetailPrint "Installing latest version..."
nsExec::Exec 'msiexec /passive /i "$PLUGINSDIR\FileBot.msi"'
2013-08-04 09:18:07 -04:00
Pop $MSI_STATUS # grab return value
${if} $MSI_STATUS == "0"
# [OpenCandy]
; This section is hidden. It will always execute during installation
; but it won't appear on your component selection screen.
; Handle any offers the user accepted
!insertmacro OpenCandyInstallEmbedded
# [/OpenCandy]
${else}
DetailPrint "msiexec error $MSI_STATUS"
2013-08-04 09:18:07 -04:00
DetailPrint "Install failed."
Abort
2013-08-04 09:18:07 -04:00
${endif}
SectionEnd
2013-08-04 09:18:07 -04:00
;--------------------------------
; .onInit NSIS callback
;--------------------------------
Function .onInit
; Display a language selection dialog box for languages
; This will only show if you have added multiple languages
; using the MUI_LANGUAGE macro.
!insertmacro MUI_LANGDLL_DISPLAY
; Set the main product section to read-only so that users
; can't turn it off on the component selection screen.
!insertmacro SetSectionFlag ${SECTIONID_MAINPRODUCT} ${SF_RO}
# [OpenCandy]
; Note: If you use a language selection system,
; e.g. MUI_LANGDLL_DISPLAY or calls to LangDLL, you must insert
; these macros after the language selection code in order for
; OpenCandy to detect the user-selected language and for any
; LangStrings you may use to be applied.
; Initialize OpenCandy
!insertmacro OpenCandyAsyncInit "${OC_STR_KEY}" "${OC_STR_SECRET}" ${OC_INIT_MODE_NORMAL} \
"${OC_STR_KEY2}" "${OC_STR_SECRET2}" ${OC_INIT_MODE_NORMAL} \
${OC_INIT_PERFORM_NOW}
# [/OpenCandy]
FunctionEnd
;--------------------------------
; .onInstSuccess NSIS callback
;--------------------------------
Function .onInstSuccess
# [OpenCandy]
; Signal successful installation, download and install accepted offers
!insertmacro OpenCandyOnInstSuccess
# [/OpenCandy]
FunctionEnd
;--------------------------------
; .onGUIEnd NSIS callback
;--------------------------------
Function .onGUIEnd
# [OpenCandy]
; Inform the OpenCandy API that the installer is about to exit
!insertmacro OpenCandyOnGuiEnd
# [/OpenCandy]
FunctionEnd
# [OpenCandy]
; Have the compiler perform some basic OpenCandy API implementation checks
!insertmacro OpenCandyAPIDoChecks
# [/OpenCandy]