Hi,

Here is an updated version with the following fixes/improvements:

* correctly set registry key for TYP file
* set registry key for index files only when present
* possibility to use own template for installer script (details below)
* installer localization (English and French at the moment)

To customize the installer script one need to create a resources directory with:

* installer_template.nsi to customize the installer script. There are four important lines that the file should have for mkgmap to generate the script properly: * ; INSERT_DEFINES_HERE should be near the beginning of the file, mkgmap will define a certain number of variables that are used later in the script * ; INSERT_ADDED_FILES_HERE mkgmap will generated the list of files to be packaged in the installer * ; INSERT_REGBIN_HERE mkgmap will add a line for the family_id registry key. This is binary and cannot be taken care of in the defines unfortunately * ; INSERT_REMOVED_FILES_HERE mkgmap will generated the list of files to be uninstalled by the uninstaller * license_template.txt this file will be displayed by the installer in the license page

the default files are provided in the examples directory of the mkgmap installation for convenience


Thanks,

N.

Index: build.xml
===================================================================
--- build.xml   (revision 1890)
+++ build.xml   (working copy)
@@ -226,6 +226,7 @@
 
                <copy todir="${dist}/examples">
                        <fileset dir="resources">
+                               <include name="installer/*"/>
                                <include name="styles/default/*"/>
                                <include name="styles/noname/*"/>
                                <include name="chars/ascii/row02.trans"/>
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);
                        
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to