Advertisement
GordCaswell

InstallerWizard.nsi

Feb 6th, 2012
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;Copyright (C) 2006-2010 John T. Haller
  2.  
  3. ;Website: http://PortableApps.com/Installer
  4.  
  5. ;This software is OSI Certified Open Source Software.
  6. ;OSI Certified is a certification mark of the Open Source Initiative.
  7.  
  8. ;This program is free software; you can redistribute it and/or
  9. ;modify it under the terms of the GNU General Public License
  10. ;as published by the Free Software Foundation; either version 2
  11. ;of the License, or (at your option) any later version.
  12.  
  13. ;This program is distributed in the hope that it will be useful,
  14. ;but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. ;GNU General Public License for more details.
  17.  
  18. ;You should have received a copy of the GNU General Public License
  19. ;along with this program; if not, write to the Free Software
  20. ;Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  21.  
  22. !define APPNAME "PortableApps.com Installer"
  23. !define VER "2.0.9.0"
  24. !define WEBSITE "PortableApps.com/Installer"
  25. !define FRIENDLYVER "2.0.9"
  26. !define PORTABLEAPPS.COMFORMATVERSION "2.0"
  27.  
  28. ;=== Program Details
  29. Name "${APPNAME}"
  30. OutFile "..\..\PortableApps.comInstaller.exe"
  31. Caption "${APPNAME}"
  32. VIProductVersion "${VER}"
  33. VIAddVersionKey ProductName "${APPNAME}"
  34. VIAddVersionKey Comments "For additional details, visit ${WEBSITE}"
  35. VIAddVersionKey CompanyName "PortableApps.com"
  36. VIAddVersionKey LegalCopyright "John T. Haller"
  37. VIAddVersionKey FileDescription "${APPNAME}"
  38. VIAddVersionKey FileVersion "${VER}"
  39. VIAddVersionKey ProductVersion "${VER}"
  40. VIAddVersionKey InternalName "${APPNAME}"
  41. VIAddVersionKey LegalTrademarks "PortableApps.com is a trademark of Rare Ideas, LLC."
  42. VIAddVersionKey OriginalFilename "PortableApps.comInstaller.exe"
  43.  
  44. ;=== Runtime Switches
  45. CRCCheck On
  46. RequestExecutionLevel user
  47.  
  48. ; Best Compression
  49. SetCompress Auto
  50. SetCompressor /SOLID lzma
  51. SetCompressorDictSize 32
  52. SetDatablockOptimize On
  53.  
  54. ;=== Include
  55. ;(Standard)
  56. !include WordFunc.nsh
  57. !insertmacro WordReplace
  58. !include FileFunc.nsh
  59. !insertmacro GetFileName
  60. !insertmacro GetParameters
  61. !insertmacro GetParent
  62. !insertmacro GetSize
  63. !include LogicLib.nsh
  64. !include MUI.nsh
  65.  
  66. ;(Addons)
  67. !include dialogs.nsh
  68.  
  69. ;(Custom)
  70. !include MoveFiles.nsh
  71. !include ReadINIStrWithDefault.nsh
  72.  
  73. ;=== Icon & Stye ===
  74. !define MUI_ICON "..\..\App\AppInfo\appicon.ico"
  75. !define MUI_HEADERIMAGE
  76. !define MUI_HEADERIMAGE_BITMAP header.bmp
  77.  
  78. BrandingText "PortableApps.com - Your Digital Life, Anywhere®"
  79. InstallButtonText "Go >"
  80. ShowInstDetails show
  81. SubCaption 3 " | Processing Files"
  82.  
  83. ;=== Variables
  84. Var FINISHTEXT
  85. Var FINISHTITLE
  86. Var INSTALLAPPDIRECTORY
  87. Var SKIPWELCOMEPAGE
  88. Var AUTOMATICCOMPILE
  89.  
  90. Var INCLUDESOURCE
  91. Var PORTABLEAPPNAME
  92. Var PORTABLEAPPNAMEDOUBLEDAMPERSANDS
  93. Var PLUGINNAME
  94. Var APPID
  95. Var SHORTNAME
  96. Var APPLANGUAGE
  97. Var ALLLANGUAGES
  98. Var INSTALLERFILENAME
  99. Var OPTIONALCOMPONENTS
  100. Var DISPLAYVERSION
  101. Var COMMONFILESPLUGIN
  102. Var USEEXTRACTEDICON
  103. Var INTERACTIVEMODE
  104. Var EULAVERSION
  105.  
  106. Var ERROROCCURED
  107.  
  108. Var AppInfoINIFile
  109. Var InstallerINIFile
  110. Var PluginInstaller
  111. Var OptionalSectionSelectedInstallType
  112.  
  113. ;=== Pages
  114. !define MUI_WELCOMEFINISHPAGE_BITMAP welcomefinish.bmp
  115. !define MUI_WELCOMEPAGE_TITLE "PortableApps.com Installer ${FRIENDLYVER}"
  116. !define MUI_WELCOMEPAGE_TEXT "Welcome to the PortableApps.com Installer.\r\n\r\nThis utility allows you to create a PortableApps.com Installer package for an app in PortableApps.com Format.  Just click next and select the application to package.\r\n\r\nLICENSE: The PortableApps.com Installer can be used with open source and freeware apps provided the installer is unmodified and the app adheres to the current PortableApps.com Format Specification as published at PortableApps.com/development. It may also be used with commercial software by contacting PortableApps.com."
  117. !define MUI_PAGE_CUSTOMFUNCTION_PRE ShowWelcomeWindow
  118. !insertmacro MUI_PAGE_WELCOME
  119. Page custom ShowOptionsWindow LeaveOptionsWindow " | Portable App Folder Selection"
  120. Page instfiles
  121. !define MUI_PAGE_CUSTOMFUNCTION_PRE ShowFinishPage
  122. !define MUI_FINISHPAGE_TITLE "$FINISHTITLE"
  123. !define MUI_FINISHPAGE_TEXT "$FINISHTEXT"
  124. !define MUI_FINISHPAGE_RUN
  125. !define MUI_FINISHPAGE_RUN_NOTCHECKED
  126. !define MUI_FINISHPAGE_RUN_TEXT "Test Installer"
  127. !define MUI_FINISHPAGE_RUN_FUNCTION "RunOnFinish"
  128. !define MUI_FINISHPAGE_SHOWREADME "$EXEDIR\Data\PortableApps.comInstallerLog.txt"
  129. !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
  130. !define MUI_FINISHPAGE_SHOWREADME_TEXT "View log file"
  131. !insertmacro MUI_PAGE_FINISH
  132.  
  133. ;=== Languages
  134. !insertmacro MUI_LANGUAGE "English"
  135.  
  136. Function .onInit
  137.     !insertmacro MUI_INSTALLOPTIONS_EXTRACT "InstallerWizardForm.ini"
  138.  
  139.     ;=== Check for settings.ini
  140.     ${IfNot} ${FileExists} $EXEDIR\Data\settings.ini
  141.         CreateDirectory $EXEDIR\Data
  142.         CopyFiles /SILENT $EXEDIR\App\DefaultData\settings.ini $EXEDIR\Data
  143.     ${EndIf}
  144.  
  145.     ; Get settings
  146.     ReadINIStr $SKIPWELCOMEPAGE "$EXEDIR\Data\settings.ini" "InstallerWizard" "SkipWelcomePage"
  147.     ReadINIStr $INSTALLAPPDIRECTORY "$EXEDIR\Data\settings.ini" "InstallerWizard" "INSTALLAPPDIRECTORY"
  148.  
  149.     ${GetParameters} $R0
  150.     ${If} $R0 != ""
  151.         StrCpy $INSTALLAPPDIRECTORY $R0
  152.         StrCpy $SKIPWELCOMEPAGE "true"
  153.         StrCpy $AUTOMATICCOMPILE "true"
  154.         ;Strip quotes from $INSTALLAPPDIRECTORY
  155.         StrCpy $R0 $INSTALLAPPDIRECTORY 1
  156.         ${If} $R0 == `"`
  157.             StrCpy $INSTALLAPPDIRECTORY $INSTALLAPPDIRECTORY "" 1
  158.             StrCpy $INSTALLAPPDIRECTORY $INSTALLAPPDIRECTORY -1
  159.         ${EndIf}
  160.     ${EndIf}
  161.  
  162.     ;=== Pre-Fill Path with Directory
  163.     WriteINIStr $PLUGINSDIR\InstallerWizardForm.ini "Field 2" "State" "$INSTALLAPPDIRECTORY"
  164. FunctionEnd
  165.  
  166. Function ShowWelcomeWindow
  167.     ${If} $SKIPWELCOMEPAGE == "true"
  168.         Abort
  169.     ${EndIf}
  170. FunctionEnd
  171.  
  172. Function ShowOptionsWindow
  173.     !insertmacro MUI_HEADER_TEXT "PortableApps.com Installer ${FRIENDLYVER}" "the open portable software standard"
  174.     ${If} $AUTOMATICCOMPILE == "true"
  175.         ${If} ${FileExists} "$INSTALLAPPDIRECTORY\App\AppInfo\appinfo.ini"
  176.             StrCpy $AppInfoINIFile "$INSTALLAPPDIRECTORY\App\AppInfo\appinfo.ini"
  177.             StrCpy $InstallerINIFile "$INSTALLAPPDIRECTORY\App\AppInfo\installer.ini"
  178.             StrCpy $PluginInstaller "false"
  179.             Abort
  180.         ${ElseIf} ${FileExists} "$INSTALLAPPDIRECTORY\Other\Source\plugininstaller.ini"
  181.             StrCpy $AppInfoINIFile "$INSTALLAPPDIRECTORY\Other\Source\plugininstaller.ini"
  182.             StrCpy $InstallerINIFile "$INSTALLAPPDIRECTORY\Other\Source\plugininstaller.ini"
  183.             StrCpy $PluginInstaller "true"
  184.             Abort
  185.         ${EndIf}
  186.     ${EndIf}
  187.     ${ReadINIStrWithDefault} $INTERACTIVEMODE "$EXEDIR\Data\settings.ini" "InstallerWizard" "InteractiveMode" "1"
  188.     WriteINIStr "$PLUGINSDIR\InstallerWizardForm.ini" "Field 3" "State" "$INTERACTIVEMODE"
  189.     InstallOptions::InitDialog /NOUNLOAD "$PLUGINSDIR\InstallerWizardForm.ini"
  190.     Pop $0
  191.     InstallOptions::Show
  192. FunctionEnd
  193.  
  194. Function LeaveOptionsWindow
  195.     ;=== Blank
  196.     ReadINIStr $INSTALLAPPDIRECTORY $PLUGINSDIR\InstallerWizardForm.ini "Field 2" "State"
  197.     ReadINIStr $INTERACTIVEMODE "$PLUGINSDIR\InstallerWizardForm.ini" "Field 3" "State"
  198.  
  199.     StrCmp $INSTALLAPPDIRECTORY "" NoInstallAppDirectoryError
  200.     ${If} ${FileExists} "$INSTALLAPPDIRECTORY\App\AppInfo\appinfo.ini"
  201.         StrCpy $AppInfoINIFile "$INSTALLAPPDIRECTORY\App\AppInfo\appinfo.ini"
  202.         StrCpy $InstallerINIFile "$INSTALLAPPDIRECTORY\App\AppInfo\installer.ini"
  203.         StrCpy $PluginInstaller "false"
  204.     ${ElseIf} ${FileExists} "$INSTALLAPPDIRECTORY\Other\Source\plugininstaller.ini"
  205.         StrCpy $AppInfoINIFile "$INSTALLAPPDIRECTORY\Other\Source\plugininstaller.ini"
  206.         StrCpy $InstallerINIFile "$INSTALLAPPDIRECTORY\Other\Source\plugininstaller.ini"
  207.         StrCpy $PluginInstaller "true"
  208.     ${ElseIf} $INTERACTIVEMODE = 1
  209.         ; No AppInfo found
  210.         ${IfNot} ${FileExists} "$INSTALLAPPDIRECTORY\*.exe"
  211.         ${AndIf} $PluginInstaller != "true"
  212.             Goto NoInstallAppDirectoryError
  213.         ${EndIf}
  214.  
  215.         MessageBox MB_ICONQUESTION|MB_YESNO "The app does not appear to have the necessary files within the App\AppInfo directory required by PortableApps.com Format.  Would you like to create the settings interactively and use a set of default icons for now for testing?" IDNO NoInstallAppDirectoryError
  216.  
  217.             ;Find EXE file
  218.             FindFirst $2 $3 "$INSTALLAPPDIRECTORY\*.exe"
  219.             StrCpy $4 0
  220.  
  221.             ${DoWhile} $3 != ""
  222.                 StrCpy $5 $3
  223.                 IntOp $4 $4 + 1
  224.                 FindNext $2 $3
  225.             ${Loop}
  226.             FindClose $2
  227.  
  228.             ${If} $4 > 1
  229.                 MessageBox MB_OK|MB_ICONEXCLAMATION `Multiple EXEs were found in the directory you selected.  The PortableApps.com Installer can only generate default information for applications with a single EXE.  Please review the information at PortableApps.com/development for details on creating the configuration files.`
  230.                 Abort
  231.             ${EndIf}
  232.  
  233.             CreateDirectory "$INSTALLAPPDIRECTORY\App\AppInfo"
  234.             CopyFiles /SILENT "$EXEDIR\App\default_bits\appicon_16.png" "$INSTALLAPPDIRECTORY\App\AppInfo"
  235.             CopyFiles /SILENT "$EXEDIR\App\default_bits\appicon_32.png" "$INSTALLAPPDIRECTORY\App\AppInfo"
  236.             CopyFiles /SILENT "$EXEDIR\App\default_bits\appicon.ico" "$INSTALLAPPDIRECTORY\App\AppInfo"
  237.             CopyFiles /SILENT "$EXEDIR\App\default_bits\appinfo.ini" "$INSTALLAPPDIRECTORY\App\AppInfo"
  238.             WriteINIStr "$INSTALLAPPDIRECTORY\App\AppInfo\appinfo.ini" "Format" "Version" "${PORTABLEAPPS.COMFORMATVERSION}"
  239.             WriteINIStr "$INSTALLAPPDIRECTORY\App\AppInfo\appinfo.ini" "Control" "Start" "$5"
  240.  
  241.             MessageBox MB_ICONINFORMATION "Before releasing this application, please be sure to create a set of proper icons in App\AppInfo."
  242.     ${Else}
  243.         Goto NoInstallAppDirectoryError
  244.     ${EndIf}
  245.  
  246.     ; Store settings
  247.     WriteINIStr "$EXEDIR\Data\settings.ini" "InstallerWizard" "INSTALLAPPDIRECTORY" $INSTALLAPPDIRECTORY
  248.     WriteINIStr "$EXEDIR\Data\settings.ini" "InstallerWizard" "InteractiveMode" $INTERACTIVEMODE
  249.     Goto EndLeaveOptionsWindow
  250.  
  251.     NoInstallAppDirectoryError:
  252.         MessageBox MB_OK|MB_ICONEXCLAMATION `Please select a valid portable app's base directory to create an installer for.`
  253.         Abort
  254.  
  255.     EndLeaveOptionsWindow:
  256. FunctionEnd
  257.  
  258. !define SetIndividualLanguage "!insertmacro SetIndividualLanguage"
  259.  
  260. !define WriteConfig "!insertmacro WriteConfig"
  261.  
  262. !macro WriteConfig Variable Value
  263.     FileWriteUTF16LE $0 `!define ${Variable} "${Value}"$\r$\n`
  264. !macroend
  265.  
  266. !macro SetIndividualLanguage IndividualLanguage
  267.     StrCpy $2 "${IndividualLanguage}"
  268.     ${ReadINIStrWithDefault} $1 $InstallerINIFile "Languages" "$2" "false"
  269.     ${If} $1 == "true"
  270.     ${OrIf} $ALLLANGUAGES == "true"
  271.         ${WriteConfig} USES_$2 "true"
  272.     ${EndIf}
  273. !macroend
  274.  
  275. !define WriteErrorToLog "!insertmacro WriteErrorToLog"
  276.  
  277. !macro WriteErrorToLog ErrorToWrite
  278.     FileOpen $9 "$EXEDIR\Data\PortableApps.comInstallerLog.txt" a
  279.     FileSeek $9 0 END
  280.     FileWriteUTF16LE $9 `ERROR: ${ErrorToWrite}$\r$\n`
  281.     FileClose $9
  282.     StrCpy $ERROROCCURED "true"
  283. !macroend
  284.  
  285. !define TransferInstallerINIToConfig "!insertmacro TransferInstallerINIToConfig"
  286.  
  287. !macro TransferInstallerINIToConfig Section Key Required
  288.     ${ReadINIStrWithDefault} $1 $InstallerINIFile ${Section} ${Key} ""
  289.     ${If} $1 != ""
  290.         ${WriteConfig} ${Key} "$1"
  291.     !if ${Required} == required
  292.     ${Else}
  293.         ${WriteErrorToLog} "Installer.ini - ${Section} - ${Key} is missing."
  294.     !endif
  295.     ${EndIf}
  296. !macroend
  297.  
  298. Section Main
  299.     SetDetailsPrint ListOnly
  300.     DetailPrint "App: $INSTALLAPPDIRECTORY"
  301.     DetailPrint " "
  302.     RealProgress::SetProgress /NOUNLOAD 1
  303.     RealProgress::GradualProgress /NOUNLOAD 2 1 90 "Processing complete."
  304.     DetailPrint "Generating installer code..."
  305.     SetDetailsPrint none
  306.  
  307.     ;Ensure the source directory exists
  308.     CreateDirectory "$INSTALLAPPDIRECTORY\Other\Source"
  309.  
  310.     ;Remove any existing installer files (leaving custom intact)
  311.     RMDir /r "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstallerLanguages"
  312.     Delete "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstaller.bmp"
  313.     Delete "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstaller.ico"
  314.     Delete "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstaller.nsi"
  315.     Delete "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstallerConfig-EXAMPLE.nsh"
  316.     Delete "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstallerConfig.nsh"
  317.     Delete "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstallerDumpLogToFile.nsh"
  318.     Delete "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstallerHeader.bmp"
  319.     Delete "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstallerMoveFiles.nsh"
  320.     Delete "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstallerStrRep.nsh"
  321.     Delete "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstallerHeaderRTL.bmp"
  322.     Delete "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstallerPlugin.nsi"
  323.     Delete "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstallerPluginConfig.nsh"
  324.  
  325.     ;Copy the current PortableApps.com Installer in
  326.     CopyFiles /SILENT "$EXEDIR\App\installer\*.*" "$INSTALLAPPDIRECTORY\Other\Source"
  327.     ${If} $PluginInstaller == "true"
  328.         Rename "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstaller.nsi" "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstallerPlugin.nsi"
  329.         Rename "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstallerConfig.nsh" "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstallerPluginConfig.nsh"
  330.     ${EndIf}
  331.  
  332.     ;Generate the configuration file
  333.     Delete "$EXEDIR\Data\PortableApps.comInstallerLog.txt"
  334.  
  335.     ;Determine icon type
  336.     ${ReadINIStrWithDefault} $1 $AppInfoINIFile "Control" "ExtractIcon" ""
  337.     ${If} $1 != ""
  338.         StrCpy $USEEXTRACTEDICON "true"
  339.     ${EndIf}
  340.  
  341.     ;Check for content
  342.     ${IfNot} ${FileExists} "$INSTALLAPPDIRECTORY\*.exe"
  343.     ${AndIf} $PluginInstaller != "true"
  344.         ${WriteErrorToLog} "No EXE in $INSTALLAPPDIRECTORY."
  345.     ${EndIf}
  346.  
  347.     ${IfNot} ${FileExists} "$INSTALLAPPDIRECTORY\help.html"
  348.     ${AndIf} $PluginInstaller != "true"
  349.         ${WriteErrorToLog} "No help.html in $INSTALLAPPDIRECTORY."
  350.     ${EndIf}
  351.  
  352.     !macro AppInfoFileMissingAskInsertDefault FileName FileDescription
  353.     ${IfNot} ${FileExists} "$INSTALLAPPDIRECTORY\App\AppInfo\${FileName}"
  354.     ${AndIf} $PluginInstaller != "true"
  355.         ${If} $USEEXTRACTEDICON == "true"
  356.             !if ${FileName} == appicon.ico
  357.             ;Copy the default icon in (appicon_*.png don't get included)
  358.             CopyFiles /SILENT "$EXEDIR\App\default_bits\${FileName}" "$INSTALLAPPDIRECTORY\App\AppInfo"
  359.             !endif
  360.         ${ElseIf} $INTERACTIVEMODE = 1
  361.         ${AndIf} ${Cmd} ${|} MessageBox MB_ICONQUESTION|MB_YESNO "The app does not have ${FileDescription} (${FileName}) in the App\AppInfo directory.  Would you like to use a default icon for test purposes for now?" IDYES ${|}
  362.             CopyFiles /SILENT "$EXEDIR\App\default_bits\${FileName}" "$INSTALLAPPDIRECTORY\App\AppInfo"
  363.             MessageBox MB_ICONINFORMATION "Before releasing this application, please be sure to create a proper ${FileName} app icon in App\AppInfo."
  364.         ${Else}
  365.             ${WriteErrorToLog} "No ${FileName} in $INSTALLAPPDIRECTORY\App\AppInfo."
  366.         ${EndIf}
  367.     ${EndIf}
  368.     !macroend
  369.  
  370.     !insertmacro AppInfoFileMissingAskInsertDefault appicon_16.png "a 16x16 PNG icon"
  371.     !insertmacro AppInfoFileMissingAskInsertDefault appicon_32.png "a 32x32 PNG icon"
  372.     !insertmacro AppInfoFileMissingAskInsertDefault appicon.ico    "an icon"
  373.  
  374.     ${If} $PluginInstaller == "true"
  375.         FileOpen $0 "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstallerPluginConfig.nsh" a
  376.     ${Else}
  377.         FileOpen $0 "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstallerConfig.nsh" a
  378.     ${EndIf}
  379.     FileSeek $0 0 END
  380.     FileWriteUTF16LE $0 `;Code generated by PortableApps.com Installer ${FRIENDLYVER}.  DO NOT EDIT.$\r$\n$\r$\n`
  381.  
  382.     ;PortableApps.comFormat Version
  383.     ${ReadINIStrWithDefault} $1 $AppInfoINIFile "Format" "Version" ""
  384.     ${If} $1 == "0.9.8"
  385.         ;Preserve old installer config in case it's needed
  386.         Rename "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstallerConfig.nsh" "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstallerConfigOld.nsh"
  387.  
  388.         ;Autogenerate App ID is handled normally when interactive
  389.  
  390.         ;Language selection is handled normally when in interactive
  391.  
  392.         ;This brings it up to 0.90
  393.         StrCpy $1 "0.90"
  394.     ${EndIf}
  395.     ${If} $1 == "0.90"
  396.         ;0.90 to 0.91 needs no changes, so it brings it to 0.91
  397.         StrCpy $1 "0.91"
  398.     ${EndIf}
  399.     ${If} $1 == "0.91"
  400.         ;0.91 to 1.0 needs no changes, so it brings it to 1.0
  401.         StrCpy $1 "1.0"
  402.     ${EndIf}
  403.     ${If} $1 == "1.0"
  404.         ;1.0 to 2.0 needs no changes, so it brings it to 2.0
  405.         WriteINIStr $AppInfoINIFile "Format" "Version" "${PORTABLEAPPS.COMFORMATVERSION}"
  406.     ${EndIf}
  407.  
  408.     !macro GetValueFromAppInfo Section Key Prompt DefaultValue Variable Required
  409.         ReadINIStr ${Variable} $AppInfoINIFile ${Section} ${Key}
  410.         ${If} ${Variable} == ""
  411.             ${If} $INTERACTIVEMODE = 1
  412.                 ${InputTextBox} "${APPNAME}" "${Prompt}" "${DefaultValue}" "255" "OK" "Cancel" 9
  413.                 ${If} $9 != ""
  414.                     StrCpy ${Variable} $9
  415.                     WriteINIStr $AppInfoINIFile ${Section} ${Key} $9
  416.                 !if ${Required} == required
  417.                 ${Else}
  418.                     ${WriteErrorToLog} "AppInfo.ini - ${Section} - ${Key} is missing."
  419.                 !endif
  420.                 ${EndIf}
  421.             !if ${Required} == required
  422.             ${Else}
  423.                 ${WriteErrorToLog} "AppInfo.ini - ${Section} - ${Key} is missing."
  424.             !endif
  425.             ${EndIf}
  426.         ${EndIf}
  427.     !macroend
  428.  
  429.     ;App Name
  430.     !insertmacro GetValueFromAppInfo \
  431.         Details \
  432.         Name \
  433.         "Enter the portable app's name (e.g. FileZilla Portable):" \
  434.         "AppName Portable" \
  435.         $PORTABLEAPPNAME \
  436.         required
  437.  
  438.     ${If} $PluginInstaller != "true"
  439.         ${WriteConfig} PORTABLEAPPNAME "$PORTABLEAPPNAME"
  440.         ${WordReplace} $PORTABLEAPPNAME "&" "~~~@@@~~~" + $PORTABLEAPPNAMEDOUBLEDAMPERSANDS
  441.         ${WordReplace} $PORTABLEAPPNAMEDOUBLEDAMPERSANDS "~~~@@@~~~" "&&" + $PORTABLEAPPNAMEDOUBLEDAMPERSANDS
  442.         ${WriteConfig} PORTABLEAPPNAMEDOUBLEDAMPERSANDS "$PORTABLEAPPNAMEDOUBLEDAMPERSANDS"
  443.     ${EndIf}
  444.  
  445.     ;Plugin Name
  446.     ${If} $PluginInstaller == "true"
  447.         !insertmacro GetValueFromAppInfo \
  448.             Details \
  449.             PluginName \
  450.             "Enter the plugin's name (e.g. Acme Plugin):" \
  451.             "Plugin" \
  452.             $PLUGINNAME \
  453.             required
  454.  
  455.         ${WriteConfig} PLUGINNAME "$PLUGINNAME"
  456.         ${WriteConfig} PORTABLEAPPNAME "$PLUGINNAME"
  457.         ${WordReplace} $PLUGINNAME "&" "~~~@@@~~~" + $PORTABLEAPPNAMEDOUBLEDAMPERSANDS
  458.         ${WordReplace} $PORTABLEAPPNAMEDOUBLEDAMPERSANDS "~~~@@@~~~" "&&" + $PORTABLEAPPNAMEDOUBLEDAMPERSANDS
  459.         ${WriteConfig} PORTABLEAPPNAMEDOUBLEDAMPERSANDS "$PORTABLEAPPNAMEDOUBLEDAMPERSANDS"
  460.         ${ReadINIStrWithDefault} $1 $AppInfoINIFile "Details" "PluginType" "App"
  461.         ${If} $1 == "CommonFiles"
  462.             StrCpy $COMMONFILESPLUGIN "true"
  463.             ${WriteConfig} COMMONFILESPLUGIN "true"
  464.         ${EndIf}
  465.     ${EndIf}
  466.  
  467.  
  468.     ;App ID
  469.     ${WordReplace} $PORTABLEAPPNAME " "   ""  + $8
  470.     ${WordReplace} $8               " "   "_" + $8
  471.     ${WordReplace} $8               "("   ""  + $8
  472.     ${WordReplace} $8               ")"   ""  + $8
  473.     ${WordReplace} $8               "["   ""  + $8
  474.     ${WordReplace} $8               "]"   ""  + $8
  475.     ${WordReplace} $8               "~"   "-" + $8
  476.     ${WordReplace} $8               "&"   "+" + $8
  477.     ${WordReplace} $8               "#"   "+" + $8
  478.     ${WordReplace} $8               "$\"" "-" + $8
  479.     ${WordReplace} $8               "*"   "+" + $8
  480.     ${WordReplace} $8               "/"   "_" + $8
  481.     ${WordReplace} $8               "\"   "_" + $8
  482.     ${WordReplace} $8               ":"   "." + $8
  483.     ${WordReplace} $8               "<"   "-" + $8
  484.     ${WordReplace} $8               ">"   "-" + $8
  485.     ${WordReplace} $8               "?"   ""  + $8
  486.     ${WordReplace} $8               "|"   "-" + $8
  487.     ${WordReplace} $8               "="   "-" + $8
  488.     ${WordReplace} $8               ","   "." + $8
  489.     ${WordReplace} $8               ";"   "." + $8
  490.     !insertmacro GetValueFromAppInfo \
  491.         Details \
  492.         AppID \
  493.         "Enter the portable app's App ID (usually the name with no spaces or symbols):" \
  494.         $8 \
  495.         $APPID \
  496.         required
  497.  
  498.     ${WriteConfig} APPID "$APPID"
  499.     StrCpy $SHORTNAME $APPID
  500.  
  501.     ;Publisher
  502.     !insertmacro GetValueFromAppInfo \
  503.         Details \
  504.         Publisher \
  505.         "Enter the publisher ('App Developer && PortableApps.com' for our apps):" \
  506.         "No Publisher Specified" \
  507.         $1 \
  508.         optional
  509.  
  510.     ;Homepage
  511.     !insertmacro GetValueFromAppInfo \
  512.         Details \
  513.         Homepage \
  514.         "Enter the app's homepage (e.g. portableapps.com):" \
  515.         "example.com" \
  516.         $1 \
  517.         optional
  518.  
  519.     ;Category
  520.     !insertmacro GetValueFromAppInfo \
  521.         Details \
  522.         Category \
  523.         "Enter the app's category *exactly* (Accessibility, Development, Education, Games, Graphics && Pictures, Internet, Music && Video, Office, Operating Systems, Utilities):" \
  524.         "" \
  525.         $1 \
  526.         optional
  527.  
  528.     ;Description
  529.     !insertmacro GetValueFromAppInfo \
  530.         Details \
  531.         Description \
  532.         "Enter the app's description (e.g. Simple FTP program.):" \
  533.         "" \
  534.         $1 \
  535.         optional
  536.  
  537.     ;Language
  538.     !insertmacro GetValueFromAppInfo \
  539.         Details \
  540.         Language \
  541.         "Enter the portable app's language as expected by NSIS (e.g. English or Multilingual):" \
  542.         "English" \
  543.         $APPLANGUAGE \
  544.         optional
  545.     ${If} $APPLANGUAGE == ""
  546.         StrCpy $APPLANGUAGE "English"
  547.     ${EndIf}
  548.  
  549.     !macro GetLicenseValueFromAppInfo Key Prompt
  550.         ReadINIStr $1 $AppInfoINIFile License ${Key}
  551.         ${If} $1 == ""
  552.             ${If} $INTERACTIVEMODE = 1
  553.                 ${If} ${Cmd} ${|} MessageBox MB_ICONQUESTION|MB_YESNO "License Question: ${Prompt}" IDYES ${|}
  554.                     StrCpy $1 "true"
  555.                 ${Else}
  556.                     StrCpy $1 "false"
  557.                 ${EndIf}
  558.                 WriteINIStr $AppInfoINIFile License ${Key} $1
  559.             ${EndIf}
  560.         ${EndIf}
  561.     !macroend
  562.  
  563.     ;License
  564.     !insertmacro GetLicenseValueFromAppInfo Shareable     "Can this application be legally shared from one user to another?"
  565.     !insertmacro GetLicenseValueFromAppInfo OpenSource    "Is this application 100% open source under an OSI-approved license?"
  566.     !insertmacro GetLicenseValueFromAppInfo Freeware      "Is this application freeware (it can be used without payment)?"
  567.     !insertmacro GetLicenseValueFromAppInfo CommercialUse "Can this app be used in a commercial environment?"
  568.  
  569.     ;EULA Version
  570.     ${ReadINIStrWithDefault} $EULAVERSION $AppInfoINIFile "License" "EULAVersion" ""
  571.  
  572.     ;Display Version
  573.     !insertmacro GetValueFromAppInfo \
  574.         Version \
  575.         DisplayVersion \
  576.         "Enter the portable app's display version (e.g. 1.0 or 2.2 Beta 1):" \
  577.         "0.1" \
  578.         $DISPLAYVERSION \
  579.         required
  580.  
  581.     ;Package Version
  582.     !insertmacro GetValueFromAppInfo \
  583.         Version \
  584.         PackageVersion \
  585.         "Enter the portable app's package version as all numbers in the form X.X.X.X (e.g. 1.0.0.0 or 2.2.0.1):" \
  586.         "0.1.0.0" \
  587.         $1 \
  588.         required
  589.  
  590.     ${WriteConfig} VERSION "$1"
  591.  
  592.     ;Filename should only be alpha, numbers as well as:  + . - _
  593.     ${If} $PluginInstaller == "true"
  594.         StrCpy $INSTALLERFILENAME "$PLUGINNAME_$DISPLAYVERSION"
  595.     ${Else}
  596.         StrCpy $INSTALLERFILENAME "$APPID_$DISPLAYVERSION"
  597.     ${EndIf}
  598.  
  599.     ${If} $APPLANGUAGE != "Multilingual"
  600.         StrCpy $INSTALLERFILENAME "$INSTALLERFILENAME_$APPLANGUAGE"
  601.     ${EndIf}
  602.  
  603.     ${WordReplace} $INSTALLERFILENAME " "   "_"    + $INSTALLERFILENAME
  604.     ${WordReplace} $INSTALLERFILENAME "("   ""     + $INSTALLERFILENAME
  605.     ${WordReplace} $INSTALLERFILENAME ")"   ""     + $INSTALLERFILENAME
  606.     ${WordReplace} $INSTALLERFILENAME "["   ""     + $INSTALLERFILENAME
  607.     ${WordReplace} $INSTALLERFILENAME "]"   ""     + $INSTALLERFILENAME
  608.     ${WordReplace} $INSTALLERFILENAME "~"   "-"    + $INSTALLERFILENAME
  609.     ${WordReplace} $INSTALLERFILENAME "&"   "-"    + $INSTALLERFILENAME
  610.     ${WordReplace} $INSTALLERFILENAME "#"   "-"    + $INSTALLERFILENAME
  611.     ${WordReplace} $INSTALLERFILENAME "$\"" "-"    + $INSTALLERFILENAME
  612.     ${WordReplace} $INSTALLERFILENAME "*"   "-"    + $INSTALLERFILENAME
  613.     ${WordReplace} $INSTALLERFILENAME "/"   "_"    + $INSTALLERFILENAME
  614.     ${WordReplace} $INSTALLERFILENAME "\"   "_"    + $INSTALLERFILENAME
  615.     ${WordReplace} $INSTALLERFILENAME ":"   "."    + $INSTALLERFILENAME
  616.     ${WordReplace} $INSTALLERFILENAME "<"   "-"    + $INSTALLERFILENAME
  617.     ${WordReplace} $INSTALLERFILENAME ">"   "-"    + $INSTALLERFILENAME
  618.     ${WordReplace} $INSTALLERFILENAME "?"   ""     + $INSTALLERFILENAME
  619.     ${WordReplace} $INSTALLERFILENAME "|"   "-"    + $INSTALLERFILENAME
  620.     ${WordReplace} $INSTALLERFILENAME "="   "-"    + $INSTALLERFILENAME
  621.     ${WordReplace} $INSTALLERFILENAME ","   "."    + $INSTALLERFILENAME
  622.     ${WordReplace} $INSTALLERFILENAME ";"   "."    + $INSTALLERFILENAME
  623.     ${WordReplace} $INSTALLERFILENAME "+"   "Plus" + $INSTALLERFILENAME
  624.  
  625.     ${ReadINIStrWithDefault} $1 $InstallerINIFile "DownloadFiles" "DownloadURL" ""
  626.     ${If} $1 != ""
  627.         StrCpy $INSTALLERFILENAME "$INSTALLERFILENAME_online"
  628.     ${EndIf}
  629.  
  630.     ${WriteConfig} FILENAME "$INSTALLERFILENAME"
  631.  
  632.    
  633.     ${ReadINIStrWithDefault} $1 $AppInfoINIFile "Control" "Start" ""
  634.         ${If} $1 == ""
  635.         ${WriteErrorToLog} "AppInfo.ini - Control - Start is missing."
  636.     ${EndIf}
  637.     ${IfNot} ${FileExists} "$INSTALLAPPDIRECTORY\$1"
  638.     ${AndIf} $PluginInstaller != "true"
  639.         ${WriteErrorToLog} "AppInfo.ini - Control - Start=$1, file is missing."
  640.     ${EndIf}
  641.  
  642.     ${ReadINIStrWithDefault} $2 $InstallerINIFile "CheckRunning" "CloseEXE" "$1"
  643.     ${WriteConfig} CHECKRUNNING "$2"
  644.     ${ReadINIStrWithDefault} $1 $InstallerINIFile "CheckRunning" "CloseName" "$PORTABLEAPPNAME"
  645.     ${WriteConfig} CLOSENAME "$1"
  646.     ${ReadINIStrWithDefault} $1 $AppInfoINIFile "SpecialPaths" "Plugins" "NONE"
  647.     ${WriteConfig} ADDONSDIRECTORYPRESERVE "$1"
  648.     ${WriteConfig} INSTALLERCOMMENTS "For additional details, visit PortableApps.com"
  649.     ${ReadINIStrWithDefault} $1 $AppInfoINIFile "Details" "Trademarks" ""
  650.     ${If} $1 != ""
  651.         StrCpy $1 "$1. "
  652.     ${EndIf}
  653.     ${WriteConfig} INSTALLERADDITIONALTRADEMARKS "$1"
  654.  
  655.     ;Source Code
  656.     ${ReadINIStrWithDefault} $INCLUDESOURCE $InstallerINIFile "Source" "IncludeInstallerSource" "false"
  657.     ${If} $INCLUDESOURCE == "true"
  658.         ${WriteConfig} INCLUDEINSTALLERSOURCE "true"
  659.     ${EndIf}
  660.  
  661.     ;Languages
  662.     ${If} $APPLANGUAGE != "Multilingual"
  663.         ${WriteConfig} INSTALLERLANGUAGE "$APPLANGUAGE"
  664.     ${Else}
  665.         ${WriteConfig} INSTALLERMULTILINGUAL "true"
  666.  
  667.         ${ReadINIStrWithDefault} $1 $InstallerINIFile "Languages" "English" ""
  668.         ${If} $1 == ""
  669.             StrCpy $ALLLANGUAGES "true"
  670.         ${EndIf}
  671.  
  672.         ${SetIndividualLanguage} "ENGLISH"
  673.         ${SetIndividualLanguage} "ENGLISHGB"
  674.         ${SetIndividualLanguage} "AFRIKAANS"
  675.         ${SetIndividualLanguage} "ALBANIAN"
  676.         ${SetIndividualLanguage} "ARABIC"
  677.         ${SetIndividualLanguage} "ARMENIAN"
  678.         ${SetIndividualLanguage} "BASQUE"
  679.         ${SetIndividualLanguage} "BELARUSIAN"
  680.         ${SetIndividualLanguage} "BOSNIAN"
  681.         ${SetIndividualLanguage} "BRETON"
  682.         ${SetIndividualLanguage} "BULGARIAN"
  683.         ${SetIndividualLanguage} "CATALAN"
  684.         ${SetIndividualLanguage} "CROATIAN"
  685.         ${SetIndividualLanguage} "CZECH"
  686.         ${SetIndividualLanguage} "DANISH"
  687.         ${SetIndividualLanguage} "DUTCH"
  688.         ${SetIndividualLanguage} "ESPERANTO"
  689.         ${SetIndividualLanguage} "ESTONIAN"
  690.         ${SetIndividualLanguage} "FARSI"
  691.         ${SetIndividualLanguage} "FINNISH"
  692.         ${SetIndividualLanguage} "FRENCH"
  693.         ${SetIndividualLanguage} "GALICIAN"
  694.         ${SetIndividualLanguage} "GERMAN"
  695.         ${SetIndividualLanguage} "GREEK"
  696.         ${SetIndividualLanguage} "HEBREW"
  697.         ${SetIndividualLanguage} "HUNGARIAN"
  698.         ${SetIndividualLanguage} "ICELANDIC"
  699.         ${SetIndividualLanguage} "INDONESIAN"
  700.         ${SetIndividualLanguage} "IRISH"
  701.         ${SetIndividualLanguage} "ITALIAN"
  702.         ${SetIndividualLanguage} "JAPANESE"
  703.         ${SetIndividualLanguage} "KOREAN"
  704.         ${SetIndividualLanguage} "KURDISH"
  705.         ${SetIndividualLanguage} "LATVIAN"
  706.         ${SetIndividualLanguage} "LITHUANIAN"
  707.         ${SetIndividualLanguage} "LUXEMBOURGISH"
  708.         ${SetIndividualLanguage} "MACEDONIAN"
  709.         ${SetIndividualLanguage} "MALAY"
  710.         ${SetIndividualLanguage} "MONGOLIAN"
  711.         ${SetIndividualLanguage} "NORWEGIAN"
  712.         ${SetIndividualLanguage} "NORWEGIANNYNORSK"
  713.         ${SetIndividualLanguage} "POLISH"
  714.         ${SetIndividualLanguage} "PORTUGUESE"
  715.         ${SetIndividualLanguage} "PORTUGUESEBR"
  716.         ${SetIndividualLanguage} "ROMANIAN"
  717.         ${SetIndividualLanguage} "RUSSIAN"
  718.         ${SetIndividualLanguage} "SERBIAN"
  719.         ${SetIndividualLanguage} "SERBIANLATIN"
  720.         ${SetIndividualLanguage} "SIMPCHINESE"
  721.         ${SetIndividualLanguage} "SLOVAK"
  722.         ${SetIndividualLanguage} "SLOVENIAN"
  723.         ${SetIndividualLanguage} "SPANISH"
  724.         ${SetIndividualLanguage} "SPANISHINTERNATIONAL"
  725.         ${SetIndividualLanguage} "SWEDISH"
  726.         ${SetIndividualLanguage} "THAI"
  727.         ${SetIndividualLanguage} "TRADCHINESE"
  728.         ${SetIndividualLanguage} "TURKISH"
  729.         ${SetIndividualLanguage} "UKRAINIAN"
  730.         ${SetIndividualLanguage} "UZBEK"
  731.         ${SetIndividualLanguage} "WELSH"
  732.     ${EndIf}
  733.  
  734.     ;EULA
  735.     ${If} $PluginInstaller == "true"
  736.         ${If} ${FileExists} "$INSTALLAPPDIRECTORY\Other\Source\PluginEULA.txt"
  737.             ${WriteConfig} LICENSEAGREEMENT "PluginEULA.txt"
  738.         ${ElseIf} ${FileExists} "$INSTALLAPPDIRECTORY\Other\Source\PluginEULA.rtf"
  739.             ${WriteConfig} LICENSEAGREEMENT "PluginEULA.rtf"
  740.         ${EndIf}
  741.     ${Else}
  742.         ${If} ${FileExists} "$INSTALLAPPDIRECTORY\Other\Source\EULA.txt"
  743.             ${WriteConfig} LICENSEAGREEMENT "eula.txt"
  744.         ${ElseIf} ${FileExists} "$INSTALLAPPDIRECTORY\Other\Source\EULA.rtf"
  745.             ${WriteConfig} LICENSEAGREEMENT "eula.rtf"
  746.         ${EndIf}
  747.     ${EndIf}
  748.  
  749.     ${If} $EULAVERSION != ""
  750.         ${WriteConfig} EULAVERSION "$EULAVERSION"
  751.     ${EndIf}
  752.  
  753.     ;OptionalComponents
  754.     ${ReadINIStrWithDefault} $OPTIONALCOMPONENTS $InstallerINIFile "OptionalComponents" "OptionalComponents" "false"
  755.     ${If} $OPTIONALCOMPONENTS == "true"
  756.         ${ReadINIStrWithDefault} $1 $InstallerINIFile "OptionalComponents" "MainSectionTitle" "$PORTABLEAPPNAME (English) [Required]"
  757.         ${WriteConfig} MAINSECTIONTITLE "$1"
  758.         ${ReadINIStrWithDefault} $1 $InstallerINIFile "OptionalComponents" "MainSectionDescription" "Install the portable app"
  759.         ${WriteConfig} MAINSECTIONDESCRIPTION "$1"
  760.         ${ReadINIStrWithDefault} $1 $InstallerINIFile "OptionalComponents" "OptionalSectionTitle" "Additional Languages"
  761.         ${WriteConfig} OPTIONALSECTIONTITLE "$1"
  762.         ${ReadINIStrWithDefault} $1 $InstallerINIFile "OptionalComponents" "OptionalSectionDescription" "Add multilingual support for this app"
  763.         ${WriteConfig} OPTIONALSECTIONDESCRIPTION "$1"
  764.         ${ReadINIStrWithDefault} $OptionalSectionSelectedInstallType $InstallerINIFile "OptionalComponents" "OptionalSectionSelectedInstallType" "Multilingual"
  765.         ${WriteConfig} OPTIONALSECTIONSELECTEDINSTALLTYPE "$OptionalSectionSelectedInstallType"
  766.         ${ReadINIStrWithDefault} $1 $InstallerINIFile "OptionalComponents" "OptionalSectionNotSelectedInstallType" "English"
  767.         ${WriteConfig} OPTIONALSECTIONNOTSELECTEDINSTALLTYPE "$1"
  768.         ${ReadINIStrWithDefault} $1 $InstallerINIFile "OptionalComponents" "OptionalSectionPreSelectedIfNonEnglishInstall" "true"
  769.         ${If} $1 == "true"
  770.             ${WriteConfig} OPTIONALSECTIONPRESELECTEDIFNONENGLISHINSTALL "$1"
  771.         ${EndIf}
  772.  
  773.         ${If} $OptionalSectionSelectedInstallType == "Multilingual"
  774.             ${ReadINIStrWithDefault} $1 $InstallerINIFile "OptionalComponents" "OptionalSectionInstalledWhenSilent" "false"
  775.         ${Else}
  776.             ${ReadINIStrWithDefault} $1 $InstallerINIFile "OptionalComponents" "OptionalSectionInstalledWhenSilent" "true"
  777.         ${EndIf}
  778.  
  779.         ${If} $1 == "true"
  780.             ${WriteConfig} OPTIONALSECTIONINSTALLEDWHENSILENT "$1"
  781.         ${EndIf}
  782.     ${EndIf}
  783.  
  784.     ;Local Files
  785.     ${ReadINIStrWithDefault} $1 $InstallerINIFile "CopyLocalFiles" "CopyLocalFiles" "false"
  786.     ${If} $1 == "true"
  787.         ${WriteConfig} COPYLOCALFILES "true"
  788.  
  789.         !insertmacro TransferInstallerINIToConfig CopyLocalFiles CopyFromRegPath -
  790.         !insertmacro TransferInstallerINIToConfig CopyLocalFiles CopyFromRegKey -
  791.         !insertmacro TransferInstallerINIToConfig CopyLocalFiles CopyFromRegRemoveDirectories -
  792.         !insertmacro TransferInstallerINIToConfig CopyLocalFiles CopyFromDirectory -
  793.         !insertmacro TransferInstallerINIToConfig CopyLocalFiles CopyToDirectory -
  794.     ${EndIf}
  795.  
  796.     ;Download files
  797.     ${ReadINIStrWithDefault} $1 $InstallerINIFile "DownloadFiles" "DownloadURL" ""
  798.     ${If} $1 != ""
  799.         StrCpy $2 $1 7
  800.  
  801.         ${If} $2 == "http://"
  802.             ${WriteConfig} DownloadURL "$1"
  803.  
  804.             !insertmacro TransferInstallerINIToConfig DownloadFiles DownloadName          required
  805.             !insertmacro TransferInstallerINIToConfig DownloadFiles DownloadFilename      required
  806.             !insertmacro TransferInstallerINIToConfig DownloadFiles DownloadMD5           -
  807.             !insertmacro TransferInstallerINIToConfig DownloadFiles DownloadTo            -
  808.             !insertmacro TransferInstallerINIToConfig DownloadFiles AdditionalInstallSize required
  809.  
  810.             ${For} $R1 1 10
  811.                 ${ReadINIStrWithDefault} $1 $InstallerINIFile "DownloadFiles" "Extract$R1To" ""
  812.                 ${If} $1 != ""
  813.                     ${If} $1 == "<ROOT>"
  814.                         StrCpy $1 ""
  815.                     ${EndIf}
  816.                     ${WriteConfig} Extract$R1To "$1"
  817.                 ${EndIf}
  818.             ${Next}
  819.  
  820.             ${For} $R1 1 10
  821.                 ${ReadINIStrWithDefault} $1 $InstallerINIFile "DownloadFiles" "Extract$R1File" ""
  822.                 ${If} $1 != ""
  823.                     ${WriteConfig} Extract$R1File "$1"
  824.                 ${EndIf}
  825.             ${Next}
  826.  
  827.             ${For} $R1 1 10
  828.                 ${ReadINIStrWithDefault} $1 $InstallerINIFile "DownloadFiles" "AdvancedExtract$R1To" ""
  829.                 ${If} $1 != ""
  830.                     ${If} $1 == "<ROOT>"
  831.                         StrCpy $1 ""
  832.                     ${EndIf}
  833.                     ${WriteConfig} AdvancedExtract$R1To "$1"
  834.                 ${EndIf}
  835.             ${Next}
  836.  
  837.             ${For} $R1 1 10
  838.                 ${ReadINIStrWithDefault} $1 $InstallerINIFile "DownloadFiles" "AdvancedExtract$R1Filter" ""
  839.                 ${If} $1 != ""
  840.                     ${WriteConfig} AdvancedExtract$R1Filter "$1"
  841.                 ${EndIf}
  842.             ${Next}
  843.  
  844.             ${ReadINIStrWithDefault} $1 $InstallerINIFile "DownloadFiles" "DoubleExtractFilename" ""
  845.             ${If} $1 != ""
  846.                 ${WriteConfig} DoubleExtractFilename "$1"
  847.  
  848.                 ${For} $R1 1 10
  849.                     ${ReadINIStrWithDefault} $1 $InstallerINIFile "DownloadFiles" "DoubleExtract$R1To" ""
  850.                     ${If} $1 != ""
  851.                         ${If} $1 == "<ROOT>"
  852.                             StrCpy $1 ""
  853.                         ${EndIf}
  854.                         ${WriteConfig} DoubleExtract$R1To "$1"
  855.                     ${EndIf}
  856.                 ${Next}
  857.  
  858.                 ${For} $R1 1 10
  859.                     ${ReadINIStrWithDefault} $1 $InstallerINIFile "DownloadFiles" "DoubleExtract$R1Filter" ""
  860.                     ${If} $1 != ""
  861.                         ${WriteConfig} DoubleExtract$R1Filter "$1"
  862.                     ${EndIf}
  863.                 ${Next}
  864.  
  865.             ${EndIf}
  866.         ${Else}
  867.             ${WriteErrorToLog} "Installer.ini - DownloadFiles - DownloadURL must begin with http://"
  868.         ${EndIf}
  869.     ${EndIf}
  870.    
  871.     ;Main directories
  872.     ${If} $PluginInstaller == "true"
  873.     ${AndIf} $COMMONFILESPLUGIN != "true"
  874.         ${ReadINIStrWithDefault} $1 $InstallerINIFile "MainDirectories" "RemoveAppDirectory" "false"
  875.     ${Else}
  876.         ${ReadINIStrWithDefault} $1 $InstallerINIFile "MainDirectories" "RemoveAppDirectory" "true"
  877.     ${EndIf}
  878.     ${If} $1 == "true"
  879.         ${WriteConfig} REMOVEAPPDIRECTORY "true"
  880.     ${EndIf}
  881.     ${ReadINIStrWithDefault} $1 $InstallerINIFile "MainDirectories" "RemoveDataDirectory" "false"
  882.     ${If} $1 == "true"
  883.         ${WriteConfig} REMOVEDATADIRECTORY "true"
  884.     ${EndIf}
  885.     ${If} $PluginInstaller == "true"
  886.         ${ReadINIStrWithDefault} $1 $InstallerINIFile "MainDirectories" "RemoveOtherDirectory" "false"
  887.     ${Else}
  888.         ${ReadINIStrWithDefault} $1 $InstallerINIFile "MainDirectories" "RemoveOtherDirectory" "true"
  889.     ${EndIf}
  890.     ${If} $1 == "true"
  891.         ${WriteConfig} REMOVEOTHERDIRECTORY "true"
  892.     ${EndIf}
  893.  
  894.     ;Preserve directories
  895.     StrCpy $R1 1
  896.     ${Do}
  897.         ${ReadINIStrWithDefault} $1 $InstallerINIFile "DirectoriesToPreserve" "PreserveDirectory$R1" ""
  898.         ${If} $1 != ""
  899.             ${WriteConfig} PRESERVEDIRECTORY$R1 "$1"
  900.         ${EndIf}
  901.         IntOp $R1 $R1 + 1
  902.     ${LoopUntil} $R1 > 10
  903.  
  904.     ;Remove directories
  905.     StrCpy $R1 1
  906.     ${Do}
  907.         ${ReadINIStrWithDefault} $1 $InstallerINIFile "DirectoriesToRemove" "RemoveDirectory$R1" ""
  908.         ${If} $1 != ""
  909.             ${WriteConfig} REMOVEDIRECTORY$R1 "$1"
  910.         ${EndIf}
  911.         IntOp $R1 $R1 + 1
  912.     ${LoopUntil} $R1 > 10
  913.  
  914.     ;Preserve files
  915.     StrCpy $R1 1
  916.     ${Do}
  917.         ${ReadINIStrWithDefault} $1 $InstallerINIFile "FilesToPreserve" "PreserveFile$R1" ""
  918.         ${If} $1 != ""
  919.             ${WriteConfig} PRESERVEFILE$R1 "$1"
  920.         ${EndIf}
  921.         IntOp $R1 $R1 + 1
  922.     ${LoopUntil} $R1 > 10
  923.  
  924.     ;Remove files
  925.     StrCpy $R1 1
  926.     ${Do}
  927.         ${ReadINIStrWithDefault} $1 $InstallerINIFile "FilesToRemove" "RemoveFile$R1" ""
  928.         ${If} $1 != ""
  929.             ${WriteConfig} REMOVEFILE$R1 "$1"
  930.         ${EndIf}
  931.         IntOp $R1 $R1 + 1
  932.     ${LoopUntil} $R1 > 10
  933.  
  934.     ;Custom code
  935.     ${If} $PluginInstaller == "true"
  936.         StrCpy $9 "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstallerPluginCustom.nsh"
  937.     ${Else}
  938.         StrCpy $9 "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstallerCustom.nsh"
  939.     ${EndIf}
  940.     ${If} ${FileExists} $9
  941.         ${WriteConfig} USESCUSTOMCODE "true"
  942.     ${EndIf}
  943.  
  944.     FileClose $0
  945.  
  946.     ; If errors have occurred, there's no point in going on to the actual generation of it.
  947.     ${If} $ERROROCCURED != "true"
  948.         ;Make the installer header
  949.         ${If} $USEEXTRACTEDICON == "true"
  950.         ${OrIf} $PluginInstaller == "true"
  951.             CopyFiles /SILENT "$EXEDIR\App\default_bits\PortableApps.comInstallerHeader.bmp" "$INSTALLAPPDIRECTORY\Other\Source"
  952.             CopyFiles /SILENT "$EXEDIR\App\default_bits\PortableApps.comInstallerHeaderRTL.bmp" "$INSTALLAPPDIRECTORY\Other\Source"
  953.         ${Else}
  954.             ExecWait `"$EXEDIR\App\bin\MakeHeader.exe" "$INSTALLAPPDIRECTORY"`
  955.         ${EndIf}
  956.  
  957.         ;Move optional component files
  958.         ${If} $OPTIONALCOMPONENTS == "true"
  959.             CreateDirectory "$INSTALLAPPDIRECTORY\Optional1"
  960.  
  961.             ;Move directories
  962.             StrCpy $R1 1
  963.             ${Do}
  964.                 ${ReadINIStrWithDefault} $1 $InstallerINIFile "OptionalComponents" "OptionalDirectory$R1" "\COMPLETED\"
  965.                 ${If} $1 != ""
  966.                 ${AndIf} $1 != "\COMPLETED\"
  967.                     ${GetParent} "$INSTALLAPPDIRECTORY\Optional1\$1" $2
  968.                     CreateDirectory $2
  969.                     Rename "$INSTALLAPPDIRECTORY\$1" "$INSTALLAPPDIRECTORY\Optional1\$1"
  970.                 ${EndIf}
  971.                 IntOp $R1 $R1 + 1
  972.             ${LoopUntil} $1 == "\COMPLETED\"
  973.  
  974.             ;Move files
  975.             StrCpy $R1 1
  976.             ${Do}
  977.                 ${ReadINIStrWithDefault} $1 $InstallerINIFile "OptionalComponents" "OptionalFile$R1" "\COMPLETED\"
  978.                 ${If} $1 != ""
  979.                 ${AndIf} $1 != "\COMPLETED\"
  980.                     ${GetParent} "$INSTALLAPPDIRECTORY\Optional1\$1" $2
  981.                     CreateDirectory $2
  982.                     ${GetParent} "$INSTALLAPPDIRECTORY\$1" $3
  983.                     ${GetFileName} "$INSTALLAPPDIRECTORY\Optional1\$1" $4
  984.                     ${MoveFiles} DOS "$4" "$3" "$2"
  985.                 ${EndIf}
  986.                 IntOp $R1 $R1 + 1
  987.             ${LoopUntil} $1 == "\COMPLETED\"
  988.  
  989.         ${EndIf}
  990.  
  991.         ;Compile the installer
  992.         SetDetailsPrint ListOnly
  993.         ${If} $PluginInstaller == "true"
  994.             DetailPrint "Creating $PLUGINNAME installer..."
  995.         ${Else}
  996.             DetailPrint "Creating $PORTABLEAPPNAME installer..."
  997.         ${EndIf}
  998.         SetDetailsPrint none
  999.  
  1000.         ;Delete existing installer if there is one
  1001.         ${GetParent} $INSTALLAPPDIRECTORY $0
  1002.         Delete "$0\$INSTALLERFILENAME.paf.exe"
  1003.         ${If} ${FileExists} "$0\$INSTALLERFILENAME.paf.exe"
  1004.             MessageBox MB_OK|MB_ICONEXCLAMATION "Unable to delete file: $0\$INSTALLERFILENAME.paf.exe.  Please be sure the file is not in use"
  1005.             ${WriteErrorToLog} "Unable to delete file: $0\$INSTALLERFILENAME.paf.exe.  Please be sure the file is not in use."
  1006.         ${Else}
  1007.             SetOutPath "$EXEDIR\App\nsis"
  1008.             ${If} $PluginInstaller == "true"
  1009.                 ExecDos::exec `"$EXEDIR\App\nsis\makensis.exe" /O"$EXEDIR\Data\PortableApps.comInstallerLog.txt" "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstallerPlugin.nsi"` "" ""
  1010.             ${Else}
  1011.                 ExecDos::exec `"$EXEDIR\App\nsis\makensis.exe" /O"$EXEDIR\Data\PortableApps.comInstallerLog.txt" "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstaller.nsi"` "" ""
  1012.             ${EndIf}
  1013.         ${EndIf}
  1014.  
  1015.         ;Move optional component files back
  1016.         ${If} $OPTIONALCOMPONENTS == "true"
  1017.             ;Move directories
  1018.             StrCpy $R1 1
  1019.             ${Do}
  1020.                 ${ReadINIStrWithDefault} $1 $InstallerINIFile "OptionalComponents" "OptionalDirectory$R1" "\COMPLETED\"
  1021.                 ${If} $1 != ""
  1022.                 ${AndIf} $1 != "\COMPLETED\"
  1023.                     Rename "$INSTALLAPPDIRECTORY\Optional1\$1" "$INSTALLAPPDIRECTORY\$1"
  1024.                 ${EndIf}
  1025.                 IntOp $R1 $R1 + 1
  1026.             ${LoopUntil} $1 == "\COMPLETED\"
  1027.  
  1028.             ;Move files
  1029.             StrCpy $R1 1
  1030.             ${Do}
  1031.                 ${ReadINIStrWithDefault} $1 $InstallerINIFile "OptionalComponents" "OptionalFile$R1" "\COMPLETED\"
  1032.                 ${If} $1 != ""
  1033.                 ${AndIf} $1 != "\COMPLETED\"
  1034.                     ${GetParent} "$INSTALLAPPDIRECTORY\Optional1\$1" $2
  1035.                     ${GetParent} "$INSTALLAPPDIRECTORY\$1" $3
  1036.                     ${GetFileName} "$INSTALLAPPDIRECTORY\Optional1\$1" $4
  1037.                     ${MoveFiles} DOS "$4" "$2" "$3"
  1038.                 ${EndIf}
  1039.                 IntOp $R1 $R1 + 1
  1040.             ${LoopUntil} $1 == "\COMPLETED\"
  1041.  
  1042.             RMDir /r "$INSTALLAPPDIRECTORY\Optional1"
  1043.         ${EndIf}
  1044.     ${EndIf}
  1045.  
  1046.     ; Done
  1047.     SetDetailsPrint ListOnly
  1048.     DetailPrint " "
  1049.     DetailPrint "Processing complete."
  1050.  
  1051.     ${If} ${FileExists} "$0\$INSTALLERFILENAME.paf.exe"
  1052.     ${AndIf} $ERROROCCURED != "true"
  1053.         StrCpy $FINISHTITLE "Installer Created"
  1054.         StrCpy $FINISHTEXT "The installer has been created. Installer location:\r\n$0\r\n\r\nInstaller name:\r\n$INSTALLERFILENAME.paf.exe"
  1055.     ${Else}
  1056.         StrCpy $FINISHTITLE "An Error Occured"
  1057.         StrCpy $FINISHTEXT "The installer was not created.  You can view the log file for more information."
  1058.         StrCpy $ERROROCCURED "true"
  1059.     ${EndIf}
  1060.  
  1061.     SetDetailsPrint none
  1062.     ;Remove the installer files if not included
  1063.     ${If} $INCLUDESOURCE != "true"
  1064.     ${AndIf} $ERROROCCURED != "true"
  1065.         RMDir /r "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstallerLanguages\"
  1066.         Delete "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstaller.bmp"
  1067.         Delete "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstaller.ico"
  1068.         Delete "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstaller.nsi"
  1069.         Delete "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstallerConfig.nsh"
  1070.         Delete "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstallerDumpLogToFile.nsh"
  1071.         Delete "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstallerHeader.bmp"
  1072.         Delete "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstallerHeaderRTL.bmp"
  1073.         Delete "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstallerMoveFiles.nsh"
  1074.         Delete "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstallerPlugin.nsi"
  1075.         Delete "$INSTALLAPPDIRECTORY\Other\Source\PortableApps.comInstallerPluginConfig.nsh"
  1076.     ${EndIf}
  1077.  
  1078.     ;Remove the Source and Other directories if empty
  1079.     RMDir "$INSTALLAPPDIRECTORY\Other\Source"
  1080.     RMDir "$INSTALLAPPDIRECTORY\Other"
  1081. SectionEnd
  1082.  
  1083. Function ShowFinishPage
  1084.     ${If} $AUTOMATICCOMPILE == "true"
  1085.     ${AndIf} $ERROROCCURED != "true"
  1086.         Abort
  1087.     ${ElseIf} $ERROROCCURED == "true"
  1088.         !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Flags" "DISABLED"
  1089.         !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 5" "State" "1"
  1090.     ${EndIf}
  1091. FunctionEnd
  1092.  
  1093. Function RunOnFinish
  1094.     Exec `"$0\$INSTALLERFILENAME.paf.exe"`
  1095. FunctionEnd
  1096.  
  1097. Function .onGUIEnd
  1098.     RealProgress::Unload
  1099. FunctionEnd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement