right_publish 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +4 -0
- data/Gemfile +20 -0
- data/Gemfile.lock +114 -0
- data/README.rdoc +113 -0
- data/Rakefile +48 -0
- data/VERSION +1 -0
- data/bin/right_publish +8 -0
- data/lib/right_publish/profile.rb +96 -0
- data/lib/right_publish/repo.rb +159 -0
- data/lib/right_publish/repos/apt.rb +178 -0
- data/lib/right_publish/repos/gem.rb +44 -0
- data/lib/right_publish/repos/yum.rb +167 -0
- data/lib/right_publish/storage.rb +90 -0
- data/lib/right_publish/stores/local.rb +29 -0
- data/lib/right_publish/stores/s3.rb +35 -0
- data/lib/right_publish.rb +97 -0
- data/right_publish.gemspec +101 -0
- data/spec/repo_manager_spec.rb +65 -0
- data/spec/repo_spec.rb +74 -0
- data/spec/repos/apt_spec.rb +288 -0
- data/spec/repos/gem_spec.rb +79 -0
- data/spec/repos/yum_spec.rb +282 -0
- data/spec/spec_helper.rb +30 -0
- data/spec/storage_manager_spec.rb +71 -0
- data/spec/storage_spec.rb +317 -0
- data/spec/stores/local_spec.rb +56 -0
- data/spec/stores/s3_spec.rb +44 -0
- metadata +274 -0
@@ -0,0 +1,101 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{right_publish}
|
8
|
+
s.version = "0.2.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Brian Szmyd", "Tony Spataro"]
|
12
|
+
s.date = %q{2013-07-03}
|
13
|
+
s.default_executable = %q{right_publish}
|
14
|
+
s.description = %q{A tool for maintaining S3-based DEB, GEM and RPM packages.}
|
15
|
+
s.email = %q{support@rightscale.com}
|
16
|
+
s.executables = ["right_publish"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"README.rdoc"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".rspec",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"bin/right_publish",
|
28
|
+
"lib/right_publish.rb",
|
29
|
+
"lib/right_publish/profile.rb",
|
30
|
+
"lib/right_publish/repo.rb",
|
31
|
+
"lib/right_publish/repos/apt.rb",
|
32
|
+
"lib/right_publish/repos/gem.rb",
|
33
|
+
"lib/right_publish/repos/yum.rb",
|
34
|
+
"lib/right_publish/storage.rb",
|
35
|
+
"lib/right_publish/stores/local.rb",
|
36
|
+
"lib/right_publish/stores/s3.rb",
|
37
|
+
"right_publish.gemspec",
|
38
|
+
"spec/repo_manager_spec.rb",
|
39
|
+
"spec/repo_spec.rb",
|
40
|
+
"spec/repos/apt_spec.rb",
|
41
|
+
"spec/repos/gem_spec.rb",
|
42
|
+
"spec/repos/yum_spec.rb",
|
43
|
+
"spec/spec_helper.rb",
|
44
|
+
"spec/storage_manager_spec.rb",
|
45
|
+
"spec/storage_spec.rb",
|
46
|
+
"spec/stores/local_spec.rb",
|
47
|
+
"spec/stores/s3_spec.rb"
|
48
|
+
]
|
49
|
+
s.homepage = %q{https://github.com/rightscale/right_publish}
|
50
|
+
s.licenses = ["Proprietary"]
|
51
|
+
s.require_paths = ["lib"]
|
52
|
+
s.rubygems_version = %q{1.3.7}
|
53
|
+
s.summary = %q{Package publishing and indexing tool}
|
54
|
+
|
55
|
+
if s.respond_to? :specification_version then
|
56
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
57
|
+
s.specification_version = 3
|
58
|
+
|
59
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
60
|
+
s.add_runtime_dependency(%q<builder>, [">= 0"])
|
61
|
+
s.add_runtime_dependency(%q<fog>, ["~> 1.9"])
|
62
|
+
s.add_runtime_dependency(%q<trollop>, ["~> 2.0"])
|
63
|
+
s.add_development_dependency(%q<rake>, ["~> 0.9"])
|
64
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
|
65
|
+
s.add_development_dependency(%q<right_develop>, ["~> 1.0"])
|
66
|
+
s.add_development_dependency(%q<rdoc>, [">= 2.4.2"])
|
67
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.0"])
|
68
|
+
s.add_development_dependency(%q<flexmock>, ["~> 0.9"])
|
69
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
70
|
+
s.add_development_dependency(%q<ruby-debug>, [">= 0.10"])
|
71
|
+
s.add_development_dependency(%q<ruby-debug19>, [">= 0.11.6"])
|
72
|
+
else
|
73
|
+
s.add_dependency(%q<builder>, [">= 0"])
|
74
|
+
s.add_dependency(%q<fog>, ["~> 1.9"])
|
75
|
+
s.add_dependency(%q<trollop>, ["~> 2.0"])
|
76
|
+
s.add_dependency(%q<rake>, ["~> 0.9"])
|
77
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
78
|
+
s.add_dependency(%q<right_develop>, ["~> 1.0"])
|
79
|
+
s.add_dependency(%q<rdoc>, [">= 2.4.2"])
|
80
|
+
s.add_dependency(%q<rspec>, ["~> 2.0"])
|
81
|
+
s.add_dependency(%q<flexmock>, ["~> 0.9"])
|
82
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
83
|
+
s.add_dependency(%q<ruby-debug>, [">= 0.10"])
|
84
|
+
s.add_dependency(%q<ruby-debug19>, [">= 0.11.6"])
|
85
|
+
end
|
86
|
+
else
|
87
|
+
s.add_dependency(%q<builder>, [">= 0"])
|
88
|
+
s.add_dependency(%q<fog>, ["~> 1.9"])
|
89
|
+
s.add_dependency(%q<trollop>, ["~> 2.0"])
|
90
|
+
s.add_dependency(%q<rake>, ["~> 0.9"])
|
91
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
92
|
+
s.add_dependency(%q<right_develop>, ["~> 1.0"])
|
93
|
+
s.add_dependency(%q<rdoc>, [">= 2.4.2"])
|
94
|
+
s.add_dependency(%q<rspec>, ["~> 2.0"])
|
95
|
+
s.add_dependency(%q<flexmock>, ["~> 0.9"])
|
96
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
97
|
+
s.add_dependency(%q<ruby-debug>, [">= 0.10"])
|
98
|
+
s.add_dependency(%q<ruby-debug19>, [">= 0.11.6"])
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'right_publish/repo'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe RightPublish::RepoManager do
|
5
|
+
|
6
|
+
def is_registered?(name, key, type)
|
7
|
+
@repo_types = RightPublish::RepoManager.repo_types
|
8
|
+
@repo_types.should have_key(name)
|
9
|
+
@repo_types[name].should equal(key)
|
10
|
+
RightPublish::RepoManager.get_repository(key).should be_instance_of(type)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should provide a hash of known repo types" do
|
14
|
+
RightPublish::RepoManager.repo_types.should be_instance_of(Hash)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "returns nil for unknown repo types" do
|
18
|
+
RightPublish::RepoManager.get_repository(:doesnotexist_repo).should be_equal(nil)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should know about the apt repository" do
|
22
|
+
is_registered?('apt', :apt_repo, RightPublish::AptRepo)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should know about the gem repository" do
|
26
|
+
is_registered?('gem', :gem_repo, RightPublish::GemRepo)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should know about the yum repository" do
|
30
|
+
is_registered?('yum', :yum_repo, RightPublish::YumRepo)
|
31
|
+
end
|
32
|
+
|
33
|
+
context ".register_repo" do
|
34
|
+
it "rejects repos without a REPO_KEY" do
|
35
|
+
class MissingKey
|
36
|
+
end
|
37
|
+
expect { RightPublish::RepoManager.register_repo(MissingKey) }.to raise_error(NameError)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "rejects repos whose key does not end in _repo" do
|
41
|
+
class BadKey
|
42
|
+
REPO_KEY = :bad_key
|
43
|
+
end
|
44
|
+
expect { RightPublish::RepoManager.register_repo(BadKey) }.to raise_error(TypeError)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "rejects repos who do not provide options" do
|
48
|
+
class NoOptions
|
49
|
+
REPO_KEY = :nooptions_repo
|
50
|
+
end
|
51
|
+
expect { RightPublish::RepoManager.register_repo(NoOptions) }.to raise_error(NameError)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "accpets repos who are properly defined" do
|
55
|
+
class GoodRepo
|
56
|
+
include RightPublish::Repo
|
57
|
+
REPO_KEY = :good_repo
|
58
|
+
REPO_OPTIONS = {}
|
59
|
+
end
|
60
|
+
RightPublish::RepoManager.register_repo(GoodRepo).should be_equal(nil)
|
61
|
+
is_registered?('good', :good_repo, GoodRepo)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
data/spec/repo_spec.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'right_publish/repo'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe RightPublish::Repo do
|
5
|
+
|
6
|
+
class FakeRepo
|
7
|
+
include RightPublish::Repo
|
8
|
+
REPO_KEY = :fake_repo
|
9
|
+
REPO_OPTIONS = {}
|
10
|
+
end
|
11
|
+
|
12
|
+
module MockLocal
|
13
|
+
STORAGE_KEY = :mocklocal_storage
|
14
|
+
STORAGE_OPTIONS = { }
|
15
|
+
|
16
|
+
def self.get_directories()
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module MockRemote
|
21
|
+
STORAGE_KEY = :mockremote_storage
|
22
|
+
STORAGE_OPTIONS = { }
|
23
|
+
|
24
|
+
def self.get_directories()
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
before(:all) do
|
29
|
+
RightPublish::StorageManager.register_storage(MockLocal)
|
30
|
+
RightPublish::StorageManager.register_storage(MockRemote)
|
31
|
+
RightPublish::RepoManager.register_repo(FakeRepo)
|
32
|
+
end
|
33
|
+
|
34
|
+
before(:each) do
|
35
|
+
flexmock(RightPublish::Profile) do |obj|
|
36
|
+
obj.should_receive(:log).and_return { |str,dbg|
|
37
|
+
}
|
38
|
+
|
39
|
+
obj.should_receive(:config).and_return {
|
40
|
+
{ :verbose=>false,
|
41
|
+
:remote_storage=>{:provider=>'mockremote'},
|
42
|
+
:local_storage=>{:provider=>'mocklocal'},
|
43
|
+
:fake_repo=>{:subdir=>'fake/'}
|
44
|
+
}
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
@repo = RightPublish::RepoManager.get_repository(:fake_repo)
|
49
|
+
end
|
50
|
+
|
51
|
+
context "#fetch" do
|
52
|
+
it "fetches from remote storage to local" do
|
53
|
+
flexmock(RightPublish::Storage).should_receive(:sync_dirs).and_return do |src,dest,options|
|
54
|
+
src.should be_equal(MockRemote)
|
55
|
+
dest.should be_equal(MockLocal)
|
56
|
+
nil
|
57
|
+
end
|
58
|
+
@repo.fetch
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context "#store" do
|
63
|
+
it "stores from local storage to remote" do
|
64
|
+
flexmock(RightPublish::Storage).should_receive(:sync_dirs).and_return do |src,dest,options|
|
65
|
+
src.should be_equal(MockLocal)
|
66
|
+
dest.should be_equal(MockRemote)
|
67
|
+
nil
|
68
|
+
end
|
69
|
+
@repo.store
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
@@ -0,0 +1,288 @@
|
|
1
|
+
require 'right_publish/repo'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe RightPublish::AptRepo do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@cache_dir = 'somedir/'
|
8
|
+
@repo_subdir = 'fake/'
|
9
|
+
|
10
|
+
@repo = flexmock(RightPublish::RepoManager.get_repository(:apt_repo)) do |obj|
|
11
|
+
obj.should_receive(:fetch)
|
12
|
+
obj.should_receive(:store)
|
13
|
+
obj.should_receive(:do_in_subdir).and_return {|dir,block| block.call}
|
14
|
+
obj.should_receive(:prune_all)
|
15
|
+
obj.should_receive(:write_conf_file)
|
16
|
+
end
|
17
|
+
|
18
|
+
flexmock(RightPublish::Profile) do |obj|
|
19
|
+
obj.should_receive(:log).and_return { |str,dbg| }
|
20
|
+
end
|
21
|
+
|
22
|
+
flexmock(File) { |obj| obj.should_receive(:file?).and_return(true) }
|
23
|
+
end
|
24
|
+
|
25
|
+
context "#publish" do
|
26
|
+
|
27
|
+
# Test the Pool (not flat) repo profile type
|
28
|
+
[false, true].each do |should_sign|
|
29
|
+
|
30
|
+
context "Pool layout#{" (with signature)" if should_sign}" do
|
31
|
+
|
32
|
+
def build_expectations(pkgs, expected_dists)
|
33
|
+
pkgs = Array(pkgs)
|
34
|
+
expected_dists = Array(expected_dists)
|
35
|
+
|
36
|
+
pkgs.each do |pkg|
|
37
|
+
expected_dists.each do |dist|
|
38
|
+
@remove_expectations[dist] ||= []
|
39
|
+
@remove_expectations[dist] << RightPublish::AptRepo.pkg_parts(pkg)[:name]
|
40
|
+
|
41
|
+
@install_expectations[dist] ||= []
|
42
|
+
@install_expectations[dist] << pkg
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
system_calls = (pkgs.size * expected_dists.size) * 2
|
49
|
+
@repo.should_receive(@system_func).times(system_calls).and_return do |cmd|
|
50
|
+
path, subcmd, distro, pkg = /reprepro\s+(?:--ask-passphrase )?(?:-C main )?-b\s+(.+)\s+(includedeb|includedsc|removesrc|remove)\s+([^\s]+)\s+([^\s]+)\s+2>&1 >\/dev\/null\Z/.match(cmd).captures
|
51
|
+
path.should be_eql(File.join(@cache_dir,@repo_subdir))
|
52
|
+
|
53
|
+
if @remove_expectations.has_key?(distro) && @remove_expectations[distro].include?(pkg)
|
54
|
+
subcmd.should include('remove') #can be remove or removesrc
|
55
|
+
@remove_expectations.should be_has_key(distro)
|
56
|
+
@remove_expectations[distro].delete(pkg)
|
57
|
+
@remove_expectations.delete(distro) if @remove_expectations[distro].empty?
|
58
|
+
else
|
59
|
+
subcmd.should be_eql((pkg.end_with?(RightPublish::AptRepo::SRC_EXTENSION) && 'includedsc') || 'includedeb')
|
60
|
+
@install_expectations.should be_has_key(distro)
|
61
|
+
@install_expectations[distro].delete(pkg)
|
62
|
+
@install_expectations.delete(distro) if @install_expectations[distro].empty?
|
63
|
+
end
|
64
|
+
0
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
before(:each) do
|
69
|
+
@apt_dists = ['quantal', 'precise', 'wheezy']
|
70
|
+
@install_expectations = {}
|
71
|
+
@remove_expectations = {}
|
72
|
+
@system_func = should_sign ? :shellout_with_password : :system
|
73
|
+
flexmock(RightPublish::Profile) do |obj|
|
74
|
+
obj.should_receive(:config).and_return {
|
75
|
+
{ :verbose=>false,
|
76
|
+
:remote_storage=>{:provider=>'mockremote'},
|
77
|
+
:local_storage=>{:provider=>'mocklocal',:cache_dir=>@cache_dir},
|
78
|
+
:apt_repo=>{
|
79
|
+
:auto=>true,
|
80
|
+
:subdir=>@repo_subdir,
|
81
|
+
:dists=>@apt_dists,
|
82
|
+
:gpg_key_id=>should_sign,
|
83
|
+
:gpg_password=>"fakepass"}
|
84
|
+
}
|
85
|
+
}
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
after(:each) do
|
90
|
+
@install_expectations.should be_empty
|
91
|
+
@remove_expectations.should be_empty
|
92
|
+
end
|
93
|
+
|
94
|
+
# Test for publish noarch packages (multicasting)
|
95
|
+
context "NoArch Packages" do
|
96
|
+
it "installs a single noarch deb file to all dists" do
|
97
|
+
deb_file = 'foo_1_all.deb'
|
98
|
+
build_expectations(deb_file,@apt_dists)
|
99
|
+
@repo.publish(deb_file, nil)
|
100
|
+
end
|
101
|
+
|
102
|
+
it "installs a single src dsc file to all dists" do
|
103
|
+
dsc_file = 'foo_1.dsc'
|
104
|
+
build_expectations(dsc_file,@apt_dists)
|
105
|
+
@repo.publish(dsc_file, nil)
|
106
|
+
end
|
107
|
+
|
108
|
+
it "installs a list of noarch deb files to all dists" do
|
109
|
+
deb_files = ['foo_1_all.deb', 'bar_1_all.deb']
|
110
|
+
build_expectations(deb_files,@apt_dists)
|
111
|
+
@repo.publish(deb_files, nil)
|
112
|
+
end
|
113
|
+
|
114
|
+
it "globs and installs a directory of noarch deb files to all dists" do
|
115
|
+
deb_files = ['foo_1_all.deb', 'bar_1_all.deb']
|
116
|
+
build_expectations(deb_files,@apt_dists)
|
117
|
+
flexmock(File) { |obj| obj.should_receive(:directory?).and_return(true) }
|
118
|
+
flexmock(Dir) { |obj| obj.should_receive(:glob).and_return(deb_files) }
|
119
|
+
@repo.publish('somedir/', nil)
|
120
|
+
end
|
121
|
+
|
122
|
+
it "fails with no files in a dir" do
|
123
|
+
flexmock(File) { |obj| obj.should_receive(:directory?).and_return(true) }
|
124
|
+
flexmock(Dir) { |obj| obj.should_receive(:glob).and_return([]) }
|
125
|
+
@repo.should_receive(@system_func).never
|
126
|
+
expect { @repo.publish('some_dir/', nil) }.to raise_error(RuntimeError)
|
127
|
+
end
|
128
|
+
|
129
|
+
it "fails with files missing a deb extenstion" do
|
130
|
+
deb_files = ['foo_1_all.deb', 'bar.all.rpm']
|
131
|
+
@repo.should_receive(@system_func).never
|
132
|
+
expect { @repo.publish(deb_files, nil) }.to raise_error(RuntimeError)
|
133
|
+
end
|
134
|
+
|
135
|
+
it "fails with a mix of noarch and binary debs" do
|
136
|
+
deb_files = ['foo_1_all.deb', 'bar_2_amd64.deb']
|
137
|
+
@repo.should_receive(@system_func).never
|
138
|
+
expect { @repo.publish(deb_files, nil) }.to raise_error(RuntimeError)
|
139
|
+
end
|
140
|
+
end # end NoArch context
|
141
|
+
|
142
|
+
context "Architecture Dependant Packages" do
|
143
|
+
before(:each) do
|
144
|
+
@target_distribution_str = 'quantal'
|
145
|
+
end
|
146
|
+
|
147
|
+
it "installs a single amd64 deb file to a dist" do
|
148
|
+
deb_file = 'foo_1_amd64.deb'
|
149
|
+
build_expectations(deb_file,@target_distribution_str)
|
150
|
+
@repo.publish(deb_file, @target_distribution_str)
|
151
|
+
end
|
152
|
+
|
153
|
+
it "installs a list of amd64 debs to a dist" do
|
154
|
+
deb_files = ['foo1.9_1.2~precise_amd64.deb', 'bar_1_amd64.deb']
|
155
|
+
build_expectations(deb_files,@target_distribution_str)
|
156
|
+
@repo.publish(deb_files, @target_distribution_str)
|
157
|
+
end
|
158
|
+
|
159
|
+
it "installs a directory mixed of amd64 and i386 debs to a dist" do
|
160
|
+
deb_files = ['foo_1_amd64.deb', 'bar_1_i386.deb']
|
161
|
+
build_expectations(deb_files,@target_distribution_str)
|
162
|
+
flexmock(File) { |obj| obj.should_receive(:directory?).and_return(true) }
|
163
|
+
flexmock(Dir) { |obj| obj.should_receive(:glob).and_return(deb_files) }
|
164
|
+
@repo.publish('some_dir/', @target_distribution_str)
|
165
|
+
end
|
166
|
+
|
167
|
+
it "fails with no files in a dir" do
|
168
|
+
flexmock(File) { |obj| obj.should_receive(:directory?).and_return(true) }
|
169
|
+
flexmock(Dir) { |obj| obj.should_receive(:glob).and_return([]) }
|
170
|
+
@repo.should_receive(@system_func).never
|
171
|
+
expect { @repo.publish('some_dir/', @target_distribution_str) }.to raise_error(RuntimeError)
|
172
|
+
end
|
173
|
+
|
174
|
+
it "fails with files missing a deb extension" do
|
175
|
+
deb_files = ['foo_1_amd64.deb', 'bar_1_i386.rpm']
|
176
|
+
@repo.should_receive(@system_func).never
|
177
|
+
expect { @repo.publish(deb_files, @target_distribution_str) }.to raise_error(RuntimeError)
|
178
|
+
end
|
179
|
+
|
180
|
+
it "fails with unknown architectures" do
|
181
|
+
deb_files = ['foo.ppc.deb', 'bar.ppc.deb']
|
182
|
+
@repo.should_receive(@system_func).never
|
183
|
+
expect { @repo.publish(deb_files, @target_distribution_str) }.to raise_error(RuntimeError)
|
184
|
+
end
|
185
|
+
|
186
|
+
it "fails when not provided with a target" do
|
187
|
+
deb_files = ['foo_1_amd64.deb', 'bar_1_i386.deb']
|
188
|
+
@repo.should_receive(@system_func).never
|
189
|
+
expect { @repo.publish(deb_files, nil) }.to raise_error(RuntimeError)
|
190
|
+
end
|
191
|
+
end # end Architecture Dependant context
|
192
|
+
end # end Pool context
|
193
|
+
end
|
194
|
+
|
195
|
+
# Test the Flat repo profile type
|
196
|
+
context "Flat layout" do
|
197
|
+
def build_expectations(pkgs)
|
198
|
+
pkgs = Array(pkgs)
|
199
|
+
|
200
|
+
pkgs.each do |pkg|
|
201
|
+
dist_path = File.join(@repo_subdir, (pkg.end_with?(RightPublish::AptRepo::BIN_EXTENSION) && 'binaries') || 'sources')
|
202
|
+
|
203
|
+
@install_expectations[dist_path] ||= []
|
204
|
+
@install_expectations[dist_path] << pkg
|
205
|
+
end
|
206
|
+
@repo.should_receive(:install_file).and_return do |pkg,dir|
|
207
|
+
@install_expectations.should be_has_key(dir)
|
208
|
+
@install_expectations[dir].delete(pkg)
|
209
|
+
@install_expectations.delete(dir) if @install_expectations[dir].empty?
|
210
|
+
end
|
211
|
+
@repo.should_receive(:system).twice.and_return(0)
|
212
|
+
end
|
213
|
+
|
214
|
+
before(:each) do
|
215
|
+
@install_expectations = {}
|
216
|
+
flexmock(RightPublish::Profile) do |obj|
|
217
|
+
obj.should_receive(:config).and_return {
|
218
|
+
{ :verbose=>false,
|
219
|
+
:remote_storage=>{:provider=>'mockremote'},
|
220
|
+
:local_storage=>{:provider=>'mocklocal',:cache_dir=>@cache_dir},
|
221
|
+
:apt_repo=>{
|
222
|
+
:apt=>false,
|
223
|
+
:subdir=>@repo_subdir }
|
224
|
+
}
|
225
|
+
}
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
after(:each) do
|
230
|
+
@install_expectations.should be_empty
|
231
|
+
end
|
232
|
+
|
233
|
+
it "installs a single deb file to repo" do
|
234
|
+
deb_file = 'foo_1_all.deb'
|
235
|
+
build_expectations(deb_file)
|
236
|
+
@repo.publish(deb_file, nil)
|
237
|
+
end
|
238
|
+
|
239
|
+
it "installs a single src deb file to repo" do
|
240
|
+
dsc_file = 'foo_1.dsc'
|
241
|
+
src_file = 'foo_1.orig.tar.gz'
|
242
|
+
diff_file = 'foo_1.diff.gz'
|
243
|
+
all_files = [dsc_file, src_file, diff_file]
|
244
|
+
flexmock(Dir).should_receive(:glob).and_return([src_file])
|
245
|
+
build_expectations(all_files)
|
246
|
+
@repo.publish(dsc_file, nil)
|
247
|
+
end
|
248
|
+
|
249
|
+
it "installs a list of deb files to repo" do
|
250
|
+
deb_files = ['foo_1_amd64.deb', 'bar_1_amd64.deb']
|
251
|
+
build_expectations(deb_files)
|
252
|
+
@repo.publish(deb_files, nil)
|
253
|
+
end
|
254
|
+
|
255
|
+
it "globs and installs a directory of deb files to repo" do
|
256
|
+
deb_files = ['foo_1_all.deb', 'bar_1.dsc']
|
257
|
+
src_file = 'bar_1.orig.tar.gz'
|
258
|
+
diff_file = 'bar_1.diff.gz'
|
259
|
+
all_files = ([deb_files, src_file, diff_file]).flatten
|
260
|
+
build_expectations(all_files)
|
261
|
+
flexmock(File) { |obj| obj.should_receive(:directory?).and_return(true) }
|
262
|
+
flexmock(Dir).should_receive(:glob).and_return do |pattern|
|
263
|
+
(pattern.end_with?('orig.tar.gz') && [src_file]) || deb_files
|
264
|
+
end
|
265
|
+
@repo.publish('somedir/', nil)
|
266
|
+
end
|
267
|
+
|
268
|
+
it "succeeds with a mix of noarch and binary debs" do
|
269
|
+
deb_files = ['foo_1_all.deb', 'bar_1_amd64.deb']
|
270
|
+
build_expectations(deb_files)
|
271
|
+
@repo.publish(deb_files, nil)
|
272
|
+
end
|
273
|
+
|
274
|
+
it "fails with no files in a dir" do
|
275
|
+
flexmock(File) { |obj| obj.should_receive(:directory?).and_return(true) }
|
276
|
+
flexmock(Dir) { |obj| obj.should_receive(:glob).and_return([]) }
|
277
|
+
@repo.should_receive(:system).never
|
278
|
+
expect { @repo.publish('some_dir/', nil) }.to raise_error(RuntimeError)
|
279
|
+
end
|
280
|
+
|
281
|
+
it "fails with files missing a deb extenstion" do
|
282
|
+
deb_files = ['foo_1_i386.deb', 'bar.all.rpm']
|
283
|
+
@repo.should_receive(:system).never
|
284
|
+
expect { @repo.publish('some_dir/', nil) }.to raise_error(RuntimeError)
|
285
|
+
end
|
286
|
+
end # end Trivial context
|
287
|
+
end # end #publish context
|
288
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'right_publish/repo'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe RightPublish::GemRepo do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@install_expectations = []
|
8
|
+
@repo_subdir = 'fake/'
|
9
|
+
@repo = flexmock(RightPublish::RepoManager.get_repository(:gem_repo)) do |obj|
|
10
|
+
obj.should_receive(:fetch)
|
11
|
+
obj.should_receive(:store)
|
12
|
+
obj.should_receive(:do_in_subdir).and_return {|dir,block| block.call}
|
13
|
+
end
|
14
|
+
|
15
|
+
flexmock(File) { |obj| obj.should_receive(:file?).and_return(true) }
|
16
|
+
|
17
|
+
flexmock(RightPublish::Profile) do |obj|
|
18
|
+
obj.should_receive(:log).and_return { |str,dbg|
|
19
|
+
}
|
20
|
+
|
21
|
+
obj.should_receive(:config).and_return {
|
22
|
+
{ :verbose=>false,
|
23
|
+
:remote_storage=>{:provider=>'mockremote'},
|
24
|
+
:local_storage=>{:provider=>'mocklocal'},
|
25
|
+
:gem_repo=>{:subdir=>@repo_subdir}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
after(:each) do
|
32
|
+
@install_expectations.should be_empty
|
33
|
+
end
|
34
|
+
|
35
|
+
context "#publish" do
|
36
|
+
def build_expectations(pkgs)
|
37
|
+
@install_expectations = Array(pkgs)
|
38
|
+
@repo.should_receive(:install_file).and_return do |pkg,dir|
|
39
|
+
@install_expectations.delete(pkg)
|
40
|
+
dir.should be_eql(File.join(@repo_subdir, RightPublish::GemRepo::GEMS_SUBDIRECTORY ))
|
41
|
+
end
|
42
|
+
@repo.should_receive(:system).once.and_return(0)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should install a single gem file" do
|
46
|
+
gem_file = 'foo-1.gem'
|
47
|
+
build_expectations(gem_file)
|
48
|
+
@repo.publish(gem_file, nil)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should install a list of gem files" do
|
52
|
+
gem_files = ['foo-1.gem', 'bar-2.0.0.gem']
|
53
|
+
build_expectations(gem_files)
|
54
|
+
@repo.publish(gem_files, nil)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should glob a directory of gem files and install them" do
|
58
|
+
gem_files = ['foo-1.gem', 'bar_game-2.0.gem']
|
59
|
+
build_expectations(gem_files)
|
60
|
+
flexmock(File) { |obj| obj.should_receive(:directory?).and_return(true) }
|
61
|
+
flexmock(Dir) { |obj| obj.should_receive(:glob).and_return(gem_files) }
|
62
|
+
@repo.publish('some_dir/', nil)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should fail with no files in a dir" do
|
66
|
+
flexmock(File) { |obj| obj.should_receive(:directory?).and_return(true) }
|
67
|
+
flexmock(Dir) { |obj| obj.should_receive(:glob).and_return([]) }
|
68
|
+
@repo.should_receive(:system).never
|
69
|
+
expect { @repo.publish('some_dir/', nil) }.to raise_error(RuntimeError)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should fail with files without a gem extenstion" do
|
73
|
+
gem_files = ['foo-1.gem', 'bar-2.rpm']
|
74
|
+
@repo.should_receive(:system).never
|
75
|
+
expect { @repo.publish(gem_files, nil) }.to raise_error(RuntimeError)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|