boxgrinder-build 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,7 +1,10 @@
1
1
 
2
+ v0.5.1
3
+
4
+ * [BGBUILD-40] Fix for running Augeas in Libguestfs
5
+
2
6
  v0.5.0
3
7
 
4
8
  * Plugins externalized from BoxGrinder Build
5
- * TODO
6
9
 
7
10
  v0.4.0
data/Manifest CHANGED
@@ -0,0 +1,26 @@
1
+ CHANGELOG
2
+ LICENSE
3
+ Manifest
4
+ README
5
+ Rakefile
6
+ bin/boxgrinder-build
7
+ lib/boxgrinder-build/appliance.rb
8
+ lib/boxgrinder-build/helpers/appliance-customize-helper.rb
9
+ lib/boxgrinder-build/helpers/augeas-helper.rb
10
+ lib/boxgrinder-build/helpers/guestfs-helper.rb
11
+ lib/boxgrinder-build/helpers/linux-helper.rb
12
+ lib/boxgrinder-build/helpers/package-helper.rb
13
+ lib/boxgrinder-build/helpers/plugin-helper.rb
14
+ lib/boxgrinder-build/managers/plugin-manager.rb
15
+ lib/boxgrinder-build/plugins/base-plugin.rb
16
+ spec/Rakefile
17
+ spec/appliance-spec.rb
18
+ spec/helpers/appliance-customize-helper-spec.rb
19
+ spec/helpers/augeas-helper-spec.rb
20
+ spec/helpers/guestfs-helper-spec.rb
21
+ spec/helpers/linux-helper-spec.rb
22
+ spec/helpers/package-helper-spec.rb
23
+ spec/helpers/plugin-helper-spec.rb
24
+ spec/managers/plugin-manager-spec.rb
25
+ spec/plugins/base-plugin-spec.rb
26
+ spec/rspec/src/appliances/jeos-f13.appl
data/Rakefile CHANGED
@@ -7,5 +7,5 @@ Echoe.new("boxgrinder-build") do |p|
7
7
  p.url = "http://www.jboss.org/stormgrind/projects/boxgrinder.html"
8
8
  p.email = "info@boxgrinder.org"
9
9
  p.ignore_pattern = /^(pkg|doc)|\.svn|CVS|\.bzr|\.DS|\.git|\.log/
10
- p.runtime_dependencies = ["commander >=4.0.3", "boxgrinder-core >=0.0.20"]
10
+ p.runtime_dependencies = ["commander ~>4.0.3", "boxgrinder-core ~>0.0.22"]
11
11
  end
data/bin/boxgrinder-build CHANGED
@@ -39,7 +39,7 @@ end
39
39
  require 'commander/import'
40
40
 
41
41
  program :name, 'BoxGrinder Build'
42
- program :version, '0.5.0'
42
+ program :version, '0.5.1'
43
43
  program :description, "A tool for building VM images from simple definition files."
44
44
  program :help, 'Hompepage', 'http://www.jboss.org/stormgrind/projects/boxgrinder/build.html'
45
45
  program :help, 'Documentation', 'http://community.jboss.org/docs/DOC-14358'
@@ -2,17 +2,17 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{boxgrinder-build}
5
- s.version = "0.5.0"
5
+ s.version = "0.5.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Marek Goldmann"]
9
- s.date = %q{2010-07-21}
9
+ s.date = %q{2010-08-23}
10
10
  s.default_executable = %q{boxgrinder-build}
11
11
  s.description = %q{A tool for creating appliances from simple plain text files for various virtual environments.}
12
12
  s.email = %q{info@boxgrinder.org}
13
13
  s.executables = ["boxgrinder-build"]
