Index: build.xml =================================================================== --- build.xml (revision 1890) +++ build.xml (working copy) @@ -226,6 +226,7 @@ + Index: resources/installer/installer_template.nsi =================================================================== --- resources/installer/installer_template.nsi (revision 1890) +++ resources/installer/installer_template.nsi (working copy) @@ -6,6 +6,7 @@ !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 @@ -15,20 +16,35 @@ ; Uninstaller pages !define MUI_UNPAGE_INSTFILES +; Language files +!define MUI_LANGDLL_ALLLANGUAGES !insertmacro MUI_LANGUAGE "English" +!insertmacro MUI_LANGUAGE "French" +LangString AlreadyInstalled ${LANG_ENGLISH} "${INSTALLER_NAME} is already installed. $\n$\nClick `OK` to remove the previous version 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 ou sur `Annuler` pour annuler cette mise � jour." + + +; 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 "${INSTALLER_NAME} is already installed. $\n$\nClick `OK` to remove the previous version or `Cancel` to cancel this upgrade." IDOK uninst + MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "$(AlreadyInstalled)" IDOK uninst Abort ;Run the uninstaller @@ -52,6 +68,10 @@ FunctionEnd +Function un.onInit +!insertmacro MUI_UNGETLANGUAGE +FunctionEnd + Section "MainSection" SectionMain ; Files to be installed SetOutPath "$INSTDIR" @@ -59,8 +79,13 @@ ; Create MapSource registry keys ; INSERT_REGBIN_HERE +!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" @@ -83,8 +108,13 @@ ; 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" Index: src/uk/me/parabola/mkgmap/combiners/NsisBuilder.java =================================================================== --- src/uk/me/parabola/mkgmap/combiners/NsisBuilder.java (revision 1890) +++ src/uk/me/parabola/mkgmap/combiners/NsisBuilder.java (working copy) @@ -14,6 +14,7 @@ package uk.me.parabola.mkgmap.combiners; import java.io.BufferedReader; +import java.io.FileInputStream; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; @@ -87,13 +88,26 @@ private void writeNsisFile() { Writer w = null; - InputStream is = getClass().getResourceAsStream("/installer/installer_template.nsi"); - if (is == null) { + InputStream inStream = null; + + try + { + inStream = new FileInputStream("resources/installer_template.nsi"); + } + catch (Exception ex) + { + inStream = null; + } + + if(inStream == null) // If not loaded from disk use from jar file + inStream = this.getClass().getResourceAsStream("/installer/installer_template.nsi"); + + if (inStream == null) { System.err.println("Could not find the installer template."); return; } try { - BufferedReader br = new BufferedReader(new InputStreamReader(is)); + BufferedReader br = new BufferedReader(new InputStreamReader(inStream)); w = new FileWriter(Utils.joinPath(outputDir, nsisFilename)); PrintWriter pw = new PrintWriter(w); @@ -124,6 +138,10 @@ pw.format(Locale.ROOT, "!define MAPNAME \"%s\"\n", baseFilename); pw.format(Locale.ROOT, "!define PRODUCT_ID \"%s\"\n", productId); pw.format(Locale.ROOT, "!define REG_KEY \"%s\"\n", familyName); + if (hasIndex) + pw.format(Locale.ROOT, "!define INDEX\n"); + if (hasTyp) + pw.format(Locale.ROOT, "!define TYPNAME \"%s\"\n", typName); } private void writeRegBin(PrintWriter pw) { @@ -168,13 +186,25 @@ */ private void writeLicenceFile() { Writer w = null; - InputStream is = getClass().getResourceAsStream("/installer/license_template.txt"); - if (is == null) { + InputStream inStream = null; + try + { + inStream = new FileInputStream("resources/license_template.txt"); + } + catch (Exception ex) + { + inStream = null; + } + + if(inStream == null) // If not loaded from disk use from jar file + inStream = this.getClass().getResourceAsStream("/installer/license_template.txt"); + + if (inStream == null) { System.err.println("Could not find the license template."); return; } try { - BufferedReader br = new BufferedReader(new InputStreamReader(is)); + BufferedReader br = new BufferedReader(new InputStreamReader(inStream)); w = new FileWriter(Utils.joinPath(outputDir, licenseFilename)); PrintWriter pw = new PrintWriter(w);