icecast.nsis 6.87 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
;NSIS based Icecast Installer
;Written by Thomas B. Rücker
;Initial version written by Stephan Jauernick
;Based on "Start Menu Folder Selection Example Script" by Joost Verburg

;--------------------------------
;Includes

; Modern UI
  !include "MUI2.nsh"

;File functions
  !include "FileFunc.nsh"

;--------------------------------
;General

  ;Name and file
  Name "Icecast"
  OutFile "icecast_win32_2.5-beta2.exe"

  ;Default installation folder
  InstallDir "$PROGRAMFILES32\Icecast"
24

25 26 27 28
  ;Get installation folder from registry if available
  InstallDirRegKey HKCU "Software\Xiph.org\Icecast" ""

  ;Request application privileges for Windows Vista
29
  RequestExecutionLevel admin
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51

  ;Installer icon
  !define MUI_ICON "bin/icecast.ico"
  !define MUI_HEADERIMAGE
  !define MUI_HEADERIMAGE_BITMAP "icecast2logo3.bmp"
  !define MUI_HEADERIMAGE_RIGHT

  !define /date BUILDTIMESTAMP "%Y-%m-%dT%H:%M:%S+%z"

;--------------------------------
;Variables

  Var RegistryPathForUninstall
  Var StartMenuFolder
  Var EstimatedSize
  Var Day
  Var Month
  Var Year
  Var DoW
  Var Hour
  Var Minute
  Var Second
52

53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
;--------------------------------
; Create URL file macro

  !macro CreateInternetShortcut FILENAME URL ICONFILE ICONINDEX
  WriteINIStr "${FILENAME}.url" "InternetShortcut" "URL" "${URL}"
  WriteINIStr "${FILENAME}.url" "InternetShortcut" "IconFile" "${ICONFILE}"
  WriteINIStr "${FILENAME}.url" "InternetShortcut" "IconIndex" "${ICONINDEX}"
  !macroend

;--------------------------------
;Interface Settings

  !define MUI_ABORTWARNING

;--------------------------------
;Pages

  !insertmacro MUI_PAGE_LICENSE doc/COPYING
  !insertmacro MUI_PAGE_COMPONENTS
  !insertmacro MUI_PAGE_DIRECTORY
73

74
  ;Start Menu Folder Page Configuration
75 76
  !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
  !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\Xiph.org\Icecast"
77
  !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
78

79
  !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
80

81
  !insertmacro MUI_PAGE_INSTFILES
82

83 84 85 86 87
  !insertmacro MUI_UNPAGE_CONFIRM
  !insertmacro MUI_UNPAGE_INSTFILES

;--------------------------------
;Languages
88

89 90 91 92 93 94 95 96 97 98 99 100
  !insertmacro MUI_LANGUAGE "English"

;--------------------------------
;Installer Sections

Section "Icecast" SecIcecastWin32

  ;Image - not supported on non-win32 builds
  ;AddBrandingImage left 175 32
  ;SetBrandingImage "icecast2logo2.bmp"

  SetOutPath "$INSTDIR"
101

102
  ;ADD YOUR OWN FILES HERE...
103

104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
  File /r "bin"
  File /r "doc"
  File /r "web"
  File /r "admin"
  File "mime.types"
  File "icecast.bat"
  ;OMG my eyes, why is Goto inherent
  IfFileExists "$INSTDIR\icecast.xml" config_exists config_nonexistent
  config_exists:
    Goto config_done
  config_nonexistent:
    File "icecast.xml"
  config_done:

  ;Store installation folder
  WriteRegStr HKCU "Software\Xiph.org\Icecast" "" $INSTDIR
120

121 122 123 124 125 126 127 128 129 130 131 132
  ;Determine installed size (will include all files, even user placed in $INSTDIR!)
  ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
  IntFmt $EstimatedSize "0x%08X" $0

  ${GetTime} "" "LS" $Day $Month $Year $DoW $Hour $Minute $Second

  ;Registry path for Windows uninstaller and software management
  StrCpy $RegistryPathForUninstall "Software\Microsoft\Windows\CurrentVersion\Uninstall\Xiph.org-Icecast"

  ;Create uninstaller
  WriteUninstaller "$INSTDIR\Uninstall.exe"
  WriteRegDWORD HKLM $RegistryPathForUninstall "EstimatedSize" "$EstimatedSize"
133
  WriteRegStr   HKLM $RegistryPathForUninstall "DisplayName" "Icecast"
