Exemplo de script NSI para criação do instalador

Como fazer o Mapsource enxergar os mapas criados com mkgmap.

Exemplo de script NSI para criação do instalador

Mensagempor paulocarvalho » 13 Mar 2014, 15:03

Um script NSI serve para criar um instalador com o compilador de instaladores Nullsoft Scriptable Install System: http://nsis.sourceforge.net/Main_Page

Código: Selecionar todos
!define DEFAULT_DIR "C:\Garmin\Maps\OSM generic routable"
!define INSTALLER_DESCRIPTION "OSM generic routable"
!define INSTALLER_NAME "OSM generic routable"
!define MAPNAME "63240000"
!define PRODUCT_ID "6"
!define REG_KEY "OSM generic routable"
!define INDEX

SetCompressor /SOLID lzma

; Includes
!include "MUI2.nsh"

; Installer pages
!define MUI_CUSTOMFUNCTION_GUIINIT myGuiInit
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE ${MAPNAME}_license.txt
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

; Uninstaller pages
!define MUI_UNPAGE_INSTFILES

; Language files
!define MUI_LANGDLL_ALLLANGUAGES
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "Spanish"
!insertmacro MUI_LANGUAGE "German"
!insertmacro MUI_LANGUAGE "Dutch"


LangString AlreadyInstalled ${LANG_ENGLISH} "${INSTALLER_NAME} is already installed. $\n$\nClick `OK` to remove the previous version and continue installation or `Cancel` to cancel this upgrade."
LangString AlreadyInstalled ${LANG_FRENCH} "${INSTALLER_NAME} est d�j� install�. $\n$\nAppuyez sur `OK` pour retirer la version pr�c�dente et continuer avec l'installation ou sur `Annuler` pour annuler cette mise � jour."
LangString AlreadyInstalled ${LANG_SPANISH} "${INSTALLER_NAME} ya est� instalado. $\n$\nPulse `Aceptar` para eliminar la versi�n anterior y continuar la instalaci�n o `Cancelar` para cancelar esta actualizaci�n."
LangString AlreadyInstalled ${LANG_GERMAN} "${INSTALLER_NAME} ist bereits installiert. $\n$\nKlick `OK` um die alte Version zu deinstallieren oder `Abbrechen` um die Installation abzubrechen."
LangString AlreadyInstalled ${LANG_DUTCH} "${INSTALLER_NAME} is reeds geinstalleerd. $\n$\nKlik op `OK` om de oude versie te verwijderen of `Annuleren` om deze update te onderbreken."

; Reservefiles
!insertmacro MUI_RESERVEFILE_LANGDLL ;Language selection dialog


Name "${INSTALLER_DESCRIPTION}"
OutFile "${INSTALLER_NAME}.exe"
InstallDir "${DEFAULT_DIR}"

Function .onInit
  !insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd

Function myGUIInit
  ; Uninstall before installing (code from http://nsis.sourceforge.net/Auto-uninstall_old_before_installing_new )
  ReadRegStr $R0 HKLM \
  "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REG_KEY}" "UninstallString"
  StrCmp $R0 "" done
 
  IfSilent silent
  MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "$(AlreadyInstalled)" IDOK uninst
  Abort

  ;Run the uninstaller
  uninst:
  ClearErrors
  ExecWait '"$R0" _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
 
  IfErrors no_remove_uninstaller done
    ;You can either use Delete /REBOOTOK in the uninstaller or add some code
    ;here to remove the uninstaller. Use a registry key to check
    ;whether the user has chosen to uninstall. If you are using an uninstaller
    ;components page, make sure all sections are uninstalled.
  no_remove_uninstaller:
 
  Goto done
 
  silent:
  ExecWait '"$R0" /S _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
 
  done:
 
FunctionEnd

Function un.onInit
!insertmacro MUI_UNGETLANGUAGE
FunctionEnd

Section "MainSection" SectionMain
; Files to be installed
  SetOutPath "$INSTDIR"
  File "${MAPNAME}.img"
  File "${MAPNAME}_mdr.img"
  File "${MAPNAME}.mdx"
  File "${MAPNAME}.tdb"
  File "63241362.img"
  File "63241363.img"
  File "63241853.img"
  File "63241854.img"
  File "63241855.img"
  File "63241914.img"
  File "63241915.img"
  File "63241916.img"
  File "63241918.img"
  File "63241977.img"
  File "63241978.img"
  File "63241979.img"
  File "63241980.img"
  File "63241982.img"
  File "63241984.img"
  File "63241987.img"
  File "63241989.img"
  File "63242010.img"
  File "63242011.img"
  File "63242012.img"
  File "63242013.img"
  File "63242014.img"

; Create MapSource registry keys
  WriteRegBin HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}" "ID" d007
