[jsword-svn] bibledesktop/etc/installer s

jswordcvs at crosswire.org jswordcvs at crosswire.org
Wed Jan 4 14:54:57 MST 2006


Update of /cvs/jsword/bibledesktop/etc/installer
In directory www.crosswire.org:/tmp/cvs-serv13625/etc/installer

Modified Files:
	setup.exe setup.nsi bibledesktop.exe 
Added Files:
	README.txt BibleDesktop.nsi 
Removed Files:
	splash.bmp 
Log Message:
Created windows installer and executable

--- splash.bmp DELETED ---

--- NEW FILE: BibleDesktop.nsi ---
; Java Launcher
;--------------

!include LogicLib.nsh

!define PRODUCT_NAME "BibleDesktop"
!define PRODUCT_VERSION "1.0"
!define CLASS "org.crosswire.bibledesktop.desktop.Desktop"
!define JAVALIB "$EXEDIR"

!define JRE_VERSION "1.4.2"
!define JRE_URL "http://dlc.sun.com/jdk/j2re-1_4_2_07-windows-i586-p.exe"

SetCompressor lzma

Var HasJRE

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
Caption "${PRODUCT_NAME} ${PRODUCT_VERSION}"
Icon "bibledesktop.ico"
OutFile "${PRODUCT_NAME}.exe"
BrandingText " "

AutoCloseWindow true
ShowInstDetails nevershow

Section ""

  Call BuildClassPath
  Pop $R1

  Call FindJRE
  Pop $R0

  StrCpy $0 '"$R0" -classpath "$R1" ${CLASS}'

;ClearErrors
;FileOpen $1 $EXEDIR\java.log w
;IfErrors done
;FileWrite $1 $0
;FileClose $1
;done:

  SetOutPath $EXEDIR
  Exec $0
SectionEnd

Function BuildClassPath
; Builds the class path with all the jars in JAVALIB
; and puts the results on the stack.

  ; save state
  Push $R0
  Push $R1
  Push $R2

  ; clear R0
  StrCpy $R0 ""
  
  ; Iterate over all the jar files in JAVALIB
  FindFirst $R1 $R2 "${JAVALIB}\*.jar"
  ${Unless} ${Errors}
    ${Do}
      ${If} $R0 == ""
        StrCpy $R0 "${JAVALIB}\$R2"
      ${Else}
        StrCpy $R0 "$R0;${JAVALIB}\$R2"
      ${EndIf}
      FindNext $R1 $R2
    ${LoopUntil} ${Errors}
    FindClose $R1
  ${EndUnless}
  
  ; restore state and put results on the stack
  Pop $R2
  Pop $R1
  Exch $R0
FunctionEnd

Function .onInit
  Call DetectJRE
  pop $HasJRE

  ${If} $HasJRE == "No"
    Call GetJRE
  ${EndIf}

  SetSilent silent
FunctionEnd

Function GetJRE
  MessageBox MB_OK "$(^NAME) uses Java ${JRE_VERSION} or later, it will now be downloaded and installed."

  StrCpy $2 "$TEMP\Java Runtime Environment.exe"
  InetLoad::load /POPUP "Getting Java for ${PRODUCT_NAME}" ${JRE_URL} $2
  Pop $R0 ;Get the return value
  StrCmp $R0 "OK" +3
  ;NSISdl::download /TIMEOUT=30000 ${JRE_URL} $2
  ;Pop $R0 ;Get the return value
  ;StrCmp $R0 "success" +3
  MessageBox MB_OK "Download failed: $R0"
  Quit
  ExecWait $2
  Delete $2
FunctionEnd

Function DetectJRE
  ; Put "Yes" or "No" on the stack

  ; save state
  push $R0

  ; When the JRE is installed so is Web Start.
  ; The current version of WebStart is something like 1.4.2_07
  ; This is more fine grained than Java Runtime Environment
  ReadRegStr $R0 HKLM "SOFTWARE\JavaSoft\Java Web Start" "CurrentVersion"

  ${If} ${JRE_VERSION} S> $R0
     StrCpy $R0 "No"
  ${Else}
     StrCpy $R0 "Yes"
  ${EndIf}

  ; restore state and put results in R0
  Exch $R0