14
- s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "bin/boxgrinder-build", "lib/boxgrinder-build/appliance.rb", "lib/boxgrinder-build/helpers/appliance-customize-helper.rb", "lib/boxgrinder-build/helpers/guestfs-helper.rb", "lib/boxgrinder-build/helpers/linux-helper.rb", "lib/boxgrinder-build/helpers/package-helper.rb", "lib/boxgrinder-build/helpers/plugin-helper.rb", "lib/boxgrinder-build/managers/plugin-manager.rb", "lib/boxgrinder-build/plugins/base-plugin.rb"]
15
- s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "bin/boxgrinder-build", "lib/boxgrinder-build/appliance.rb", "lib/boxgrinder-build/helpers/appliance-customize-helper.rb", "lib/boxgrinder-build/helpers/guestfs-helper.rb", "lib/boxgrinder-build/helpers/linux-helper.rb", "lib/boxgrinder-build/helpers/package-helper.rb", "lib/boxgrinder-build/helpers/plugin-helper.rb", "lib/boxgrinder-build/managers/plugin-manager.rb", "lib/boxgrinder-build/plugins/base-plugin.rb", "spec/Rakefile", "spec/appliance-spec.rb", "spec/helpers/appliance-customize-helper-spec.rb", "spec/helpers/guestfs-helper-spec.rb", "spec/helpers/linux-helper-spec.rb", "spec/helpers/package-helper-spec.rb", "spec/helpers/plugin-helper-spec.rb", "spec/managers/plugin-manager-spec.rb", "spec/plugins/base-plugin-spec.rb", "spec/rspec/src/appliances/jeos-f13.appl", "boxgrinder-build.gemspec"]
14
+ s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "bin/boxgrinder-build", "lib/boxgrinder-build/appliance.rb", "lib/boxgrinder-build/helpers/appliance-customize-helper.rb", "lib/boxgrinder-build/helpers/augeas-helper.rb", "lib/boxgrinder-build/helpers/guestfs-helper.rb", "lib/boxgrinder-build/helpers/linux-helper.rb", "lib/boxgrinder-build/helpers/package-helper.rb", "lib/boxgrinder-build/helpers/plugin-helper.rb", "lib/boxgrinder-build/managers/plugin-manager.rb", "lib/boxgrinder-build/plugins/base-plugin.rb"]
15
+ s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "bin/boxgrinder-build", "lib/boxgrinder-build/appliance.rb", "lib/boxgrinder-build/helpers/appliance-customize-helper.rb", "lib/boxgrinder-build/helpers/augeas-helper.rb", "lib/boxgrinder-build/helpers/guestfs-helper.rb", "lib/boxgrinder-build/helpers/linux-helper.rb", "lib/boxgrinder-build/helpers/package-helper.rb", "lib/boxgrinder-build/helpers/plugin-helper.rb", "lib/boxgrinder-build/managers/plugin-manager.rb", "lib/boxgrinder-build/plugins/base-plugin.rb", "spec/Rakefile", "spec/appliance-spec.rb", "spec/helpers/appliance-customize-helper-spec.rb", "spec/helpers/augeas-helper-spec.rb", "spec/helpers/guestfs-helper-spec.rb", "spec/helpers/linux-helper-spec.rb", "spec/helpers/package-helper-spec.rb", "spec/helpers/plugin-helper-spec.rb", "spec/managers/plugin-manager-spec.rb", "spec/plugins/base-plugin-spec.rb", "spec/rspec/src/appliances/jeos-f13.appl", "boxgrinder-build.gemspec"]
16
16
  s.homepage = %q{http://www.jboss.org/stormgrind/projects/boxgrinder.html}
17
17
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Boxgrinder-build", "--main", "README"]
18
18
  s.require_paths = ["lib"]
@@ -25,14 +25,14 @@ Gem::Specification.new do |s|
25
25
  s.specification_version = 3
26
26
 
27
27
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
- s.add_runtime_dependency(%q<commander>, [">= 4.0.3"])
29
- s.add_runtime_dependency(%q<boxgrinder-core>, [">= 0.0.20"])
28
+ s.add_runtime_dependency(%q<commander>, ["~> 4.0.3"])
29
+ s.add_runtime_dependency(%q<boxgrinder-core>, ["~> 0.0.22"])
30
30
  else
31
- s.add_dependency(%q<commander>, [">= 4.0.3"])
32
- s.add_dependency(%q<boxgrinder-core>, [">= 0.0.20"])
31
+ s.add_dependency(%q<commander>, ["~> 4.0.3"])
32
+ s.add_dependency(%q<boxgrinder-core>, ["~> 0.0.22"])
33
33
  end
34
34
  else
35
- s.add_dependency(%q<commander>, [">= 4.0.3"])
36
- s.add_dependency(%q<boxgrinder-core>, [">= 0.0.20"])
35
+ s.add_dependency(%q<commander>, ["~> 4.0.3"])
36
+ s.add_dependency(%q<boxgrinder-core>, ["~> 0.0.22"])
37
37
  end
38
38
  end
@@ -0,0 +1,76 @@
1
+ # JBoss, Home of Professional Open Source
2
+ # Copyright 2009, Red Hat Middleware LLC, and individual contributors
3
+ # by the @authors tag. See the copyright.txt in the distribution for a
4
+ # full listing of individual contributors.
5
+ #
6
+ # This is free software; you can redistribute it and/or modify it
7
+ # under the terms of the GNU Lesser General Public License as
8
+ # published by the Free Software Foundation; either version 2.1 of
9
+ # the License, or (at your option) any later version.
10
+ #
11
+ # This software is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ # Lesser General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public
17
+ # License along with this software; if not, write to the Free
18
+ # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19
+ # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
20
+
21
+ require 'logger'
22
+
23
+ module BoxGrinder
24
+ class AugeasHelper
25
+ def initialize( guestfs, guestfs_helper, options = {})
26
+ @guestfs = guestfs
27
+ @guestfs_helper = guestfs_helper
28
+ @log = options[:log] || Logger.new(STDOUT)
29
+
30
+ @files = {}
31
+ end
32
+
33
+ def edit( &block )
34
+ @log.debug "Changing configuration files using augeas..."
35
+
36
+ instance_eval &block if block
37
+
38
+ if @files.empty?
39
+ @log.debug "No files specified to change, skipping..."
40
+ return
41
+ end
42
+
43
+ @guestfs.aug_init( "/", 32 )
44
+
45
+ unload = []
46
+
47
+ @files.keys.each do |file_name|
48
+ unload << ". != '#{file_name}'"
49
+ end
50
+
51
+ @guestfs.aug_rm( "/augeas/load//incl[#{unload.join(' and ')}]" )
52
+ @guestfs.aug_load
53
+
54
+ @files.each do |file, changes|
55
+ changes.each do |key, value|
56
+
57
+ @guestfs.aug_set("/files#{file}/#{key}", value)
58
+ end
59
+ end
60
+
61
+ @guestfs.aug_save
62
+
63
+ @log.debug "Augeas changes saved."
64
+ end
65
+
66
+ def set( name, key, value )
67
+ unless @guestfs.exists( name ) != 0
68
+ @log.debug "File '#{name}' doesn't exists, skipping augeas changes..."
69
+ return
70
+ end
71
+
72
+ @files[name] = {} unless @files.has_key?( name )
73
+ @files[name][key] = value
74
+ end
75
+ end
76
+ end
@@ -18,6 +18,7 @@
18
18
  # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19
19
  # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
20
20
 
21
+ require 'boxgrinder-build/helpers/augeas-helper'
21
22
  require 'guestfs'
22
23
  require 'logger'
23
24
 
@@ -197,5 +198,9 @@ module BoxGrinder
197
198
  mount_partition( partition, @guestfs.sh( "/sbin/e2label #{partition}" ).chomp.strip )
198
199
  end
199
200
  end
201
+
202
+ def augeas( &block )
203
+ AugeasHelper.new( @guestfs, self, :log => @log ).edit( &block )
204
+ end
200
205
  end
201
206
  end
@@ -0,0 +1,64 @@
1
+ require 'boxgrinder-build/helpers/augeas-helper'
2
+
3
+ module BoxGrinder
4
+ describe AugeasHelper do
5
+
6
+ before(:each) do
7
+ @log = Logger.new('/dev/null')
8
+
9
+ @guestfs = mock('GuestFS')
10
+ @guestfs_helper = mock('GuestFSHelper')
11
+
12
+ @helper = AugeasHelper.new( @guestfs, @guestfs_helper, :log => @log)
13
+ end
14
+
15
+ it "should not execute augeas commands if there a no files to change" do
16
+ @helper.edit do
17
+ end
18
+ end
19
+
20
+ it "should change configuration for one file" do
21
+ @guestfs.should_receive(:exists).with('/etc/ssh/sshd_config').and_return(1)
22
+ @guestfs.should_receive(:aug_init).with('/', 32)
23
+ @guestfs.should_receive(:aug_rm).with("/augeas/load//incl[. != '/etc/ssh/sshd_config']")
24
+ @guestfs.should_receive(:aug_load)
25
+ @guestfs.should_receive(:aug_set).with("/files/etc/ssh/sshd_config/UseDNS", "no")
26
+ @guestfs.should_receive(:aug_save)
27
+
28
+ @helper.edit do
29
+ set( '/etc/ssh/sshd_config', 'UseDNS', 'no')
30
+ end
31
+ end
32
+
33
+ it "should change configuration for two files" do
34
+ @guestfs.should_receive(:exists).with('/etc/ssh/sshd_config').and_return(1)
35
+ @guestfs.should_receive(:exists).with('/etc/sysconfig/selinux').and_return(1)
36
+ @guestfs.should_receive(:aug_init).with('/', 32)
37
+ @guestfs.should_receive(:aug_rm).with("/augeas/load//incl[. != '/etc/ssh/sshd_config' and . != '/etc/sysconfig/selinux']")
38
+ @guestfs.should_receive(:aug_load)
39
+ @guestfs.should_receive(:aug_set).with("/files/etc/ssh/sshd_config/UseDNS", "no")
40
+ @guestfs.should_receive(:aug_set).with("/files/etc/sysconfig/selinux/SELINUX", "permissive")
41
+ @guestfs.should_receive(:aug_save)
42
+
43
+ @helper.edit do
44
+ set( '/etc/ssh/sshd_config', 'UseDNS', 'no')
45
+ set( '/etc/sysconfig/selinux', 'SELINUX', 'permissive')
46
+ end
47
+ end
48
+
49
+ it "should change one configuration for two files because one file doesn't exists" do
50
+ @guestfs.should_receive(:exists).with('/etc/ssh/sshd_config').and_return(1)
51
+ @guestfs.should_receive(:exists).with('/etc/sysconfig/selinux').and_return(0)
52
+ @guestfs.should_receive(:aug_init).with('/', 32)
53
+ @guestfs.should_receive(:aug_rm).with("/augeas/load//incl[. != '/etc/ssh/sshd_config']")
54
+ @guestfs.should_receive(:aug_load)
55
+ @guestfs.should_receive(:aug_set).with("/files/etc/ssh/sshd_config/UseDNS", "no")
56
+ @guestfs.should_receive(:aug_save)
57
+
58
+ @helper.edit do
59
+ set( '/etc/ssh/sshd_config', 'UseDNS', 'no')
60
+ set( '/etc/sysconfig/selinux', 'SELINUX', 'permissive')
61
+ end
62
+ end
63
+ end
64
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 0
9
- version: 0.5.0
8
+ - 1
9
+ version: 0.5.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Marek Goldmann
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-21 00:00:00 +02:00
17
+ date: 2010-08-23 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -22,7 +22,7 @@ dependencies:
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ">="
25
+ - - ~>
26
26
  - !ruby/object:Gem::Version
27
27
  segments:
28
28
  - 4
@@ -36,13 +36,13 @@ dependencies:
36
36
  prerelease: false
37
37
  requirement: &id002 !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ">="
39
+ - - ~>
40
40
  - !ruby/object:Gem::Version
41
41
  segments:
42
42
  - 0
43
43
  - 0
44
- - 20
45
- version: 0.0.20
44
+ - 22
45
+ version: 0.0.22
46
46
  type: :runtime
47
47
  version_requirements: *id002
48
48
  description: A tool for creating appliances from simple plain text files for various virtual environments.
@@ -58,6 +58,7 @@ extra_rdoc_files:
58
58
  - bin/boxgrinder-build
59
59
  - lib/boxgrinder-build/appliance.rb
60
60
  - lib/boxgrinder-build/helpers/appliance-customize-helper.rb
61
+ - lib/boxgrinder-build/helpers/augeas-helper.rb
61
62
  - lib/boxgrinder-build/helpers/guestfs-helper.rb
62
63
  - lib/boxgrinder-build/helpers/linux-helper.rb
63
64
  - lib/boxgrinder-build/helpers/package-helper.rb
@@ -73,6 +74,7 @@ files:
73
74
  - bin/boxgrinder-build
74
75
  - lib/boxgrinder-build/appliance.rb
75
76
  - lib/boxgrinder-build/helpers/appliance-customize-helper.rb
77
+ - lib/boxgrinder-build/helpers/augeas-helper.rb
76
78
  - lib/boxgrinder-build/helpers/guestfs-helper.rb
77
79
  - lib/boxgrinder-build/helpers/linux-helper.rb
78
80
  - lib/boxgrinder-build/helpers/package-helper.rb
@@ -82,6 +84,7 @@ files:
82
84
  - spec/Rakefile
83
85
  - spec/appliance-spec.rb
84
86
  - spec/helpers/appliance-customize-helper-spec.rb
87
+ - spec/helpers/augeas-helper-spec.rb
85
88
  - spec/helpers/guestfs-helper-spec.rb
86
89
  - spec/helpers/linux-helper-spec.rb
87
90
  - spec/helpers/package-helper-spec.rb