electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

electrum.nsi (7342B)


      1 ;--------------------------------
      2 ;Include Modern UI
      3   !include "TextFunc.nsh" ;Needed for the $GetSize function. I know, doesn't sound logical, it isn't.
      4   !include "MUI2.nsh"
      5   
      6 ;--------------------------------
      7 ;Variables
      8 
      9   !define PRODUCT_NAME "Electrum"
     10   !define PRODUCT_WEB_SITE "https://github.com/spesmilo/electrum"
     11   !define PRODUCT_PUBLISHER "Electrum Technologies GmbH"
     12   !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
     13 
     14 ;--------------------------------
     15 ;General
     16 
     17   ;Name and file
     18   Name "${PRODUCT_NAME}"
     19   OutFile "dist/electrum-setup.exe"
     20 
     21   ;Default installation folder
     22   InstallDir "$PROGRAMFILES\${PRODUCT_NAME}"
     23 
     24   ;Get installation folder from registry if available
     25   InstallDirRegKey HKCU "Software\${PRODUCT_NAME}" ""
     26 
     27   ;Request application privileges for Windows Vista
     28   RequestExecutionLevel admin
     29 
     30   ;Specifies whether or not the installer will perform a CRC on itself before allowing an install
     31   CRCCheck on
     32   
     33   ;Sets whether or not the details of the install are shown. Can be 'hide' (the default) to hide the details by default, allowing the user to view them, or 'show' to show them by default, or 'nevershow', to prevent the user from ever seeing them.
     34   ShowInstDetails show
     35   
     36   ;Sets whether or not the details of the uninstall  are shown. Can be 'hide' (the default) to hide the details by default, allowing the user to view them, or 'show' to show them by default, or 'nevershow', to prevent the user from ever seeing them.
     37   ShowUninstDetails show
     38   
     39   ;Sets the colors to use for the install info screen (the default is 00FF00 000000. Use the form RRGGBB (in hexadecimal, as in HTML, only minus the leading '#', since # can be used for comments). Note that if "/windows" is specified as the only parameter, the default windows colors will be used.
     40   InstallColors /windows
     41   
     42   ;This command sets the compression algorithm used to compress files/data in the installer. (http://nsis.sourceforge.net/Reference/SetCompressor)
     43   SetCompressor /SOLID lzma
     44   
     45   ;Sets the dictionary size in megabytes (MB) used by the LZMA compressor (default is 8 MB).
     46   SetCompressorDictSize 64
     47   
     48   ;Sets the text that is shown (by default it is 'Nullsoft Install System vX.XX') in the bottom of the install window. Setting this to an empty string ("") uses the default; to set the string to blank, use " " (a space).
     49   BrandingText "${PRODUCT_NAME} Installer v${PRODUCT_VERSION}" 
     50   
     51   ;Sets what the titlebars of the installer will display. By default, it is 'Name Setup', where Name is specified with the Name command. You can, however, override it with 'MyApp Installer' or whatever. If you specify an empty string (""), the default will be used (you can however specify " " to achieve a blank string)
     52   Caption "${PRODUCT_NAME}"
     53 
     54   ;Adds the Product Version on top of the Version Tab in the Properties of the file.
     55   VIProductVersion 1.0.0.0
     56   
     57   ;VIAddVersionKey - Adds a field in the Version Tab of the File Properties. This can either be a field provided by the system or a user defined field.
     58   VIAddVersionKey ProductName "${PRODUCT_NAME} Installer"
     59   VIAddVersionKey Comments "The installer for ${PRODUCT_NAME}"
     60   VIAddVersionKey CompanyName "${PRODUCT_NAME}"
     61   VIAddVersionKey LegalCopyright "2013-2018 ${PRODUCT_PUBLISHER}"
     62   VIAddVersionKey FileDescription "${PRODUCT_NAME} Installer"
     63   VIAddVersionKey FileVersion ${PRODUCT_VERSION}
     64   VIAddVersionKey ProductVersion ${PRODUCT_VERSION}
     65   VIAddVersionKey InternalName "${PRODUCT_NAME} Installer"
     66   VIAddVersionKey LegalTrademarks "${PRODUCT_NAME} is a trademark of ${PRODUCT_PUBLISHER}" 
     67   VIAddVersionKey OriginalFilename "${PRODUCT_NAME}.exe"
     68 
     69 ;--------------------------------
     70 ;Interface Settings
     71 
     72   !define MUI_ABORTWARNING
     73   !define MUI_ABORTWARNING_TEXT "Are you sure you wish to abort the installation of ${PRODUCT_NAME}?"
     74   
     75   !define MUI_ICON "c:\electrum\electrum\gui\icons\electrum.ico"
     76   
     77 ;--------------------------------
     78 ;Pages
     79 
     80   !insertmacro MUI_PAGE_DIRECTORY
     81   !insertmacro MUI_PAGE_INSTFILES
     82   !insertmacro MUI_UNPAGE_CONFIRM
     83   !insertmacro MUI_UNPAGE_INSTFILES
     84 
     85 ;--------------------------------
     86 ;Languages
     87 
     88   !insertmacro MUI_LANGUAGE "English"
     89 
     90 ;--------------------------------
     91 ;Installer Sections
     92 
     93 ;Check if we have Administrator rights
     94 Function .onInit
     95 	UserInfo::GetAccountType
     96 	pop $0
     97 	${If} $0 != "admin" ;Require admin rights on NT4+
     98 		MessageBox mb_iconstop "Administrator rights required!"
     99 		SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
    100 		Quit
    101 	${EndIf}
    102 FunctionEnd
    103 
    104 Section
    105   SetOutPath $INSTDIR
    106 
    107   ;Uninstall previous version files
    108   RMDir /r "$INSTDIR\*.*"
    109   Delete "$DESKTOP\${PRODUCT_NAME}.lnk"
    110   Delete "$SMPROGRAMS\${PRODUCT_NAME}\*.*"
    111   
    112   ;Files to pack into the installer
    113   File /r "dist\electrum\*.*"
    114   File "c:\electrum\electrum\gui\icons\electrum.ico"
    115 
    116   ;Store installation folder
    117   WriteRegStr HKCU "Software\${PRODUCT_NAME}" "" $INSTDIR
    118 
    119   ;Create uninstaller
    120   DetailPrint "Creating uninstaller..."
    121   WriteUninstaller "$INSTDIR\Uninstall.exe"
    122 
    123   ;Create desktop shortcut
    124   DetailPrint "Creating desktop shortcut..."
    125   CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\electrum-${PRODUCT_VERSION}.exe" ""
    126 
    127   ;Create start-menu items
    128   DetailPrint "Creating start-menu items..."
    129   CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
    130   CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall.lnk" "$INSTDIR\Uninstall.exe" "" "$INSTDIR\Uninstall.exe" 0
    131   CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk" "$INSTDIR\electrum-${PRODUCT_VERSION}.exe" "" "$INSTDIR\electrum-${PRODUCT_VERSION}.exe" 0
    132   CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME} Testnet.lnk" "$INSTDIR\electrum-${PRODUCT_VERSION}.exe" "--testnet" "$INSTDIR\electrum-${PRODUCT_VERSION}.exe" 0
    133 
    134 
    135   ;Links bitcoin: URI's to Electrum
    136   WriteRegStr HKCU "Software\Classes\bitcoin" "" "URL:bitcoin Protocol"
    137   WriteRegStr HKCU "Software\Classes\bitcoin" "URL Protocol" ""
    138   WriteRegStr HKCU "Software\Classes\bitcoin" "DefaultIcon" "$\"$INSTDIR\electrum.ico, 0$\""
    139   WriteRegStr HKCU "Software\Classes\bitcoin\shell\open\command" "" "$\"$INSTDIR\electrum-${PRODUCT_VERSION}.exe$\" $\"%1$\""
    140 
    141   ;Adds an uninstaller possibility to Windows Uninstall or change a program section
    142   WriteRegStr HKCU "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
    143   WriteRegStr HKCU "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\Uninstall.exe"
    144   WriteRegStr HKCU "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
    145   WriteRegStr HKCU "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
    146   WriteRegStr HKCU "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
    147   WriteRegStr HKCU "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\electrum.ico"
    148 
    149   ;Fixes Windows broken size estimates
    150   ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
    151   IntFmt $0 "0x%08X" $0
    152   WriteRegDWORD HKCU "${PRODUCT_UNINST_KEY}" "EstimatedSize" "$0"
    153 SectionEnd
    154 
    155 ;--------------------------------
    156 ;Descriptions
    157 
    158 ;--------------------------------
    159 ;Uninstaller Section
    160 
    161 Section "Uninstall"
    162   RMDir /r "$INSTDIR\*.*"
    163 
    164   RMDir "$INSTDIR"
    165 
    166   Delete "$DESKTOP\${PRODUCT_NAME}.lnk"
    167   Delete "$SMPROGRAMS\${PRODUCT_NAME}\*.*"
    168   RMDir  "$SMPROGRAMS\${PRODUCT_NAME}"
    169   
    170   DeleteRegKey HKCU "Software\Classes\bitcoin"
    171   DeleteRegKey HKCU "Software\${PRODUCT_NAME}"
    172   DeleteRegKey HKCU "${PRODUCT_UNINST_KEY}"
    173 SectionEnd