FunctionEnd

Function FindJRE
;
;  Find JRE (javaw.exe) and put it on the stack
;  1 - in .\jre directory (JRE Installed with application)
;  2 - in JAVA_HOME environment variable
;  3 - in the registry
;  Else an error
;
;  Note: It is possible that this will find a version of java
;        that is earlier than what is required.

  ; save state
  Push $R0

  ${If} ${FileExists} "$EXEDIR\jre\bin\javaw.exe"
     StrCpy $R0 "$EXEDIR\jre\bin\javaw.exe"
  ${Else}
    ReadEnvStr $R0 "JAVA_HOME"
    ${If} ${FileExists} "$R0\bin\javaw.exe"
      StrCpy $R0 "$R0\bin\javaw.exe"
    ${Else}
      ReadRegStr $R0 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" "CurrentVersion"
      ReadRegStr $R0 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment\$R0" "JavaHome"
      ${If} ${FileExists} "$R0\bin\javaw.exe"
        StrCpy $R0 "$R0\bin\javaw.exe"
      ${Else}
        ReadRegStr $R0 HKLM "SOFTWARE\JavaSoft\Java Development Kit" "CurrentVersion"
        ReadRegStr $R0 HKLM "SOFTWARE\JavaSoft\Java Development Kit\$R0" "JavaHome"
        ${If} ${FileExists} "$R0\bin\javaw.exe"
          StrCpy $R0 "$R0\bin\javaw.exe"
        ${Else}
          MessageBox MB_OK "Could not find Java.$\rPlease install Java and try again."
          Quit
        ${EndIf}
      ${EndIf}
    ${EndIf}
  ${EndIf}

  ; restore state and put results in R0
  Exch $R0
FunctionEnd
Index: setup.nsi
===================================================================
RCS file: /cvs/jsword/bibledesktop/etc/installer/setup.nsi,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** setup.nsi	1 Jan 2006 03:06:39 -0000	1.2
--- setup.nsi	4 Jan 2006 21:54:55 -0000	1.3
***************
*** 1,191 ****
! # Auto-generated by EclipseNSIS Script Wizard
! # Dec 30, 2005 10:28:50 PM
! 
! Name BibleDesktop
! # Defines
! !define REGKEY "SOFTWARE\$(^Name)"
! !define VERSION 1.0
! !define COMPANY "CrossWire Bible Society"
! !define URL http://www.crosswire.org/bibledesktop
  
! # MUI defines
! !define MUI_ICON bibledesktop.ico
! !define MUI_FINISHPAGE_NOAUTOCLOSE
! !define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM
! !define MUI_STARTMENUPAGE_NODISABLE
! !define MUI_STARTMENUPAGE_REGISTRY_KEY Software\$(^Name)
! !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME StartMenuGroup
! !define MUI_STARTMENUPAGE_DEFAULT_FOLDER $(^Name)
! !define MUI_FINISHPAGE_RUN $INSTDIR\$(^Name).exe
! !define MUI_CUSTOMFUNCTION_GUIINIT CustomGUIInit
! !define MUI_UNICON bibledesktop.ico
! !define MUI_UNFINISHPAGE_NOAUTOCLOSE
  
! # Included files
! !include Sections.nsh
! !include MUI.nsh
  
! # Reserved Files
! ReserveFile "${NSISDIR}\Plugins\BGImage.dll"
! ReserveFile "${NSISDIR}\Plugins\AdvSplash.dll"
  
! # Variables
! Var StartMenuGroup
  
! # Installer pages
  !insertmacro MUI_PAGE_WELCOME
! !insertmacro MUI_PAGE_LICENSE gpl.txt
  !insertmacro MUI_PAGE_DIRECTORY
! !insertmacro MUI_PAGE_STARTMENU Application $StartMenuGroup
  !insertmacro MUI_PAGE_INSTFILES
  !insertmacro MUI_PAGE_FINISH
- !insertmacro MUI_UNPAGE_CONFIRM
- !insertmacro MUI_UNPAGE_INSTFILES
  
! # Installer languages
! !insertmacro MUI_LANGUAGE English
  