!ifdef INDEX 
  WriteRegStr HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}" "IDX" "$INSTDIR\${MAPNAME}.mdx"
  WriteRegStr HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}" "MDR" "$INSTDIR\${MAPNAME}_mdr.img"
!endif
!ifdef TYPNAME 
  WriteRegStr HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}" "TYP" "$INSTDIR\${TYPNAME}"
!endif
  WriteRegStr HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}\${PRODUCT_ID}" "BMAP" "$INSTDIR\${MAPNAME}.img"
  WriteRegStr HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}\${PRODUCT_ID}" "LOC" "$INSTDIR"
  WriteRegStr HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}\${PRODUCT_ID}" "TDB" "$INSTDIR\${MAPNAME}.tdb"
 
; Write uninstaller
  WriteUninstaller "$INSTDIR\Uninstall.exe"

; Create uninstaller registry keys
  WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_KEY}" "DisplayName" "$(^Name)"
  WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_KEY}" "UninstallString" "$INSTDIR\Uninstall.exe"
  WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_KEY}" "NoModify" 1
 
SectionEnd

Section "Uninstall"
; Files to be uninstalled
  Delete "$INSTDIR\${MAPNAME}.img"
  Delete "$INSTDIR\${MAPNAME}_mdr.img"
  Delete "$INSTDIR\${MAPNAME}.mdx"
  Delete "$INSTDIR\${MAPNAME}.tdb"
  Delete "$INSTDIR\63241362.img"
  Delete "$INSTDIR\63241363.img"
  Delete "$INSTDIR\63241853.img"
  Delete "$INSTDIR\63241854.img"
  Delete "$INSTDIR\63241855.img"
  Delete "$INSTDIR\63241914.img"
  Delete "$INSTDIR\63241915.img"
  Delete "$INSTDIR\63241916.img"
  Delete "$INSTDIR\63241918.img"
  Delete "$INSTDIR\63241977.img"
  Delete "$INSTDIR\63241978.img"
  Delete "$INSTDIR\63241979.img"
  Delete "$INSTDIR\63241980.img"
  Delete "$INSTDIR\63241982.img"
  Delete "$INSTDIR\63241984.img"
  Delete "$INSTDIR\63241987.img"
  Delete "$INSTDIR\63241989.img"
  Delete "$INSTDIR\63242010.img"
  Delete "$INSTDIR\63242011.img"
  Delete "$INSTDIR\63242012.img"
  Delete "$INSTDIR\63242013.img"
  Delete "$INSTDIR\63242014.img"
  Delete "$INSTDIR\Uninstall.exe"

  RmDir "$INSTDIR"

; Registry cleanup
  DeleteRegValue HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}" "ID"
!ifdef INDEX 
  DeleteRegValue HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}" "IDX"
  DeleteRegValue HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}" "MDR"
!endif
!ifdef TYPNAME 
  DeleteRegValue HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}" "TYP"
!endif
  DeleteRegValue HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}\${PRODUCT_ID}" "BMAP"
  DeleteRegValue HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}\${PRODUCT_ID}" "LOC"
  DeleteRegValue HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}\${PRODUCT_ID}" "TDB"
  DeleteRegKey /IfEmpty HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}\${PRODUCT_ID}"
  DeleteRegKey /IfEmpty HKLM "SOFTWARE\Garmin\MapSource\Families\${REG_KEY}"
 
  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REG_KEY}"

SectionEnd

Fonte: Você precisa esta logado para ver os links. Registre-se.
paulocarvalho
 
Mensagens: 290
Registrado em: 02 Ago 2013, 17:41

Voltar para Instalação dos mapas para uso no Mapsource

Quem está online

Usuários navegando neste fórum: Nenhum usuário registrado e 1 visitante