RubyPackager 0.2.1.20101110 → 1.0.0.20120301
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/AUTHORS +1 -1
- data/ChangeLog +40 -1
- data/LICENSE +1 -1
- data/README +2 -5
- data/ReleaseInfo +2 -2
- data/bin/Release.rb +18 -18
- data/lib/RubyPackager/Distributors/RubyGems.rb +67 -0
- data/lib/RubyPackager/Distributors/SourceForge.rb +22 -75
- data/lib/RubyPackager/Installers/Gem.rb +34 -34
- data/lib/RubyPackager/ReleaseInfo.rb +87 -85
- data/lib/RubyPackager/Releaser.rb +91 -73
- data/lib/RubyPackager/Tools.rb +62 -33
- data/lib/RubyPackager/i386-cygwin/PlatformReleaser.rb +16 -15
- data/lib/RubyPackager/i386-linux/PlatformReleaser.rb +16 -15
- data/lib/RubyPackager/i386-mingw32/Installers/NSIS.rb +59 -0
- data/lib/RubyPackager/i386-mingw32/PlatformReleaser.rb +171 -0
- data/lib/RubyPackager/i386-mingw32/edicon/edicon.exe +0 -0
- data/lib/RubyPackager/i386-mswin32/Installers/NSIS.rb +12 -12
- data/lib/RubyPackager/i386-mswin32/PlatformReleaser.rb +34 -31
- metadata +42 -10
- data/TODO +0 -16
data/lib/RubyPackager/Tools.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2009-
|
2
|
+
# Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
|
3
3
|
# Licensed under the terms specified in LICENSE file. No warranty is provided.
|
4
4
|
#++
|
5
5
|
|
@@ -7,39 +7,28 @@ module RubyPackager
|
|
7
7
|
|
8
8
|
module Tools
|
9
9
|
|
10
|
-
#
|
11
|
-
@@Passwords = {}
|
12
|
-
|
13
|
-
# Get a needed password.
|
14
|
-
# Ask it from the user if we don't know it
|
10
|
+
# Set options that will be used by SSH calls
|
15
11
|
#
|
16
|
-
# Parameters
|
17
|
-
# * *
|
18
|
-
#
|
19
|
-
# *
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
# TODO: Hide the output
|
25
|
-
@@Passwords[iLogin] = $stdin.gets.strip
|
26
|
-
end
|
27
|
-
|
28
|
-
return @@Passwords[iLogin]
|
12
|
+
# Parameters::
|
13
|
+
# * *iSSHHost* (_String_): The SSH host
|
14
|
+
# * *iSSHLogin* (_String_): The SSH login
|
15
|
+
# * *iOptions* (<em>map<Symbol,Object></em>): Additional options [optional = {}]:
|
16
|
+
# * *:ask_for_password* (_Boolean_): Do we ask for the user password to give to SSH ?
|
17
|
+
# * *:ask_for_key_passphrase* (_Boolean_): Do we ask for the key passphrase to give to SSH ?
|
18
|
+
def set_ssh_options(iSSHHost, iSSHLogin, iOptions = {})
|
19
|
+
@SSHHost, @SSHLogin, @SSHOptions = iSSHHost, iSSHLogin, iOptions
|
29
20
|
end
|
30
21
|
|
31
22
|
# Execute some SSH command on a remote host protected with password
|
32
23
|
#
|
33
|
-
# Parameters
|
34
|
-
# * *iSSHHost* (_String_): The SSH host
|
35
|
-
# * *iSSHLogin* (_String_): The SSH login
|
24
|
+
# Parameters::
|
36
25
|
# * *iCmd* (_String_): The command to execute
|
37
|
-
def
|
26
|
+
def ssh(iCmd)
|
38
27
|
require 'net/ssh'
|
39
28
|
Net::SSH.start(
|
40
|
-
|
41
|
-
|
42
|
-
|
29
|
+
@SSHHost,
|
30
|
+
@SSHLogin,
|
31
|
+
get_net_ssh_options
|
43
32
|
) do |iSSH|
|
44
33
|
puts(iSSH.exec!(iCmd))
|
45
34
|
end
|
@@ -47,17 +36,15 @@ module RubyPackager
|
|
47
36
|
|
48
37
|
# Copy files through SCP.
|
49
38
|
#
|
50
|
-
# Parameters
|
51
|
-
# * *iSCPHost* (_String_): Host
|
52
|
-
# * *iSCPLogin* (_String_): Login
|
39
|
+
# Parameters::
|
53
40
|
# * *iFileSrc* (_String_): Path to local file to copy from
|
54
41
|
# * *iFileDst* (_String_): Path to remote file to copy to
|
55
|
-
def
|
42
|
+
def scp(iFileSrc, iFileDst)
|
56
43
|
require 'net/scp'
|
57
44
|
Net::SCP.start(
|
58
|
-
|
59
|
-
|
60
|
-
|
45
|
+
@SSHHost,
|
46
|
+
@SSHLogin,
|
47
|
+
get_net_ssh_options
|
61
48
|
) do |iSCP|
|
62
49
|
iSCP.upload!(iFileSrc, iFileDst) do |iChunk, iName, iSent, iTotal|
|
63
50
|
printf "#{iName}: #{iSent}/#{iTotal}\015"
|
@@ -67,6 +54,48 @@ module RubyPackager
|
|
67
54
|
end
|
68
55
|
end
|
69
56
|
|
57
|
+
private
|
58
|
+
|
59
|
+
# The map of stored passwords, per login
|
60
|
+
@@Passwords = {}
|
61
|
+
|
62
|
+
# Get a needed password.
|
63
|
+
# Ask it from the user if we don't know it
|
64
|
+
#
|
65
|
+
# Parameters::
|
66
|
+
# * *iLogin* (_String_): String for which we want the password
|
67
|
+
# Return::
|
68
|
+
# * _String_: Password
|
69
|
+
def get_password(iLogin)
|
70
|
+
if (@@Passwords[iLogin] == nil)
|
71
|
+
# Ask for it
|
72
|
+
require 'highline/import'
|
73
|
+
@@Passwords[iLogin] = ask("Enter password for #{iLogin}:") do |ioQuestion|
|
74
|
+
ioQuestion.echo = false
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
return @@Passwords[iLogin]
|
79
|
+
end
|
80
|
+
|
81
|
+
# Get the real SSH options that will be given to the Net::SSH library
|
82
|
+
# These are based on the way SSH options are set by set_ssh_options
|
83
|
+
#
|
84
|
+
# Return::
|
85
|
+
# * <em>map<Symbol,Object></em>: The Net::SSH options
|
86
|
+
def get_net_ssh_options
|
87
|
+
rOptions = {}
|
88
|
+
|
89
|
+
if (@SSHOptions[:ask_for_password])
|
90
|
+
rOptions[:password] = get_password("login #{@SSHLogin}")
|
91
|
+
end
|
92
|
+
if (@SSHOptions[:ask_for_key_passphrase])
|
93
|
+
rOptions[:passphrase] = get_password("key passphrase of #{@SSHLogin}")
|
94
|
+
end
|
95
|
+
|
96
|
+
return rOptions
|
97
|
+
end
|
98
|
+
|
70
99
|
end
|
71
100
|
|
72
101
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2009-
|
2
|
+
# Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
|
3
3
|
# Licensed under the terms specified in LICENSE file. No warranty is provided.
|
4
4
|
#++
|
5
5
|
|
@@ -16,18 +16,19 @@ module RubyPackager
|
|
16
16
|
|
17
17
|
# Check if the tools we will use to generate an executable are present
|
18
18
|
#
|
19
|
-
# Parameters
|
19
|
+
# Parameters::
|
20
20
|
# * *iRootDir* (_String_): Root directory
|
21
21
|
# * *iIncludeRuby* (_Boolean_): Do we include Ruby in the release ?
|
22
|
-
#
|
22
|
+
# * *iNeedBinaryCompilation* (_Boolean_): Do we need to compile RB files into a binary executable ?
|
23
|
+
# Return::
|
23
24
|
# * _Boolean_: Are tools correctly useable ?
|
24
|
-
def
|
25
|
+
def check_exe_tools(iRootDir, iIncludeRuby, iNeedBinaryCompilation)
|
25
26
|
rSuccess = true
|
26
27
|
|
27
28
|
if (iIncludeRuby)
|
28
29
|
# We need allinoneruby
|
29
30
|
if (Gem.find_files('allinoneruby').empty?)
|
30
|
-
|
31
|
+
log_err "Need to have allinoneruby gem to release including Ruby.\nPlease install allinoneruby gem (gem install allinoneruby)."
|
31
32
|
rSuccess = false
|
32
33
|
end
|
33
34
|
end
|
@@ -38,14 +39,14 @@ module RubyPackager
|
|
38
39
|
# Create the binary.
|
39
40
|
# This is called when the core library has been copied in the release directory.
|
40
41
|
#
|
41
|
-
# Parameters
|
42
|
+
# Parameters::
|
42
43
|
# * *iRootDir* (_String_): Root directory
|
43
44
|
# * *iReleaseDir* (_String_): Release directory
|
44
45
|
# * *iIncludeRuby* (_Boolean_): Do we include Ruby in the release ?
|
45
46
|
# * *iExecutableInfo* (<em>map<Symbol,Object></em>): The executable information
|
46
|
-
# Return
|
47
|
+
# Return::
|
47
48
|
# * _Boolean_: Success ?
|
48
|
-
def
|
49
|
+
def create_binary(iRootDir, iReleaseDir, iIncludeRuby, iExecutableInfo)
|
49
50
|
rSuccess = true
|
50
51
|
|
51
52
|
lBinSubDir = "Launch/#{RUBY_PLATFORM}/bin"
|
@@ -55,21 +56,21 @@ module RubyPackager
|
|
55
56
|
# First create the binary containing all ruby
|
56
57
|
lBinDir = "#{iReleaseDir}/#{lBinSubDir}"
|
57
58
|
FileUtils::mkdir_p(lBinDir)
|
58
|
-
|
59
|
+
change_dir(lBinDir) do
|
59
60
|
lCmd = "allinoneruby #{lBinName}"
|
60
61
|
rSuccess = system(lCmd)
|
61
62
|
if (!rSuccess)
|
62
|
-
|
63
|
+
log_err "Error while executing \"#{lCmd}\""
|
63
64
|
end
|
64
65
|
end
|
65
66
|
end
|
66
67
|
if (rSuccess)
|
67
68
|
# Then create the real executable
|
68
69
|
# Generate the Shell file that launches everything for Linux
|
69
|
-
File.open("#{iReleaseDir}/#{iExecutableInfo[:
|
70
|
+
File.open("#{iReleaseDir}/#{iExecutableInfo[:exe_name]}", 'w') do |oFile|
|
70
71
|
oFile << "\#!/bin/sh
|
71
72
|
\#--
|
72
|
-
\# Copyright (c) 2009-
|
73
|
+
\# Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
|
73
74
|
\# Licensed under the terms specified in LICENSE file. No warranty is provided.
|
74
75
|
\#++
|
75
76
|
|
@@ -94,14 +95,14 @@ then
|
|
94
95
|
\# Set the environment correctly to execute Ruby from the extracted dir
|
95
96
|
export LD_LIBRARY_PATH=`pwd`/tempruby/bin:`pwd`/tempruby/lib:`pwd`/tempruby/lib/lib1:`pwd`/tempruby/lib/lib2:`pwd`/tempruby/lib/lib3:`pwd`/tempruby/lib/lib4:${LD_LIRARY_PATH}
|
96
97
|
export RUBYOPT=
|
97
|
-
./tempruby/bin/ruby -w #{iExecutableInfo[:
|
98
|
+
./tempruby/bin/ruby -w #{iExecutableInfo[:startup_rb_file]}
|
98
99
|
else
|
99
100
|
echo 'Ruby found on current platform. Use it directly.'
|
100
|
-
ruby -w #{iExecutableInfo[:
|
101
|
+
ruby -w #{iExecutableInfo[:startup_rb_file]}
|
101
102
|
fi
|
102
103
|
"
|
103
104
|
end
|
104
|
-
File.chmod(0755, "#{iReleaseDir}/#{iExecutableInfo[:
|
105
|
+
File.chmod(0755, "#{iReleaseDir}/#{iExecutableInfo[:exe_name]}")
|
105
106
|
end
|
106
107
|
|
107
108
|
return rSuccess
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2009-
|
2
|
+
# Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
|
3
3
|
# Licensed under the terms specified in LICENSE file. No warranty is provided.
|
4
4
|
#++
|
5
5
|
|
@@ -16,18 +16,19 @@ module RubyPackager
|
|
16
16
|
|
17
17
|
# Check if the tools we will use to generate an executable are present
|
18
18
|
#
|
19
|
-
# Parameters
|
19
|
+
# Parameters::
|
20
20
|
# * *iRootDir* (_String_): Root directory
|
21
21
|
# * *iIncludeRuby* (_Boolean_): Do we include Ruby in the release ?
|
22
|
-
#
|
22
|
+
# * *iNeedBinaryCompilation* (_Boolean_): Do we need to compile RB files into a binary executable ?
|
23
|
+
# Return::
|
23
24
|
# * _Boolean_: Are tools correctly useable ?
|
24
|
-
def
|
25
|
+
def check_exe_tools(iRootDir, iIncludeRuby, iNeedBinaryCompilation)
|
25
26
|
rSuccess = true
|
26
27
|
|
27
28
|
if (iIncludeRuby)
|
28
29
|
# We need allinoneruby
|
29
30
|
if (Gem.find_files('allinoneruby').empty?)
|
30
|
-
|
31
|
+
log_err "Need to have allinoneruby gem to release including Ruby.\nPlease install allinoneruby gem (gem install allinoneruby)."
|
31
32
|
rSuccess = false
|
32
33
|
end
|
33
34
|
end
|
@@ -38,14 +39,14 @@ module RubyPackager
|
|
38
39
|
# Create the binary.
|
39
40
|
# This is called when the core library has been copied in the release directory.
|
40
41
|
#
|
41
|
-
# Parameters
|
42
|
+
# Parameters::
|
42
43
|
# * *iRootDir* (_String_): Root directory
|
43
44
|
# * *iReleaseDir* (_String_): Release directory
|
44
45
|
# * *iIncludeRuby* (_Boolean_): Do we include Ruby in the release ?
|
45
46
|
# * *iExecutableInfo* (<em>map<Symbol,Object></em>): The executable information
|
46
|
-
# Return
|
47
|
+
# Return::
|
47
48
|
# * _Boolean_: Success ?
|
48
|
-
def
|
49
|
+
def create_binary(iRootDir, iReleaseDir, iIncludeRuby, iExecutableInfo)
|
49
50
|
rSuccess = true
|
50
51
|
|
51
52
|
lBinSubDir = "Launch/#{RUBY_PLATFORM}/bin"
|
@@ -55,21 +56,21 @@ module RubyPackager
|
|
55
56
|
# First create the binary containing all ruby
|
56
57
|
lBinDir = "#{iReleaseDir}/#{lBinSubDir}"
|
57
58
|
FileUtils::mkdir_p(lBinDir)
|
58
|
-
|
59
|
+
change_dir(lBinDir) do
|
59
60
|
lCmd = "allinoneruby #{lBinName}"
|
60
61
|
rSuccess = system(lCmd)
|
61
62
|
if (!rSuccess)
|
62
|
-
|
63
|
+
log_err "Error while executing \"#{lCmd}\""
|
63
64
|
end
|
64
65
|
end
|
65
66
|
end
|
66
67
|
if (rSuccess)
|
67
68
|
# Then create the real executable
|
68
69
|
# Generate the Shell file that launches everything for Linux
|
69
|
-
File.open("#{iReleaseDir}/#{iExecutableInfo[:
|
70
|
+
File.open("#{iReleaseDir}/#{iExecutableInfo[:exe_name]}", 'w') do |oFile|
|
70
71
|
oFile << "\#!/bin/sh
|
71
72
|
\#--
|
72
|
-
\# Copyright (c) 2009-
|
73
|
+
\# Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
|
73
74
|
\# Licensed under the terms specified in LICENSE file. No warranty is provided.
|
74
75
|
\#++
|
75
76
|
|
@@ -94,14 +95,14 @@ then
|
|
94
95
|
\# Set the environment correctly to execute Ruby from the extracted dir
|
95
96
|
export LD_LIBRARY_PATH=`pwd`/tempruby/bin:`pwd`/tempruby/lib:`pwd`/tempruby/lib/lib1:`pwd`/tempruby/lib/lib2:`pwd`/tempruby/lib/lib3:`pwd`/tempruby/lib/lib4:${LD_LIRARY_PATH}
|
96
97
|
export RUBYOPT=
|
97
|
-
./tempruby/bin/ruby -w #{iExecutableInfo[:
|
98
|
+
./tempruby/bin/ruby -w #{iExecutableInfo[:startup_rb_file]}
|
98
99
|
else
|
99
100
|
echo 'Ruby found on current platform. Use it directly.'
|
100
|
-
ruby -w #{iExecutableInfo[:
|
101
|
+
ruby -w #{iExecutableInfo[:startup_rb_file]}
|
101
102
|
fi
|
102
103
|
"
|
103
104
|
end
|
104
|
-
File.chmod(0755, "#{iReleaseDir}/#{iExecutableInfo[:
|
105
|
+
File.chmod(0755, "#{iReleaseDir}/#{iExecutableInfo[:exe_name]}")
|
105
106
|
end
|
106
107
|
|
107
108
|
return rSuccess
|
@@ -0,0 +1,59 @@
|
|
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
|
@@ -0,0 +1,171 @@
|
|
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
|