! # Installer attributes
! OutFile setup.exe
! InstallDir $PROGRAMFILES\$(^Name)
! CRCCheck on
! XPStyle on
! ShowInstDetails hide
! VIProductVersion 1.0.0.0
! VIAddVersionKey ProductName $(^Name)
! VIAddVersionKey ProductVersion "${VERSION}"
! VIAddVersionKey CompanyName "${COMPANY}"
! VIAddVersionKey CompanyWebsite "${URL}"
! VIAddVersionKey FileVersion ""
! VIAddVersionKey FileDescription ""
! VIAddVersionKey LegalCopyright ""
! InstallDirRegKey HKLM "${REGKEY}" Path
! ShowUninstDetails hide
  
! # Installer sections
! Section -Main SEC0000
!     SetOutPath $INSTDIR
!     SetOverwrite on
!     File bibledesktop.exe
!     File ..\..\target\ant\installed\lucene-1.4.3.jar
!     File ..\..\target\ant\installed\bibledesktop.jar
!     File ..\..\target\ant\installed\common.jar
!     File ..\..\target\ant\installed\commons-codec-1.3.jar
!     File ..\..\target\ant\installed\commons-httpclient-3.0.jar
!     File ..\..\target\ant\installed\commons-logging.jar
!     File ..\..\target\ant\installed\commons-net-1.4.1.jar
!     File ..\..\target\ant\installed\jdom-1.0.jar
!     File ..\..\target\ant\installed\jlfgr-1_0.jar
!     File ..\..\target\ant\installed\jsword.jar
!     WriteRegStr HKLM "${REGKEY}\Components" Main 1
! SectionEnd
  
! Section -post SEC0001
!     WriteRegStr HKLM "${REGKEY}" Path $INSTDIR
!     WriteUninstaller $INSTDIR\uninstall.exe
!     !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
!     SetOutPath $SMPROGRAMS\$StartMenuGroup
!     CreateShortCut "$SMPROGRAMS\$StartMenuGroup\$(^Name).lnk" $INSTDIR\$(^Name).exe
!     CreateShortCut "$SMPROGRAMS\$StartMenuGroup\Uninstall $(^Name).lnk" $INSTDIR\uninstall.exe
!     !insertmacro MUI_STARTMENU_WRITE_END
!     WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)"
!     WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayVersion "${VERSION}"
!     WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" Publisher "${COMPANY}"
!     WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" URLInfoAbout "${URL}"
!     WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayIcon $INSTDIR\uninstall.exe
!     WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" UninstallString $INSTDIR\uninstall.exe
!     WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoModify 1
!     WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoRepair 1
! SectionEnd
  
! # Macro for selecting uninstaller sections
! !macro SELECT_UNSECTION SECTION_NAME UNSECTION_ID
!     Push $R0
!     ReadRegStr $R0 HKLM "${REGKEY}\Components" "${SECTION_NAME}"
!     StrCmp $R0 1 0 next${UNSECTION_ID}
!     !insertmacro SelectSection "${UNSECTION_ID}"
!     Goto done${UNSECTION_ID}
! next${UNSECTION_ID}:
!     !insertmacro UnselectSection "${UNSECTION_ID}"
! done${UNSECTION_ID}:
!     Pop $R0
! !macroend
  
! # Uninstaller sections
! Section /o un.Main UNSEC0000
!     Delete /REBOOTOK $INSTDIR\jsword.jar
!     Delete /REBOOTOK $INSTDIR\jlfgr-1_0.jar
!     Delete /REBOOTOK $INSTDIR\jdom-1.0.jar
!     Delete /REBOOTOK $INSTDIR\commons-net-1.4.0.jar
!     Delete /REBOOTOK $INSTDIR\commons-logging.jar
!     Delete /REBOOTOK $INSTDIR\commons-httpclient-3.0-rc3.jar
!     Delete /REBOOTOK $INSTDIR\commons-codec-1.3.jar
!     Delete /REBOOTOK $INSTDIR\common.jar
!     Delete /REBOOTOK $INSTDIR\bibledesktop.jar
!     Delete /REBOOTOK $INSTDIR\lucene-1.4.3.jar
!     Delete /REBOOTOK $INSTDIR\bibledesktop.exe
!     DeleteRegValue HKLM "${REGKEY}\Components" Main
  SectionEnd
  
