automateit 0.80116 → 0.80624
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +3 -1
- data/CHANGES.txt +12 -0
- data/Hoe.rake +3 -1
- data/Manifest.txt +58 -5
- data/README.txt +5 -9
- data/Rakefile +26 -105
- data/TODO.txt +50 -48
- data/bin/ai +0 -0
- data/bin/aifield +0 -0
- data/bin/aissh +0 -0
- data/bin/aitag +0 -0
- data/bin/automateit +0 -0
- data/lib/automateit.rb +0 -0
- data/lib/automateit/account_manager/etc.rb +0 -0
- data/lib/automateit/account_manager/nscd.rb +1 -0
- data/lib/automateit/address_manager/bsd.rb +0 -0
- data/lib/automateit/address_manager/freebsd.rb +0 -0
- data/lib/automateit/address_manager/openbsd.rb +0 -0
- data/lib/automateit/address_manager/portable.rb +0 -0
- data/lib/automateit/address_manager/sunos.rb +0 -0
- data/lib/automateit/constants.rb +4 -3
- data/lib/automateit/interpreter.rb +2 -4
- data/lib/automateit/platform_manager/windows.rb +0 -0
- data/lib/automateit/plugin/driver.rb +0 -0
- data/lib/automateit/root.rb +1 -1
- data/lib/automateit/shell_manager.rb +0 -0
- data/lib/automateit/shell_manager/portable.rb +8 -2
- data/lib/automateit/shell_manager/which_base.rb +0 -0
- data/lib/automateit/shell_manager/which_unix.rb +0 -0
- data/lib/automateit/shell_manager/which_windows.rb +0 -0
- data/lib/ext/object.rb +2 -2
- data/lib/inactive_support/core_ext/time/conversions.rb +4 -2
- data/misc/index_gem_repository.rb +0 -0
- data/misc/setup_egg.rb +0 -0
- data/misc/setup_gem_dependencies.sh +0 -0
- data/misc/setup_rubygems.sh +0 -0
- data/spec/extras/automateit_service_sysv_test +0 -0
- data/spec/extras/scratch.rb +0 -0
- data/spec/extras/simple_recipe.rb +0 -0
- data/spec/integration/account_manager_spec.rb +0 -0
- data/spec/integration/address_manager_portable_spec.rb +0 -0
- data/spec/integration/cli_spec.rb +0 -0
- data/spec/integration/platform_manager_spec.rb +0 -0
- data/spec/integration/shell_manager_spec.rb +24 -0
- data/spec/unit/edit_manager_spec.rb +0 -0
- data/spec/unit/field_manager_spec.rb +0 -0
- data/spec/unit/interpreter_spec.rb +0 -0
- data/spec/unit/object_spec.rb +2 -2
- data/spec/unit/plugins_spec.rb +0 -0
- data/spec/unit/tag_manager_spec.rb +0 -0
- metadata +131 -130
- metadata.gz.sig +0 -0
- data/lib/automateit/package_manager.rb.orig +0 -256
- data/misc/setup_ruby-dbi.rb +0 -24
- data/spec/integration/package_manager_spec.rb.orig +0 -123
metadata.gz.sig
CHANGED
Binary file
|
@@ -1,256 +0,0 @@
|
|
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'
|
data/misc/setup_ruby-dbi.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
#!/usr/bin/env automateit
|
2
|
-
|
3
|
-
# Install ruby-dbi package and the basic drivers
|
4
|
-
|
5
|
-
package_manager.install <<-HERE, :with => :gem
|
6
|
-
postgres-pr
|
7
|
-
sqlite3-ruby
|
8
|
-
### mysql # FIXME Fails because of compile dependencies
|
9
|
-
HERE
|
10
|
-
|
11
|
-
mktempdircd do
|
12
|
-
download "http://rubyforge.org/frs/download.php/12368/dbi-0.1.1.tar.gz"
|
13
|
-
sh "tar xvfz *.tar.gz"
|
14
|
-
extracted_to = Dir.entries(".").select{|t| t=~/\w+/ && File::directory?(t)}.first
|
15
|
-
cd extracted_to do
|
16
|
-
# FIXME mysql and sqlite fail due to compile dependencies
|
17
|
-
### ruby setup.rb config --with=dbi,dbd_pg,dbd_mysql,dbd_sqlite && \
|
18
|
-
sh <<-HERE
|
19
|
-
ruby setup.rb config --with=dbi,dbd_pg && \
|
20
|
-
ruby setup.rb setup && \
|
21
|
-
ruby setup.rb install
|
22
|
-
HERE
|
23
|
-
end
|
24
|
-
end
|
@@ -1,123 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(File.expand_path(__FILE__)), "/../spec_helper.rb")
|
2
|
-
|
3
|
-
PACKAGE_FOUND_ERROR = %q{ERROR: Found the '%s' package installed for %s. You're probably not using this obscure package and should remove it so that this test can run. In the unlikely event that you actually rely on this package, change the spec to test with another unused package.}
|
4
|
-
PACKAGE_DRIVER_MISSING_ERROR = "NOTE: Can't check %s on this platform, #{__FILE__}"
|
5
|
-
|
6
|
-
if not INTERPRETER.euid?
|
7
|
-
puts "NOTE: Can't check 'euid' on this platform, #{__FILE__}"
|
8
|
-
elsif not INTERPRETER.superuser?
|
9
|
-
puts "NOTE: Must be root to check #{__FILE__}"
|
10
|
-
else
|
11
|
-
describe "AutomateIt::PackageManager", :shared => true do
|
12
|
-
before(:all) do
|
13
|
-
@level = Logger::WARN
|
14
|
-
@a = AutomateIt.new(:verbosity => @level)
|
15
|
-
@m = @a.package_manager
|
16
|
-
@fake_package = "not_a_real_package"
|
17
|
-
end
|
18
|
-
|
19
|
-
after(:all) do
|
20
|
-
@d.uninstall(@package, :quiet => true)
|
21
|
-
end
|
22
|
-
|
23
|
-
def uninstall_package(packages, opts={})
|
24
|
-
opts[:quiet] = true
|
25
|
-
return @d.uninstall(packages, opts)
|
26
|
-
end
|
27
|
-
|
28
|
-
def install_package(packages, opts={})
|
29
|
-
opts[:quiet] = true
|
30
|
-
opts[:force] = [:pecl, :pear].include?(@d.token)
|
31
|
-
return @d.install(packages, opts)
|
32
|
-
end
|
33
|
-
|
34
|
-
# Some specs below leave side-effects which others depend on, although
|
35
|
-
# these are clearly documented within the specs. This is necessary
|
36
|
-
# because doing proper setup/teardown for each test would make it run 5x
|
37
|
-
# slower and take over a minute. Although this approach is problematic,
|
38
|
-
# the performance boost is worth it.
|
39
|
-
|
40
|
-
it "should not install an invalid package" do
|
41
|
-
@d.log.silence(Logger::FATAL) do
|
42
|
-
lambda{ install_package(@fake_package) }.should raise_error(ArgumentError)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should install a package" do
|
47
|
-
install_package(@package).should be_true
|
48
|
-
# Leaves behind an installed package
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should not re-install an installed package" do
|
52
|
-
# Expects package to be installed
|
53
|
-
install_package(@package).should be_false
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should find an installed package" do
|
57
|
-
# Expects package to be installed
|
58
|
-
@d.installed?(@package).should be_true
|
59
|
-
@d.not_installed?(@package).should be_false
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should not find a package that's not installed" do
|
63
|
-
@d.installed?(@fake_package).should be_false
|
64
|
-
@d.not_installed?(@fake_package).should be_true
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should find group of packages" do
|
68
|
-
@d.installed?(@package, @fake_package, :details => true).should == [false, [@package]]
|
69
|
-
@d.not_installed?(@package, @fake_package, :details => true).should == [false, [@fake_package]]
|
70
|
-
# Leaves behind an installed package
|
71
|
-
end
|
72
|
-
|
73
|
-
it "should uninstall a package" do
|
74
|
-
# Expects package to be installed
|
75
|
-
uninstall_package(@package).should be_true
|
76
|
-
end
|
77
|
-
|
78
|
-
it "should not uninstall a package that's not installed" do
|
79
|
-
uninstall_package(@package).should be_false
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
#-----------------------------------------------------------------------
|
84
|
-
|
85
|
-
targets = {
|
86
|
-
# :apt => "nomarch", # Obscure package for extracting ARC files from the 80's
|
87
|
-
# :yum => "nomarch", # Obscure package for extracting ARC files from the 80's
|
88
|
-
# :portage => "arc", # Obscure package for extracting ARC files from the 80's
|
89
|
-
# :gem => "s33r", # Alpha-grade package its author deprecated in favor of another
|
90
|
-
# :egg => "_sre.py", # Slower reimplementation of ancient Python Regexps
|
91
|
-
# :pear => "File_DICOM", # Obscure package for DICOM X-rays, abandoned in 2003
|
92
|
-
# :pecl => "ecasound", # Obscure package for Ecasound libs, abandoned in 2003
|
93
|
-
:cpan => "Acme::please", # Insane gimmick port of intercal's please statements
|
94
|
-
}
|
95
|
-
|
96
|
-
if INTERPRETER.tagged?(:centos)
|
97
|
-
# CentOS lacks "nomarch", so use a less obscure archiver from the early 90's.
|
98
|
-
targets[:yum] = "arj"
|
99
|
-
end
|
100
|
-
|
101
|
-
targets.each_pair do |driver_token, package|
|
102
|
-
# Run the following from the shell to skip package tests:
|
103
|
-
# export AUTOMATEIT_SPEC_SKIP_PACKAGES=1
|
104
|
-
# Or clear it out:
|
105
|
-
# unset AUTOMATEIT_SPEC_SKIP_PACKAGES
|
106
|
-
next unless ENV["AUTOMATEIT_SPEC_SKIP_PACKAGES"].nil?
|
107
|
-
|
108
|
-
driver = INTERPRETER.package_manager[driver_token]
|
109
|
-
if driver.available?
|
110
|
-
describe driver.class.to_s do
|
111
|
-
it_should_behave_like "AutomateIt::PackageManager"
|
112
|
-
|
113
|
-
before(:all) do
|
114
|
-
@d = @m[driver_token]
|
115
|
-
@package = package
|
116
|
-
raise PACKAGE_FOUND_ERROR % [@package, @d.class] if @d.installed?(@package)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
else
|
120
|
-
puts PACKAGE_DRIVER_MISSING_ERROR % driver.class
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|