dw-boxgrinder-tarball-platform-plugin 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -7,13 +7,13 @@ require 'rake/rdoctask'
7
7
  require 'rake/testtask'
8
8
 
9
9
  spec = Gem::Specification.new do |s|
10
- s.name = 'SamplePlugin'
11
- s.version = '0.0.1'
10
+ s.name = 'DWBoxgrinderTarballPlatformPlugin'
11
+ s.version = '0.0.2'
12
12
  s.has_rdoc = true
13
13
  s.extra_rdoc_files = ['README', 'LICENSE']
14
- s.summary = 'Your summary here'
14
+ s.summary = 'A way to customise an existing minimal OS install according to a BoxGrinder appliance definition'
15
15
  s.description = s.summary
16
- s.author = ''
16
+ s.author = 'Peter Royle'
17
17
  s.email = ''
18
18
  # s.executables = ['your_executable_here']
19
19
  s.files = %w(LICENSE README Rakefile) + Dir.glob("{bin,lib,spec}/**/*")
@@ -31,7 +31,7 @@ Rake::RDocTask.new do |rdoc|
31
31
  files =['README', 'LICENSE', 'lib/**/*.rb']
32
32
  rdoc.rdoc_files.add(files)
33
33
  rdoc.main = "README" # page to start on
34
- rdoc.title = "SamplePlugin Docs"
34
+ rdoc.title = "DWBoxgrinderTarballPlatformPlugin Docs"
35
35
  rdoc.rdoc_dir = 'doc/rdoc' # rdoc output folder
36
36
  rdoc.options << '--line-numbers'
37
37
  end
@@ -1,14 +1,14 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{dw-boxgrinder-tarball-platform-plugin}
3
- s.version = "0.0.1"
3
+ s.version = "0.0.2"
4
4
 
5
5
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
6
6
  s.authors = ["Pete Royle"]
7
7
  s.date = %q{2012-05-21}
8
8
  s.description = %q{BoxGrinder Build Tarball Platform Plugin}
9
9
  s.email = %q{howardmoon@screamingcoder.com}
10
- s.extra_rdoc_files = ["CHANGELOG", "lib/dw-boxgrinder-tarball-platform-plugin.rb", "lib/dw-boxgrinder-tarball-platform-plugin/tarball_plugin.rb"]
11
- s.files = ["CHANGELOG", "Rakefile", "lib/dw-boxgrinder-tarball-platform-plugin.rb", "lib/dw-boxgrinder-tarball-platform-plugin/tarball_plugin.rb", "dw-boxgrinder-tarball-platform-plugin.gemspec"]
10
+ s.extra_rdoc_files = ["CHANGELOG", "lib/dw-boxgrinder-tarball-platform-plugin.rb", "lib/dw-boxgrinder-tarball-platform-plugin/tarball_plugin.rb", "lib/dw-boxgrinder-tarball-platform-plugin/rpm_helper.rb"]
11
+ s.files = ["CHANGELOG", "Rakefile", "lib/dw-boxgrinder-tarball-platform-plugin.rb", "lib/dw-boxgrinder-tarball-platform-plugin/tarball_plugin.rb", "lib/dw-boxgrinder-tarball-platform-plugin/rpm_helper.rb", "lib/dw-boxgrinder-tarball-platform-plugin/src/base.repo", "dw-boxgrinder-tarball-platform-plugin.gemspec"]
12
12
  s.homepage = %q{http://www.digitalworx.com.au}
13
13
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "dw-boxgrinder-tarball-platform-plugin"]
14
14
  s.require_paths = ["lib"]
