automateit 0.71230 → 0.80116
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/CHANGES.txt +8 -0
- data/TODO.txt +2 -1
- data/examples/basic/recipes/install.rb +1 -1
- data/lib/automateit/package_manager.rb +5 -4
- data/lib/automateit/package_manager.rb.orig +256 -0
- data/lib/automateit/package_manager/gem.rb +34 -4
- data/lib/automateit/root.rb +1 -1
- data/lib/inactive_support/basic_object.rb +5 -3
- data/misc/setup_rubygems.sh +13 -13
- data/spec/integration/examples_spec.rb +23 -15
- data/spec/unit/package_manager_spec.rb +28 -0
- metadata +3 -2
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGES.txt
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
0.80116:
|
2
|
+
Date: Wed, 16 Jan 2008 23:55:44 -0800
|
3
|
+
Desc:
|
4
|
+
- (!) Fixed bug that prevented AutomateIt from working without the Builder gem's "blankslate" library. This fix should completely eliminate AutomateIt's dependence on Builder and ActiveSupport, like 0.71230 was supposed to do. This error was missed because other gems provide a "blankslate"-workalike and thus merely uninstalling Builder wasn't enough to confirm the previous fix.
|
5
|
+
- (+) Improved PackageManager::Gem, it can now use commands other than "gem" to manage RubyGem packages, such as "gem1.8". It now detects the best available command, but also lets you specify a default or choose one on a per-call basis. See the PackageManager::Gem documentation for examples. Comments are sought on the new syntax.
|
6
|
+
- Improved PackageManager#_list_normalizer, it now accepts comments mid-way through a line and can parse arrays of strings.
|
7
|
+
- Updated misc/setup_rubygems.sh, a simple shell script that downloads and install RubyGems 1.0.1, useful for bootstrapping a system to get AutomateIt running on it.
|
8
|
+
|
1
9
|
0.71230:
|
2
10
|
Date: Sun, 30 Dec 2007 14:05:31 -0800
|
3
11
|
Desc:
|
data/TODO.txt
CHANGED
@@ -3,6 +3,7 @@ KEY: Important? Urgent? Easy? 1=yes, 0=no
|
|
3
3
|
#===[ App ]=============================================================
|
4
4
|
|
5
5
|
#---[ Quality issues ]--------------------------------------------------
|
6
|
+
111 TagManager -- Catch bad YAML using friendly exceptions
|
6
7
|
!!! ServiceManager -- Create new #stop_and_start, and add new #restart as #tell wrapper
|
7
8
|
111 ServiceManager -- Write tests for start_and_enable and such
|
8
9
|
!!! AccountManager -- Solaris fails 5% of the time on the last spec.
|
@@ -34,7 +35,7 @@ KEY: Important? Urgent? Easy? 1=yes, 0=no
|
|
34
35
|
000 Shell -- Incorporate which.cmd so #which can work on Windows
|
35
36
|
|
36
37
|
000 Interpreter#invoke and HelpfulERB -- Extract error context code into class
|
37
|
-
000 Interpeter -- Implement #
|
38
|
+
000 Interpeter -- Implement #track_changes, #changed?
|
38
39
|
000 DatabaseManager -- Design
|
39
40
|
000 SourceManager -- Design
|
40
41
|
000 ScheduleManager -- Design
|
@@ -26,7 +26,7 @@ if tagged?(:myapp_servers)
|
|
26
26
|
mkdir_p(lookup(:path)) do
|
27
27
|
# Run shell commands to create the app and database
|
28
28
|
unless File.exists?("config/routes.rb")
|
29
|
-
sh("rails --database=sqlite3 . > /dev/null")
|
29
|
+
sh("rails --database=sqlite3 . > /dev/null") or raise "Rails isn't fully installed"
|
30
30
|
end
|
31
31
|
|
32
32
|
# Create the database if it doesn't exist.
|
@@ -214,7 +214,7 @@ class AutomateIt::PackageManager::BaseDriver < AutomateIt::Plugin::Driver
|
|
214
214
|
packages = [packages.to_s]
|
215
215
|
when String
|
216
216
|
nitpick "LN Ss"
|
217
|
-
packages = packages
|
217
|
+
packages = _string_to_packages(packages)
|
218
218
|
when Hash
|
219
219
|
# Don't do anything
|
220
220
|
nitpick "LN Sh"
|
@@ -227,7 +227,7 @@ class AutomateIt::PackageManager::BaseDriver < AutomateIt::Plugin::Driver
|
|
227
227
|
|
228
228
|
case packages
|
229
229
|
when Array
|
230
|
-
result = packages.map(&:to_s).
|
230
|
+
result = packages.map(&:to_s).map{|t| _string_to_packages(t)}.flatten.uniq
|
231
231
|
when Hash
|
232
232
|
result = packages.stringify_keys
|
233
233
|
when Symbol, String
|
@@ -240,8 +240,9 @@ class AutomateIt::PackageManager::BaseDriver < AutomateIt::Plugin::Driver
|
|
240
240
|
return result
|
241
241
|
end
|
242
242
|
|
243
|
-
|
244
|
-
|
243
|
+
def _string_to_packages(string)
|
244
|
+
string.scan(/^\s*([^#]+)\s*/).flatten.map{|t| t.split}.flatten.uniq
|
245
|
+
end
|
245
246
|
end
|
246
247
|
|
247
248
|
# Drivers
|
@@ -0,0 +1,256 @@
|
|
1
|
+
# == PackageManager
|
2
|
+
#
|
3
|
+
# The PackageManager provides a way to manage packages, e.g., install,
|
4
|
+
# uninstall and query if the Apache package is installed with APT.
|
5
|
+
#
|
6
|
+
# Examples:
|
7
|
+
#
|
8
|
+
# package_manager.installed?("apache2") # => false
|
9
|
+
# package_manager.install("apache2") # => true
|
10
|
+
# package_manager.installed?("apache2") # => true
|
11
|
+
# package_manager.uninstall("apache2") # => true
|
12
|
+
# package_manager.not_installed("apache2") # => true
|
13
|
+
#
|
14
|
+
# Commands can accept arrays:
|
15
|
+
#
|
16
|
+
# package_manager.install("apache2", "bash")
|
17
|
+
# package_manager.installed? %w(apache2 bash)
|
18
|
+
#
|
19
|
+
# Commands can also accept a single, annotated string as a manifest -- useful
|
20
|
+
# for installing large numbers of packages at once:
|
21
|
+
#
|
22
|
+
# package_manager.install <<HERE, :with => :apt
|
23
|
+
# # One per line
|
24
|
+
# apache
|
25
|
+
# bash
|
26
|
+
#
|
27
|
+
# # Or many on the same line
|
28
|
+
# sysvconfig sysv-rc-conf
|
29
|
+
# HERE
|
30
|
+
#
|
31
|
+
# Commands can also accept a hash of names to paths -- necessary for installing
|
32
|
+
# packages stored on the filesystem:
|
33
|
+
#
|
34
|
+
# # Is the package called "TracTags" installed? If not, run the installer
|
35
|
+
# # with the "/tmp/tractags_latest" path as an argument:
|
36
|
+
# package.manager.install({"TracTags" => "/tmp/tractags_latest"}, :with => :egg)
|
37
|
+
class AutomateIt::PackageManager < AutomateIt::Plugin::Manager
|
38
|
+
# Alias for #install
|
39
|
+
def add(*packages) dispatch_to(:install, *packages) end
|
40
|
+
|
41
|
+
# Alias for #uninstall
|
42
|
+
def remove(*packages) dispatch_to(:uninstall, *packages) end
|
43
|
+
|
44
|
+
# Are these +packages+ installed?
|
45
|
+
#
|
46
|
+
# Options:
|
47
|
+
# * :details -- Returns an array containing the boolean result value and an
|
48
|
+
# array with a subset of installed +packages+. Boolean, defaults to false.
|
49
|
+
def installed?(*packages) dispatch(*packages) end
|
50
|
+
|
51
|
+
# Are these +packages+ not installed?
|
52
|
+
#
|
53
|
+
# Options:
|
54
|
+
# * :details -- Returns an array containing the boolean result value and an
|
55
|
+
# array with a subset of +packages+ not installed. Boolean, defaults to false.
|
56
|
+
def not_installed?(*packages) dispatch(*packages) end
|
57
|
+
|
58
|
+
# Install these +packages+. Returns +true+ if any packages are installed
|
59
|
+
# successfully; or +false+ if all packages were already installed.
|
60
|
+
def install(*packages) dispatch(*packages) end
|
61
|
+
|
62
|
+
# Uninstall these +packages+. Returns +true+ if any packages are uninstalled
|
63
|
+
# successfully; or +false+ if none of the packages are installed.
|
64
|
+
def uninstall(*packages) dispatch(*packages) end
|
65
|
+
end
|
66
|
+
|
67
|
+
# == PackageManager::BaseDriver
|
68
|
+
#
|
69
|
+
# Base class for all PackageManager drivers.
|
70
|
+
class AutomateIt::PackageManager::BaseDriver < AutomateIt::Plugin::Driver
|
71
|
+
protected
|
72
|
+
|
73
|
+
# Are these +packages+ installed? Works like PackageManager#installed?
|
74
|
+
# but calls a block that actually checks whether the packages are
|
75
|
+
# installed and returns an array of packages installed.
|
76
|
+
#
|
77
|
+
# For example:
|
78
|
+
# _installed_helper?("package1", "package2", :details => true) do |packages, opts|
|
79
|
+
# # Dummy code which reports that these packages are installed:
|
80
|
+
# ["package1]
|
81
|
+
# end
|
82
|
+
def _installed_helper?(*packages, &block) # :yields: filtered_packages, opts
|
83
|
+
_raise_unless_available
|
84
|
+
|
85
|
+
packages, opts = args_and_opts(*packages)
|
86
|
+
packages = _list_normalizer(packages)
|
87
|
+
packages = packages.keys if Hash === packages
|
88
|
+
|
89
|
+
available = block.call(packages, opts)
|
90
|
+
truth = (packages - available).empty?
|
91
|
+
result = opts[:details] ? [truth, available] : truth
|
92
|
+
log.debug(PNOTE+"installed?(#{packages.inspect}) => #{truth}: #{available.inspect}")
|
93
|
+
return result
|
94
|
+
end
|
95
|
+
|
96
|
+
# Are these +packages+ not installed?
|
97
|
+
def _not_installed_helper?(*packages)
|
98
|
+
_raise_unless_available
|
99
|
+
|
100
|
+
# Requires that your PackageManager#installed? method is implemented.
|
101
|
+
packages, opts = args_and_opts(*packages)
|
102
|
+
packages = _list_normalizer(packages)
|
103
|
+
packages = packages.keys if Hash === packages
|
104
|
+
|
105
|
+
available = [installed?(packages, :details => true)].flatten
|
106
|
+
missing = packages - available
|
107
|
+
truth = (packages - missing).empty?
|
108
|
+
result = opts[:details] ? [truth, missing] : truth
|
109
|
+
log.debug(PNOTE+"not_installed?(#{packages.inspect}) => #{truth}: #{missing.inspect}")
|
110
|
+
return result
|
111
|
+
end
|
112
|
+
|
113
|
+
# Install these +packages+. Works like PackageManager#install but calls a
|
114
|
+
# block that's responsible for actually installing the packages and
|
115
|
+
# returning true if the installation succeeded. This block is only called
|
116
|
+
# if packages need to be installed and receives a filtered list of
|
117
|
+
# packages that are guaranteed not to be installed on the system already.
|
118
|
+
#
|
119
|
+
# For example:
|
120
|
+
# _install_helper("package1", "package2", :quiet => true) do |packages, opts|
|
121
|
+
# # Dummy code that installs packages here, e.g:
|
122
|
+
# system("apt-get", "install", "-y", packages)
|
123
|
+
# end
|
124
|
+
def _install_helper(*packages, &block) # :yields: filtered_packages, opts
|
125
|
+
_raise_unless_available
|
126
|
+
|
127
|
+
packages, opts = args_and_opts(*packages)
|
128
|
+
packages = _list_normalizer(packages)
|
129
|
+
|
130
|
+
check_packages = \
|
131
|
+
case packages
|
132
|
+
when Hash
|
133
|
+
packages.keys
|
134
|
+
else
|
135
|
+
packages
|
136
|
+
end
|
137
|
+
|
138
|
+
missing = not_installed?(check_packages, :details => true)[1]
|
139
|
+
return false if missing.blank?
|
140
|
+
|
141
|
+
install_packages = \
|
142
|
+
case packages
|
143
|
+
when Hash
|
144
|
+
missing.map{|t| packages[t]}
|
145
|
+
else
|
146
|
+
missing
|
147
|
+
end
|
148
|
+
block.call(install_packages, opts)
|
149
|
+
|
150
|
+
return true if preview?
|
151
|
+
unless (failed = not_installed?(check_packages, :details => true)[1]).empty?
|
152
|
+
raise ArgumentError.new("Couldn't install: #{failed.join(' ')}")
|
153
|
+
else
|
154
|
+
return true
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
# Uninstall these +packages+. Works like PackageManager#uninstall but calls a
|
159
|
+
# block that's responsible for actually uninstalling the packages and
|
160
|
+
# returning true if the uninstall succeeded. This block is only called
|
161
|
+
# if packages need to be uninstalled and receives a filtered list of
|
162
|
+
# packages that are guaranteed to be installed on the system.
|
163
|
+
#
|
164
|
+
# For example:
|
165
|
+
# _uninstall_helper("package1", "package2", :quiet => true) do |packages, opts|
|
166
|
+
# # Dummy code that removes packages here, e.g:
|
167
|
+
# system("apt-get", "remove", "-y", packages)
|
168
|
+
# end
|
169
|
+
def _uninstall_helper(*packages, &block) # :yields: filtered_packages, opts
|
170
|
+
_raise_unless_available
|
171
|
+
|
172
|
+
packages, opts = args_and_opts(*packages)
|
173
|
+
packages = _list_normalizer(packages)
|
174
|
+
|
175
|
+
check_packages = \
|
176
|
+
case packages
|
177
|
+
when Hash
|
178
|
+
packages.keys
|
179
|
+
else
|
180
|
+
packages
|
181
|
+
end
|
182
|
+
|
183
|
+
present = installed?(check_packages, :details => true)[1]
|
184
|
+
return false if present.blank?
|
185
|
+
|
186
|
+
uninstall_packages = \
|
187
|
+
case packages
|
188
|
+
when Hash
|
189
|
+
present.map{|t| packages[t]}
|
190
|
+
else
|
191
|
+
present
|
192
|
+
end
|
193
|
+
block.call(uninstall_packages, opts)
|
194
|
+
|
195
|
+
return true if preview?
|
196
|
+
unless (failed = installed?(check_packages, :details => true)[1]).empty?
|
197
|
+
raise ArgumentError.new("Couldn't uninstall: #{failed.join(' ')}")
|
198
|
+
else
|
199
|
+
return true
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
# Returns a normalized array of packages. Transforms manifest string into
|
204
|
+
# packages. Turns symbols into string, strips blank lines and comments.
|
205
|
+
def _list_normalizer(*packages)
|
206
|
+
packages = [packages].flatten
|
207
|
+
if packages.size == 1
|
208
|
+
packages = packages.first
|
209
|
+
nitpick "LN SI %s" % packages.inspect
|
210
|
+
nitpick "LN Sc %s" % packages.class
|
211
|
+
case packages
|
212
|
+
when Symbol
|
213
|
+
nitpick "LN Sy"
|
214
|
+
packages = [packages.to_s]
|
215
|
+
when String
|
216
|
+
nitpick "LN Ss"
|
217
|
+
packages = packages.scan(LIST_NORMALIZER_RE).join(" ").split
|
218
|
+
when Hash
|
219
|
+
# Don't do anything
|
220
|
+
nitpick "LN Sh"
|
221
|
+
else
|
222
|
+
nitpick "LN S?"
|
223
|
+
raise TypeError.new("Unknown input type: #{packages.class}")
|
224
|
+
end
|
225
|
+
nitpick "LN SO %s" % packages.inspect
|
226
|
+
end
|
227
|
+
|
228
|
+
case packages
|
229
|
+
when Array
|
230
|
+
result = packages.map(&:to_s).grep(LIST_NORMALIZER_RE)
|
231
|
+
when Hash
|
232
|
+
result = packages.stringify_keys
|
233
|
+
when Symbol, String
|
234
|
+
result = packages.to_s
|
235
|
+
else
|
236
|
+
raise TypeError.new("Unknown input type: #{packages.class}")
|
237
|
+
end
|
238
|
+
|
239
|
+
nitpick "LN RR %s" % result.inspect
|
240
|
+
return result
|
241
|
+
end
|
242
|
+
|
243
|
+
# Expression for matching packages in arguments
|
244
|
+
LIST_NORMALIZER_RE = /^\s*([^\s#]+)/
|
245
|
+
end
|
246
|
+
|
247
|
+
# Drivers
|
248
|
+
require 'automateit/package_manager/dpkg'
|
249
|
+
require 'automateit/package_manager/apt'
|
250
|
+
require 'automateit/package_manager/yum'
|
251
|
+
require 'automateit/package_manager/gem'
|
252
|
+
require 'automateit/package_manager/egg'
|
253
|
+
require 'automateit/package_manager/portage'
|
254
|
+
require 'automateit/package_manager/pear'
|
255
|
+
require 'automateit/package_manager/pecl'
|
256
|
+
require 'automateit/package_manager/cpan'
|
@@ -2,10 +2,35 @@
|
|
2
2
|
#
|
3
3
|
# The Gem driver for the PackageManager provides a way to manage software
|
4
4
|
# packages for RubyGems using the +gem+ command.
|
5
|
+
#
|
6
|
+
# === Specifying version of gem to use
|
7
|
+
#
|
8
|
+
# You can specify the command to use with each call using the gem option, e.g., the "gem1.8" below:
|
9
|
+
#
|
10
|
+
# package_manager.install 'rails', :with => :gem, :gem => "gem1.8"
|
11
|
+
#
|
12
|
+
# Or set a default and all subsequent calls will use it:
|
13
|
+
#
|
14
|
+
# package_manager[:gem].setup(:gem => "gem1.8")
|
15
|
+
# package_manager.install 'rails', :with => :gem
|
5
16
|
class AutomateIt::PackageManager::Gem < AutomateIt::PackageManager::BaseDriver
|
17
|
+
attr_accessor :gem
|
18
|
+
|
19
|
+
# FIXME Can't tell which gem program is used until we can use #which, need a new paradigm for #available?
|
6
20
|
depends_on \
|
7
|
-
:programs => %w(gem),
|
8
21
|
:libraries => %w(expect pty)
|
22
|
+
### :programs => %w(gem),
|
23
|
+
|
24
|
+
def setup(*args)
|
25
|
+
super(*args)
|
26
|
+
|
27
|
+
args, opts = args_and_opts(*args)
|
28
|
+
if opts[:gem]
|
29
|
+
@gem = opts[:gem]
|
30
|
+
else
|
31
|
+
@gem ||= %w(gem gem1.8 gem1.9).inject(nil){|s,v| s ? s : interpreter.which(v)}
|
32
|
+
end
|
33
|
+
end
|
9
34
|
|
10
35
|
def suitability(method, *args) # :nodoc:
|
11
36
|
# Never select GEM as the default driver
|
@@ -15,7 +40,8 @@ class AutomateIt::PackageManager::Gem < AutomateIt::PackageManager::BaseDriver
|
|
15
40
|
# See PackageManager#installed?
|
16
41
|
def installed?(*packages)
|
17
42
|
return _installed_helper?(*packages) do |list, opts|
|
18
|
-
|
43
|
+
gem = opts[:gem] || self.gem
|
44
|
+
cmd = "#{gem} list --local 2>&1"
|
19
45
|
|
20
46
|
log.debug(PEXEC+cmd)
|
21
47
|
data = `#{cmd}`
|
@@ -44,6 +70,8 @@ class AutomateIt::PackageManager::Gem < AutomateIt::PackageManager::BaseDriver
|
|
44
70
|
# See PackageManager#install
|
45
71
|
def install(*packages)
|
46
72
|
return _install_helper(*packages) do |list, opts|
|
73
|
+
gem = opts[:gem] || self.gem
|
74
|
+
|
47
75
|
# Why is the "gem" utility such a steaming pile of offal? Lameness include:
|
48
76
|
# - Requires interactive input to install a package, with no way to prevent this
|
49
77
|
# - Repeatedly updates indexes even when there's no reason to, and can't be told to stop
|
@@ -60,7 +88,7 @@ class AutomateIt::PackageManager::Gem < AutomateIt::PackageManager::BaseDriver
|
|
60
88
|
# gem options:
|
61
89
|
# -y : Include dependencies,
|
62
90
|
# -E : use /usr/bin/env for installed executables; but only with >= 0.9.4
|
63
|
-
cmd = "gem install -y"
|
91
|
+
cmd = "#{gem} install -y"
|
64
92
|
cmd << " --no-ri" if opts[:ri] == false or opts[:docs] == false
|
65
93
|
cmd << " --no-rdoc" if opts[:rdoc] == false or opts[:docs] == false
|
66
94
|
cmd << " --source #{opts[:source]}" if opts[:source]
|
@@ -125,6 +153,8 @@ class AutomateIt::PackageManager::Gem < AutomateIt::PackageManager::BaseDriver
|
|
125
153
|
# See PackageManager#uninstall
|
126
154
|
def uninstall(*packages)
|
127
155
|
return _uninstall_helper(*packages) do |list, opts|
|
156
|
+
gem = opts[:gem] || self.gem
|
157
|
+
|
128
158
|
# TODO PackageManager::gem#uninstall -- add logic to handle prompts during removal
|
129
159
|
=begin
|
130
160
|
# idiotic program MAY prompt you like this on uninstall:
|
@@ -161,7 +191,7 @@ root@ubuntu:/mnt/satori/svnwork/automateit/src/examples/myapp_rails#
|
|
161
191
|
for package in list
|
162
192
|
# gem options:
|
163
193
|
# -x : remove installed executables
|
164
|
-
cmd = "gem uninstall -x #{package} < /dev/null"
|
194
|
+
cmd = "#{gem} uninstall -x #{package} < /dev/null"
|
165
195
|
cmd << " > /dev/null" if opts[:quiet]
|
166
196
|
cmd << " 2>&1"
|
167
197
|
interpreter.sh(cmd)
|
data/lib/automateit/root.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
# Ruby 1.9 introduces BasicObject
|
1
|
+
# Ruby 1.9 introduces BasicObject, until then use this approximation from here:
|
2
|
+
# http://onestepback.org/index.cgi/Tech/Ruby/BlankSlate.rdoc
|
2
3
|
unless defined? BasicObject
|
3
|
-
|
4
|
-
|
4
|
+
class BasicObject
|
5
|
+
instance_methods.each { |m| undef_method m unless m =~ /^__/ }
|
6
|
+
end
|
5
7
|
end
|
data/misc/setup_rubygems.sh
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
#!/usr/bin/env bash
|
2
2
|
|
3
|
+
# SUMMARY: Installs the rubygems system for managing Ruby libraries
|
4
|
+
|
3
5
|
# RELEASES: http://rubyforge.org/frs/?group_id=126
|
4
6
|
|
5
|
-
|
6
|
-
URL
|
7
|
+
URL="http://rubyforge.org/frs/download.php/29548/rubygems-1.0.1.tgz"
|
8
|
+
PACKAGE=$(echo $URL | sed "s/\.[^\.]*$//; s/^.*\///")
|
7
9
|
|
8
10
|
pushd "/tmp"
|
9
|
-
|
10
|
-
CACHE
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
sudo ruby setup.rb
|
17
|
-
|
11
|
+
CACHE=`mktemp -d install_rubygems.XXXXXXXXXX`
|
12
|
+
pushd "$CACHE"
|
13
|
+
wget -c -T20 -q "$URL"
|
14
|
+
tar xfz "$PACKAGE.tgz"
|
15
|
+
cd "$PACKAGE"
|
16
|
+
sudo ruby setup.rb
|
17
|
+
popd
|
18
18
|
popd
|
19
|
-
rm -rf "$CACHE"
|
20
19
|
|
21
|
-
|
20
|
+
# Uninstall, only run this if there's no other version of rubygems on the system or it'll destroy those up too:
|
21
|
+
### rm -rf /usr/bin/{gem{,1.*},update_rubygems*} /usr/local/lib/site_ruby/1.8/{{,r}ubygems.rb,rubygems} /usr/lib/ruby/gems
|
@@ -17,34 +17,42 @@ else
|
|
17
17
|
|
18
18
|
# Get the fully qualified filename for the interpreter.
|
19
19
|
# XXX What bad things will this do if, say, running with JRuby?
|
20
|
-
ruby = begin
|
20
|
+
INTERPRETER.params[:ruby] = begin
|
21
21
|
c = ::Config::CONFIG
|
22
22
|
File::join(c['bindir'], c['ruby_install_name']) << c['EXEEXT']
|
23
23
|
end
|
24
24
|
|
25
|
+
def wrap_command(cmd, &block)
|
26
|
+
INTERPRETER.instance_eval do
|
27
|
+
log.silence(Logger::WARN) do
|
28
|
+
output = `#{params[:ruby]} #{cmd} 2>&1`
|
29
|
+
begin
|
30
|
+
block.call
|
31
|
+
rescue Exception => e
|
32
|
+
puts "ERROR, failed while running command:\n#{cmd}\n#{output}"
|
33
|
+
raise e
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
25
39
|
begin
|
26
40
|
# Preview examples to cause a NotImplemented error on unsupported platforms
|
27
41
|
AutomateIt::invoke(params[:installer], :verbosity => Logger::WARN, :preview => true, :friendly_exceptions => false)
|
28
42
|
|
29
43
|
it "should install the example" do
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
File.directory?("/tmp/myapp_server").should be_true
|
35
|
-
service_manager.started?("myapp_server", :wait => 5).should be_true
|
36
|
-
end
|
44
|
+
wrap_command("bin/automateit #{params[:installer]}") do
|
45
|
+
File.exists?("/etc/init.d/myapp_server").should be_true
|
46
|
+
File.directory?("/tmp/myapp_server").should be_true
|
47
|
+
INTERPRETER.service_manager.started?("myapp_server", :wait => 5).should be_true
|
37
48
|
end
|
38
49
|
end
|
39
50
|
|
40
51
|
it "should uninstall the example" do
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
File.directory?("/tmp/myapp_server").should be_false
|
46
|
-
service_manager.stopped?("myapp_server", :wait => 5).should be_true
|
47
|
-
end
|
52
|
+
wrap_command("bin/automateit #{params[:uninstaller]}") do
|
53
|
+
File.exists?("/etc/init.d/myapp_server").should be_false
|
54
|
+
File.directory?("/tmp/myapp_server").should be_false
|
55
|
+
INTERPRETER.service_manager.stopped?("myapp_server", :wait => 5).should be_true
|
48
56
|
end
|
49
57
|
end
|
50
58
|
rescue NotImplementedError => e
|
@@ -7,6 +7,34 @@ describe AutomateIt::PackageManager::DPKG do
|
|
7
7
|
@d = @m.drivers[:dpkg]
|
8
8
|
end
|
9
9
|
|
10
|
+
it "should parse a string of package names" do
|
11
|
+
# Given
|
12
|
+
string = <<-HERE
|
13
|
+
foo bar # ignore
|
14
|
+
baz
|
15
|
+
# feh
|
16
|
+
meh quux
|
17
|
+
quux
|
18
|
+
HERE
|
19
|
+
|
20
|
+
@d.send(:_list_normalizer, string).sort.should == %w(bar baz foo meh quux)
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
it "should parse an array of package names" do
|
25
|
+
# Given
|
26
|
+
array = [
|
27
|
+
"foo bar # ignore",
|
28
|
+
"baz",
|
29
|
+
"# feh",
|
30
|
+
"meh quux",
|
31
|
+
"quux",
|
32
|
+
]
|
33
|
+
|
34
|
+
@d.send(:_list_normalizer, array).sort.should == %w(bar baz foo meh quux)
|
35
|
+
end
|
36
|
+
|
37
|
+
|
10
38
|
it "should handle hash arguments" do
|
11
39
|
# Given
|
12
40
|
@d.should_receive(:_raise_unless_available).any_number_of_times.and_return(true)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: automateit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "0.
|
4
|
+
version: "0.80116"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igal Koshevoy
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
COR01yWDcVLdM89nNLk=
|
31
31
|
-----END CERTIFICATE-----
|
32
32
|
|
33
|
-
date:
|
33
|
+
date: 2008-01-17 00:00:00 -08:00
|
34
34
|
default_executable:
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
@@ -168,6 +168,7 @@ files:
|
|
168
168
|
- lib/automateit/tag_manager/yaml.rb
|
169
169
|
- lib/automateit/tag_manager/tag_parser.rb
|
170
170
|
- lib/automateit/download_manager.rb
|
171
|
+
- lib/automateit/package_manager.rb.orig
|
171
172
|
- lib/automateit/template_manager/base.rb
|
172
173
|
- lib/automateit/template_manager/erb.rb
|
173
174
|
- lib/tempster.rb
|
metadata.gz.sig
CHANGED
Binary file
|