-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-installer-b2g.nsi
224 lines (181 loc) · 7.7 KB
/
build-installer-b2g.nsi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
/**
* Installer for boot2gecko desktop client.
* This is an unofficial installer for the boot2gecko desktop client (https://wiki.mozilla.org/B2G)
*
* Create the following directory structure:
* installer/ (git clone https://github.com/sihorton/b2g-desktop-profile-installer)
* b2g-desktop-profile/ (git clone https://github.com/sihorton/b2g-desktop-profile)
* b2g-extract (http://ftp.mozilla.org/pub/mozilla.org/b2g/nightly/latest-mozilla-central/)
*
* @author: sihorton
*/
!define PRODUCT_NAME "b2g-gaia-desktop"
!define PRODUCT_PUBLISHER "sihorton"
!define PRODUCT_WEB_SITE "http://github.com/sihorton/b2g-desktop-profile-installer"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
!include "config.nsi"
!macro CreateInternetShortcut FILENAME URL
WriteINIStr "${FILENAME}.url" "InternetShortcut" "URL" "${URL}"
!macroend
; Welcome page
!insertmacro MUI_PAGE_WELCOME
; Components page
!insertmacro MUI_PAGE_COMPONENTS
; Directory page
!define MUI_DIRECTORYPAGE_TEXT_TOP 'If installing b2g-desktop then select the directory to install to. If you have selected to only instal Gaia UI to an existing b2g-desktop client then select the directory where b2g is installed on your machine.'
!insertmacro MUI_PAGE_DIRECTORY
; Start menu page
var ICONS_GROUP
!define MUI_STARTMENUPAGE_NODISABLE
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "b2g-gaia-desktop"
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_STARTMENU_REGVAL}"
!insertmacro MUI_PAGE_STARTMENU Application $ICONS_GROUP
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!define MUI_FINISHPAGE_TEXT "In b2g-desktop Press [Home] key to return to the homescreen after launching an app."
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_TEXT "Run ${PRODUCT_NAME}"
!define MUI_FINISHPAGE_RUN_FUNCTION "Launch-b2g"
;!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\${PROFILE_DIR_DEST}\install-readme.txt"
!insertmacro MUI_PAGE_FINISH
; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES
; Language files
!insertmacro MUI_LANGUAGE "English"
; MUI end ------
Name "${PRODUCT_NAME}"
OutFile "${PRODUCT_NAME}_${PRODUCT_VERSION}.exe"
InstallDir "$PROGRAMFILES\${PRODUCT_NAME}"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails hide
ShowUnInstDetails hide
Function .onInit
Var /GLOBAL DelDir
;try to see if it is running--
FindProcDLL::FindProc "b2g.exe"
IntCmp $R0 1 0 notRunning
MessageBox MB_OK|MB_ICONEXCLAMATION "b2g-desktop is running. Click ok to close the process." /SD IDOK
KillProcDLL::KillProc "b2g.exe"
notRunning:
ReadRegStr $DelDir ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "InstallDir"
; Check to see if already installed
ReadRegStr $R0 ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString"
IfFileExists $R0 +1 NotInstalled
MessageBox MB_YESNO "${PRODUCT_NAME} is already installed, should we uninstall the existing version first?$\nNo will install over the top of the existing version." IDYES Uninstall IDNO NotInstalled
Uninstall:
ExecWait '"$R0" /S _?=$INSTDIR'
Delete "$R0"
RmDir "$DelDir"
NotInstalled:
FunctionEnd
Section "b2g-desktop" SEC01
SetShellVarContext all
SetOverwrite ifnewer
SetOutPath "$INSTDIR"
CreateDirectory "$INSTDIR"
;install version info and launch / auto update.
File "version.txt"
File "b2g-desktop.exe"
File "b2g-update.exe"
;install code
File /r /x ".git" "${B2G_DIR_SRC}\"
File "${PROFILE_DIR_SRC}\gkmedias.dll"
; Shortcuts
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
CreateDirectory "$SMPROGRAMS\$ICONS_GROUP"
CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\${PRODUCT_NAME}.lnk" "$INSTDIR\b2g.exe"
CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\b2g.exe"
!insertmacro MUI_STARTMENU_WRITE_END
SectionEnd
Section "Gaia UI" SEC02
SetShellVarContext all
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
;Required gkmedias.dll is not part of b2g currently so add file if it is missing.
IfFileExists "$INSTDIR\gkmedias.dll" skipGkmediasFix doGkmediasFix
doGkmediasFix:
File "${PROFILE_DIR_SRC}\gkmedias.dll"
skipGkmediasFix:
;required file is now copied or already existed.
CreateDirectory "$INSTDIR\${PROFILE_DIR_DEST}"
;Copy in the desktop profile.
SetOutPath "$INSTDIR\${PROFILE_DIR_DEST}"
File /r /x ".git" /x "install.bat" "${PROFILE_DIR_SRC}\"
SetOutPath "$INSTDIR"
;CreateShortCut "$INSTDIR\b2g-desktop.lnk" "$INSTDIR\b2g.exe" \
;'-profile "${PROFILE_DIR_DEST}"'
; Shortcuts
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
CreateDirectory "$SMPROGRAMS\$ICONS_GROUP"
CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\${PRODUCT_NAME}.lnk" "$INSTDIR\b2g-desktop.exe"
;'-profile "${PROFILE_DIR_DEST}"'
CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\b2g-desktop.exe"
;'-profile "${PROFILE_DIR_DEST}"'
!insertmacro MUI_STARTMENU_WRITE_END
SectionEnd
; Section descriptions
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SEC01} "an emulator for running boot2gecko on a windows pc."
!insertmacro MUI_DESCRIPTION_TEXT ${SEC02} "Gaia is the user interface (webapps and os user interface) for boot2gecko"
!insertmacro MUI_FUNCTION_DESCRIPTION_END
Section -AdditionalIcons
SetShellVarContext all
SetOutPath $INSTDIR
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
!insertmacro CreateInternetShortcut \
"$SMPROGRAMS\$ICONS_GROUP\Website.url" \
"http://github.com/sihorton/b2g-desktop-profile-installer/"
!insertmacro CreateInternetShortcut \
"$SMPROGRAMS\$ICONS_GROUP\Boot2Gecko.url" \
"http://developer.mozilla.org/en/Mozilla/Boot_to_Gecko/"
!insertmacro CreateInternetShortcut \
"$SMPROGRAMS\$ICONS_GROUP\b2g-desktop downloads.url" \
"http://ftp.mozilla.org/pub/mozilla.org/b2g/nightly/latest-mozilla-central/"
CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Uninstall.lnk" "$INSTDIR\uninst.exe"
!insertmacro MUI_STARTMENU_WRITE_END
SectionEnd
Section -Post
SetShellVarContext all
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\b2g.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "InstallDir" "$INSTDIR"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\b2g.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd
Function un.onUninstSuccess
HideWindow
IfSilent +2 0
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
FunctionEnd
Function un.onInit
IfSilent silent noisy
noisy:
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
Abort
goto ok
silent:
SetAutoClose true
ok:
FunctionEnd
Section Uninstall
SetShellVarContext all
!insertmacro MUI_STARTMENU_GETFOLDER "Application" $ICONS_GROUP
Delete "$DESKTOP\${PRODUCT_NAME}.lnk"
RMDir /r "$SMPROGRAMS\$ICONS_GROUP"
RMDir /r "$INSTDIR\"
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
SetAutoClose true
SectionEnd
Function Launch-b2g
;ExecShell "" "$INSTDIR\b2g-desktop.lnk"
Exec "$INSTDIR\b2g-desktop.exe /NOUPDATE"
FunctionEnd