puppet 2.7.25 → 2.7.26
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.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- data/bin/puppet +4 -0
- data/ext/build_defaults.yaml +4 -4
- data/ext/debian/control +1 -1
- data/ext/packaging/Gemfile +8 -0
- data/ext/packaging/Gemfile.lock +28 -0
- data/ext/packaging/README.md +31 -4
- data/ext/packaging/lib/packaging.rb +21 -0
- data/ext/packaging/lib/packaging/config.rb +277 -0
- data/ext/packaging/lib/packaging/config/params.rb +175 -0
- data/ext/packaging/lib/packaging/tar.rb +186 -0
- data/ext/packaging/lib/packaging/util.rb +44 -0
- data/ext/packaging/lib/packaging/util/date.rb +15 -0
- data/ext/packaging/lib/packaging/util/file.rb +60 -0
- data/ext/packaging/lib/packaging/util/jira.rb +83 -0
- data/ext/packaging/lib/packaging/util/net.rb +16 -0
- data/ext/packaging/lib/packaging/util/rake_utils.rb +57 -0
- data/ext/packaging/lib/packaging/util/serialization.rb +19 -0
- data/ext/packaging/lib/packaging/util/tool.rb +30 -0
- data/ext/packaging/lib/packaging/util/version.rb +300 -0
- data/ext/packaging/packaging.rake +10 -5
- data/ext/packaging/spec/fixtures/config/ext/build_defaults.yaml +2 -0
- data/ext/packaging/spec/fixtures/config/ext/project_data.yaml +2 -0
- data/ext/packaging/spec/fixtures/config/params.yaml +2 -0
- data/ext/packaging/spec/fixtures/util/pre_tasks.yaml +4 -0
- data/ext/packaging/spec/lib/packaging/config_spec.rb +330 -0
- data/ext/packaging/spec/lib/packaging/tar_spec.rb +122 -0
- data/ext/packaging/spec/lib/packaging/util/file_spec.rb +48 -0
- data/ext/packaging/spec/lib/packaging/util/jira_spec.rb +50 -0
- data/ext/packaging/spec/lib/packaging/util/net_spec.rb +23 -0
- data/ext/packaging/spec/lib/packaging/util/rake_utils_spec.rb +70 -0
- data/ext/packaging/spec/lib/packaging/util/version_spec.rb +67 -0
- data/ext/packaging/spec/lib/packaging_spec.rb +19 -0
- data/ext/packaging/spec/spec_helper.rb +10 -0
- data/ext/packaging/spec/tasks/00_utils_spec.rb +218 -88
- data/ext/packaging/tasks/00_utils.rake +63 -320
- data/ext/packaging/tasks/30_metrics.rake +4 -4
- data/ext/packaging/tasks/apple.rake +28 -13
- data/ext/packaging/tasks/build.rake +2 -176
- data/ext/packaging/tasks/deb.rake +61 -20
- data/ext/packaging/tasks/deb_repos.rake +12 -12
- data/ext/packaging/tasks/doc.rake +5 -5
- data/ext/packaging/tasks/fetch.rake +9 -9
- data/ext/packaging/tasks/gem.rake +59 -33
- data/ext/packaging/tasks/ips.rake +22 -23
- data/ext/packaging/tasks/jenkins.rake +34 -34
- data/ext/packaging/tasks/jenkins_dynamic.rake +22 -19
- data/ext/packaging/tasks/load_extras.rake +21 -0
- data/ext/packaging/tasks/mock.rake +16 -16
- data/ext/packaging/tasks/pe_deb.rake +2 -2
- data/ext/packaging/tasks/pe_remote.rake +9 -9
- data/ext/packaging/tasks/pe_rpm.rake +1 -1
- data/ext/packaging/tasks/pe_ship.rake +48 -37
- data/ext/packaging/tasks/pe_sign.rake +5 -5
- data/ext/packaging/tasks/release.rake +5 -5
- data/ext/packaging/tasks/remote_build.rake +27 -27
- data/ext/packaging/tasks/retrieve.rake +5 -5
- data/ext/packaging/tasks/rpm.rake +27 -10
- data/ext/packaging/tasks/rpm_repos.rake +13 -12
- data/ext/packaging/tasks/ship.rake +67 -45
- data/ext/packaging/tasks/sign.rake +37 -30
- data/ext/packaging/tasks/tar.rake +14 -69
- data/ext/packaging/tasks/tickets.rake +449 -0
- data/ext/packaging/tasks/update.rake +2 -2
- data/ext/packaging/tasks/vendor_gems.rake +2 -2
- data/ext/packaging/tasks/version.rake +8 -38
- data/ext/packaging/tasks/z_data_dump.rake +35 -3
- data/ext/packaging/templates/downstream.xml.erb +2 -2
- data/ext/packaging/templates/packaging.xml.erb +13 -13
- data/ext/packaging/templates/repo.xml.erb +9 -7
- data/lib/puppet/indirector/facts/facter.rb +1 -1
- data/lib/puppet/version.rb +1 -1
- data/spec/unit/indirector/facts/facter_spec.rb +2 -2
- metadata +38 -13
- data/ext/packaging/spec/tasks/build_object_spec.rb +0 -178
- data/ext/packaging/tasks/10_setupvars.rake +0 -135
- data/ext/packaging/tasks/20_setupextravars.rake +0 -53
- data/ext/packaging/tasks/template.rake +0 -27
@@ -0,0 +1,122 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe "tar.rb" do
|
5
|
+
let(:project) { "packaging" }
|
6
|
+
let(:version) { "1.2.3" }
|
7
|
+
let(:files) { [ "a", "b", "c" ] }
|
8
|
+
let(:templates) do
|
9
|
+
[
|
10
|
+
"ext/redhat/spec.erb",
|
11
|
+
{ "source" => "ext/debian/control.erb", "target" => "ext/debian/not-a-control-file" },
|
12
|
+
"ext/debian/changelog.erb",
|
13
|
+
"ext/packaging/thing.erb"
|
14
|
+
]
|
15
|
+
end
|
16
|
+
let(:expanded_templates) do
|
17
|
+
[
|
18
|
+
"#{PROJECT_ROOT}/ext/redhat/spec.erb",
|
19
|
+
{ "source" => "ext/debian/control.erb", "target" => "ext/debian/not-a-control-file" },
|
20
|
+
"#{PROJECT_ROOT}/ext/debian/changelog.erb"
|
21
|
+
]
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#expand_templates" do
|
25
|
+
it "should be invoked when Pkg::Config.templates is set" do
|
26
|
+
Pkg::Config.config_from_hash(
|
27
|
+
{
|
28
|
+
:templates => templates,
|
29
|
+
:project => project,
|
30
|
+
:version => version,
|
31
|
+
:files => files,
|
32
|
+
:project_root => PROJECT_ROOT,
|
33
|
+
:packaging_root => "ext/packaging"
|
34
|
+
})
|
35
|
+
|
36
|
+
Pkg::Tar.any_instance.should_receive(:expand_templates)
|
37
|
+
Pkg::Tar.new
|
38
|
+
end
|
39
|
+
|
40
|
+
it "packaging templates should be filtered and paths should be expanded" do
|
41
|
+
Pkg::Config.config_from_hash(
|
42
|
+
{
|
43
|
+
:templates => templates,
|
44
|
+
:project => project,
|
45
|
+
:version => version,
|
46
|
+
:files => files,
|
47
|
+
:project_root => PROJECT_ROOT,
|
48
|
+
:packaging_root => "ext/packaging"
|
49
|
+
})
|
50
|
+
|
51
|
+
templates.each do |temp|
|
52
|
+
if temp.is_a?(String)
|
53
|
+
Dir.stub(:glob).with(File.join(PROJECT_ROOT, temp)).and_return(File.join(PROJECT_ROOT, temp))
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
tar = Pkg::Tar.new
|
58
|
+
tar.templates = templates
|
59
|
+
tar.expand_templates
|
60
|
+
tar.templates.should eq expanded_templates
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "#template" do
|
65
|
+
it "should handle hashes and strings correctly" do
|
66
|
+
Pkg::Config.config_from_hash(
|
67
|
+
{
|
68
|
+
:templates => expanded_templates,
|
69
|
+
:project => project,
|
70
|
+
:version => version,
|
71
|
+
:files => files,
|
72
|
+
:project_root => PROJECT_ROOT,
|
73
|
+
:packaging_root => "ext/packaging"
|
74
|
+
})
|
75
|
+
|
76
|
+
# Set up correct stubs and expectations
|
77
|
+
expanded_templates.each do |temp|
|
78
|
+
if temp.is_a?(String)
|
79
|
+
full_path_temp = File.join(PROJECT_ROOT, temp)
|
80
|
+
target = full_path_temp.sub(File.extname(full_path_temp), "")
|
81
|
+
elsif temp.is_a?(Hash)
|
82
|
+
full_path_temp = File.join(PROJECT_ROOT, temp["source"])
|
83
|
+
target = File.join(PROJECT_ROOT, temp["target"])
|
84
|
+
end
|
85
|
+
|
86
|
+
Dir.stub(:glob).with(full_path_temp).and_return(full_path_temp)
|
87
|
+
File.stub(:exist?).with(full_path_temp).and_return(true)
|
88
|
+
Pkg::Util::File.should_receive(:erb_file).with(full_path_temp, target, true, :binding => an_instance_of(Binding))
|
89
|
+
end
|
90
|
+
|
91
|
+
Pkg::Tar.new.template
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should raise an error if the template source can't be found" do
|
95
|
+
Pkg::Config.config_from_hash(
|
96
|
+
{
|
97
|
+
:templates => expanded_templates,
|
98
|
+
:project => project,
|
99
|
+
:version => version,
|
100
|
+
:files => files,
|
101
|
+
:project_root => PROJECT_ROOT,
|
102
|
+
:packaging_root => "ext/packaging"
|
103
|
+
})
|
104
|
+
|
105
|
+
# Set up correct stubs and expectations
|
106
|
+
expanded_templates.each do |temp|
|
107
|
+
if temp.is_a?(String)
|
108
|
+
full_path_temp = File.join(PROJECT_ROOT, temp)
|
109
|
+
target = full_path_temp.sub(File.extname(full_path_temp), "")
|
110
|
+
elsif temp.is_a?(Hash)
|
111
|
+
full_path_temp = File.join(PROJECT_ROOT, temp["source"])
|
112
|
+
target = File.join(PROJECT_ROOT, temp["target"])
|
113
|
+
end
|
114
|
+
|
115
|
+
Dir.stub(:glob).with(full_path_temp).and_return(full_path_temp)
|
116
|
+
File.stub(:exist?).with(full_path_temp).and_return(false)
|
117
|
+
end
|
118
|
+
|
119
|
+
expect { Pkg::Tar.new.template }.to raise_error RuntimeError
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Pkg::Util::File" do
|
4
|
+
let(:source) { "/tmp/placething.tar.gz" }
|
5
|
+
let(:target) { "/tmp" }
|
6
|
+
let(:options) { "--thing-for-tar" }
|
7
|
+
let(:tar) { "/usr/bin/tar" }
|
8
|
+
|
9
|
+
describe "#untar_into" do
|
10
|
+
before :each do
|
11
|
+
Pkg::Util::Tool.stub(:find_tool).with('tar', :required => true) { tar }
|
12
|
+
end
|
13
|
+
|
14
|
+
it "raises an exception if the source doesn't exist" do
|
15
|
+
Pkg::Util::File.should_receive(:file_exists?).with(source, {:required => true}).and_raise(RuntimeError)
|
16
|
+
Pkg::Util::File.should_not_receive(:ex)
|
17
|
+
expect { Pkg::Util::File.untar_into(source) }.to raise_error(RuntimeError)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "unpacks the tarball to the current directory if no target is passed" do
|
21
|
+
Pkg::Util::File.should_receive(:file_exists?).with(source, {:required => true}) { true }
|
22
|
+
Pkg::Util::File.should_receive(:ex).with("#{tar} -xf #{source}")
|
23
|
+
Pkg::Util::File.untar_into(source)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "unpacks the tarball to the current directory with options if no target is passed" do
|
27
|
+
Pkg::Util::File.should_receive(:file_exists?).with(source, {:required => true}) { true }
|
28
|
+
Pkg::Util::File.should_receive(:ex).with("#{tar} #{options} -xf #{source}")
|
29
|
+
Pkg::Util::File.untar_into(source, nil, options)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "unpacks the tarball into the target" do
|
33
|
+
File.stub(:exist?).with(source) { true }
|
34
|
+
Pkg::Util::File.should_receive(:file_exists?).with(source, {:required => true}) { true }
|
35
|
+
Pkg::Util::File.should_receive(:file_writable?).with(target) { true }
|
36
|
+
Pkg::Util::File.should_receive(:ex).with("#{tar} -C #{target} -xf #{source}")
|
37
|
+
Pkg::Util::File.untar_into(source, target)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "unpacks the tarball into the target with options passed" do
|
41
|
+
File.stub(:exist?).with(source) { true }
|
42
|
+
Pkg::Util::File.should_receive(:file_exists?).with(source, {:required => true}) { true }
|
43
|
+
Pkg::Util::File.should_receive(:file_writable?).with(target) { true }
|
44
|
+
Pkg::Util::File.should_receive(:ex).with("#{tar} #{options} -C #{target} -xf #{source}")
|
45
|
+
Pkg::Util::File.untar_into(source, target, options)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'packaging/util/jira'
|
4
|
+
|
5
|
+
describe Pkg::Util::Jira do
|
6
|
+
it "should build an expected set of client options" do
|
7
|
+
options = described_class.jira_client_options("user", "password", "http://devnull.tld")
|
8
|
+
expect(options[:username]).to eq("user")
|
9
|
+
expect(options[:password]).to eq("password")
|
10
|
+
expect(options[:site]).to eq("http://devnull.tld")
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should extract a project name from the project list" do
|
14
|
+
Project = Struct.new(:key, :name)
|
15
|
+
projects = [Project.new("PUP", "PUP"), Project.new("FOO", "BAR")]
|
16
|
+
|
17
|
+
expect(described_class.jira_project_name(projects, "PUP")).to eq("PUP")
|
18
|
+
expect(described_class.jira_project_name(projects, "FOO")).to eq("BAR")
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should build a parent ticket's fields" do
|
22
|
+
fields = described_class.jira_issue_fields("summary",
|
23
|
+
"desc",
|
24
|
+
"PUP",
|
25
|
+
nil,
|
26
|
+
"ivy")
|
27
|
+
|
28
|
+
expect(fields['summary']).to eq("summary")
|
29
|
+
expect(fields['description']).to eq("desc")
|
30
|
+
expect(fields['project']['key']).to eq("PUP")
|
31
|
+
expect(fields['issuetype']['name']).to eq("Task")
|
32
|
+
expect(fields['assignee']['name']).to eq("ivy")
|
33
|
+
expect(fields['parent']).to eq(nil)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should build a subtask ticket's fields" do
|
37
|
+
fields = described_class.jira_issue_fields("sub summary",
|
38
|
+
"sub desc",
|
39
|
+
"PUP",
|
40
|
+
42,
|
41
|
+
"bean")
|
42
|
+
|
43
|
+
expect(fields['summary']).to eq("sub summary")
|
44
|
+
expect(fields['description']).to eq("sub desc")
|
45
|
+
expect(fields['project']['key']).to eq("PUP")
|
46
|
+
expect(fields['issuetype']['name']).to eq("Sub-task")
|
47
|
+
expect(fields['assignee']['name']).to eq("bean")
|
48
|
+
expect(fields['parent']['id']).to eq(42)
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Pkg::Util::Net" do
|
4
|
+
let(:target) { "/tmp/placething" }
|
5
|
+
let(:target_uri) { "http://google.com" }
|
6
|
+
let(:content) { "stuff" }
|
7
|
+
|
8
|
+
describe "#fetch_uri" do
|
9
|
+
context "given a target directory" do
|
10
|
+
it "does nothing if the directory isn't writable" do
|
11
|
+
File.stub(:writable?).with(File.dirname(target)) { false }
|
12
|
+
File.should_receive(:open).never
|
13
|
+
Pkg::Util::Net.fetch_uri(target_uri, target)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "writes the content of the uri to a file if directory is writable" do
|
17
|
+
File.should_receive(:writable?).once.with(File.dirname(target)) { true }
|
18
|
+
File.should_receive(:open).once.with(target, 'w')
|
19
|
+
Pkg::Util::Net.fetch_uri(target_uri, target)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Pkg::Util::RakeUtils" do
|
4
|
+
let(:foo_defined?) { Rake::Task.task_defined?(:foo) }
|
5
|
+
let(:bar_defined?) { Rake::Task.task_defined?(:bar) }
|
6
|
+
let(:define_foo) { body = proc{}; Rake::Task.define_task(:foo, &body) }
|
7
|
+
let(:define_bar) { body = proc{}; Rake::Task.define_task(:bar, &body) }
|
8
|
+
|
9
|
+
before(:each) do
|
10
|
+
if foo_defined?
|
11
|
+
Rake::Task[:foo].clear_prerequisites
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#task_defined?" do
|
16
|
+
context "given a Rake::Task task name" do
|
17
|
+
it "should return true if the task exists" do
|
18
|
+
Rake::Task.stub(:task_defined?).with(:foo) {true}
|
19
|
+
expect(Pkg::Util::RakeUtils.task_defined?(:foo)).to be_true
|
20
|
+
end
|
21
|
+
it "should return false if the task does not exist" do
|
22
|
+
Rake::Task.stub(:task_defined?).with(:foo) {false}
|
23
|
+
expect(Pkg::Util::RakeUtils.task_defined?(:foo)).to be_false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#get_task" do
|
29
|
+
it "should return a task object for a named task" do
|
30
|
+
foo = nil
|
31
|
+
if !foo_defined?
|
32
|
+
foo = define_foo
|
33
|
+
else
|
34
|
+
foo = Rake::Task[:foo]
|
35
|
+
end
|
36
|
+
task = Pkg::Util::RakeUtils.get_task(:foo)
|
37
|
+
expect(task).to be_a(Rake::Task)
|
38
|
+
expect(task).to be(foo)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#add_dependency" do
|
43
|
+
it "should add a dependency to a given rake task" do
|
44
|
+
foo = nil
|
45
|
+
bar = nil
|
46
|
+
if !foo_defined?
|
47
|
+
foo = define_foo
|
48
|
+
else
|
49
|
+
foo = Rake::Task[:foo]
|
50
|
+
end
|
51
|
+
if !bar_defined?
|
52
|
+
bar = define_bar
|
53
|
+
else
|
54
|
+
bar = Rake::Task[:bar]
|
55
|
+
end
|
56
|
+
Pkg::Util::RakeUtils.add_dependency(foo, bar)
|
57
|
+
expect(Rake::Task["foo"].prerequisites).to include(bar)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "#evaluate_pre_tasks" do
|
62
|
+
context "Given a data file with :pre_tasks defined" do
|
63
|
+
it "should, for each k=>v pair, add v as a dependency to k" do
|
64
|
+
Pkg::Config.config_from_yaml(File.join(FIXTURES, 'util', 'pre_tasks.yaml'))
|
65
|
+
expect(Pkg::Util::RakeUtils).to receive(:add_dependency)
|
66
|
+
Pkg::Util::RakeUtils.evaluate_pre_tasks
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe "Pkg::Util::Version" do
|
5
|
+
context "#versionbump" do
|
6
|
+
let(:version_file) { "thing.txt" }
|
7
|
+
let(:version) { "1.2.3" }
|
8
|
+
let(:orig_contents) { "abcd\nVERSION = @DEVELOPMENT_VERSION@\n" }
|
9
|
+
let(:updated_contents) { "abcd\nVERSION = #{version}\n" }
|
10
|
+
|
11
|
+
it "should update the version file contents accordingly" do
|
12
|
+
Pkg::Config.config_from_hash({:project => "foo", :version_file => version_file})
|
13
|
+
IO.stub(:read).with(version_file).and_return(orig_contents)
|
14
|
+
Pkg::Config.stub(:version).and_return(version)
|
15
|
+
version_file_to_write = double('file')
|
16
|
+
File.should_receive(:open).with(version_file, 'w').and_yield(version_file_to_write)
|
17
|
+
version_file_to_write.should_receive(:write).with(updated_contents)
|
18
|
+
Pkg::Util::Version.versionbump
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "#is_less_than_one?" do
|
23
|
+
context "with a version that starts with '0'" do
|
24
|
+
it "should return true" do
|
25
|
+
Pkg::Util::Version.stub(:get_dash_version).and_return("0.0.1")
|
26
|
+
Pkg::Util::Version.is_less_than_one?.should be(true)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "with a version that starts with '1' or greater" do
|
31
|
+
it "should return false" do
|
32
|
+
Pkg::Util::Version.stub(:get_dash_version).and_return("1.0.0")
|
33
|
+
Pkg::Util::Version.is_less_than_one?.should be(false)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "#is_final?" do
|
39
|
+
|
40
|
+
context "with version_strategy 'rc_final'" do
|
41
|
+
it "should use 'is_rc?' and return the opposite" do
|
42
|
+
Pkg::Util::Version.stub(:is_rc?).and_return(false)
|
43
|
+
Pkg::Config.stub(:version_strategy).and_return("rc_final")
|
44
|
+
Pkg::Util::Version.should_receive(:is_rc?)
|
45
|
+
Pkg::Util::Version.is_final?.should be(true)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context "with version_strategy 'odd_even'" do
|
50
|
+
it "should use 'is_odd?' and return the opposite" do
|
51
|
+
Pkg::Util::Version.stub(:is_odd?).and_return(false)
|
52
|
+
Pkg::Config.stub(:version_strategy).and_return("odd_even")
|
53
|
+
Pkg::Util::Version.should_receive(:is_odd?)
|
54
|
+
Pkg::Util::Version.is_final?.should be(true)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context "with version_strategy 'zero_based'" do
|
59
|
+
it "should use 'is_less_than_one?' and return the opposite" do
|
60
|
+
Pkg::Util::Version.stub(:is_less_than_one?).and_return(false)
|
61
|
+
Pkg::Config.stub(:version_strategy).and_return("zero_based")
|
62
|
+
Pkg::Util::Version.should_receive(:is_less_than_one?)
|
63
|
+
Pkg::Util::Version.is_final?.should be(true)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# We load packaging.rb once, in spec_helper, to avoid reloading the library
|
4
|
+
# and issuing warnings about already defined constants.
|
5
|
+
describe "Pkg" do
|
6
|
+
it "should require the utilities module, Pkg::Util" do
|
7
|
+
Pkg::Util.should_not be_nil
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should require the configuration module, Pkg::Config" do
|
11
|
+
Pkg::Config.should_not be_nil
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should require the tar library, Pkg::Tar" do
|
15
|
+
Pkg::Tar.should_not be_nil
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
@@ -4,9 +4,19 @@ require 'pathname'
|
|
4
4
|
require 'rake'
|
5
5
|
|
6
6
|
SPECDIR = Pathname(__FILE__).dirname
|
7
|
+
PROJECT_ROOT = File.expand_path(File.join(Pathname(__FILE__).dirname, ".."))
|
8
|
+
FIXTURES = File.join(SPECDIR, 'fixtures')
|
9
|
+
|
10
|
+
require File.join(SPECDIR, '..', 'lib', 'packaging.rb')
|
7
11
|
|
8
12
|
def load_task(name)
|
9
13
|
return false if (@loaded ||= {})[name]
|
10
14
|
load File.join(SPECDIR, '..', 'tasks', name)
|
11
15
|
@loaded[name] = true
|
12
16
|
end
|
17
|
+
|
18
|
+
def reset_env(keys)
|
19
|
+
keys.each do |key|
|
20
|
+
ENV[key] = nil
|
21
|
+
end
|
22
|
+
end
|
@@ -1,118 +1,248 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
require 'spec_helper'
|
3
|
-
load_task
|
4
|
-
load_task 'build.rake'
|
3
|
+
load_task('00_utils.rake')
|
5
4
|
|
6
5
|
describe "00_utils" do
|
7
6
|
TestVersions = {
|
8
|
-
'0.
|
9
|
-
:
|
10
|
-
:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
7
|
+
'0.3.2-20140507.175526-5' => {
|
8
|
+
:ref_type => "tag",
|
9
|
+
:method_map => {
|
10
|
+
:git_describe_version => %w{0.3.2 20140507.175526 5},
|
11
|
+
:get_dash_version => '0.3.2-20140507.175526-5',
|
12
|
+
:get_dot_version => '0.3.2.20140507.175526.5',
|
13
|
+
:get_debversion => '0.3.2.20140507.175526.5-1puppetlabs1',
|
14
|
+
:get_rpmversion => '0.3.2.20140507.175526.5',
|
15
|
+
:get_rpmrelease => '1',
|
16
|
+
:is_rc? => false,
|
17
|
+
:is_odd? => true,
|
18
|
+
:is_less_than_one? => true,
|
19
|
+
},
|
18
20
|
},
|
19
|
-
'0.
|
20
|
-
:
|
21
|
-
:
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
21
|
+
'0.7.0' => {
|
22
|
+
:ref_type => "tag",
|
23
|
+
:method_map => {
|
24
|
+
:git_describe_version => %w{0.7.0},
|
25
|
+
:get_dash_version => '0.7.0',
|
26
|
+
:get_ips_version => '0.7.0,3.14159-0',
|
27
|
+
:get_dot_version => '0.7.0',
|
28
|
+
:get_debversion => '0.7.0-1puppetlabs1',
|
29
|
+
:get_rpmversion => '0.7.0',
|
30
|
+
:get_rpmrelease => '1',
|
31
|
+
:is_rc? => false,
|
32
|
+
:is_odd? => true,
|
33
|
+
:is_less_than_one? => true,
|
34
|
+
},
|
29
35
|
},
|
30
|
-
'0.
|
31
|
-
:
|
32
|
-
:
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
'0.8.0rc10' => {
|
37
|
+
:ref_type => "tag",
|
38
|
+
:method_map => {
|
39
|
+
:git_describe_version => %w{0.8.0rc10},
|
40
|
+
:get_dash_version => '0.8.0rc10',
|
41
|
+
:get_ips_version => '0.8.0rc10,3.14159-0',
|
42
|
+
:get_dot_version => '0.8.0rc10',
|
43
|
+
:get_debversion => '0.8.0-0.1rc10puppetlabs1',
|
44
|
+
:get_rpmversion => '0.8.0',
|
45
|
+
:get_rpmrelease => '0.1rc10',
|
46
|
+
:is_rc? => true,
|
47
|
+
:is_odd? => false,
|
48
|
+
:is_less_than_one? => true,
|
49
|
+
},
|
40
50
|
},
|
41
|
-
'0.
|
42
|
-
:
|
43
|
-
:
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
+
'0.7.0-rc1' => {
|
52
|
+
:ref_type => "tag",
|
53
|
+
:method_map => {
|
54
|
+
:git_describe_version => %w{0.7.0 rc1},
|
55
|
+
:get_dash_version => '0.7.0-rc1',
|
56
|
+
:get_ips_version => '0.7.0,3.14159-0',
|
57
|
+
:get_dot_version => '0.7.0.rc1',
|
58
|
+
:get_debversion => '0.7.0-0.1rc1puppetlabs1',
|
59
|
+
:get_rpmversion => '0.7.0',
|
60
|
+
:get_rpmrelease => '0.1rc1',
|
61
|
+
:is_rc? => true,
|
62
|
+
:is_odd? => true,
|
63
|
+
:is_less_than_one? => true,
|
64
|
+
},
|
51
65
|
},
|
52
|
-
'0.
|
53
|
-
:
|
54
|
-
:
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
66
|
+
'0.4.0-rc1-63-ge391f55' => {
|
67
|
+
:ref_type => "commit",
|
68
|
+
:method_map => {
|
69
|
+
:git_describe_version => %w{0.4.0 rc1 63},
|
70
|
+
:get_dash_version => '0.4.0-rc1-63',
|
71
|
+
:get_ips_version => '0.4.0,3.14159-63',
|
72
|
+
:get_dot_version => '0.4.0.rc1.63',
|
73
|
+
:get_debversion => '0.4.0-0.1rc1.63puppetlabs1',
|
74
|
+
:get_rpmversion => '0.4.0',
|
75
|
+
:get_rpmrelease => '0.1rc1.63',
|
76
|
+
:is_rc? => true,
|
77
|
+
:is_odd? => false,
|
78
|
+
:is_less_than_one? => true,
|
79
|
+
},
|
63
80
|
},
|
64
|
-
'0.
|
65
|
-
:
|
66
|
-
:
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
81
|
+
'0.6.0-rc1-63-ge391f55-dirty' => {
|
82
|
+
:ref_type => "commit",
|
83
|
+
:method_map => {
|
84
|
+
:git_describe_version => %w{0.6.0 rc1 63 dirty},
|
85
|
+
:get_dash_version => '0.6.0-rc1-63-dirty',
|
86
|
+
:get_ips_version => '0.6.0,3.14159-63-dirty',
|
87
|
+
:get_dot_version => '0.6.0.rc1.63.dirty',
|
88
|
+
:get_debversion => '0.6.0-0.1rc1.63dirtypuppetlabs1',
|
89
|
+
:get_rpmversion => '0.6.0',
|
90
|
+
:get_rpmrelease => '0.1rc1.63dirty',
|
91
|
+
:is_rc? => true,
|
92
|
+
:is_odd? => false,
|
93
|
+
:is_less_than_one? => true,
|
94
|
+
},
|
95
|
+
},
|
96
|
+
'0.7.0-63-ge391f55' => {
|
97
|
+
:ref_type => "commit",
|
98
|
+
:method_map => {
|
99
|
+
:git_describe_version => %w{0.7.0 63},
|
100
|
+
:get_dash_version => '0.7.0-63',
|
101
|
+
:get_ips_version => '0.7.0,3.14159-63',
|
102
|
+
:get_dot_version => '0.7.0.63',
|
103
|
+
:get_debversion => '0.7.0.63-1puppetlabs1',
|
104
|
+
:get_rpmversion => '0.7.0.63',
|
105
|
+
:get_rpmrelease => '1',
|
106
|
+
:is_rc? => false,
|
107
|
+
:is_odd? => true,
|
108
|
+
:is_less_than_one? => true,
|
109
|
+
},
|
110
|
+
},
|
111
|
+
'0.7.0-63-ge391f55-dirty' => {
|
112
|
+
:ref_type => "commit",
|
113
|
+
:method_map => {
|
114
|
+
:git_describe_version => %w{0.7.0 63 dirty},
|
115
|
+
:get_dash_version => '0.7.0-63-dirty',
|
116
|
+
:get_ips_version => '0.7.0,3.14159-63-dirty',
|
117
|
+
:get_dot_version => '0.7.0.63.dirty',
|
118
|
+
:get_debversion => '0.7.0.63.dirty-1puppetlabs1',
|
119
|
+
:get_rpmversion => '0.7.0.63.dirty',
|
120
|
+
:get_rpmrelease => '1',
|
121
|
+
:is_rc? => false,
|
122
|
+
:is_odd? => true,
|
123
|
+
:is_less_than_one? => true,
|
124
|
+
},
|
125
|
+
},
|
126
|
+
'1.7.0' => {
|
127
|
+
:ref_type => "tag",
|
128
|
+
:method_map => {
|
129
|
+
:is_less_than_one? => false,
|
130
|
+
},
|
131
|
+
},
|
132
|
+
'1.8.0rc10' => {
|
133
|
+
:ref_type => "tag",
|
134
|
+
:method_map => {
|
135
|
+
:is_less_than_one? => false,
|
136
|
+
},
|
137
|
+
},
|
138
|
+
'1.7.0-rc1' => {
|
139
|
+
:ref_type => "tag",
|
140
|
+
:method_map => {
|
141
|
+
:is_less_than_one? => false,
|
142
|
+
},
|
75
143
|
},
|
76
|
-
'
|
77
|
-
:
|
78
|
-
:
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
:
|
84
|
-
:
|
85
|
-
|
144
|
+
'1.4.0-rc1-63-ge391f55' => {
|
145
|
+
:ref_type => "commit",
|
146
|
+
:method_map => {
|
147
|
+
:is_less_than_one? => false,
|
148
|
+
},
|
149
|
+
},
|
150
|
+
'1.6.0-rc1-63-ge391f55-dirty' => {
|
151
|
+
:ref_type => "commit",
|
152
|
+
:method_map => {
|
153
|
+
:is_less_than_one? => false,
|
154
|
+
},
|
155
|
+
},
|
156
|
+
'1.7.0-63-ge391f55' => {
|
157
|
+
:ref_type => "commit",
|
158
|
+
:method_map => {
|
159
|
+
:is_less_than_one? => false,
|
160
|
+
},
|
161
|
+
},
|
162
|
+
'1.7.0-63-ge391f55-dirty' => {
|
163
|
+
:ref_type => "commit",
|
164
|
+
:method_map => {
|
165
|
+
:is_less_than_one? => false,
|
166
|
+
},
|
86
167
|
},
|
87
168
|
}
|
88
169
|
|
89
|
-
before :all do
|
90
|
-
@build = Build::BuildInstance.new
|
91
|
-
end
|
92
|
-
|
93
170
|
TestVersions.keys.sort.each do |input|
|
171
|
+
before :each do
|
172
|
+
Pkg::Config.project_root = File.expand_path(File.dirname(__FILE__))
|
173
|
+
end
|
174
|
+
|
94
175
|
describe "Versioning based on #{input}" do
|
95
|
-
results = TestVersions[input]
|
176
|
+
results = TestVersions[input][:method_map]
|
177
|
+
let(:ref_type) { TestVersions[input][:ref_type] }
|
96
178
|
results.keys.sort_by(&:to_s).each do |method|
|
97
|
-
it "using
|
179
|
+
it "using Pkg::Util::Version.#{method} #{input.inspect} becomes #{results[method].inspect}" do
|
98
180
|
# We have to call the `stub!` alias because we are trying to stub on
|
99
181
|
# `self`, and in the scope of an rspec block that is overridden to
|
100
182
|
# return a new double, not to stub a method!
|
101
|
-
|
183
|
+
Pkg::Config.release = "1"
|
184
|
+
Pkg::Util::Version.should_receive(:git_ref_type).and_return(ref_type)
|
102
185
|
|
103
186
|
if method.to_s.include?("deb")
|
104
|
-
|
105
|
-
|
187
|
+
Pkg::Util::Version.should_receive(:run_git_describe_internal).and_return(input)
|
188
|
+
Pkg::Config.packager = "puppetlabs"
|
106
189
|
elsif method.to_s.include?("rpm")
|
107
|
-
|
190
|
+
Pkg::Util::Version.should_receive(:run_git_describe_internal).and_return(input)
|
108
191
|
else
|
109
|
-
|
110
|
-
|
111
|
-
|
192
|
+
Pkg::Util::Version.stub(:uname_r) { "3.14159" }
|
193
|
+
Pkg::Util::Version.stub(:is_git_repo) { true }
|
194
|
+
Pkg::Util::Version.should_receive(:run_git_describe_internal).and_return(input)
|
112
195
|
end
|
113
|
-
|
196
|
+
Pkg::Util::Version.send(method).should == results[method]
|
114
197
|
end
|
115
198
|
end
|
116
199
|
end
|
117
200
|
end
|
201
|
+
|
202
|
+
describe "#set_cow_envs" do
|
203
|
+
before(:each) do
|
204
|
+
reset_env(["DIST", "ARCH", "PE_VER", "BUILDMIRROR"])
|
205
|
+
Pkg::Config.deb_build_mirrors = nil
|
206
|
+
Pkg::Config.build_pe = nil
|
207
|
+
Pkg::Config.pe_version = nil
|
208
|
+
end
|
209
|
+
|
210
|
+
after(:all) do
|
211
|
+
reset_env(["DIST", "ARCH", "PE_VER", "BUILDMIRROR"])
|
212
|
+
Pkg::Config.deb_build_mirrors = nil
|
213
|
+
Pkg::Config.build_pe = nil
|
214
|
+
Pkg::Config.pe_version = nil
|
215
|
+
end
|
216
|
+
|
217
|
+
it "should always set DIST and ARCH correctly" do
|
218
|
+
self.send(:set_cow_envs, "base-wheezy-i386.cow")
|
219
|
+
ENV["DIST"].should eq("wheezy")
|
220
|
+
ENV["ARCH"].should eq("i386")
|
221
|
+
ENV["PE_VER"].should be_nil
|
222
|
+
ENV["BUILDMIRROR"].should be_nil
|
223
|
+
end
|
224
|
+
|
225
|
+
it "should set BUILDMIRROR if Pkg::Config.deb_build_mirrors is set" do
|
226
|
+
Pkg::Config.deb_build_mirrors = ["deb http://pl-build-tools.delivery.puppetlabs.net/debian __DIST__ main", "deb http://debian.is.awesome/wait no it is not"]
|
227
|
+
self.send(:set_cow_envs, "base-wheezy-i386.cow")
|
228
|
+
ENV["DIST"].should eq("wheezy")
|
229
|
+
ENV["ARCH"].should eq("i386")
|
230
|
+
ENV["PE_VER"].should be_nil
|
231
|
+
ENV["BUILDMIRROR"].should eq("deb http://pl-build-tools.delivery.puppetlabs.net/debian wheezy main | deb http://debian.is.awesome/wait no it is not")
|
232
|
+
end
|
233
|
+
|
234
|
+
it "should set PE_VER if Pkg::Config.build_pe is truthy" do
|
235
|
+
Pkg::Config.build_pe = true
|
236
|
+
Pkg::Config.pe_version = "3.2"
|
237
|
+
self.send(:set_cow_envs, "base-wheezy-i386.cow")
|
238
|
+
ENV["DIST"].should eq("wheezy")
|
239
|
+
ENV["ARCH"].should eq("i386")
|
240
|
+
ENV["PE_VER"].should eq("3.2")
|
241
|
+
ENV["BUILDMIRROR"].should be_nil
|
242
|
+
end
|
243
|
+
|
244
|
+
it "should fail on a badly formatted cow" do
|
245
|
+
expect { self.send(:set_cow_envs, "wheezy-i386") }.to raise_error(RuntimeError)
|
246
|
+
end
|
247
|
+
end
|
118
248
|
end
|