tazusb view win32/tazusb.nsi @ rev 143
tazusb: update VERSION
author | Richard Dunbar <mojo@slitaz.org> |
---|---|
date | Tue Apr 23 01:22:11 2013 +0000 (2013-04-23) |
parents | 102764ce0603 |
children | 244df7906749 |
line source
1 ; Tazusb
2 ; Windows installer for Slitaz
3 ; (c) 2009 Cedric Tissieres (slitaz@objectif-securite.ch)
4 ; You'll need to put 7z.exe and 7z.dll from http://www.7-zip.org/ and syslinux.exe from http://syslinux.zytor.com/
5 ; in the NSIS plugins directory before compiling the script. Adapt the FROM_DIR constant too.
6 ; To add a translation, add the corresponding "!insertmacro MUI_LANGUAGE" and translates all the LangString you'll find below.
8 !define NAME "TazUSB - SliTaz LiveUSB utility "
9 !define FILENAME "tazusb"
10 !define VERSION "v0.2"
11 !define FROM_DIR "C:\ophcrack\livecd"
13 SetCompressor LZMA
14 CRCCheck On
15 XPStyle on
17 !include "MUI2.nsh"
18 !include "FileFunc.nsh"
21 # MUI Settings #####################################
22 ;**************
24 ; Interface settings
25 !define MUI_FINISHPAGE_NOAUTOCLOSE
26 !define MUI_HEADERIMAGE
27 !define MUI_HEADERIMAGE_BITMAP "${FROM_DIR}\slitaz-logo-nsis.bmp"
28 !define MUI_HEADERIMAGE_BITMAP_NOSTRETCH
30 ; Welcome page
31 !define MUI_WELCOMEPAGE_TITLE $(Welcome_Title)
32 !define MUI_WELCOMEPAGE_TEXT $(Welcome_Text)
33 !insertmacro MUI_PAGE_WELCOME
34 ; ISO page
35 Var IsoFileHw
36 Var IsoFile
37 Var Label
38 Var Label2
39 Page custom isoFilePage
40 ; Drive page
41 Var DestDriveHW
42 Var DestDrive
43 Page custom drivePage
44 ; Warning page
45 Page custom warningPage
46 ; Instfiles page
47 !insertmacro MUI_PAGE_INSTFILES
48 ; Finish page
49 !define MUI_FINISHPAGE_TITLE $(Finish_Title)
50 !define MUI_FINISHPAGE_TEXT $(Finish_Text)
51 !define MUI_FINISHPAGE_LINK $(Finish_Link)
52 !define MUI_FINISHPAGE_LINK_LOCATION "http://slitaz.org"
53 !insertmacro MUI_PAGE_FINISH
55 ; Language files
56 !insertmacro MUI_LANGUAGE "English" ;first language is the default language
57 !insertmacro MUI_LANGUAGE "French"
58 !insertmacro MUI_LANGUAGE "Portuguese"
61 ; Reserve files
63 ; MUI end ------
65 ; General Parameters
66 Name "${NAME} ${VERSION}"
67 OutFile "${FROM_DIR}\${FILENAME}.exe"
69 # Languages ######################################
71 ; English
72 LangString Welcome_Title ${LANG_ENGLISH} "${NAME}"
73 LangString Welcome_Text ${LANG_ENGLISH} "Welcome to TazUSB. This tool will help you install Slitaz on a USB drive."
74 LangString Finish_Title ${LANG_ENGLISH} "TazUSB has completed Slitaz installation."
75 LangString Finish_Text ${LANG_ENGLISH} "Slitaz is now installed on your USB drive and the drive is bootable."
76 LangString Finish_Link ${LANG_ENGLISH} "Slitaz website"
77 LangString IsoPage_Title ${LANG_ENGLISH} "Select ISO file"
78 LangString IsoPage_Title2 ${LANG_ENGLISH} "Choose the ISO image which will be installed on your USB drive."
79 LangString IsoPage_Text ${LANG_ENGLISH} "Select Slitaz ISO file to be installed on your USB drive. You can download it from http://www.slitaz.org if needed."
80 LangString IsoPage_Input ${LANG_ENGLISH} "Slitaz ISO File"
81 LangString IsoFile ${LANG_ENGLISH} "ISO file|*.iso"
82 LangString DrivePage_Title ${LANG_ENGLISH} "Choose USB drive location"
83 LangString DrivePage_Title2 ${LANG_ENGLISH} "Choose the USB drive on which to install Slitaz."
84 LangString DrivePage_Text ${LANG_ENGLISH} "TazUSB will install Slitaz on the following drive. Make sure that this drive can be safely deleted! Click Next to continue."
85 LangString DrivePage_Input ${LANG_ENGLISH} "Destination USB Drive"
86 LangString WarningPage_Title ${LANG_ENGLISH} "Warning!"
87 LangString WarningPage_Title2 ${LANG_ENGLISH} "TazUSB is ready to install Slitaz on the selected drive."
88 LangString WarningPage_Text ${LANG_ENGLISH} "TazUSB is now ready to install Slitaz from:$\r$\n$\r$\n$IsoFile $\r$\n$\r$\non your selected destination USB drive:$\r$\n$\r$\n$DestDrive. $\r$\n$\r$\nThe contents of this drive will be deleted! If you are sure, click Next to continue."
89 LangString Iso2USB_Extract ${LANG_ENGLISH} "Extract files from $IsoFile"
90 LangString Iso2USB_CreateSyslinux ${LANG_ENGLISH} "Create syslinux configuration files on $DestDrive"
91 LangString Iso2USB_ExecuteSyslinux ${LANG_ENGLISH} "Execute syslinux on $R0"
92 LangString Iso2USB_WarningSyslinux ${LANG_ENGLISH} "An error ($R8) occurred when executing syslinux.$\r$\nYour USB drive won't be bootable..."
94 ; French
95 LangString Welcome_Title ${LANG_FRENCH} "${NAME}"
96 LangString Welcome_Text ${LANG_FRENCH} "Bienvenue dans TazUSB. Cet outil va vous aider à installer Slitaz sur une clé USB."
97 LangString Finish_Title ${LANG_FRENCH} "L'installation a été terminée par TazUSB."
98 LangString Finish_Text ${LANG_FRENCH} "Slitaz est maintenant installé sur votre clé USB et celle-ci est démarrable."
99 LangString Finish_Link ${LANG_FRENCH} "Site web de Slitaz"
100 LangString IsoPage_Title ${LANG_FRENCH} "Sélectionner un fichier ISO"
101 LangString IsoPage_Title2 ${LANG_FRENCH} "Choisissez l'image ISO qui sera installée sur votre clé USB."
102 LangString IsoPage_Text ${LANG_FRENCH} "Sélectionnez l'image ISO de Slitaz qui sera installée sur votre clé USB. Vous pouvez en télécharger une sur http://www.slitaz.org au besoin."
103 LangString IsoPage_Input ${LANG_FRENCH} "Image ISO Slitaz"
104 LangString IsoFile ${LANG_FRENCH} "Image ISO|*.iso"
105 LangString DrivePage_Title ${LANG_FRENCH} "Sélectionner un lecteur USB"
106 LangString DrivePage_Title2 ${LANG_FRENCH} "Choisissez le lecteur USB sur lequel sera installé Slitaz"
107 LangString DrivePage_Text ${LANG_FRENCH} "TazUSB va maintenant installer Slitaz sur le lecteur sélectionné ci-dessous. Assurez-vous que les données contenues sur cette clé peuvent être effacées! Cliquer sur Suivant pour continuer."
108 LangString DrivePage_Input ${LANG_FRENCH} "Lecteur USB de destination"
109 LangString WarningPage_Title ${LANG_FRENCH} "Attention!"
110 LangString WarningPage_Title2 ${LANG_FRENCH} "TazUSB est prêt à installer Slitaz sur le lecteur sélectionné."
111 LangString WarningPage_Text ${LANG_FRENCH} "TazUSB est maintenant prêt à installer Slitaz depuis:$\r$\n$\r$\n$IsoFile $\r$\n$\r$\nsur le lecteur USB sélectionné:$\r$\n$\r$\n$DestDrive. $\r$\n$\r$\nLe contenu de ce lecteur peut être effacé! Si vous êtes sûr, cliquer sur Suivant pour continuer."
112 LangString Iso2USB_Extract ${LANG_FRENCH} "Extraction des fichiers de $IsoFile"
113 LangString Iso2USB_CreateSyslinux ${LANG_FRENCH} "Création de la configuration syslinux sur $DestDrive"
114 LangString Iso2USB_ExecuteSyslinux ${LANG_FRENCH} "Exécution de syslinux sur $R0"
115 LangString Iso2USB_WarningSyslinux ${LANG_FRENCH} "Une erreur ($R8) est survenue pendant l'exécution de syslinux.$\r$\n Votre clé USB ne sera pas démarrable..."
117 ; Portuguese
118 LangString Welcome_Title ${LANG_PORTUGUESE} "${NAME}"
119 LangString Welcome_Text ${LANG_PORTUGUESE} "Bem-vindo ao TazUSB. Este aplicativo o ajudará a instalar o SliTaz em um drive USB."
120 LangString Finish_Title ${LANG_PORTUGUESE} "O TazUSB finalizou a instalação do SliTaz."
121 LangString Finish_Text ${LANG_PORTUGUESE} "O SliTaz está instalado em seu drive USB e o processo de boot agora pode ser feito."
122 LangString Finish_Link ${LANG_PORTUGUESE} "Site do Slitaz"
123 LangString IsoPage_Title ${LANG_PORTUGUESE} "Selecionar arquivo ISO"
124 LangString IsoPage_Title2 ${LANG_PORTUGUESE} "Escolher imagem ISO a ser instalada no drive USB."
125 LangString IsoPage_Text ${LANG_PORTUGUESE} "Selecionar imagem ISO do SliTaz a ser instalada no drive USB. Você pode obtê-la, se necessário, em http://www.slitaz.org."
126 LangString IsoPage_Input ${LANG_PORTUGUESE} "Arquivo ISO do SliTaz"
127 LangString IsoFile ${LANG_PORTUGUESE} "Arquivo ISO|*.iso"
128 LangString DrivePage_Title ${LANG_PORTUGUESE} "Escolha a localização do drive USB"
129 LangString DrivePage_Title2 ${LANG_PORTUGUESE} "Escolha o drive USB no qual o SliTaz será instalado."
130 LangString DrivePage_Text ${LANG_PORTUGUESE} "O TazUSB instalará o SliTaz no seguinte drive. Certifique-se de que o conteúdo deste drive possa ser seguramente apagado! Clique Next para continuar."
131 LangString DrivePage_Input ${LANG_PORTUGUESE} "Drive USB de destino"
132 LangString WarningPage_Title ${LANG_PORTUGUESE} "Aviso!"
133 LangString WarningPage_Title2 ${LANG_PORTUGUESE} "O TazUSB está pronto para instalar o SliTaz no drive selecionado."
134 LangString WarningPage_Text ${LANG_PORTUGUESE} "O TazUSB está pronto para instalar o SliTaz de:$\r$\n$\r$\n$IsoFile $\r$\n$\r$\nem seu drive de destino selecionado:$\r$\n$\r$\n$DestDrive. $\r$\n$\r$\nO conteúdo deste drive será apagado! Para prosseguir com a operação, clique Next para continuar."
135 LangString Iso2USB_Extract ${LANG_PORTUGUESE} "Extrair arquivos de $IsoFile"
136 LangString Iso2USB_CreateSyslinux ${LANG_PORTUGUESE} "Criar arquivos de configuração do syslinux em $DestDrive"
137 LangString Iso2USB_ExecuteSyslinux ${LANG_PORTUGUESE} "Executar syslinux em $R0"
138 LangString Iso2USB_WarningSyslinux ${LANG_PORTUGUESE} "Um erro ($R8) ocorreu durante a execução do syslinux.$\r$\nSeu drive USB não será inicializável..."
140 # Functions #######################################
142 Function isoFilePage
144 !insertmacro MUI_HEADER_TEXT $(IsoPage_Title) $(IsoPage_Title2)
146 nsDialogs::Create 1018
148 ${If} $IsoFile == ""
149 GetDlgItem $6 $HWNDPARENT 1 ; Get "Next" control handle
150 EnableWindow $6 0 ; disable "Next" control
151 ${EndIf}
153 ${NSD_CreateLabel} 0 0 100% 30 $(IsoPage_Text)
154 Pop $Label
156 ${NSD_CreateLabel} 15 102 100% 15 $(IsoPage_Input)
157 Pop $Label2
159 nsDialogs::CreateControl EDIT ${DEFAULT_STYLES}|${WS_TABSTOP}|${ES_AUTOHSCROLL}|${ES_READONLY} ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE} 10 120 85% 20 $IsoFile
160 Pop $IsoFileHw
162 ${NSD_CreateBrowseButton} 89% 120 7% 20 ...
163 Var /GLOBAL IsoFile_BrowseButton
164 Pop $IsoFile_BrowseButton
165 GetFunctionAddress $0 OnClick_IsoFile_BrowseButton
166 nsDialogs::OnClick $IsoFile_BrowseButton $0
168 nsDialogs::Show
169 FunctionEnd
171 Function OnClick_IsoFile_BrowseButton
174 nsDialogs::SelectFileDialog /NOUNLOAD open "" $(IsoFile)
175 Pop $0
177 ${If} $0 != ""
178 ${NSD_SetText} $IsoFileHw $0
179 StrCpy $IsoFile "$0"
180 GetDlgItem $6 $HWNDPARENT 1 ; Get "Next" control handle
181 EnableWindow $6 1 ; enable "Next" control
182 ${EndIf}
184 FunctionEnd
186 Function drivePage
188 !insertmacro MUI_HEADER_TEXT $(DrivePage_Title) $(DrivePage_Title2)
190 nsDialogs::Create 1018
192 ${If} $DestDrive == ""
193 GetDlgItem $6 $HWNDPARENT 1 ; Get "Next" control handle
194 EnableWindow $6 0 ; disable "Next" control
195 ${EndIf}
197 ${NSD_CreateLabel} 0 0 100% 30 $(DrivePage_Text)
198 Pop $Label
200 ${NSD_CreateLabel} 15 102 100% 15 $(DrivePage_Input)
201 Pop $Label2
203 ${NSD_CreateDroplist} 10 120 85% 20 ""
204 Pop $DestDriveHw
205 ${NSD_OnChange} $DestDriveHw db_select.onchange
206 ${GetDrives} "FDD+HDD" driveListFiller
207 ${If} $DestDrive != ""
208 ${NSD_CB_SelectString} $DestDriveHw $DestDrive
209 ${EndIf}
211 nsDialogs::Show
212 FunctionEnd
214 Function db_select.onchange
215 Pop $DestDriveHw
216 ${NSD_GetText} $DestDriveHw $0
217 StrCpy $DestDrive "$0"
218 GetDlgItem $6 $HWNDPARENT 1 ; Get "Next" control handle
219 EnableWindow $6 1 ; enable "Next" control
220 FunctionEnd
222 Function driveListFiller
223 SendMessage $DestDriveHw ${CB_ADDSTRING} 0 "STR:$9"
224 Push 1 ; must push something - see GetDrives documentation
225 FunctionEnd
227 Function warningPage
229 !insertmacro MUI_HEADER_TEXT $(WarningPage_Title) $(WarningPage_Title2)
231 nsDialogs::Create 1018
233 ${NSD_CreateLabel} 0 0 100% 80% $(WarningPage_Text)
234 Pop $Label
236 nsDialogs::Show
237 FunctionEnd
239 Function ExtractIt
240 ; Code taken from 7zarchive.nsh (c) 2008 qwertymodo
242 InitPluginsDir
243 File /oname=$PLUGINSDIR\7z.exe "${NSISDIR}\plugins\7z.exe"
244 File /oname=$PLUGINSDIR\7z.dll "${NSISDIR}\plugins\7z.dll"
246 ClearErrors
248 Exch $0 ; ADDITIONAL_PARAMETERS (added to the end of the program call)
249 Exch 1
250 Exch $1 ; EXTRACT_PATHS (either "fullpaths" or "nopaths"; defaults to nopaths)
251 Exch 2
252 Exch $2 ; DESTINATION_FOLDER
253 Exch 3
254 Exch $3 ; FILE_FILTER (if blank, extracts all files; allows for wildcards, e.g. "*.doc")
255 Exch 4
256 Exch $4 ; SOURCE_ARCHIVE
257 Push $5
259 ;Extract all files if no filter specified
260 StrCmp $3 "" +2 0
261 StrCpy $3 "$\"$3$\""
263 ;Default folder if not specified
264 StrCmp $2 "" 0 GotFolder
265 !insertmacro GetParent
266 ${GetParent} "$4" $2
267 !insertmacro GetBaseName
268 ${GetBaseName} "$4" $5
269 StrCpy $2 "$2\$5"
271 GotFolder:
272 CreateDirectory $2
273 StrCmp $1 "fullpaths" 0 +2
274 StrCpy $5 "x"
275 StrCmp $1 "nopaths" +2 0
276 StrCmp $1 "" 0 +2
277 StrCpy $5 "e"
279 nsExec::ExecToLog '"$PLUGINSDIR\7z.exe" x $\"$4$\" $\"-o$2$\" $3 $0'
281 Pop $0 ;nsExec return value
283 Pop $5
284 Pop $4
285 Pop $0
286 Pop $1
287 Pop $2
288 Pop $3
290 FunctionEnd
292 !macro _ExtractFromArchive SOURCE_ARCHIVE FILE_FILTER DESTINATION_FOLDER EXTRACT_PATHS ADDITIONAL_PARAMETERS
293 Push "${SOURCE_ARCHIVE}"
294 Push "${FILE_FILTER}"
295 Push "${DESTINATION_FOLDER}"
296 Push "${EXTRACT_PATHS}"
297 Push "${ADDITIONAL_PARAMETERS}"
298 Call ExtractIt
299 !macroend
301 !define ExtractFromArchive '!insertmacro "_ExtractFromArchive"'
304 Function .onInit
306 !insertmacro MUI_LANGDLL_DISPLAY
308 FunctionEnd
310 # Section #######################################
313 Section "iso2usb" main
314 InitPluginsDir
315 File /oname=$PLUGINSDIR\syslinux.exe "${NSISDIR}\plugins\syslinux.exe"
317 SetShellVarContext all
319 ; Extract files from archive
320 DetailPrint $(Iso2USB_Extract)
321 ${ExtractFromArchive} "$IsoFile" "" "$DestDrive" "" "-y -x![BOOT]*"
323 ; Create syslinux directory and files
324 Var /GLOBAL BootDir
325 StrCpy $BootDir $DestDrive -1
326 StrCpy $BootDir "$BootDir\boot"
327 IfFileExists "$BootDir\syslinux\syslinux.cfg" SkipCreateSyslinux CreateSyslinux
328 CreateSyslinux:
329 DetailPrint $(Iso2USB_CreateSyslinux)
330 CreateDirectory "$BootDir\syslinux"
331 CopyFiles "$BootDir\isolinux\*.*" "$BootDir\syslinux"
332 Rename "$BootDir\syslinux\isolinux.cfg" "$BootDir\syslinux\syslinux.cfg"
334 SkipCreateSyslinux:
335 ; Execute syslinux on the drive
336 StrCpy $R0 $DestDrive -1 ; remove \ for syslinux
337 ClearErrors
338 DetailPrint $(Iso2USB_ExecuteSyslinux)
339 ExecWait '$PLUGINSDIR\syslinux.exe -maf -d boot\syslinux $R0' $R8
340 DetailPrint "Return $R8"
342 Banner::destroy
343 ${If} $R8 != 0
344 MessageBox MB_ICONEXCLAMATION|MB_OK $(Iso2USB_WarningSyslinux)
345 ${EndIf}
347 SectionEnd