! Section un.post UNSEC0001
!     DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"
!     Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\Uninstall $(^Name).lnk"
!     Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\$(^Name).lnk"
!     Delete /REBOOTOK $INSTDIR\uninstall.exe
!     DeleteRegValue HKLM "${REGKEY}" StartMenuGroup
!     DeleteRegValue HKLM "${REGKEY}" Path
!     DeleteRegKey /ifempty HKLM "${REGKEY}\Components"
!     DeleteRegKey /ifempty HKLM "${REGKEY}"
!     RMDir /REBOOTOK $SMPROGRAMS\$StartMenuGroup
!     RMDir /REBOOTOK $INSTDIR
  SectionEnd
  
! # Installer functions
! Function CustomGUIInit
!     Push $R1
!     Push $R2
!     BgImage::SetReturn /NOUNLOAD on
!     BgImage::SetBg /NOUNLOAD /GRADIENT "0 0 128 0 0 0"
!     Pop $R1
!     StrCmp $R1 success 0 error
!     File /oname=$PLUGINSDIR\bgimage.bmp splash.bmp
!     System::call "user32::GetSystemMetrics(i 0)i.R1"
!     System::call "user32::GetSystemMetrics(i 1)i.R2"
!     IntOp $R1 $R1 - 599
!     IntOp $R1 $R1 / 2
!     IntOp $R2 $R2 - 307
!     IntOp $R2 $R2 / 2
!     BGImage::AddImage /NOUNLOAD $PLUGINSDIR\bgimage.bmp $R1 $R2
!     CreateFont $R1 "Times New Roman" 26 700 /ITALIC
!     BGImage::AddText /NOUNLOAD "$(^SetupCaption)" $R1 "255 255 255" 16 8 500 100
!     Pop $R1
!     StrCmp $R1 success 0 error
!     BGImage::Redraw /NOUNLOAD
!     Goto done
! error:
!     MessageBox MB_OK|MB_ICONSTOP $R1
! done:
!     Pop $R2
!     Pop $R1
! FunctionEnd
  
- Function .onGUIEnd
-     BGImage::Destroy
- FunctionEnd
  
! Function .onInit
!     InitPluginsDir
!     Push $R1
!     File /oname=$PLUGINSDIR\spltmp.bmp splash.bmp
!     advsplash::show 1000 600 400 -1 $PLUGINSDIR\spltmp
!     Pop $R1
!     Pop $R1
  FunctionEnd
  
- # Uninstaller functions
  Function un.onInit
!     ReadRegStr $INSTDIR HKLM "${REGKEY}" Path
!     ReadRegStr $StartMenuGroup HKLM "${REGKEY}" StartMenuGroup
!     !insertmacro SELECT_UNSECTION Main ${UNSEC0000}
  FunctionEnd
  
--- 1,99 ----
! ; Script generated by the HM NIS Edit Script Wizard.
  
! ; HM NIS Edit Wizard helper defines
! !define PRODUCT_NAME "BibleDesktop"
! !define PRODUCT_VERSION "1.0"
! !define PRODUCT_PUBLISHER "Crosswire Bible Society"
! !define PRODUCT_WEB_SITE "http://www.crosswire.org/bibledesktop/index.html"
! !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\bibledesktop.exe"
! !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
! !define PRODUCT_UNINST_ROOT_KEY "HKLM"
  
! SetCompressor lzma
  
! ; MUI 1.67 compatible ------
! !include "MUI.nsh"
  
! ; MUI Settings
! !define MUI_ABORTWARNING
! !define MUI_ICON "bibledesktop.ico"
! !define MUI_UNICON "bibledesktop.ico"
  
! ; Welcome page
  !insertmacro MUI_PAGE_WELCOME
! ; License page
! !insertmacro MUI_PAGE_LICENSE "gpl.txt"
! ; Directory page
  !insertmacro MUI_PAGE_DIRECTORY
! ; Instfiles page
  !insertmacro MUI_PAGE_INSTFILES
