Permalink
Browse files

Make an installer with NSIS.

  • Loading branch information...
1 parent 5e6e1f3 commit 9b65fb0cc3c99ad561154451efff9d7d0b7b0292 @mcolyer committed Feb 17, 2011
Showing with 137 additions and 6 deletions.
  1. +7 −0 LICENSE
  2. +6 −3 README.md
  3. +18 −2 Rakefile
  4. +1 −1 installer/launch4j.xml
  5. +105 −0 installer/nsis.nsi
View
@@ -0,0 +1,7 @@
+Copyright (c) 2009 - 2011: Matt Colyer
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
@@ -35,17 +35,18 @@ PowerMeter.
:token: "your-token"
:variable: "your-path-with.d1-appended"
-To Build
+To Build the Windows Installer
--------
-In order to build the self contained binaries, you'll need a working jruby interpreter.
+In order to build the self contained binaries, you'll need Java 1.6 and
+(NSIS)[1], both are available as packages in Ubuntu.
git clone git://github.com/mcolyer/smartermeter.git
cd smartermeter
bundle install --path vendor/gems --without test
rake package
-All of the required files are now placed in pkg/base/
+The installer will be generated in pkg/
Questions
---------
@@ -63,3 +64,5 @@ Questions
* How can I help?
Make sure it works, make cool things with it or send me git pull requests.
+
+[1]: http://nsis.sourceforge.net/
View
@@ -138,8 +138,7 @@ task :create_launcher do
`installer/launch4j/launch4j #{configuration}`
end
-desc "Package all required files into pkg/base"
-task :package => [:fetch_jruby, :fetch_launch4j, :package_gems, :create_launcher] do
+task :copy_smartermeter do
src_dir = Dir.glob(File.join(File.dirname(__FILE__), "lib", "*"))
dest_dir = File.join(File.dirname(__FILE__), "pkg", "base")
FileUtils.mkdir_p(dest_dir)
@@ -148,6 +147,23 @@ task :package => [:fetch_jruby, :fetch_launch4j, :package_gems, :create_launcher
FileUtils.cp(Dir.glob(File.join(File.dirname(__FILE__), "icon*")), dest_dir)
end
+task :copy_smartermeter do
+ src_dir = Dir.glob(File.join(File.dirname(__FILE__), "lib", "*"))
+ dest_dir = File.join(File.dirname(__FILE__), "pkg", "base")
+ FileUtils.mkdir_p(dest_dir)
+ FileUtils.cp_r(src_dir, dest_dir)
+
+ FileUtils.cp(Dir.glob(File.join(File.dirname(__FILE__), "icon*")), dest_dir)
+end
+
+task :nsis_installer do
+ nsis_file = File.join(File.dirname(__FILE__), "installer", "nsis.nsi")
+ `makensis -DVERSION=#{version} #{nsis_file}`
+end
+
+desc "Package all required files into pkg/base"
+task :package => [:fetch_jruby, :fetch_launch4j, :package_gems, :create_launcher, :copy_smartermeter, :nsis_installer]
+
#############################################################################
#
# Packaging tasks
View
@@ -13,7 +13,7 @@
<stayAlive>false</stayAlive>
<manifest></manifest>
<icon></icon>
- <var>GEM_HOME=jruby/1.8</var>
+ <var>GEM_HOME=gems</var>
<singleInstance>
<mutexName>smartermeter</mutexName>
<windowTitle>Smartermeter</windowTitle>
View
@@ -0,0 +1,105 @@
+;NSIS Modern User Interface
+;Welcome/Finish Page Example Script
+;Written by Joost Verburg
+
+;--------------------------------
+;Include Modern UI
+
+ !include "MUI2.nsh"
+
+;--------------------------------
+;General
+
+ ;Name and file
+ Name "Smartermeter"
+ OutFile "../pkg/smartermeter-${VERSION}.exe"
+
+ ;Default installation folder
+ InstallDir "$PROGRAMFILES\Smartermeter"
+
+ ;Get installation folder from registry if available
+ InstallDirRegKey HKCU "Software\Smartermeter" ""
+
+ ;Request application privileges for Windows Vista
+ RequestExecutionLevel user
+
+;--------------------------------
+;Interface Settings
+
+ !define MUI_ABORTWARNING
+
+;--------------------------------
+;Pages
+
+ !insertmacro MUI_PAGE_WELCOME
+ !insertmacro MUI_PAGE_LICENSE "..\LICENSE"
+ !insertmacro MUI_PAGE_COMPONENTS
+ !insertmacro MUI_PAGE_DIRECTORY
+ !insertmacro MUI_PAGE_INSTFILES
+ !insertmacro MUI_PAGE_FINISH
+
+ !insertmacro MUI_UNPAGE_WELCOME
+ !insertmacro MUI_UNPAGE_CONFIRM
+ !insertmacro MUI_UNPAGE_INSTFILES
+ !insertmacro MUI_UNPAGE_FINISH
+
+;--------------------------------
+;Languages
+
+ !insertmacro MUI_LANGUAGE "English"
+
+;--------------------------------
+;Installer Sections
+
+Section "Smartermeter Base" SecBase
+
+ SetOutPath "$INSTDIR"
+
+ ;ADD YOUR OWN FILES HERE...
+ File /r "../pkg/base/*"
+
+ CreateDirectory "$SMPROGRAMS\Smartermeter"
+ CreateShortCut "$SMPROGRAMS\Smartermeter\Smartermeter.lnk" "$INSTDIR\smartermeter.exe"
+ CreateShortCut "$SMPROGRAMS\Smartermeter\Uninstall.lnk" "$INSTDIR\uninstall.exe"
+
+ ;Store installation folder
+ WriteRegStr HKCU "Software\Smartermeter" "" $INSTDIR
+
+ ;Create uninstaller
+ WriteUninstaller "$INSTDIR\uninstall.exe"
+SectionEnd
+
+;--------------------------------
+;Descriptions
+
+ ;Language strings
+ LangString DESC_SecBase ${LANG_ENGLISH} "The smartermeter application."
+
+ ;Assign language strings to sections
+ !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
+ !insertmacro MUI_DESCRIPTION_TEXT ${SecBase} $(DESC_SecBase)
+ !insertmacro MUI_FUNCTION_DESCRIPTION_END
+
+;--------------------------------
+;Uninstaller Section
+
+Section "Uninstall"
+
+ ;ADD YOUR OWN FILES HERE...
+
+ Delete "$INSTDIR\*.rb"
+ Delete "$INSTDIR\*.png"
+ Delete "$INSTDIR\*.jar"
+ Delete "$INSTDIR\*.exe"
+ RMDIR /r "$INSTDIR\gems"
+ RMDIR /r "$INSTDIR\smartermeter"
+
+ Delete "$SMPROGRAMS\Smartermeter\Smartermeter.lnk"
+ Delete "$SMPROGRAMS\Smartermeter\Uninstall.lnk"
+ RMDIR "$SMPROGRAMS\Smartermeter"
+
+ RMDir "$INSTDIR"
+
+ DeleteRegKey /ifempty HKCU "Software\Smartermeter"
+
+SectionEnd

0 comments on commit 9b65fb0

Please sign in to comment.