MiscJunk logo
Page banner

Creating Mapset Installers

Introduction

When creating custom mapsets for Garmin GPS units, utilizing them is fairly simple. A utility such as SendMap can be used to upload maps. The mapsets can also be integrated into Garmin's Mapsource program, either manually or aided by a utilities such as these:

MapSetToolKit
Img2Mapsource
Mapsource Mapset Manager

When distributing the mapset to the general public a more general and automatic process is preferred. The purpose of this page is to demonstrate how to use a free installation application to create self-installer for custom GPS mapsets.

Resources

The software used to create the installer is the nullsoft scriptable install system (NSIS). It is a very powerful installation system that is used for many well known software applications. For our purpose, only the most basic funtionality will be utilized.

The build script for this example can be obtained here:

Installation Script

The script is fairly self-explanatory and will be descibed in more detail below. It can be compiled (creating the self-installer) via one the GUI available for NSIS or simply from a command prompt:

> c:\progra~1\nsis\makensis install.txt

For an example of an installer created by this script, please refer to my own MN OHV mapset page.

Installation Script

The build script is listed below with additional explanations/commments.

; install.nsi
;--------------------------------
!include "MUI.nsh"

Here is the first section to customize. The "Installer Name" is simply a title used through-out the installer. The executable name is the what you want the finished installer to be named, such as install.exe or setup.exe. YOUR_MAPSET_NAME is used though-out the script and should be a short description of your mapset. It will be used in defining the default intallation directory and in various registry entries.


; The name of the installer - used throughout the installer
Name "Your Installer Name"

; The file to write - where to put the finished installer
OutFile "D:\some_path\your_executable.exe"

; The default installation directory
InstallDir $PROGRAMFILES\YOUR_MAPSET_NAME

;--------------------------------
;Interface Settings
;--------------------------------
!define MUI_ABORTWARNING

;--------------------------------
;Pages
;--------------------------------

The two welcome screens that are defined here are optional. At least one should be used to warn the user to what the installer does but the second, customized welcome screen is good if you want to display copyright information, etc.


; Generic welcome screen (optional)
!insertmacro MUI_PAGE_WELCOME

; Custom welcome screen (optional)
!define MUI_WELCOMEPAGE_TITLE "Please Note:"
!define MUI_WELCOMEPAGE_TEXT "Your welcome message.\r\nNote how to add line returns.\r\n"
!insertmacro MUI_PAGE_WELCOME

; Installation directory dialog
!insertmacro MUI_PAGE_DIRECTORY

; Installation
!insertmacro MUI_PAGE_INSTFILES

The readme section defined here is optional. If you don't have a readme file that you want to display then you can delete this section.


; Readme (optional)
!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\your_readme_file.txt"

!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

;--------------------------------
;Languages
;--------------------------------
!insertmacro MUI_LANGUAGE "English"

;--------------------------------
; The stuff to install
;--------------------------------
Section "Install"

; Set output path to the installation directory.
SetOutPath $INSTDIR

This "File" line defines where NSIS can find the files that you want compiled into the installer.


; Source files for creating installation
File /a "D:\some_path\*.*"

The following section handles all of the registry entries. In addtion to YOUR_MAPSET_NAME, which was described above, you need to specify YOUR_MAPSET_NUMBER. This should be a number that is unique to your mapset. Usually numbers greater than 1000 are safe to use.


; Write the installation path into the registry
WriteRegStr HKLM "SOFTWARE\YOUR_MAPSET_NAME" "Install_Dir" "$INSTDIR"
WriteRegStr HKLM "SOFTWARE\YOUR_MAPSET_NAME" "Version" "1.01"

; Write the MapSource configuration into the registry
WriteRegStr HKLM "SOFTWARE\Garmin\MapSource\Products\YOUR_MAPSET_NUMBER" "LOC" "$INSTDIR\"
WriteRegStr HKLM "SOFTWARE\Garmin\MapSource\Products\YOUR_MAPSET_NUMBER" "BMAP" "$INSTDIR\YOUR_MAPSET_NAME.img"
WriteRegStr HKLM "SOFTWARE\Garmin\MapSource\Products\YOUR_MAPSET_NUMBER" "TDB" "$INSTDIR\YOUR_MAPSET_NAME.tdb"

The following section adds an uninstall feature. DisplayName should be a short (multiple words are OK) description of your mapset and a longer description can follow.


; Write the uninstall keys for Windows
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\YOUR_MAPSET_NAME" "DisplayName" "Your mapset description"
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\YOUR_MAPSET_NAME" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\YOUR_MAPSET_NAME" "NoModify" 1
WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\YOUR_MAPSET_NAME" "NoRepair" 1

WriteUninstaller "uninstall.exe"
SectionEnd

;--------------------------------
; Uninstaller
;--------------------------------

Use the same values you used above for the following section.


Section "Uninstall"
; Remove registry keys
DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\YOUR_MAPSET_NAME"
DeleteRegKey HKLM "SOFTWARE\YOUR_MAPSET_NAME"
DeleteRegKey HKLM "SOFTWARE\Garmin\MapSource\Products\YOUR_MAPSET_NUMBER"

; Remove files and uninstaller
Delete $INSTDIR\*.*
Delete $INSTDIR\uninstall.exe

; Remove directories used
RMDir "$INSTDIR"
SectionEnd

Last updated: 9 Mar 2007