tazusb rev 99 3.0.1

move NSI file to win32
author Eric Joseph-Alexandre <erjo@slitaz.org>
date Tue Feb 14 01:05:02 2012 +0100 (2012-02-14)
parents 2700a1ca2a0e
children 3d64a13374e6
files tazusb.nsi
line diff
     1.1 --- a/tazusb.nsi	Thu Feb 09 08:19:42 2012 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,347 +0,0 @@
     1.4 -; Tazusb
     1.5 -; Windows installer for Slitaz
     1.6 -; (c) 2009 Cedric Tissieres (slitaz@objectif-securite.ch)
     1.7 -; You'll need to put 7z.exe and 7z.dll from http://www.7-zip.org/ and syslinux.exe from http://syslinux.zytor.com/ 
     1.8 -; in the NSIS plugins directory before compiling the script. Adapt the FROM_DIR constant too. 
     1.9 -; To add a translation, add the corresponding "!insertmacro MUI_LANGUAGE" and translates all the LangString you'll find below.  
    1.10 -
    1.11 -!define NAME "TazUSB - SliTaz LiveUSB utility "
    1.12 -!define FILENAME "tazusb"
    1.13 -!define VERSION "v0.2"
    1.14 -!define FROM_DIR "C:\ophcrack\livecd"
    1.15 -
    1.16 -SetCompressor LZMA
    1.17 -CRCCheck On
    1.18 -XPStyle on
    1.19 -
    1.20 -!include "MUI2.nsh"
    1.21 -!include "FileFunc.nsh"
    1.22 -
    1.23 -
    1.24 -# MUI Settings #####################################
    1.25 -;**************
    1.26 -
    1.27 -; Interface settings
    1.28 -!define MUI_FINISHPAGE_NOAUTOCLOSE
    1.29 -!define MUI_HEADERIMAGE
    1.30 -!define MUI_HEADERIMAGE_BITMAP "${FROM_DIR}\slitaz-logo-nsis.bmp" 
    1.31 -!define MUI_HEADERIMAGE_BITMAP_NOSTRETCH
    1.32 -
    1.33 -; Welcome page
    1.34 -!define MUI_WELCOMEPAGE_TITLE $(Welcome_Title)
    1.35 -!define MUI_WELCOMEPAGE_TEXT $(Welcome_Text)
    1.36 -!insertmacro MUI_PAGE_WELCOME
    1.37 -; ISO page
    1.38 -Var IsoFileHw
    1.39 -Var IsoFile
    1.40 -Var Label
    1.41 -Var Label2
    1.42 -Page custom isoFilePage
    1.43 -; Drive page
    1.44 -Var DestDriveHW
    1.45 -Var DestDrive
    1.46 -Page custom drivePage
    1.47 -; Warning page
    1.48 -Page custom warningPage
    1.49 -; Instfiles page
    1.50 -!insertmacro MUI_PAGE_INSTFILES
    1.51 -; Finish page
    1.52 -!define MUI_FINISHPAGE_TITLE $(Finish_Title)
    1.53 -!define MUI_FINISHPAGE_TEXT $(Finish_Text)
    1.54 -!define MUI_FINISHPAGE_LINK $(Finish_Link)
    1.55 -!define MUI_FINISHPAGE_LINK_LOCATION "http://slitaz.org"
    1.56 -!insertmacro MUI_PAGE_FINISH
    1.57 -
    1.58 -; Language files
    1.59 -!insertmacro MUI_LANGUAGE "English" ;first language is the default language
    1.60 -!insertmacro MUI_LANGUAGE "French"
    1.61 -!insertmacro MUI_LANGUAGE "Portuguese"
    1.62 -
    1.63 -
    1.64 -; Reserve files
    1.65 -
    1.66 -; MUI end ------
    1.67 -
    1.68 -; General Parameters
    1.69 -Name "${NAME} ${VERSION}"
    1.70 -OutFile "${FROM_DIR}\${FILENAME}.exe"
    1.71 -
    1.72 -# Languages ######################################
    1.73 -
    1.74 -; English
    1.75 -LangString Welcome_Title ${LANG_ENGLISH} "${NAME}"
    1.76 -LangString Welcome_Text ${LANG_ENGLISH} "Welcome to TazUSB. This tool will help you install Slitaz on a USB drive."
    1.77 -LangString Finish_Title ${LANG_ENGLISH} "TazUSB has completed Slitaz installation."
    1.78 -LangString Finish_Text ${LANG_ENGLISH} "Slitaz is now installed on your USB drive and the drive is bootable."
    1.79 -LangString Finish_Link ${LANG_ENGLISH} "Slitaz website"
    1.80 -LangString IsoPage_Title ${LANG_ENGLISH} "Select ISO file"
    1.81 -LangString IsoPage_Title2 ${LANG_ENGLISH} "Choose the ISO image which will be installed on your USB drive."
    1.82 -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."
    1.83 -LangString IsoPage_Input ${LANG_ENGLISH} "Slitaz ISO File"
    1.84 -LangString IsoFile ${LANG_ENGLISH} "ISO file|*.iso"
    1.85 -LangString DrivePage_Title ${LANG_ENGLISH} "Choose USB drive location"
    1.86 -LangString DrivePage_Title2 ${LANG_ENGLISH} "Choose the USB drive in which to install Slitaz."
    1.87 -LangString DrivePage_Text ${LANG_ENGLISH} "TazUSB will install Slitaz in the following drive. Make sure that this drive can be safely deleted! Click Next to continue."
    1.88 -LangString DrivePage_Input ${LANG_ENGLISH} "Destination USB Drive"
    1.89 -LangString WarningPage_Title ${LANG_ENGLISH} "Warning!"
    1.90 -LangString WarningPage_Title2 ${LANG_ENGLISH} "TazUSB is ready to install Slitaz on the selected drive."
    1.91 -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."
    1.92 -LangString Iso2USB_Extract ${LANG_ENGLISH} "Extract files from $IsoFile"
    1.93 -LangString Iso2USB_CreateSyslinux ${LANG_ENGLISH} "Create syslinux configuration files on $DestDrive"
    1.94 -LangString Iso2USB_ExecuteSyslinux ${LANG_ENGLISH} "Execute syslinux on $R0"
    1.95 -LangString Iso2USB_WarningSyslinux ${LANG_ENGLISH} "An error ($R8) occurred when executing syslinux.$\r$\nYour USB drive won't be bootable..."
    1.96 -
    1.97 -; French
    1.98 -LangString Welcome_Title ${LANG_FRENCH} "${NAME}"
    1.99 -LangString Welcome_Text ${LANG_FRENCH} "Bienvenue dans TazUSB. Cet outil va vous aider à installer Slitaz sur une clé USB."
   1.100 -LangString Finish_Title ${LANG_FRENCH} "L'installation a été terminée par TazUSB."
   1.101 -LangString Finish_Text ${LANG_FRENCH} "Slitaz est maintenant installé sur votre clé USB et celle-ci est démarrable."
   1.102 -LangString Finish_Link ${LANG_FRENCH} "Site web de Slitaz"
   1.103 -LangString IsoPage_Title ${LANG_FRENCH} "Sélectionner un fichier ISO"
   1.104 -LangString IsoPage_Title2 ${LANG_FRENCH} "Choisissez l'image ISO qui sera installée sur votre clé USB."
   1.105 -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."
   1.106 -LangString IsoPage_Input ${LANG_FRENCH} "Image ISO Slitaz"
   1.107 -LangString IsoFile ${LANG_FRENCH} "Image ISO|*.iso"
   1.108 -LangString DrivePage_Title ${LANG_FRENCH} "Sélectionner un lecteur USB"
   1.109 -LangString DrivePage_Title2 ${LANG_FRENCH} "Choisissez le lecteur USB sur lequel sera installé Slitaz"
   1.110 -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."
   1.111 -LangString DrivePage_Input ${LANG_FRENCH} "Lecteur USB de destination"
   1.112 -LangString WarningPage_Title ${LANG_FRENCH} "Attention!"
   1.113 -LangString WarningPage_Title2 ${LANG_FRENCH} "TazUSB est prêt à installer Slitaz sur le lecteur sélectionné."
   1.114 -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."
   1.115 -LangString Iso2USB_Extract ${LANG_FRENCH} "Extraction des fichiers de $IsoFile"
   1.116 -LangString Iso2USB_CreateSyslinux ${LANG_FRENCH} "Création de la configuration syslinux sur $DestDrive"
   1.117 -LangString Iso2USB_ExecuteSyslinux ${LANG_FRENCH} "Exécution de syslinux sur $R0"
   1.118 -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..."
   1.119 -
   1.120 -; Portuguese
   1.121 -LangString Welcome_Title ${LANG_PORTUGUESE} "${NAME}"
   1.122 -LangString Welcome_Text ${LANG_PORTUGUESE} "Bem-vindo ao TazUSB. Este aplicativo o ajudará a instalar o SliTaz em um drive USB."
   1.123 -LangString Finish_Title ${LANG_PORTUGUESE} "O TazUSB finalizou a instalação do SliTaz."
   1.124 -LangString Finish_Text ${LANG_PORTUGUESE} "O SliTaz está instalado em seu drive USB e o processo de boot agora pode ser feito."
   1.125 -LangString Finish_Link ${LANG_PORTUGUESE} "Site do Slitaz"
   1.126 -LangString IsoPage_Title ${LANG_PORTUGUESE} "Selecionar arquivo ISO"
   1.127 -LangString IsoPage_Title2 ${LANG_PORTUGUESE} "Escolher imagem ISO a ser instalada no drive USB."
   1.128 -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."
   1.129 -LangString IsoPage_Input ${LANG_PORTUGUESE} "Arquivo ISO do SliTaz"
   1.130 -LangString IsoFile ${LANG_PORTUGUESE} "Arquivo ISO|*.iso"
   1.131 -LangString DrivePage_Title ${LANG_PORTUGUESE} "Escolha a localização do drive USB"
   1.132 -LangString DrivePage_Title2 ${LANG_PORTUGUESE} "Escolha o drive USB no qual o SliTaz será instalado."
   1.133 -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."
   1.134 -LangString DrivePage_Input ${LANG_PORTUGUESE} "Drive USB de destino"
   1.135 -LangString WarningPage_Title ${LANG_PORTUGUESE} "Aviso!"
   1.136 -LangString WarningPage_Title2 ${LANG_PORTUGUESE} "O TazUSB está pronto para instalar o SliTaz no drive selecionado."
   1.137 -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."
   1.138 -LangString Iso2USB_Extract ${LANG_PORTUGUESE} "Extrair arquivos de $IsoFile"
   1.139 -LangString Iso2USB_CreateSyslinux ${LANG_PORTUGUESE} "Criar arquivos de configuração do syslinux em  $DestDrive"
   1.140 -LangString Iso2USB_ExecuteSyslinux ${LANG_PORTUGUESE} "Executar syslinux em $R0"
   1.141 -LangString Iso2USB_WarningSyslinux ${LANG_PORTUGUESE} "Um erro ($R8) ocorreu durante a execução do syslinux.$\r$\nSeu drive USB não será inicializável..."
   1.142 -
   1.143 -# Functions #######################################
   1.144 -
   1.145 -Function isoFilePage
   1.146 -
   1.147 -  !insertmacro MUI_HEADER_TEXT $(IsoPage_Title) $(IsoPage_Title2) 
   1.148 - 
   1.149 -  nsDialogs::Create 1018
   1.150 -  
   1.151 -  ${If} $IsoFile == ""
   1.152 -    GetDlgItem $6 $HWNDPARENT 1 ; Get "Next" control handle
   1.153 -    EnableWindow $6 0 ; disable "Next" control
   1.154 -  ${EndIf}
   1.155 - 
   1.156 -  ${NSD_CreateLabel} 0 0 100% 30 $(IsoPage_Text)
   1.157 -  Pop $Label
   1.158 -
   1.159 -  ${NSD_CreateLabel} 15 102 100% 15 $(IsoPage_Input)
   1.160 -  Pop $Label2
   1.161 -  
   1.162 -  nsDialogs::CreateControl EDIT ${DEFAULT_STYLES}|${WS_TABSTOP}|${ES_AUTOHSCROLL}|${ES_READONLY} ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE} 10 120 85% 20 $IsoFile
   1.163 -  Pop $IsoFileHw
   1.164 -        
   1.165 -  ${NSD_CreateBrowseButton} 89% 120 7% 20 ...
   1.166 -  Var /GLOBAL IsoFile_BrowseButton
   1.167 -  Pop $IsoFile_BrowseButton 
   1.168 -  GetFunctionAddress $0 OnClick_IsoFile_BrowseButton
   1.169 -  nsDialogs::OnClick $IsoFile_BrowseButton $0
   1.170 -  
   1.171 -  nsDialogs::Show
   1.172 -FunctionEnd
   1.173 -
   1.174 -Function OnClick_IsoFile_BrowseButton
   1.175 -
   1.176 -
   1.177 -nsDialogs::SelectFileDialog /NOUNLOAD open "" $(IsoFile)
   1.178 -Pop $0
   1.179 -
   1.180 -${If} $0 != ""
   1.181 -   ${NSD_SetText} $IsoFileHw $0
   1.182 -   StrCpy $IsoFile "$0"
   1.183 -   GetDlgItem $6 $HWNDPARENT 1 ; Get "Next" control handle
   1.184 -   EnableWindow $6 1 ; enable "Next" control
   1.185 -${EndIf}
   1.186 -
   1.187 -FunctionEnd
   1.188 -
   1.189 -Function drivePage
   1.190 -
   1.191 -  !insertmacro MUI_HEADER_TEXT $(DrivePage_Title) $(DrivePage_Title2)
   1.192 - 
   1.193 -  nsDialogs::Create 1018
   1.194 -  
   1.195 -  ${If} $DestDrive == ""
   1.196 -    GetDlgItem $6 $HWNDPARENT 1 ; Get "Next" control handle
   1.197 -    EnableWindow $6 0 ; disable "Next" control
   1.198 -  ${EndIf}
   1.199 - 
   1.200 -  ${NSD_CreateLabel} 0 0 100% 30 $(DrivePage_Text)
   1.201 -  Pop $Label
   1.202 -  
   1.203 -  ${NSD_CreateLabel} 15 102 100% 15 $(DrivePage_Input)
   1.204 -  Pop $Label2
   1.205 -  
   1.206 -  ${NSD_CreateDroplist} 10 120 85% 20 ""
   1.207 -	Pop $DestDriveHw
   1.208 -		${NSD_OnChange} $DestDriveHw db_select.onchange
   1.209 -		${GetDrives} "FDD+HDD" driveListFiller
   1.210 -  ${If} $DestDrive != ""
   1.211 -	${NSD_CB_SelectString} $DestDriveHw $DestDrive
   1.212 -  ${EndIf}
   1.213 -  
   1.214 -  nsDialogs::Show
   1.215 -FunctionEnd
   1.216 -
   1.217 -Function db_select.onchange
   1.218 -  Pop $DestDriveHw
   1.219 -  ${NSD_GetText} $DestDriveHw $0
   1.220 -  StrCpy $DestDrive "$0"
   1.221 -  GetDlgItem $6 $HWNDPARENT 1 ; Get "Next" control handle
   1.222 -  EnableWindow $6 1 ; enable "Next" control
   1.223 -FunctionEnd
   1.224 -
   1.225 -Function driveListFiller
   1.226 -	SendMessage $DestDriveHw ${CB_ADDSTRING} 0 "STR:$9"
   1.227 -	Push 1 ; must push something - see GetDrives documentation
   1.228 -FunctionEnd
   1.229 -
   1.230 -Function warningPage
   1.231 -
   1.232 -  !insertmacro MUI_HEADER_TEXT $(WarningPage_Title) $(WarningPage_Title2)
   1.233 - 
   1.234 -  nsDialogs::Create 1018
   1.235 - 
   1.236 -  ${NSD_CreateLabel} 0 0 100% 80% $(WarningPage_Text)
   1.237 -  Pop $Label
   1.238 -  
   1.239 -  nsDialogs::Show
   1.240 -FunctionEnd
   1.241 -
   1.242 -Function ExtractIt
   1.243 -  ; Code taken from 7zarchive.nsh  (c) 2008 qwertymodo
   1.244 -  
   1.245 -  InitPluginsDir
   1.246 -  File /oname=$PLUGINSDIR\7z.exe "${NSISDIR}\plugins\7z.exe"
   1.247 -  File /oname=$PLUGINSDIR\7z.dll "${NSISDIR}\plugins\7z.dll"
   1.248 -
   1.249 -  ClearErrors
   1.250 -
   1.251 -  Exch $0      ; ADDITIONAL_PARAMETERS (added to the end of the program call)
   1.252 -  Exch 1
   1.253 -  Exch $1      ; EXTRACT_PATHS (either "fullpaths" or "nopaths"; defaults to nopaths)
   1.254 -  Exch 2
   1.255 -  Exch $2      ; DESTINATION_FOLDER
   1.256 -  Exch 3
   1.257 -  Exch $3      ; FILE_FILTER (if blank, extracts all files; allows for wildcards, e.g. "*.doc")
   1.258 -  Exch 4
   1.259 -  Exch $4      ; SOURCE_ARCHIVE
   1.260 -  Push $5
   1.261 -
   1.262 -  ;Extract all files if no filter specified
   1.263 -  StrCmp $3 "" +2 0
   1.264 -  StrCpy $3 "$\"$3$\""
   1.265 -
   1.266 -  ;Default folder if not specified
   1.267 -  StrCmp $2 "" 0 GotFolder
   1.268 -  !insertmacro GetParent
   1.269 -  ${GetParent} "$4" $2
   1.270 -  !insertmacro GetBaseName
   1.271 -  ${GetBaseName} "$4" $5
   1.272 -  StrCpy $2 "$2\$5"
   1.273 -
   1.274 -  GotFolder:
   1.275 -  CreateDirectory $2
   1.276 -  StrCmp $1 "fullpaths" 0 +2
   1.277 -  StrCpy $5 "x"
   1.278 -  StrCmp $1 "nopaths" +2 0
   1.279 -  StrCmp $1 "" 0 +2
   1.280 -  StrCpy $5 "e"
   1.281 -
   1.282 -  nsExec::ExecToLog '"$PLUGINSDIR\7z.exe" x $\"$4$\" $\"-o$2$\" $3 $0'
   1.283 -
   1.284 -  Pop $0 ;nsExec return value
   1.285 -
   1.286 -  Pop $5
   1.287 -  Pop $4
   1.288 -  Pop $0
   1.289 -  Pop $1
   1.290 -  Pop $2
   1.291 -  Pop $3
   1.292 -
   1.293 -FunctionEnd
   1.294 -
   1.295 -!macro _ExtractFromArchive SOURCE_ARCHIVE FILE_FILTER DESTINATION_FOLDER EXTRACT_PATHS ADDITIONAL_PARAMETERS
   1.296 -  Push "${SOURCE_ARCHIVE}"
   1.297 -  Push "${FILE_FILTER}"
   1.298 -  Push "${DESTINATION_FOLDER}"
   1.299 -  Push "${EXTRACT_PATHS}"
   1.300 -  Push "${ADDITIONAL_PARAMETERS}"
   1.301 -  Call ExtractIt
   1.302 -!macroend
   1.303 -
   1.304 -!define ExtractFromArchive '!insertmacro "_ExtractFromArchive"'
   1.305 -
   1.306 -
   1.307 -Function .onInit
   1.308 -
   1.309 -  !insertmacro MUI_LANGDLL_DISPLAY
   1.310 -
   1.311 -FunctionEnd
   1.312 -
   1.313 -# Section #######################################
   1.314 -
   1.315 -
   1.316 -Section "iso2usb" main
   1.317 -  InitPluginsDir
   1.318 -  File /oname=$PLUGINSDIR\syslinux.exe "${NSISDIR}\plugins\syslinux.exe"
   1.319 -  
   1.320 -  SetShellVarContext all
   1.321 -  
   1.322 -  ; Extract files from archive
   1.323 -  DetailPrint $(Iso2USB_Extract)
   1.324 -  ${ExtractFromArchive} "$IsoFile" "" "$DestDrive" "" "-y -x![BOOT]*"
   1.325 -
   1.326 -  ; Create syslinux directory and files
   1.327 -  Var /GLOBAL BootDir
   1.328 -  StrCpy $BootDir $DestDrive -1 
   1.329 -  StrCpy $BootDir "$BootDir\boot"
   1.330 -  IfFileExists "$BootDir\syslinux\syslinux.cfg" SkipCreateSyslinux CreateSyslinux
   1.331 -  CreateSyslinux:
   1.332 -  DetailPrint $(Iso2USB_CreateSyslinux) 
   1.333 -  CreateDirectory "$BootDir\syslinux"
   1.334 -  CopyFiles "$BootDir\isolinux\*.*" "$BootDir\syslinux"
   1.335 -  Rename "$BootDir\syslinux\isolinux.cfg" "$BootDir\syslinux\syslinux.cfg"
   1.336 -
   1.337 -  SkipCreateSyslinux:
   1.338 -  ; Execute syslinux on the drive
   1.339 -  StrCpy $R0 $DestDrive -1 ; remove \ for syslinux
   1.340 -  ClearErrors
   1.341 -  DetailPrint $(Iso2USB_ExecuteSyslinux)
   1.342 -   	  ExecWait '$PLUGINSDIR\syslinux.exe -maf -d boot\syslinux $R0' $R8
   1.343 -  	  DetailPrint "Return $R8"
   1.344 -
   1.345 -      Banner::destroy
   1.346 -	  ${If} $R8 != 0
   1.347 -            MessageBox MB_ICONEXCLAMATION|MB_OK $(Iso2USB_WarningSyslinux)
   1.348 -	  ${EndIf}
   1.349 -  
   1.350 -SectionEnd