dw-boxgrinder-tarball-platform-plugin 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG
ADDED
File without changes
|
data/Rakefile
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rake'
|
4
|
+
require 'rake/clean'
|
5
|
+
require 'rake/gempackagetask'
|
6
|
+
require 'rake/rdoctask'
|
7
|
+
require 'rake/testtask'
|
8
|
+
|
9
|
+
spec = Gem::Specification.new do |s|
|
10
|
+
s.name = 'SamplePlugin'
|
11
|
+
s.version = '0.0.1'
|
12
|
+
s.has_rdoc = true
|
13
|
+
s.extra_rdoc_files = ['README', 'LICENSE']
|
14
|
+
s.summary = 'Your summary here'
|
15
|
+
s.description = s.summary
|
16
|
+
s.author = ''
|
17
|
+
s.email = ''
|
18
|
+
# s.executables = ['your_executable_here']
|
19
|
+
s.files = %w(LICENSE README Rakefile) + Dir.glob("{bin,lib,spec}/**/*")
|
20
|
+
s.require_path = "lib"
|
21
|
+
s.bindir = "bin"
|
22
|
+
end
|
23
|
+
|
24
|
+
Rake::GemPackageTask.new(spec) do |p|
|
25
|
+
p.gem_spec = spec
|
26
|
+
p.need_tar = true
|
27
|
+
p.need_zip = true
|
28
|
+
end
|
29
|
+
|
30
|
+
Rake::RDocTask.new do |rdoc|
|
31
|
+
files =['README', 'LICENSE', 'lib/**/*.rb']
|
32
|
+
rdoc.rdoc_files.add(files)
|
33
|
+
rdoc.main = "README" # page to start on
|
34
|
+
rdoc.title = "SamplePlugin Docs"
|
35
|
+
rdoc.rdoc_dir = 'doc/rdoc' # rdoc output folder
|
36
|
+
rdoc.options << '--line-numbers'
|
37
|
+
end
|
38
|
+
|
39
|
+
Rake::TestTask.new do |t|
|
40
|
+
t.test_files = FileList['test/**/*.rb']
|
41
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = %q{dw-boxgrinder-tarball-platform-plugin}
|
3
|
+
s.version = "0.0.1"
|
4
|
+
|
5
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
6
|
+
s.authors = ["Pete Royle"]
|
7
|
+
s.date = %q{2012-05-21}
|
8
|
+
s.description = %q{BoxGrinder Build Tarball Platform Plugin}
|
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"]
|
12
|
+
s.homepage = %q{http://www.digitalworx.com.au}
|
13
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "dw-boxgrinder-tarball-platform-plugin"]
|
14
|
+
s.require_paths = ["lib"]
|
15
|
+
s.rubyforge_project = %q{BoxGrinder Build}
|
16
|
+
s.rubygems_version = %q{1.3.6}
|
17
|
+
s.summary = %q{Tarball Platform Plugin}
|
18
|
+
|
19
|
+
if s.respond_to? :specification_version then
|
20
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
21
|
+
s.specification_version = 3
|
22
|
+
|
23
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
24
|
+
s.add_runtime_dependency(%q<boxgrinder-build>, [">= 0.5.0"])
|
25
|
+
s.add_runtime_dependency(%q<minitar>, [">= 0.5.3"])
|
26
|
+
else
|
27
|
+
s.add_dependency(%q<boxgrinder-build>, [">= 0.5.0"])
|
28
|
+
s.add_dependency(%q<minitar>, [">= 0.5.3"])
|
29
|
+
end
|
30
|
+
else
|
31
|
+
s.add_dependency(%q<boxgrinder-build>, [">= 0.5.0"])
|
32
|
+
s.add_dependency(%q<minitar>, [">= 0.5.3"])
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
# Copyright 2012, Digital Worx Aust
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
# See the License for the specific language governing permissions and
|
11
|
+
# limitations under the License.
|
12
|
+
|
13
|
+
require 'boxgrinder-build/plugins/base-plugin'
|
14
|
+
require "fileutils"
|
15
|
+
require 'zlib'
|
16
|
+
require 'archive/tar/minitar'
|
17
|
+
require 'archive/tar/minitar/command'
|
18
|
+
require 'set'
|
19
|
+
|
20
|
+
|
21
|
+
module BoxGrinder
|
22
|
+
|
23
|
+
class TarballPlugin < BasePlugin
|
24
|
+
plugin :type => :platform, :name => :tarball, :full_name => "Tarball"
|
25
|
+
|
26
|
+
include FileUtils
|
27
|
+
include Archive::Tar
|
28
|
+
|
29
|
+
attr_accessor :appliance_config, :log, :dir, :plugin_info
|
30
|
+
|
31
|
+
def after_init
|
32
|
+
@tar_name = "#{@appliance_config.name}.tgz"
|
33
|
+
register_deliverable(
|
34
|
+
:tarball => @tar_name
|
35
|
+
)
|
36
|
+
register_supported_os('centos', ["4", "5", "6"])
|
37
|
+
register_supported_os('fedora', ["15", "16"])
|
38
|
+
end
|
39
|
+
|
40
|
+
def execute
|
41
|
+
|
42
|
+
# Create a temporary directory to work from
|
43
|
+
@working_dir = "#{@dir.tmp}"
|
44
|
+
mkdir_p(@working_dir)
|
45
|
+
|
46
|
+
# collect the RPMs and create an install_rpms.sh script to add to the payload
|
47
|
+
install_rpms_script_name = "install_rpms.sh"
|
48
|
+
create_script(install_rpms_script_name, :prefix => "yum install -y ", :lines => @appliance_config.packages) {|line|
|
49
|
+
"#{line} "
|
50
|
+
}
|
51
|
+
|
52
|
+
# collect all post->base commands and create an install script to add to the payload
|
53
|
+
install_post_script_name = "install_post.sh"
|
54
|
+
create_script(install_post_script_name, :lines => @appliance_config.post['base']) {|line|
|
55
|
+
"#{line}\n"
|
56
|
+
}
|
57
|
+
|
58
|
+
# create a root install script to install rpms and perform post
|
59
|
+
install_all_script_name = "install.sh"
|
60
|
+
create_script(install_all_script_name, :lines => [install_rpms_script_name, install_post_script_name]) {|line|
|
61
|
+
"sh #{line}\n"
|
62
|
+
}
|
63
|
+
|
64
|
+
# Copy all files into the working directory to add to the payload
|
65
|
+
for tgt_dir in @appliance_config.files.keys
|
66
|
+
sources = @appliance_config.files[tgt_dir]
|
67
|
+
for source in sources
|
68
|
+
# convert '../xxx/yyy' to 'xxx/yyy'
|
69
|
+
tgt_path_suffix = source.scan(/([^\.]+)[\\\/][^\\\/]+/)
|
70
|
+
full_tgt_path = "#{tmp_path(tgt_dir)}/#{tgt_path_suffix}"
|
71
|
+
mkdir_p(full_tgt_path)
|
72
|
+
cp_r("#{source}", full_tgt_path)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# create the tar in the build tmp directory, and it will be moved into the
|
77
|
+
# deliverables directory automatically
|
78
|
+
root_tar_path = tmp_path('')
|
79
|
+
@tar_name = "#{@appliance_config.name}.tgz"
|
80
|
+
Dir.chdir(root_tar_path) do
|
81
|
+
begin
|
82
|
+
sgz = Zlib::GzipWriter.new(File.open(@tar_name, 'wb'))
|
83
|
+
tar = Archive::Tar::Minitar::Output.new(sgz)
|
84
|
+
uniq_entries = Set.new
|
85
|
+
for tgt_dir in @appliance_config.files.keys
|
86
|
+
# remove leading slashes for relative paths
|
87
|
+
tgt_rel = "#{tgt_dir.scan(/[\\\/]*(.*)/)}"
|
88
|
+
Find.find(tgt_rel) do |entry|
|
89
|
+
if !uniq_entries.include?(entry)
|
90
|
+
Minitar.pack_file(entry, tar)
|
91
|
+
uniq_entries << entry
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
# add all generated scripts
|
96
|
+
for script_name in @created_scripts
|
97
|
+
Minitar.pack_file(script_name, tar)
|
98
|
+
end
|
99
|
+
ensure
|
100
|
+
tar.close
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
def tmp_path(dir_name)
|
107
|
+
"#{@working_dir}/#{dir_name}"
|
108
|
+
end
|
109
|
+
|
110
|
+
def create_script(script_name, options = {}, &line_processor)
|
111
|
+
script = (options[:prefix] || "")
|
112
|
+
for line in options[:lines]
|
113
|
+
processed_line = line_processor.call line
|
114
|
+
script << processed_line
|
115
|
+
end
|
116
|
+
script << (options[:suffix] || "")
|
117
|
+
File.open(tmp_path(script_name), 'w') {|script_file|
|
118
|
+
script_file.puts(script)
|
119
|
+
}
|
120
|
+
# record the names of all generated scripts, so we can add them to the tarball
|
121
|
+
@created_scripts ||= []
|
122
|
+
@created_scripts << script_name
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
|
128
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Copyright 2012, Digital Worx Aust
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
# See the License for the specific language governing permissions and
|
11
|
+
# limitations under the License.
|
12
|
+
|
13
|
+
require 'dw-boxgrinder-tarball-platform-plugin/tarball_plugin'
|
14
|
+
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dw-boxgrinder-tarball-platform-plugin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Pete Royle
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-05-21 00:00:00 +10:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: boxgrinder-build
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 11
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 5
|
33
|
+
- 0
|
34
|
+
version: 0.5.0
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: minitar
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 13
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
- 5
|
49
|
+
- 3
|
50
|
+
version: 0.5.3
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
53
|
+
description: BoxGrinder Build Tarball Platform Plugin
|
54
|
+
email: howardmoon@screamingcoder.com
|
55
|
+
executables: []
|
56
|
+
|
57
|
+
extensions: []
|
58
|
+
|
59
|
+
extra_rdoc_files:
|
60
|
+
- CHANGELOG
|
61
|
+
- lib/dw-boxgrinder-tarball-platform-plugin.rb
|
62
|
+
- lib/dw-boxgrinder-tarball-platform-plugin/tarball_plugin.rb
|
63
|
+
files:
|
64
|
+
- CHANGELOG
|
65
|
+
- Rakefile
|
66
|
+
- lib/dw-boxgrinder-tarball-platform-plugin.rb
|
67
|
+
- lib/dw-boxgrinder-tarball-platform-plugin/tarball_plugin.rb
|
68
|
+
- dw-boxgrinder-tarball-platform-plugin.gemspec
|
69
|
+
has_rdoc: true
|
70
|
+
homepage: http://www.digitalworx.com.au
|
71
|
+
licenses: []
|
72
|
+
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options:
|
75
|
+
- --line-numbers
|
76
|
+
- --inline-source
|
77
|
+
- --title
|
78
|
+
- dw-boxgrinder-tarball-platform-plugin
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
hash: 3
|
87
|
+
segments:
|
88
|
+
- 0
|
89
|
+
version: "0"
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
hash: 11
|
96
|
+
segments:
|
97
|
+
- 1
|
98
|
+
- 2
|
99
|
+
version: "1.2"
|
100
|
+
requirements: []
|
101
|
+
|
102
|
+
rubyforge_project: BoxGrinder Build
|
103
|
+
rubygems_version: 1.4.2
|
104
|
+
signing_key:
|
105
|
+
specification_version: 3
|
106
|
+
summary: Tarball Platform Plugin
|
107
|
+
test_files: []
|
108
|
+
|