Subversion Repositories svn1-original

Rev

Blame | Last modification | View Log | RSS feed

;NSIS Setup Script for Mara.exe

!define VER_MAJOR 2003
!define VER_MINOR 04
!define NAME "Mara"
!define DEVELOPER "DDP"

;--------------------------------
;Configuration

OutFile setup_${VER_MAJOR}_${VER_MINOR}.exe
SetCompressor bzip2

InstType "Standard (Program Only)"
InstType "Data (Include Historical Data)"
InstType "Full (Source and historical data)"

ShowInstDetails show
ShowUninstDetails show
SetDateSave on

;---------------------------------
; Set the default installation directory, but then read
; the registory key used to maintain the last install
;
InstallDir $PROGRAMFILES\${NAME}
InstallDirRegKey HKLM SOFTWARE\${DEVELOPER}\${NAME} "Install_Dir"

;--------------------------------
!ifndef CLASSIC_UI

  ;Include Modern UI Macro's
  !include "${NSISDIR}\Contrib\Modern UI\System.nsh"

  ;--------------------------------
  ;Modern UI Configuration

  !define MUI_PRODUCT ${NAME}
  !define MUI_VERSION ${VER_MAJOR}_${VER_MINOR}

  !define MUI_NAME "${NAME} ${MUI_VERSION}" ;Installer name

  !define MUI_WELCOMEPAGE
  !define MUI_LICENSEPAGE
  !define MUI_COMPONENTSPAGE
    !define MUI_COMPONENTSPAGE_SMALLDESC
  !define MUI_DIRECTORYPAGE

;  !define MUI_STARTMENUPAGE
    !define MUI_STARTMENUPAGE_VARIABLE ${NAME}
    !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
    !define MUI_STARTMENUPAGE_REGISTRY_KEY "SOFTWARE\${DEVELOPER}\${NAME}"
    !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start_Menu_Folder"

  !define MUI_FINISHPAGE
    ;!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
    ;!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\readme.txt"
    !define MUI_FINISHPAGE_NOREBOOTSUPPORT
    ; !define MUI_FINISHPAGE_NOAUTOCLOSE

  !define MUI_ABORTWARNING
  
  !define MUI_UNINSTALLER
  !define MUI_UNCONFIRMPAGE

  !define MUI_HEADERBITMAP "${NSISDIR}\Contrib\Icons\modern-header.bmp"
  !define MUI_SPECIALBITMAP "${NSISDIR}\Contrib\Icons\modern-wizard nsis llama.bmp"

  ;--------------------------------
  ;Languages

  !define MUI_TEXT_WELCOME_INFO_TEXT "This wizard will guide you through the installation of MARA. A marathon tracking program\n\n"
  !insertmacro MUI_LANGUAGE "English"
  
  ;--------------------------------
  ;Reserve Files
  
  !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
  !insertmacro MUI_RESERVEFILE_SPECIALINI
  !insertmacro MUI_RESERVEFILE_SPECIALBITMAP

!endif

;--------------------------------
;Data

LicenseData license.txt

;--------------------------------
;Installer Sections

!define SF_SELECTED 1

Section "Mara Program (required)" SecCore
  SectionIn 1 2 3 RO
  SetOutPath $INSTDIR
  RMDir /r $SMPROGRAMS\NSIS

  SetOverwrite on
  File mara.exe
  File MARA_OLD.EXE
  File mara.ico
  File getx07.exe
  File license.txt
SectionEnd

SubSection /e "Historical Data" SecData
    Section "2001" SecData2001Base
        SectionIn 2 3
        SetOutPath $INSTDIR
        File brmr2001.dat
        File brmr2001.csv
        File brmr2001.cnf
    SectionEnd

    SubSection "2002" SecData2002
        Section "2002" SecData2002Base
            SectionIn 2 3
            SetOutPath $INSTDIR
            File brmr2002.dat
            File brmr2002.csv
            File brmr2002.cnf
        SectionEnd

        Section "2002 Text" SecData2002Text
            SectionIn 2 3
            SetOutPath $INSTDIR
            File /nonfatal brmr2002*.txt
        SectionEnd

        Section "2002 HTML" SecData2002Html
            SectionIn 2 3
            SetOutPath $INSTDIR
            File brmr2002*.html
        SectionEnd
    SubSectionEnd
    
SubSectionEnd

Section "Full Source Code" SecCode
  SectionIn 3
  SetOutPath $INSTDIR
  File *.c
  File *.h
  File makefile
  File *.bas
  File *.nsi

