diff options
Diffstat (limited to 'nsis/plugin-updater.nsi')
| -rw-r--r-- | nsis/plugin-updater.nsi | 173 |
1 files changed, 173 insertions, 0 deletions
diff --git a/nsis/plugin-updater.nsi b/nsis/plugin-updater.nsi new file mode 100644 index 0000000..efb4b15 --- /dev/null +++ b/nsis/plugin-updater.nsi | |||
| @@ -0,0 +1,173 @@ | |||
| 1 | ; Dependencies: | ||
| 2 | ; - nsisunz.dll Plug-in | ||
| 3 | ; - InstallOptions.dll Plug-in | ||
| 4 | ; | ||
| 5 | ; usage: plugin-updater.exe /ini 'path\to\some-install-options.ini' | ||
| 6 | ;-------------------------------- | ||
| 7 | |||
| 8 | !include "sylpheed-defs.nsh" | ||
| 9 | |||
| 10 | SetCompressor /SOLID lzma | ||
| 11 | |||
| 12 | ;-------------------------------- | ||
| 13 | |||
| 14 | !include "MUI.nsh" | ||
| 15 | !include "Sections.nsh" | ||
| 16 | !include "FileFunc.nsh" | ||
| 17 | !include "LogicLib.nsh" | ||
| 18 | |||
| 19 | ; location of nsisunz.dll | ||
| 20 | !addplugindir "." | ||
| 21 | |||
| 22 | ; MUI Settings | ||
| 23 | !define MUI_ABORTWARNING | ||
| 24 | !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install-blue.ico" | ||
| 25 | !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall-blue.ico" | ||
| 26 | |||
| 27 | ;-------------------------------- | ||
| 28 | |||
| 29 | !define INSTALL_OPTIONS_INI "$R2" | ||
| 30 | !define TEMP1 $R3 ;Temp variable | ||
| 31 | |||
| 32 | OutFile "plugin-updater.exe" | ||
| 33 | Name "${PRODUCT_NAME} Plugin Updater" | ||
| 34 | Caption "$(^Name)" | ||
| 35 | ShowInstDetails show | ||
| 36 | CompletedText "$(plugin_updater_completed_text)" | ||
| 37 | BrandingText "${INST_NAME} ${INST_VERSION}" | ||
| 38 | |||
| 39 | ; $INSTDIR | ||
| 40 | InstallDir "$PROGRAMFILES\${PRODUCT_NAME}" | ||
| 41 | InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" "" | ||
| 42 | |||
| 43 | ;Things that need to be extracted on startup (keep these lines before any File command!) | ||
| 44 | ;Only useful for BZIP2 compression | ||
| 45 | ;Use ReserveFile for your own InstallOptions INI files too! | ||
| 46 | |||
| 47 | ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll" | ||
| 48 | |||
| 49 | RequestExecutionLevel admin | ||
| 50 | XPStyle on | ||
| 51 | |||
| 52 | ;Order of pages | ||
| 53 | Page custom SetCustom ValidateCustom ": Select update plugins" ;Custom page. InstallOptions gets called in SetCustom. | ||
| 54 | !define MUI_PAGE_HEADER_TEXT "$(plugin_updater_extracting)" | ||
| 55 | !define MUI_PAGE_HEADER_SUBTEXT "$(plugin_updater_extracting_files)" | ||
| 56 | !define MUI_INSTFILESPAGE_FINISHHEADER_TEXT "$(plugin_updater_extracted)" | ||
| 57 | !define MUI_INSTFILESPAGE_FINISHHEADER_SUBTEXT "$(plugin_updater_extracted_description)" | ||
| 58 | !define MUI_INSTFILESPAGE_ABORTHEADER_TEXT "$(plugin_updater_extraction_aborted)" | ||
| 59 | !define MUI_INSTFILESPAGE_ABORTHEADER_SUBTEXT "$(plugin_updater_extraction_aborted_description)" | ||
| 60 | ; Instfiles page | ||
| 61 | !insertmacro MUI_PAGE_INSTFILES | ||
| 62 | |||
| 63 | ;-------------------------------- | ||
| 64 | ; Language files | ||
| 65 | !insertmacro MUI_LANGUAGE "English" # ${LANG_ENGLISH} | ||
| 66 | !insertmacro MUI_LANGUAGE "Spanish" # ${LANG_SPANISH} | ||
| 67 | !insertmacro MUI_LANGUAGE "Japanese" # ${LANG_JAPANESE} | ||
| 68 | |||
| 69 | !include "English.nsh" | ||
| 70 | !include "Spanish.nsh" | ||
| 71 | !include "Japanese.nsh" | ||
| 72 | ;-------------------------------- | ||
| 73 | |||
| 74 | Var field | ||
| 75 | Var NumFields | ||
| 76 | Var URL | ||
| 77 | Var basename | ||
| 78 | Var name | ||
| 79 | Var archive | ||
| 80 | |||
| 81 | Section "Components" | ||
| 82 | |||
| 83 | ;Get Install Options dialog user input | ||
| 84 | |||
| 85 | ;DetailPrint "TEMP=$TEMP" | ||
| 86 | |||
| 87 | ReadINIStr $NumFields "${INSTALL_OPTIONS_INI}" "Settings" "NumFields" | ||
| 88 | ;DetailPrint "NumFields=$NumFields" | ||
| 89 | |||
| 90 | StrCpy $field 1 | ||
| 91 | ${While} $field < $NumFields ; > | ||
| 92 | IntOp $field $field + 1 | ||
| 93 | ReadINIStr ${TEMP1} "${INSTALL_OPTIONS_INI}" "Field $field" "State" | ||
| 94 | StrCmp ${TEMP1} 0 skip | ||
| 95 | ReadINIStr $URL "${INSTALL_OPTIONS_INI}" "Field $field" "URL" | ||
| 96 | ReadINIStr $basename "${INSTALL_OPTIONS_INI}" "Field $field" "basename" | ||
| 97 | ReadINIStr $name "${INSTALL_OPTIONS_INI}" "Field $field" "name" | ||
| 98 | ;DetailPrint "Field $field State=${TEMP1}" | ||
| 99 | ;DetailPrint "Field $field URL=$URL" | ||
| 100 | ;DetailPrint "Field $field basename=$basename" | ||
| 101 | ;DetailPrint "Field $field name=$name" | ||
| 102 | StrCpy $archive "$TEMP\sylpheed-plugin-$basename.zip" | ||
| 103 | |||
| 104 | DetailPrint "$name:" | ||
| 105 | DetailPrint "Downloading from $URL" | ||
| 106 | DetailPrint " to $archive" | ||
| 107 | NSISdl::download \ | ||
| 108 | /TRANSLATE2 "$(downloading)" "$(connecting)" "$(second)" "$(minute)" "$(hour)" "$(seconds)" "$(minutes)" "$(hours)" "$(progress)" \ | ||
| 109 | /TIMEOUT=30000 "$URL" "$archive" | ||
| 110 | Pop $0 | ||
| 111 | StrCmp "$0" "success" download_ok | ||
| 112 | DetailPrint "$(download_failed) $0" | ||
| 113 | Abort | ||
| 114 | download_ok: | ||
| 115 | |||
| 116 | SetOutPath "$INSTDIR" | ||
| 117 | nsisunz::UnzipToLog /text "$(plugin_updater_nsisunz_text)" "$archive" "$INSTDIR" | ||
| 118 | |||
| 119 | ; Always check for errors. Everything else than "success" means an error. | ||
| 120 | Pop $0 | ||
| 121 | StrCmp $0 "success" extract_ok | ||
| 122 | Abort "$0" | ||
| 123 | extract_ok: | ||
| 124 | |||
| 125 | skip: | ||
| 126 | ${EndWhile} | ||
| 127 | |||
| 128 | SectionEnd | ||
| 129 | |||
| 130 | |||
| 131 | Function .onInit | ||
| 132 | InitPluginsDir | ||
| 133 | |||
| 134 | ${GetParameters} $R0 | ||
| 135 | ${GetOptions} "$R0" "/ini" "${INSTALL_OPTIONS_INI}" | ||
| 136 | |||
| 137 | StrCmp "${INSTALL_OPTIONS_INI}" "" 0 ini_option_found | ||
| 138 | MessageBox MB_ICONEXCLAMATION|MB_OK "usage: plugin-updater.exe /ini 'path\to\some-install-options.ini'" | ||
| 139 | Abort | ||
| 140 | ini_option_found: | ||
| 141 | FunctionEnd | ||
| 142 | |||
| 143 | Function SetCustom | ||
| 144 | ;Display the InstallOptions dialog | ||
| 145 | |||
| 146 | !insertmacro MUI_HEADER_TEXT "$(plugin_updater_header)" "$(plugin_updater_header_description)" | ||
| 147 | |||
| 148 | Push ${TEMP1} | ||
| 149 | |||
| 150 | InstallOptions::dialog "${INSTALL_OPTIONS_INI}" | ||
| 151 | Pop ${TEMP1} | ||
| 152 | |||
| 153 | Pop ${TEMP1} | ||
| 154 | |||
| 155 | FunctionEnd | ||
| 156 | |||
| 157 | Function ValidateCustom | ||
| 158 | |||
| 159 | ReadINIStr $NumFields "${INSTALL_OPTIONS_INI}" "Settings" "NumFields" | ||
| 160 | |||
| 161 | StrCpy $field 1 | ||
| 162 | ${While} $field < $NumFields ; > | ||
| 163 | IntOp $field $field + 1 | ||
| 164 | ReadINIStr ${TEMP1} "${INSTALL_OPTIONS_INI}" "Field $field" "State" | ||
| 165 | StrCmp ${TEMP1} 1 done | ||
| 166 | ${EndWhile} | ||
| 167 | |||
| 168 | MessageBox MB_ICONEXCLAMATION|MB_OK "$(plugin_updater_must_select)" | ||
| 169 | Abort | ||
| 170 | |||
| 171 | done: | ||
| 172 | |||
| 173 | FunctionEnd | ||
