RubyPackager 1.2.0.20120302 → 1.2.1.20131211

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,171 +0,0 @@
1
- #--
2
- # Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
- # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
- #++
5
-
6
- # This file prepares a win32 distribution on mingw32 architecture
7
-
8
- # Require needed to generate the temporary ruby file that produces the executable
9
- require 'tmpdir'
10
-
11
- module RubyPackager
12
-
13
- class PlatformReleaser
14
-
15
- PLATFORM_DIR = File.dirname(__FILE__)
16
-
17
- # Check if the tools we will use to generate an executable are present
18
- #
19
- # Parameters::
20
- # * *iRootDir* (_String_): Root directory
21
- # * *iIncludeRuby* (_Boolean_): Do we include Ruby in the release ?
22
- # * *iNeedBinaryCompilation* (_Boolean_): Do we need to compile RB files into a binary executable ?
23
- # Return::
24
- # * _Boolean_: Are tools correctly useable ?
25
- def check_exe_tools(iRootDir, iIncludeRuby, iNeedBinaryCompilation)
26
- rSuccess = true
27
-
28
- if (iIncludeRuby)
29
- # We need allinoneruby
30
- if (Gem.find_files('allinoneruby').empty?)
31
- log_err "Need to have allinoneruby gem to release including Ruby.\nPlease install allinoneruby gem (gem install allinoneruby)."
32
- rSuccess = false
33
- end
34
- end
35
- if (iNeedBinaryCompilation)
36
- # Check that edicon is present
37
- if (!File.exists?("#{PLATFORM_DIR}/edicon/edicon.exe"))
38
- log_err "Need to have edicon.exe installed in #{PLATFORM_DIR}/edicon to set a Windows executable's icon.\nPlease install edicon, part of Ocra Gem (gem install ocra), and copy from the Gem directory (ocra-1.1.1/share/ocra/edicon.exe) to #{PLATFORM_DIR}/edicon/edicon.exe."
39
- rSuccess = false
40
- end
41
- # Check that exerb is present
42
- if (!system('exerb.bat --version'))
43
- log_err "Need to have exerb installed in the system PATH to create a Windows executable.\nPlease download and install exerb from http://exerb.sourceforge.jp/index.en.html"
44
- rSuccess = false
45
- end
46
- end
47
-
48
- return rSuccess
49
- end
50
-
51
- # Create the binary.
52
- # This is called when the core library has been copied in the release directory.
53
- #
54
- # Parameters::
55
- # * *iRootDir* (_String_): Root directory
56
- # * *iReleaseDir* (_String_): Release directory
57
- # * *iIncludeRuby* (_Boolean_): Do we include Ruby in the release ?
58
- # * *iExecutableInfo* (<em>map<Symbol,Object></em>): The executable information
59
- # Return::
60
- # * _Boolean_: Success ?
61
- def create_binary(iRootDir, iReleaseDir, iIncludeRuby, iExecutableInfo)
62
- rSuccess = true
63
-
64
- lBinSubDir = "Launch/#{RUBY_PLATFORM}/bin"
65
- lRubyBaseBinName = nil
66
- lRubyLaunchCmd = nil
67
- if (iExecutableInfo[:terminal_application])
68
- lRubyBaseBinName = 'ruby'
69
- lRubyLaunchCmd = 'ruby'
70
- else
71
- lRubyBaseBinName = 'rubyw'
72
- lRubyLaunchCmd = 'start rubyw'
73
- end
74
- lBinName = "#{lRubyBaseBinName}-#{RUBY_VERSION}.exe"
75
- if (iIncludeRuby)
76
- # First create the binary containing all ruby
77
- lBinDir = "#{iReleaseDir}/#{lBinSubDir}"
78
- FileUtils::mkdir_p(lBinDir)
79
- change_dir(lBinDir) do
80
- lCmd = nil
81
- if (iExecutableInfo[:terminal_application])
82
- lCmd = "allinoneruby.bat #{lBinName}"
83
- else
84
- lCmd = "allinoneruby.bat --rubyw #{lBinName}"
85
- end
86
- rSuccess = system(lCmd)
87
- if (!rSuccess)
88
- log_err "Error while executing \"#{lCmd}\""
89
- end
90
- end
91
- end
92
- if (rSuccess)
93
- # Then create the real executable
94
- # Generate the Ruby file that launches everything for Windows
95
- lTempFileName = "#{Dir.tmpdir}/EXE_#{RUBY_PLATFORM}_Gen.rb"
96
- File.open(lTempFileName, 'w') do |oFile|
97
- oFile << "
98
- \#--
99
- \# Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
100
- \# Licensed under the terms specified in LICENSE file. No warranty is provided.
101
- \#++
102
-
103
- \# This file is generated by RubyPackager for Windows (mingw32).
104
- \# This is a temporary file that should not exist anymore once the release has been done.
105
-
106
- \# This file has to launch the correct binary. There can be several binaries dependending on the configuration.
107
- \# This is the file that will be created as the executable to launch.
108
-
109
- module RubyPackager
110
-
111
- \# Execute a shell command
112
- \#
113
- \# Parameters::
114
- \# * *iCmd* (_String_): The shell command to execute
115
- \# Return::
116
- \# * _Boolean_: Success ?
117
- def self.shellExecute(iCmd)
118
- puts \"> \#{iCmd}\"
119
- rSuccess = system(iCmd)
120
-
121
- if (!rSuccess)
122
- puts \"Error while executing '\#{iCmd}'\"
123
- end
124
-
125
- return rSuccess
126
- end
127
-
128
- end
129
-
130
- \# Test if Ruby is installed
131
- lSuccess = false
132
- lCurrentDir = Dir.getwd
133
- if (system('#{lRubyBaseBinName} --version'))
134
- \# Launch directly
135
- puts \"Ruby found in environment. Using it directly.\"
136
- lSuccess = RubyPackager::shellExecute(\"#{lRubyLaunchCmd} -w \\\"\#{lCurrentDir}/#{iExecutableInfo[:startup_rb_file]}\\\" \#{ARGV.join(' ')}\")
137
- end
138
- if (!lSuccess)
139
- \# Use allinoneruby
140
- puts \"Ruby not found in environment. Using shipped Ruby.\"
141
- lSuccess = RubyPackager::shellExecute(\"start \\\"Title\\\" \\\"\#{lCurrentDir}/#{lBinSubDir}/#{lBinName}\\\" \\\"\#{lCurrentDir}/#{iExecutableInfo[:startup_rb_file]}\\\" \#{ARGV.join(' ')}\")
142
- if (!lSuccess)
143
- puts 'Unable to execute the application. Please reinstall it.'
144
- puts 'Hit enter to quit.'
145
- $stdin.gets
146
- end
147
- end
148
- "
149
- end
150
- change_dir(iReleaseDir) do
151
- rSuccess = system("exerb.bat -o #{iExecutableInfo[:exe_name]}.exe #{lTempFileName}")
152
- end
153
- if (rSuccess)
154
- File.unlink(lTempFileName)
155
- # And set its icon
156
- lEdiconCmd = "#{PLATFORM_DIR}/edicon/edicon.exe #{iReleaseDir}/#{iExecutableInfo[:exe_name]}.exe #{iRootDir}/#{iExecutableInfo[:icon_name]}"
157
- rSuccess = system(lEdiconCmd)
158
- if (!rSuccess)
159
- log_err "Error while executing \"#{lEdiconCmd}\""
160
- end
161
- else
162
- log_err "Error while executing \"exerb.bat -o #{iExecutableInfo[:exe_name]}.exe #{lTempFileName}\""
163
- end
164
- end
165
-
166
- return rSuccess
167
- end
168
-
169
- end
170
-
171
- end
@@ -1,59 +0,0 @@
1
- #--
2
- # Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
- # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
- #++
5
-
6
- module RubyPackager
7
-
8
- module Installers
9
-
10
- class NSIS
11
-
12
- # Check that we can use this installer
13
- #
14
- # Return::
15
- # * _Boolean_: Can we use this installer ?
16
- def check_tools
17
- rSuccess = true
18
-
19
- # Check that makensis is present
20
- if (!system('makensis /VERSION'))
21
- log_err "Need to have MakeNSIS installed in the system PATH to create installer.\nPlease download and install MakeNSIS in the PATH from http://nsis.sourceforge.net/Main_Page"
22
- rSuccess = false
23
- end
24
-
25
- return rSuccess
26
- end
27
-
28
- # Create the installer with everything in the release directory.
29
- #
30
- # Parameters::
31
- # * *iRootDir* (_String_): The Root directory
32
- # * *iReleaseDir* (_String_): The release directory (all files to put in the installer are there)
33
- # * *iInstallerDir* (_String_): The directory where the installer has to be put
34
- # * *iVersion* (_String_): Release version
35
- # * *iReleaseInfo* (_ReleaseInfo_): Release info
36
- # Return::
37
- # * _String_: File name to distribute, or nil in case of failure
38
- def create_installer(iRootDir, iReleaseDir, iInstallerDir, iVersion, iReleaseInfo)
39
- rFileName = nil
40
-
41
- if (iReleaseInfo.install_info[:nsis_file_name] == nil)
42
- log_err 'No NSISFileName specified among the Install description.'
43
- else
44
- lNSISOK = system("makensis /DVERSION=#{iVersion} \"/DRELEASEDIR=#{iReleaseDir.gsub(/\//,'\\')}\" \"#{iRootDir.gsub(/\//,'\\')}\\#{iReleaseInfo.install_info[:nsis_file_name].gsub(/\//,'\\')}\"")
45
- if (lNSISOK)
46
- lInstallerDir = File.dirname("#{iRootDir}/#{iReleaseInfo.install_info[:nsis_file_name]}")
47
- rFileName = "#{iReleaseInfo.install_info[:installer_name]}_#{iVersion}_setup.exe"
48
- FileUtils.mv("#{lInstallerDir}/setup.exe", "#{iInstallerDir}/#{rFileName}")
49
- end
50
- end
51
-
52
- return rFileName
53
- end
54
-
55
- end
56
-
57
- end
58
-
59
- end