SectionEnd

Section "Desktop Shortcuts" SecIcons
  SectionIn 1 2 3
  SetOutPath $INSTDIR

  CreateShortCut "$DESKTOP\Mara.lnk" "$INSTDIR\mara.exe" "brmr" "$INSTDIR\mara.ico"

SectionEnd

Section "Start Menu Entry" SecStartMenu
  SectionIn 1 2 3
  !insertmacro MUI_STARTMENU_WRITE_BEGIN
    
    ;Create shortcuts
    CreateDirectory "$SMPROGRAMS\${MUI_STARTMENUPAGE_VARIABLE}"
    CreateShortCut "$SMPROGRAMS\${MUI_STARTMENUPAGE_VARIABLE}\Mara.lnk" "$INSTDIR\mara.exe" "brmr" "$INSTDIR\mara.ico"
    CreateShortCut "$SMPROGRAMS\${MUI_STARTMENUPAGE_VARIABLE}\UnInstall.lnk" "$INSTDIR\uninstall.exe"

  !insertmacro MUI_STARTMENU_WRITE_END
SectionEnd

Section -post

  ; Write the installation path into the registry
  WriteRegStr HKLM SOFTWARE\${DEVELOPER}\${NAME} "Install_Dir" "$INSTDIR"
  WriteRegStr HKLM SOFTWARE\${DEVELOPER}\${NAME} "Install_Version" "${VER_MAJOR}_${VER_MINOR}"

  ; Write the uninstall keys for Windows
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "DisplayName" "Mara Program (remove only)"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "UninstallString" '"$INSTDIR\uninstall.exe"'
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "DisplayIcon" '"$INSTDIR\mara.ico"'

  ; Write the uninstaller
  WriteUninstaller "uninstall.exe"

SectionEnd

;--------------------------------
;Descriptions

!ifndef CLASSIC_UI

!insertmacro MUI_FUNCTIONS_DESCRIPTION_BEGIN
  !insertmacro MUI_DESCRIPTION_TEXT ${SecCore}          "The core files required to use Mara"
  !insertmacro MUI_DESCRIPTION_TEXT ${SecData}          "Data from past events"
  !insertmacro MUI_DESCRIPTION_TEXT ${SecData2001Base}  "Basic data files from 2001"
  !insertmacro MUI_DESCRIPTION_TEXT ${SecData2002}      "Data and Reports for 2002"
  !insertmacro MUI_DESCRIPTION_TEXT ${SecData2002Base}  "Basic data files from 2002"
  !insertmacro MUI_DESCRIPTION_TEXT ${SecData2002Text}  "Text reports from 2002"
  !insertmacro MUI_DESCRIPTION_TEXT ${SecData2002Html}  "HTML reports from 2002"
  !insertmacro MUI_DESCRIPTION_TEXT ${SecCode}          "Source Code for the Mara Program"
  !insertmacro MUI_DESCRIPTION_TEXT ${SecIcons}         "Desktop Shortcut"
  !insertmacro MUI_DESCRIPTION_TEXT ${SecStartMenu}     "Start Menu Entry"
!insertmacro MUI_FUNCTIONS_DESCRIPTION_END
 
!endif

;--------------------------------
;Uninstaller Section

Section Uninstall

  ; Delete the entire directory
  RMDir /r $INSTDIR

  ; Delete the desktop shortcut
  Delete "$DESKTOP\Mara.lnk"

  ; Delete the StartMenu entry
  ReadRegStr $R0 "${MUI_STARTMENUPAGE_REGISTRY_ROOT}" "${MUI_STARTMENUPAGE_REGISTRY_KEY}" "${MUI_STARTMENUPAGE_REGISTRY_VALUENAME}"
  StrCmp $R0 "" noshortcuts
  
    Delete "$SMPROGRAMS\$R0\Mara.lnk"
    Delete "$SMPROGRAMS\$R0\uninstall.lnk"
    RMDir "$SMPROGRAMS\$R0"     ;Only if empty, so it won't delete other shortcuts
    
  noshortcuts:
  
  ; Delete the registery data
  DeleteRegKey HKLM SOFTWARE\${DEVELOPER}\${NAME}
  DeleteRegKey /ifempty HKLM SOFTWARE\${DEVELOPER}

  !ifndef CLASSIC_UI
    ;Modern UI Finish Header
    !insertmacro MUI_UNFINISHHEADER
  !endif

SectionEnd