+ ; Finish page
+ !define MUI_FINISHPAGE_RUN "$INSTDIR\bibledesktop.exe"
  !insertmacro MUI_PAGE_FINISH
  
! ; Uninstaller pages
! !insertmacro MUI_UNPAGE_INSTFILES
  
! ; Language files
! !insertmacro MUI_LANGUAGE "English"
  
! ; Reserve files
! !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
  
! ; MUI end ------
  
! Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
! OutFile "Setup.exe"
! InstallDir "$PROGRAMFILES\${PRODUCT_NAME}"
! InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
! ShowInstDetails show
! ShowUnInstDetails show
  
! Section "MainSection" SEC01
!   SetOutPath "$INSTDIR"
!   SetOverwrite ifnewer
!   File "bibledesktop.exe"
!   CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
!   CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk" "$INSTDIR\bibledesktop.exe"
!   CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\bibledesktop.exe"
!   File ..\..\target\ant\installed\*.jar
  SectionEnd
  
! Section -AdditionalIcons
!   WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
!   CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME} on the Web.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
!   CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall ${PRODUCT_NAME}.lnk" "$INSTDIR\uninst.exe"
  SectionEnd
  
! Section -Post
!   WriteUninstaller "$INSTDIR\uninst.exe"
!   WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\bibledesktop.exe"
!   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
!   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
!   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\bibledesktop.exe"
!   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
!   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
!   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
! SectionEnd
  
  
! Function un.onUninstSuccess
!   HideWindow
!   MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
  FunctionEnd
  
  Function un.onInit
!   MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
!   Abort
  FunctionEnd
  
+ Section Uninstall
+   Delete /REBOOTOK "$DESKTOP\${PRODUCT_NAME}.lnk"
+ 
+   RMDir /r /REBOOTOK "$SMPROGRAMS\${PRODUCT_NAME}"
+   RMDir /r /REBOOTOK $INSTDIR
+ 
+   DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
+   DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
+   SetAutoClose true
+ SectionEnd
\ No newline at end of file

Index: bibledesktop.exe
===================================================================
RCS file: /cvs/jsword/bibledesktop/etc/installer/bibledesktop.exe,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
Binary files /tmp/cvsZ1Pq3z and /tmp/cvs8oYeT7 differ

Index: setup.exe
===================================================================
RCS file: /cvs/jsword/bibledesktop/etc/installer/setup.exe,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
Binary files /tmp/cvs6hFwID and /tmp/cvszYYhKb differ

--- NEW FILE: README.txt ---
This file describes how to build and maintain a windows installer for BibleDesktop.

Currently we are using NSIS (NullSoft Scriptable Install System) to deploy BibleDesktop to Windows.

Prerequsites:
1) A windows computer to build the installer.
2) NSIS installed your Windows computer. You can obtain it here:
    http://nsis.sourceforge.net/Download
3) InetLoad.dll in the NSIS/plugins directory. You can obtain it from here:
    http://nsis.sourceforge.net/mediawiki/images/b/b4/InetLoad.zip
*) Optionally, install EclipseNSIS plugin. You can obtain it here:
    http://eclipsensis.sourceforge.net
   This plugin allows for wizard creation,
                      for smart editing,
                      for simple compiling
   of NSIS scripts.

In this directory there are two scripts. One for running the application and the other for deploying the application.

The application script, BibleDesktop.nsi, will create BibleDesktop.exe.
The program when run will check to see if Java is installed.
If it is not then it will offer to automatically download and install it.
This script will need to be updated from time to time to get the current version of Java.
Once there is a suitable Java on the computer, it will run BibleDesktop.

The deployment script will create setup.exe.

The typical pattern of events to build the whole shebang is:
1) Build all the jars using ant.
2) Compile the application script into BibleDesktop.exe
   This only needs to be done when BibleDesktop.nsi changes
3) Compile the setup script into setup.exe.
   This needs to be done each time the jars change or Setup.nsi changes.
4) Copy the setup.exe to a suitable place on crosswire.org.

At this point and time, these steps are manual. While it would be good to automate it,
we don't release often enough to make this a big deal. And we may change how we do
things before the next release.


More information about the jsword-svn mailing list