automateit 0.70930 → 0.71003
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.tar.gz.sig +0 -0
- data/CHANGES.txt +7 -0
- data/lib/automateit.rb +0 -1
- data/lib/automateit/account_manager/passwd.rb +1 -0
- data/lib/automateit/package_manager/gem.rb +1 -0
- data/lib/automateit/root.rb +1 -1
- data/lib/automateit/shell_manager.rb +10 -3
- data/lib/automateit/shell_manager/portable.rb +54 -7
- data/spec/integration/shell_manager_spec.rb +78 -1
- metadata +2 -2
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGES.txt
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
0.71003:
|
2
|
+
Date: Wed, 03 Oct 2007 01:17:32 -0700
|
3
|
+
Desc:
|
4
|
+
- Fixed bug in #backup on JRuby because it lacks methods to query properties. It now copies the file and timestamp, but not the owner/group/mode because these can't be queried on JRuby.
|
5
|
+
- Improved #cp with new :preserve => :try option so that properties are preserved when possible, but no exception is thrown when these can't be preserved.
|
6
|
+
- Improved #touch with options for :like and :stamp options.
|
7
|
+
|
1
8
|
0.70930:
|
2
9
|
Date: Sun, 30 Sep 2007 15:10:43 -0700
|
3
10
|
Desc:
|
data/lib/automateit.rb
CHANGED
@@ -55,6 +55,7 @@ class ::AutomateIt::AccountManager::Passwd < ::AutomateIt::AccountManager::BaseD
|
|
55
55
|
def _passwd_raw(user, password, opts={})
|
56
56
|
quiet = (opts[:quiet] or not log.info?)
|
57
57
|
|
58
|
+
require 'open4'
|
58
59
|
return Open4::popen4("passwd %s 2>&1" % user) do |pid, sin, sout, serr|
|
59
60
|
$expect_verbose = ! quiet
|
60
61
|
2.times do
|
@@ -85,6 +85,7 @@ class AutomateIt::PackageManager::Gem < AutomateIt::PackageManager::BaseDriver
|
|
85
85
|
uninstall_needed = false
|
86
86
|
begin
|
87
87
|
require 'expect'
|
88
|
+
require 'open4'
|
88
89
|
exitstruct = Open4::popen4(cmd) do |pid, sin, sout, serr|
|
89
90
|
$expect_verbose = opts[:quiet] ? false : true
|
90
91
|
|
data/lib/automateit/root.rb
CHANGED
@@ -195,8 +195,11 @@ class AutomateIt::ShellManager < AutomateIt::Plugin::Manager
|
|
195
195
|
# +false+ if all are present.
|
196
196
|
#
|
197
197
|
# Options:
|
198
|
-
# * :preserve --
|
199
|
-
#
|
198
|
+
# * :preserve -- Preserve file modification time and ownership. Defaults to
|
199
|
+
# false. Can be +true+, +false+, or :try. If :try, the properties will be
|
200
|
+
# preserved if possible on the platform, whereas +true+ will raise an
|
201
|
+
# exception if not available.
|
202
|
+
# * :recursive -- Copy files and directories recursively, boolean.
|
200
203
|
def cp(sources, target, opts={}) dispatch(sources, target, opts) end
|
201
204
|
|
202
205
|
# Copy the +sources+ to the +target+ recursively. Returns an array of
|
@@ -250,7 +253,11 @@ class AutomateIt::ShellManager < AutomateIt::Plugin::Manager
|
|
250
253
|
# Create the +targets+ as files if needed and update their modification
|
251
254
|
# time. Unlike most other commands provided by ShellManager, this one will
|
252
255
|
# always modify the targets. Returns an array of targets modified.
|
253
|
-
|
256
|
+
#
|
257
|
+
# Options:
|
258
|
+
# * :like -- Touch the targets like this file. Defaults to none.
|
259
|
+
# * :stamp -- Set the targets to the specified timestamp. Defaults to Time.now.
|
260
|
+
def touch(targets, opts={}) dispatch(targets, opts) end
|
254
261
|
end
|
255
262
|
|
256
263
|
# == ShellManager::BaseDriver
|
@@ -49,7 +49,7 @@ class AutomateIt::ShellManager::Portable < AutomateIt::ShellManager::BaseDriver
|
|
49
49
|
if is_dir
|
50
50
|
cp_opts = {}
|
51
51
|
cp_opts[:recursive] = true if is_dir
|
52
|
-
cp_opts[:preserve] =
|
52
|
+
cp_opts[:preserve] = :try
|
53
53
|
|
54
54
|
source_children = _directory_contents(source)
|
55
55
|
#puts "sc: %s" % source_children.inspect
|
@@ -210,8 +210,16 @@ class AutomateIt::ShellManager::Portable < AutomateIt::ShellManager::BaseDriver
|
|
210
210
|
opt = opt.to_sym
|
211
211
|
fu_opts[opt] = opts[opt] if opts[opt]
|
212
212
|
end
|
213
|
-
|
214
|
-
fu_opts_with_preserve =
|
213
|
+
|
214
|
+
fu_opts_with_preserve = fu_opts.clone
|
215
|
+
fu_opts_with_preserve[:preserve] = \
|
216
|
+
if opts[:preserve] == :try
|
217
|
+
fsim = File::Stat.instance_methods
|
218
|
+
(fsim.include?("uid") and fsim.include?("gid") and
|
219
|
+
fsim.include?("mode") and fsim.include?("atime"))
|
220
|
+
else
|
221
|
+
opts[:preserve]
|
222
|
+
end
|
215
223
|
|
216
224
|
changed = []
|
217
225
|
sources_a = [sources].flatten
|
@@ -454,9 +462,48 @@ class AutomateIt::ShellManager::Portable < AutomateIt::ShellManager::BaseDriver
|
|
454
462
|
end
|
455
463
|
|
456
464
|
# See ShellManager#touch
|
457
|
-
def touch(targets)
|
458
|
-
|
459
|
-
|
460
|
-
|
465
|
+
def touch(targets, opts={})
|
466
|
+
like = opts.delete(:like)
|
467
|
+
stamp = opts.delete(:stamp)
|
468
|
+
quiet = opts.delete(:quiet) == true ? true : false
|
469
|
+
time = \
|
470
|
+
if stamp
|
471
|
+
stamp
|
472
|
+
elsif like
|
473
|
+
begin
|
474
|
+
File.stat(like).mtime
|
475
|
+
rescue Errno::ENOENT => e
|
476
|
+
if preview?
|
477
|
+
Time.now
|
478
|
+
else
|
479
|
+
raise e
|
480
|
+
end
|
481
|
+
end
|
482
|
+
else
|
483
|
+
Time.now
|
484
|
+
end
|
485
|
+
|
486
|
+
unless quiet
|
487
|
+
msg = PEXEC << "touch"
|
488
|
+
msg << " --reference %s" % like if like
|
489
|
+
msg << " --stamp %s" % stamp if stamp
|
490
|
+
msg << " " << [targets].flatten.join(" ")
|
491
|
+
log.info(msg)
|
492
|
+
end
|
493
|
+
|
494
|
+
results = []
|
495
|
+
for target in [targets].flatten
|
496
|
+
begin
|
497
|
+
stat = File.stat(target)
|
498
|
+
next if stat.mtime.to_i == time.to_i
|
499
|
+
rescue Errno::ENOENT
|
500
|
+
File.open(target, "a"){} unless preview?
|
501
|
+
end
|
502
|
+
File.utime(time, time, target) unless preview?
|
503
|
+
results << target
|
504
|
+
end
|
505
|
+
|
506
|
+
return false if results.empty?
|
507
|
+
return targets.is_a?(String) ? results.first : results
|
461
508
|
end
|
462
509
|
end
|
@@ -371,6 +371,10 @@ describe AutomateIt::ShellManager, " in general" do
|
|
371
371
|
File.exists?(dir).should be_false
|
372
372
|
end
|
373
373
|
end
|
374
|
+
end
|
375
|
+
|
376
|
+
describe AutomateIt::ShellManager, " when touching files" do
|
377
|
+
it_should_behave_like "AutomateIt::ShellManager"
|
374
378
|
|
375
379
|
it "should create files and change their timestamps (touch)" do
|
376
380
|
@m.mktempdircd do
|
@@ -386,6 +390,79 @@ describe AutomateIt::ShellManager, " in general" do
|
|
386
390
|
before.should <= after
|
387
391
|
end
|
388
392
|
end
|
393
|
+
|
394
|
+
it "should touch files with a specific timestamp (touch)" do
|
395
|
+
@m.mktempdircd do
|
396
|
+
target = "foo"
|
397
|
+
stamp = Time.now - 60
|
398
|
+
stamp.should_not == Time.now
|
399
|
+
|
400
|
+
@m.touch(target, :stamp => stamp).should == target
|
401
|
+
stat = File.stat(target)
|
402
|
+
stamp.to_i.should == stat.mtime.to_i
|
403
|
+
|
404
|
+
@m.touch(target, :stamp => stamp).should be_false
|
405
|
+
end
|
406
|
+
end
|
407
|
+
|
408
|
+
it "should touch files with a timestamp like other files (touch)" do
|
409
|
+
@m.mktempdircd do
|
410
|
+
source = "foo"
|
411
|
+
target = "bar"
|
412
|
+
stamp = Time.now - 60
|
413
|
+
stamp.should_not == Time.now
|
414
|
+
@m.touch(source, :stamp => stamp)
|
415
|
+
|
416
|
+
@m.touch(target, :like => source).should == target
|
417
|
+
stat = File.stat(target)
|
418
|
+
stamp.to_i.should == stat.mtime.to_i
|
419
|
+
|
420
|
+
@m.touch(target, :like => source).should be_false
|
421
|
+
end
|
422
|
+
end
|
423
|
+
|
424
|
+
it "should not change timestamps in preview mode (touch)" do
|
425
|
+
@m.mktempdircd do
|
426
|
+
target = "foo"
|
427
|
+
@m.touch(target)
|
428
|
+
stamp = File.stat(target).mtime
|
429
|
+
|
430
|
+
begin
|
431
|
+
@m.preview = true
|
432
|
+
@m.touch(target)
|
433
|
+
File.stat(target).mtime.to_i == stamp.to_i
|
434
|
+
ensure
|
435
|
+
@m.preview = false
|
436
|
+
end
|
437
|
+
end
|
438
|
+
end
|
439
|
+
|
440
|
+
it "should raise errors when setting timestamps like non-existing files (touch)" do
|
441
|
+
@m.mktempdircd do
|
442
|
+
source = "source"
|
443
|
+
target = "target"
|
444
|
+
File.exists?(source).should be_false
|
445
|
+
File.exists?(target).should be_false
|
446
|
+
|
447
|
+
lambda { @m.touch(target, :like => source) }.should raise_error(Errno::ENOENT)
|
448
|
+
end
|
449
|
+
end
|
450
|
+
|
451
|
+
it "should not raise errors when setting timestamps like non-existing files in preview mode (touch)" do
|
452
|
+
@m.mktempdircd do
|
453
|
+
source = "source"
|
454
|
+
target = "target"
|
455
|
+
File.exists?(source).should be_false
|
456
|
+
File.exists?(target).should be_false
|
457
|
+
|
458
|
+
begin
|
459
|
+
@m.preview = true
|
460
|
+
@m.touch(target, :like => source).should == target
|
461
|
+
ensure
|
462
|
+
@m.preview = false
|
463
|
+
end
|
464
|
+
end
|
465
|
+
end
|
389
466
|
end
|
390
467
|
|
391
468
|
describe AutomateIt::ShellManager, " when managing modes" do
|
@@ -428,7 +505,7 @@ describe AutomateIt::ShellManager, " when managing modes" do
|
|
428
505
|
end
|
429
506
|
end
|
430
507
|
|
431
|
-
#it "should set the default mask (umask)" # TODO
|
508
|
+
#it "should set the default mask (umask)" # TODO
|
432
509
|
end
|
433
510
|
|
434
511
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: automateit
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: "0.
|
7
|
-
date: 2007-10-
|
6
|
+
version: "0.71003"
|
7
|
+
date: 2007-10-04 00:00:00 -07:00
|
8
8
|
summary: AutomateIt is an open-source tool for automating the setup and maintenance of UNIX-like systems
|
9
9
|
require_paths:
|
10
10
|
- lib
|
metadata.gz.sig
CHANGED
Binary file
|