@@ -0,0 +1,41 @@
1
+ require "fileutils"
2
+
3
+ $YUM_REPOS_DIR="etc/yum.repos.d"
4
+
5
+ module RpmHelper
6
+
7
+ include FileUtils
8
+
9
+ def install_repos(working_root_dir)
10
+ @log.debug "Installing repositories from appliance definition file..."
11
+
12
+ # It seems that the directory is not always created by default if default repos are inhibited (e.g. SL6)
13
+ yum_d = "#{working_root_dir}/#{$YUM_REPOS_DIR}/"
14
+ mkdir_p(yum_d)
15
+
16
+ @appliance_config.repos.each do |repo|
17
+ if repo['ephemeral']
18
+ @log.debug "Repository '#{repo['name']}' is an ephemeral repo. It'll not be installed in the appliance."
19
+ next
20
+ end
21
+
22
+ @log.debug "Installing #{repo['name']} repo..."
23
+ repo_file = File.read("#{File.dirname(__FILE__)}/src/base.repo").gsub(/#NAME#/, repo['name'])
24
+
25
+ ['baseurl', 'mirrorlist'].each do |type|
26
+ repo_file << ("#{type}=#{repo[type]}\n") unless repo[type].nil?
27
+ end
28
+
29
+ File.open("#{yum_d}#{repo['name']}.repo", 'w') {|repo_file_out|
30
+ repo_file_out.puts(repo_file)
31
+ }
32
+
33
+ @log.debug "wrote to #{yum_d}#{repo['name']}.repo: "
34
+ @log.debug repo_file
35
+
36
+
37
+ end
38
+ @log.debug "Repositories installed."
39
+ end
40
+
41
+ end
@@ -0,0 +1,4 @@
1
+ [#NAME#]
2
+ name=#NAME#
3
+ enabled=1
4
+ gpgcheck=0
@@ -16,6 +16,7 @@ require 'zlib'
16
16
  require 'archive/tar/minitar'
17
17
  require 'archive/tar/minitar/command'
18
18
  require 'set'
19
+ require 'dw-boxgrinder-tarball-platform-plugin/rpm_helper'
19
20
 
20
21
 
21
22
  module BoxGrinder
@@ -24,6 +25,7 @@ module BoxGrinder
24
25
  plugin :type => :platform, :name => :tarball, :full_name => "Tarball"
25
26
 
26
27
  include FileUtils
28
+ include RpmHelper
27
29
  include Archive::Tar
28
30
 
29
31
  attr_accessor :appliance_config, :log, :dir, :plugin_info
@@ -33,8 +35,6 @@ module BoxGrinder
33
35
  register_deliverable(
34
36
  :tarball => @tar_name
35
37
  )
36
- register_supported_os('centos', ["4", "5", "6"])
37
- register_supported_os('fedora', ["15", "16"])
38
38
  end
39
39
 
40
40
  def execute
@@ -43,6 +43,9 @@ module BoxGrinder
43
43
  @working_dir = "#{@dir.tmp}"
44
44
  mkdir_p(@working_dir)
45
45
 
46
+ # add custom repos into the /etc/yum.repos.d dir
47
+ install_repos(tmp_path(''))
48
+
46
49
  # collect the RPMs and create an install_rpms.sh script to add to the payload
47
50
  install_rpms_script_name = "install_rpms.sh"
48
51
  create_script(install_rpms_script_name, :prefix => "yum install -y ", :lines => @appliance_config.packages) {|line|
@@ -51,7 +54,11 @@ module BoxGrinder
51
54
 
52
55
  # collect all post->base commands and create an install script to add to the payload
53
56
  install_post_script_name = "install_post.sh"
54
- create_script(install_post_script_name, :lines => @appliance_config.post['base']) {|line|
57
+ boxgrinder_env = ["# more BoxGrinder-like environment", "export PATH=$PATH:/sbin/:/usr/sbin/", ""]
58
+ reboot_warning = "echo 'It is highly recommended that you reboot this matchine now before proceeding, as that is more in line with the natural BoxGrinder VM creation process.'"
59
+ lines = boxgrinder_env | @appliance_config.post['base']
60
+ lines << reboot_warning
61
+ create_script(install_post_script_name, :lines => lines) {|line|
55
62
  "#{line}\n"
56
63
  }
57
64
 
@@ -82,6 +89,11 @@ module BoxGrinder
82
89
  sgz = Zlib::GzipWriter.new(File.open(@tar_name, 'wb'))
83
90
  tar = Archive::Tar::Minitar::Output.new(sgz)
84
91
  uniq_entries = Set.new
92
+ # add custom repo definitions
93
+ @appliance_config.repos.each do |repo|
94
+ Minitar.pack_file("#{$YUM_REPOS_DIR}/#{repo['name']}.repo", tar)
95
+ end
96
+ # add all files from the "files:" section
85
97
  for tgt_dir in @appliance_config.files.keys
86
98
  # remove leading slashes for relative paths
87
99
  tgt_rel = "#{tgt_dir.scan(/[\\\/]*(.*)/)}"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dw-boxgrinder-tarball-platform-plugin
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Pete Royle
@@ -60,11 +60,14 @@ extra_rdoc_files:
60
60
  - CHANGELOG
61
61
  - lib/dw-boxgrinder-tarball-platform-plugin.rb
62
62
  - lib/dw-boxgrinder-tarball-platform-plugin/tarball_plugin.rb
63
+ - lib/dw-boxgrinder-tarball-platform-plugin/rpm_helper.rb
63
64
  files:
64
65
  - CHANGELOG
65
66
  - Rakefile
66
67
  - lib/dw-boxgrinder-tarball-platform-plugin.rb
67
68
  - lib/dw-boxgrinder-tarball-platform-plugin/tarball_plugin.rb
69
+ - lib/dw-boxgrinder-tarball-platform-plugin/rpm_helper.rb
70
+ - lib/dw-boxgrinder-tarball-platform-plugin/src/base.repo
68
71
  - dw-boxgrinder-tarball-platform-plugin.gemspec
69
72
  has_rdoc: true
70
73
  homepage: http://www.digitalworx.com.au