134 135 136 137 138 139 140 141 142 143 144 145 146 147
  WriteRegStr   HKLM $RegistryPathForUninstall "UninstallString" "$\"$INSTDIR\Uninstall.exe$\""
  WriteRegStr   HKLM $RegistryPathForUninstall "DisplayIcon" "$INSTDIR\bin\icecast.ico"
  WriteRegStr   HKLM $RegistryPathForUninstall "Publisher" "Xiph.org Foundation / The Icecast Project"
  WriteRegStr   HKLM $RegistryPathForUninstall "HelpLink" "http://icecast.org/contact"
  WriteRegStr   HKLM $RegistryPathForUninstall "URLInfoAbout" "http://icecast.org/"
  WriteRegStr   HKLM $RegistryPathForUninstall "DisplayVersion" "2.5 beta2"
  WriteRegStr   HKLM $RegistryPathForUninstall "InstallLocation" "$INSTDIR"
  WriteRegStr   HKLM $RegistryPathForUninstall "InstallDate" "$Year$Month$Day"
  WriteRegDWORD HKLM $RegistryPathForUninstall "NoModify" 0x1
  WriteRegDWORD HKLM $RegistryPathForUninstall "NoRepair" 0x1
  WriteRegDWORD HKLM $RegistryPathForUninstall "VersionMajor" 0x2
  WriteRegDWORD HKLM $RegistryPathForUninstall "VersionMinor" 0x4
  WriteRegDWORD HKLM $RegistryPathForUninstall "VersionServicePack" 0x63
  ;WriteRegStr HKLM "$RegistryPathForUninstall "" ""
148

149 150

  !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
151

152 153 154 155 156 157 158
    ;Create shortcuts
    CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
    CreateShortcut "$SMPROGRAMS\$StartMenuFolder\Run Icecast (Console).lnk" "$INSTDIR\icecast.bat" "" "$INSTDIR\bin\icecast.ico" "" "" "" "Icecast (Starts in a console window)"
    CreateShortcut "$SMPROGRAMS\$StartMenuFolder\Icecast Config.lnk" "%SystemRoot%\system32\notepad.exe" "$INSTDIR\icecast.xml" "" "" "" "" "Open Icecast config for editing in Notepad"
    !insertmacro CreateInternetShortcut "$SMPROGRAMS\$StartMenuFolder\Icecast web status (public)" "http://127.0.0.1:8000/" "$INSTDIR\bin\icecast.ico" "0"
    !insertmacro CreateInternetShortcut "$SMPROGRAMS\$StartMenuFolder\Icecast web admin interface" "http://127.0.0.1:8000/admin/" "$INSTDIR\bin\icecast.ico" "0"
    CreateShortcut "$SMPROGRAMS\$StartMenuFolder\Icecast documentation.lnk" "$INSTDIR\doc\index.html"
159

160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
  !insertmacro MUI_STARTMENU_WRITE_END

  ;Create logging directory
  CreateDirectory "$INSTDIR\log"

SectionEnd

;--------------------------------
;Descriptions

  ;Language strings
  LangString DESC_SecIcecastWin32 ${LANG_ENGLISH} "Icecast for win32 with all required files and libraries"

  ;Assign language strings to sections
  !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
    !insertmacro MUI_DESCRIPTION_TEXT ${SecIcecastWin32} $(DESC_SecIcecastWin32)
  !insertmacro MUI_FUNCTION_DESCRIPTION_END
177

178 179 180 181 182 183 184 185 186 187 188 189 190 191
;--------------------------------
;Uninstaller Section

Section "Uninstall"

  ;ADD YOUR OWN FILES HERE...
  RMDir /r "$INSTDIR\bin"
  RMDir /r "$INSTDIR\doc"
  Delete "$INSTDIR\mime.types"
  Delete "$INSTDIR\icecast.bat"

  Delete "$INSTDIR\Uninstall.exe"

  RMDir "$INSTDIR"
192

193
  !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
194

195 196 197 198 199 200 201 202 203 204
  Delete "$SMPROGRAMS\$StartMenuFolder\Run Icecast (Console).lnk"
  Delete "$SMPROGRAMS\$StartMenuFolder\Icecast Config.lnk"
  Delete "$SMPROGRAMS\$StartMenuFolder\Icecast documentation.lnk"
  Delete "$SMPROGRAMS\$StartMenuFolder\Icecast web status (public).url"
  Delete "$SMPROGRAMS\$StartMenuFolder\Icecast web admin interface.url"
  RMDir "$SMPROGRAMS\$StartMenuFolder"

  ;Registry path for Windows uninstaller and software management
  StrCpy $RegistryPathForUninstall "Software\Microsoft\Windows\CurrentVersion\Uninstall\Xiph.org-Icecast"
  DeleteRegKey HKLM "$RegistryPathForUninstall"
205

206 207 208 209 210 211 212
  ;DeleteRegKey /ifempty HKCU "Software\Xiph.org\Icecast"

SectionEnd

Function .onInit
  SectionSetFlags ${SecIcecastWin32} 17
FunctionEnd