simp-rake-helpers 4.1.1 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/lib/simp/rake.rb +4 -19
- data/lib/simp/rake/build/auto.rb +241 -506
- data/lib/simp/rake/build/build.rb +22 -155
- data/lib/simp/rake/build/clean.rb +3 -11
- data/lib/simp/rake/build/constants.rb +16 -78
- data/lib/simp/rake/build/deps.rb +8 -1
- data/lib/simp/rake/build/iso.rb +8 -6
- data/lib/simp/rake/build/pkg.rb +372 -304
- data/lib/simp/rake/build/rpmdeps.rb +2 -2
- data/lib/simp/rake/build/spec.rb +2 -1
- data/lib/simp/rake/build/tar.rb +11 -13
- data/lib/simp/rake/build/unpack.rb +2 -1
- data/lib/simp/rake/build/upload.rb +2 -1
- data/lib/simp/rake/helpers.rb +23 -0
- data/lib/simp/rake/helpers/version.rb +1 -1
- data/lib/simp/rake/pkg.rb +177 -312
- data/lib/simp/rake/pupmod/helpers.rb +13 -10
- data/lib/simp/rpm.rb +348 -65
- data/lib/simp/yum.rb +209 -0
- data/spec/lib/simp/files/simp_build/src/{build → assets/simp/build}/simp.spec +0 -0
- data/spec/lib/simp/files/testpackage-1-0.el7.noarch.rpm +0 -0
- data/spec/lib/simp/files/testpackage-dist.spec +42 -0
- data/spec/lib/simp/files/testpackage-multi.spec +7 -5
- data/spec/lib/simp/rpm_spec.rb +289 -14
- data/spec/spec_helper.rb +3 -0
- metadata +6 -3
data/lib/simp/yum.rb
ADDED
@@ -0,0 +1,209 @@
|
|
1
|
+
module Simp
|
2
|
+
# Various utilities for dealing with YUM repos
|
3
|
+
class Simp::YUM
|
4
|
+
|
5
|
+
class Error < StandardError
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'tmpdir'
|
9
|
+
require 'facter'
|
10
|
+
require 'simp/rpm'
|
11
|
+
|
12
|
+
attr_reader :yum_conf
|
13
|
+
|
14
|
+
def initialize(yum_conf, initialize_cache = false)
|
15
|
+
if File.exist?(yum_conf)
|
16
|
+
@yum_conf = File.absolute_path(yum_conf)
|
17
|
+
else
|
18
|
+
raise(Error, "Could not find yum configuration at '#{yum_conf}'")
|
19
|
+
end
|
20
|
+
|
21
|
+
# Only need to look these up once!
|
22
|
+
@@yum_cmd ||= %x(which yum).strip
|
23
|
+
raise(Error, "Error: Could not find 'yum'. Please install and try again.") if @@yum_cmd.empty?
|
24
|
+
|
25
|
+
tmp_dir = ENV['TMPDIR'] || '/tmp'
|
26
|
+
|
27
|
+
# Ensure that yumdownloader uses a fresh cache directory for each run of a given platform
|
28
|
+
@@yum_cache ||= File.join(tmp_dir, 'yum_cache-' +
|
29
|
+
Facter.fact('operatingsystem').value + '-' +
|
30
|
+
Facter.fact('operatingsystemmajrelease').value + '-' +
|
31
|
+
Facter.fact('architecture').value)
|
32
|
+
|
33
|
+
FileUtils.mkdir_p(@@yum_cache)
|
34
|
+
|
35
|
+
@@yum ||= "TMPDIR=#{@@yum_cache} #{@@yum_cmd} -c #{@yum_conf}"
|
36
|
+
|
37
|
+
@@yumdownloader_cmd ||= %x(which yumdownloader).strip
|
38
|
+
raise(Error, "Error: Could not find 'yumdownloader'. Please install and try again.") if @@yumdownloader_cmd.empty?
|
39
|
+
|
40
|
+
@@yumdownloader ||= "TMPDIR=#{@@yum_cache} #{@@yumdownloader_cmd} -c #{@yum_conf}"
|
41
|
+
|
42
|
+
@@curl ||= %x(which curl).strip
|
43
|
+
raise(Error, "Error: Could not find 'curl'. Please install and try again.") if @@curl.empty?
|
44
|
+
|
45
|
+
@@file ||= %x(which file).strip
|
46
|
+
raise(Error, "Error: Could not find 'file'. Please install and try again.") if @@file.empty?
|
47
|
+
|
48
|
+
generate_cache if initialize_cache
|
49
|
+
end
|
50
|
+
|
51
|
+
def clean_yum_cache_dir
|
52
|
+
# Make this as safe as we can
|
53
|
+
if @@yum_cache =~ /yum_cache/
|
54
|
+
FileUtils.remove_entry(@@yum_cache)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def generate_cache
|
59
|
+
puts "Attempting to generate build-specific YUM cache from\n #{@yum_conf}"
|
60
|
+
|
61
|
+
%x(#{@@yum} clean all 2>/dev/null)
|
62
|
+
%x(#{@@yum} makecache 2>/dev/null)
|
63
|
+
|
64
|
+
unless $?.success?
|
65
|
+
puts "WARNING: Unable to generate build-specific YUM cache from #{@yum_conf}"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# Create a reasonable YUM config file
|
70
|
+
# * yum_tmp => The directory in which to store the YUM DB and any other temporary files
|
71
|
+
#
|
72
|
+
# Returns the location of the YUM configuration
|
73
|
+
def self.generate_yum_conf(yum_dir=nil)
|
74
|
+
yum_dir ||= Dir.pwd
|
75
|
+
|
76
|
+
raise(Error, "Could not find YUM data dir at '#{yum_dir}'") unless File.directory?(yum_dir)
|
77
|
+
|
78
|
+
yum_conf = nil
|
79
|
+
Dir.chdir(yum_dir) do
|
80
|
+
# Create the target directory
|
81
|
+
yum_tmp = File.join('packages','yum_tmp')
|
82
|
+
|
83
|
+
FileUtils.mkdir_p(yum_tmp) unless File.directory?(yum_tmp)
|
84
|
+
|
85
|
+
yum_cache = File.expand_path('yum_cache', yum_tmp)
|
86
|
+
FileUtils.mkdir_p(yum_cache) unless File.directory?(yum_cache)
|
87
|
+
|
88
|
+
yum_logfile = File.expand_path('yum.log', yum_tmp)
|
89
|
+
|
90
|
+
repo_dirs = []
|
91
|
+
|
92
|
+
# Add the global directory
|
93
|
+
repo_dirs << File.expand_path('../my_repos')
|
94
|
+
|
95
|
+
if File.directory?('my_repos')
|
96
|
+
# Add the local user repos if they exist
|
97
|
+
repo_dirs << File.expand_path('my_repos')
|
98
|
+
else
|
99
|
+
# Add the default Internet repos otherwise
|
100
|
+
repo_dirs << File.expand_path('repos')
|
101
|
+
end
|
102
|
+
|
103
|
+
# Create our YUM config file
|
104
|
+
yum_conf = File.expand_path('yum.conf', yum_tmp)
|
105
|
+
|
106
|
+
File.open(yum_conf, 'w') do |fh|
|
107
|
+
fh.puts <<-EOM.gsub(/^\s+/,'')
|
108
|
+
[main]
|
109
|
+
keepcache = 0
|
110
|
+
persistdir = #{yum_cache}
|
111
|
+
logfile = #{yum_logfile}
|
112
|
+
exactarch = 1
|
113
|
+
obsoletes = 0
|
114
|
+
gpgcheck = 0
|
115
|
+
plugins = 1
|
116
|
+
reposdir = #{repo_dirs.join(' ')}
|
117
|
+
assumeyes = 1
|
118
|
+
EOM
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
return yum_conf
|
123
|
+
end
|
124
|
+
|
125
|
+
# Returns the full name of the latest package of the given name
|
126
|
+
#
|
127
|
+
# Returns nil if nothing found
|
128
|
+
def available_package(rpm)
|
129
|
+
yum_output = %x(#{@@yum} -C list #{rpm} 2>/dev/null)
|
130
|
+
|
131
|
+
found_rpm = nil
|
132
|
+
if $?.success?
|
133
|
+
pkg_name, pkg_version = yum_output.lines.last.strip.split(/\s+/)
|
134
|
+
pkg_name, pkg_arch = pkg_name.split('.')
|
135
|
+
|
136
|
+
found_rpm = %(#{pkg_name}-#{pkg_version}.#{pkg_arch}.rpm)
|
137
|
+
end
|
138
|
+
|
139
|
+
return found_rpm
|
140
|
+
end
|
141
|
+
|
142
|
+
def get_sources(rpm)
|
143
|
+
sources = %x(#{@@yumdownloader} --urls #{File.basename(rpm,'.rpm')} 2>/dev/null).split("\n").grep(%r(\.rpm$))
|
144
|
+
|
145
|
+
raise(Error, "No sources found for '#{rpm}'") if sources.empty?
|
146
|
+
|
147
|
+
return sources
|
148
|
+
end
|
149
|
+
|
150
|
+
def get_source(rpm, arch=nil)
|
151
|
+
sources = get_sources(rpm)
|
152
|
+
|
153
|
+
if arch
|
154
|
+
native_sources = sources.grep(%r((#{arch}|noarch)\.rpm$))
|
155
|
+
|
156
|
+
if native_sources.size > 1
|
157
|
+
# We can't have more than one native source
|
158
|
+
raise(Error, "More than one native source found for #{rpm}:\n * #{native_sources.join("\n *")}")
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
return sources.first
|
163
|
+
end
|
164
|
+
|
165
|
+
def download(rpm, opts={:target_dir => nil})
|
166
|
+
target_dir = Dir.pwd
|
167
|
+
|
168
|
+
if opts[:target_dir]
|
169
|
+
target_dir = File.absolute_path(opts[:target_dir])
|
170
|
+
end
|
171
|
+
|
172
|
+
Dir.mktmpdir do |dir|
|
173
|
+
Dir.chdir(dir) do
|
174
|
+
# If just passed an RPM name, use yumdownloader
|
175
|
+
if rpm !~ %r(://)
|
176
|
+
# In case someone passed a path
|
177
|
+
rpm_name = rpm.split(File::SEPARATOR).last
|
178
|
+
|
179
|
+
#FIXME Should really report stderr output so user can
|
180
|
+
# diagnose the problem
|
181
|
+
%x(#{@@yumdownloader} #{File.basename(rpm_name, '.rpm')} 2>/dev/null)
|
182
|
+
else
|
183
|
+
# If passed a URL, curl it and fall back to yumdownloader
|
184
|
+
rpm_name = rpm.split('/').last
|
185
|
+
|
186
|
+
%x(#{@@curl} -L --max-redirs 10 -s -o #{rpm_name} -k #{rpm})
|
187
|
+
|
188
|
+
# Check what we've just downloaded
|
189
|
+
if !(File.exist?(rpm_name) || %x(#{@@file} #{rpm_name}).include('RPM'))
|
190
|
+
# Fall back on yumdownloader
|
191
|
+
FileUtils.rm_f(rpm_name)
|
192
|
+
|
193
|
+
%x(#{@@yumdownloader} #{File.basename(rpm_name, '.rpm')} 2> /dev/null)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
rpms = Dir.glob('*.rpm')
|
198
|
+
raise(Error, "Could not find any remote RPMs for #{rpm}") if rpms.empty?
|
199
|
+
|
200
|
+
# Copy over all of the RPMs
|
201
|
+
rpms.each do |new_rpm|
|
202
|
+
FileUtils.mkdir_p(target_dir)
|
203
|
+
FileUtils.mv(new_rpm, target_dir)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
File without changes
|
Binary file
|
@@ -0,0 +1,42 @@
|
|
1
|
+
Name: testpackage
|
2
|
+
Version: 1
|
3
|
+
Release: 0%{?dist}
|
4
|
+
Summary: dummy test package #2
|
5
|
+
BuildArch: noarch
|
6
|
+
|
7
|
+
License: Apache-2.0
|
8
|
+
URL: http://foo.bar
|
9
|
+
|
10
|
+
%description
|
11
|
+
A dummy package used to test Simp::RPM methods
|
12
|
+
|
13
|
+
%prep
|
14
|
+
exit 0
|
15
|
+
|
16
|
+
%build
|
17
|
+
exit 0
|
18
|
+
|
19
|
+
|
20
|
+
%install
|
21
|
+
exit 0
|
22
|
+
|
23
|
+
%clean
|
24
|
+
exit 0
|
25
|
+
|
26
|
+
%files
|
27
|
+
%doc
|
28
|
+
|
29
|
+
|
30
|
+
%package doc
|
31
|
+
Summary: Documentation for dummy test package #2
|
32
|
+
License: Apache-2.0
|
33
|
+
Version: 1.0.1
|
34
|
+
Release: 2
|
35
|
+
|
36
|
+
%description doc
|
37
|
+
Documentation for the 2nd dummy package used to test Simp::RPM methods
|
38
|
+
|
39
|
+
|
40
|
+
%changelog
|
41
|
+
* Wed Jun 10 2015 nobody
|
42
|
+
- some comment
|
@@ -1,4 +1,4 @@
|
|
1
|
-
Name: testpackage
|
1
|
+
Name: testpackage
|
2
2
|
Version: 1
|
3
3
|
Release: 0
|
4
4
|
Summary: dummy test package #2
|
@@ -27,12 +27,14 @@ exit 0
|
|
27
27
|
%doc
|
28
28
|
|
29
29
|
|
30
|
-
%package
|
31
|
-
Summary: dummy test package #2
|
30
|
+
%package doc
|
31
|
+
Summary: Documentation for dummy test package #2
|
32
32
|
License: Apache-2.0
|
33
|
+
Version: 1.0.1
|
34
|
+
Release: 2
|
33
35
|
|
34
|
-
%description
|
35
|
-
|
36
|
+
%description doc
|
37
|
+
Documentation for the 2nd dummy package used to test Simp::RPM methods
|
36
38
|
|
37
39
|
|
38
40
|
%changelog
|
data/spec/lib/simp/rpm_spec.rb
CHANGED
@@ -3,48 +3,323 @@ require 'spec_helper'
|
|
3
3
|
|
4
4
|
describe Simp::RPM do
|
5
5
|
before :all do
|
6
|
+
Simp::RPM.stubs(:system_dist).returns('.testdist')
|
7
|
+
|
6
8
|
dir = File.expand_path( 'files', File.dirname( __FILE__ ) )
|
7
9
|
@spec_file = File.join( dir, 'testpackage.spec' )
|
8
10
|
@spec_obj = Simp::RPM.new( @spec_file )
|
11
|
+
|
9
12
|
@m_spec_file = File.join( dir, 'testpackage-multi.spec' )
|
10
|
-
@m_spec_obj = Simp::RPM.new( @
|
13
|
+
@m_spec_obj = Simp::RPM.new( @m_spec_file )
|
14
|
+
|
11
15
|
@rpm_file = File.join( dir, 'testpackage-1-0.noarch.rpm' )
|
12
|
-
@rpm_obj = Simp::RPM.new( @
|
16
|
+
@rpm_obj = Simp::RPM.new( @rpm_file )
|
17
|
+
|
18
|
+
@d_spec_file = File.join( dir, 'testpackage-dist.spec' )
|
19
|
+
@d_spec_obj = Simp::RPM.new( @d_spec_file )
|
20
|
+
|
21
|
+
@d_rpm_file = File.join( dir, 'testpackage-1-0.el7.noarch.rpm' )
|
22
|
+
@d_rpm_obj = Simp::RPM.new( @d_rpm_file )
|
23
|
+
|
24
|
+
#FIXME
|
25
|
+
# @signed_rpm_file = File.join( dir, 'testpackage-1-0.noarch.rpm' )
|
26
|
+
# @signed_rpm_obj = Simp::RPM.new( @signed_rpm_file )
|
13
27
|
end
|
14
28
|
|
15
|
-
describe
|
29
|
+
describe 'class #initialize' do
|
16
30
|
|
17
|
-
it
|
31
|
+
it 'initializes w/unsigned RPM (smoke test)' do
|
18
32
|
expect( @rpm_obj.class ).to eq Simp::RPM
|
19
33
|
end
|
20
34
|
|
21
|
-
|
35
|
+
#FIXME
|
36
|
+
# it 'initializes w/signed RPM (smoke test)' do
|
37
|
+
# expect( @signed_rpm_obj.class ).to eq Simp::RPM
|
38
|
+
# end
|
39
|
+
|
40
|
+
it 'initializes w/spec file (smoke test)' do
|
22
41
|
expect( @spec_obj.class ).to eq Simp::RPM
|
23
42
|
end
|
24
43
|
|
25
|
-
it
|
44
|
+
it 'initializes w/multi-package spec file (smoke test)' do
|
26
45
|
expect( @m_spec_obj.class ).to eq Simp::RPM
|
27
46
|
end
|
28
47
|
|
48
|
+
it 'fails to initialize when rpm source cannot be opened' do
|
49
|
+
expect{ Simp::RPM.new('/does/not/exist/') }.to raise_error(RuntimeError)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe 'getter methods' do
|
54
|
+
context '#packages' do
|
55
|
+
it 'returns packages' do
|
56
|
+
expect( @rpm_obj.packages ).to eq ['testpackage']
|
57
|
+
# expect( @signed_rpm_obj.packages ).to eq ['testpackage']
|
58
|
+
expect( @spec_obj.packages ).to eq ['testpackage']
|
59
|
+
expect( @m_spec_obj.packages ).to eq ['testpackage','testpackage-doc']
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context '#basename' do
|
64
|
+
it 'returns basename' do
|
65
|
+
expect( @rpm_obj.basename ).to eq 'testpackage'
|
66
|
+
# expect( @signed_rpm_obj.basename ).to eq 'testpackage'
|
67
|
+
expect( @spec_obj.basename ).to eq 'testpackage'
|
68
|
+
expect( @m_spec_obj.basename ).to eq 'testpackage'
|
69
|
+
expect( @m_spec_obj.basename('testpackage') ).to eq 'testpackage'
|
70
|
+
expect( @m_spec_obj.basename('testpackage-doc') ).to eq 'testpackage-doc'
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'fails when invalid package specified' do
|
74
|
+
expect { @rpm_obj.basename('oops') }.to raise_error(ArgumentError)
|
75
|
+
# expect { @signed_rpm_obj.basename('oops') }.to raise_error(ArgumentError)
|
76
|
+
expect { @spec_obj.basename('oops') }.to raise_error(ArgumentError)
|
77
|
+
expect { @m_spec_obj.basename('oops') }.to raise_error(ArgumentError)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context '#version' do
|
82
|
+
it 'returns version' do
|
83
|
+
expect( @rpm_obj.version ).to eq '1'
|
84
|
+
# expect( @signed_rpm_obj.version ).to eq '1'
|
85
|
+
expect( @spec_obj.version ).to eq '1'
|
86
|
+
expect( @m_spec_obj.version ).to eq '1'
|
87
|
+
expect( @m_spec_obj.version('testpackage') ).to eq '1'
|
88
|
+
expect( @m_spec_obj.version('testpackage-doc') ).to eq '1.0.1'
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'fails when invalid package specified' do
|
92
|
+
expect { @rpm_obj.version('oops') }.to raise_error(ArgumentError)
|
93
|
+
# expect { @signed_rpm_obj.version('oops') }.to raise_error(ArgumentError)
|
94
|
+
expect { @spec_obj.version('oops') }.to raise_error(ArgumentError)
|
95
|
+
expect { @m_spec_obj.version('oops') }.to raise_error(ArgumentError)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
context '#release' do
|
100
|
+
it 'returns release' do
|
101
|
+
expect( @rpm_obj.release ).to eq '0'
|
102
|
+
# expect( @signed_rpm_obj.release ).to eq '0'
|
103
|
+
expect( @spec_obj.release ).to eq '0'
|
104
|
+
expect( @m_spec_obj.release ).to eq '0'
|
105
|
+
expect( @m_spec_obj.release('testpackage') ).to eq '0'
|
106
|
+
expect( @m_spec_obj.release('testpackage-doc') ).to eq '2'
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'fails when invalid package specified' do
|
110
|
+
expect { @rpm_obj.release('oops') }.to raise_error(ArgumentError)
|
111
|
+
# expect { @signed_rpm_obj.release('oops') }.to raise_error(ArgumentError)
|
112
|
+
expect { @spec_obj.release('oops') }.to raise_error(ArgumentError)
|
113
|
+
expect { @m_spec_obj.release('oops') }.to raise_error(ArgumentError)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context '#full_version' do
|
118
|
+
it 'returns full_version' do
|
119
|
+
expect( @rpm_obj.full_version ).to eq '1-0'
|
120
|
+
# expect( @signed_rpm_obj.full_version ).to eq '1-0'
|
121
|
+
expect( @spec_obj.full_version ).to eq '1-0'
|
122
|
+
expect( @m_spec_obj.full_version ).to eq '1-0'
|
123
|
+
expect( @m_spec_obj.full_version('testpackage') ).to eq '1-0'
|
124
|
+
expect( @m_spec_obj.full_version('testpackage-doc') ).to eq '1.0.1-2'
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'fails when invalid package specified' do
|
128
|
+
expect { @rpm_obj.full_version('oops') }.to raise_error(ArgumentError)
|
129
|
+
# expect { @signed_rpm_obj.full_version('oops') }.to raise_error(ArgumentError)
|
130
|
+
expect { @spec_obj.full_version('oops') }.to raise_error(ArgumentError)
|
131
|
+
expect { @m_spec_obj.full_version('oops') }.to raise_error(ArgumentError)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
context '#name' do
|
136
|
+
it 'returns name' do
|
137
|
+
expect( @rpm_obj.name ).to eq 'testpackage-1-0'
|
138
|
+
# expect( @signed_rpm_obj.name ).to eq 'testpackage-1-0'
|
139
|
+
expect( @spec_obj.name ).to eq 'testpackage-1-0'
|
140
|
+
expect( @m_spec_obj.name ).to eq 'testpackage-1-0'
|
141
|
+
expect( @m_spec_obj.name('testpackage') ).to eq 'testpackage-1-0'
|
142
|
+
expect( @m_spec_obj.name('testpackage-doc') ).to eq 'testpackage-doc-1.0.1-2'
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'fails when invalid package specified' do
|
146
|
+
expect { @rpm_obj.name('oops') }.to raise_error(ArgumentError)
|
147
|
+
# expect { @signed_rpm_obj.name('oops') }.to raise_error(ArgumentError)
|
148
|
+
expect { @spec_obj.name('oops') }.to raise_error(ArgumentError)
|
149
|
+
expect { @m_spec_obj.name('oops') }.to raise_error(ArgumentError)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
context '#arch' do
|
154
|
+
it 'returns arch' do
|
155
|
+
expect( @rpm_obj.arch ).to eq 'noarch'
|
156
|
+
# expect( @signed_rpm_obj.arch ).to eq 'noarch'
|
157
|
+
expect( @spec_obj.arch ).to eq 'noarch'
|
158
|
+
expect( @m_spec_obj.arch ).to eq 'noarch'
|
159
|
+
expect( @m_spec_obj.arch('testpackage') ).to eq 'noarch'
|
160
|
+
expect( @m_spec_obj.arch('testpackage-doc') ).to eq 'noarch'
|
161
|
+
end
|
162
|
+
|
163
|
+
it 'fails when invalid package specified' do
|
164
|
+
expect { @rpm_obj.arch('oops') }.to raise_error(ArgumentError)
|
165
|
+
# expect { @signed_rpm_obj.arch('oops') }.to raise_error(ArgumentError)
|
166
|
+
expect { @spec_obj.arch('oops') }.to raise_error(ArgumentError)
|
167
|
+
expect { @m_spec_obj.arch('oops') }.to raise_error(ArgumentError)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
context '#signature' do
|
172
|
+
it 'returns signature' do
|
173
|
+
expect( @rpm_obj.signature ).to be nil
|
174
|
+
# expect( @signed_rpm_obj.signature ).to eq 'xxxx'
|
175
|
+
expect( @spec_obj.signature ).to be nil
|
176
|
+
expect( @m_spec_obj.signature ).to be nil
|
177
|
+
expect( @m_spec_obj.signature('testpackage') ).to be nil
|
178
|
+
expect( @m_spec_obj.signature('testpackage-doc') ).to be nil
|
179
|
+
end
|
180
|
+
|
181
|
+
it 'fails when invalid package specified' do
|
182
|
+
expect { @rpm_obj.signature('oops') }.to raise_error(ArgumentError)
|
183
|
+
# expect { @signed_rpm_obj.signature('oops') }.to raise_error(ArgumentError)
|
184
|
+
expect { @spec_obj.signature('oops') }.to raise_error(ArgumentError)
|
185
|
+
expect { @m_spec_obj.signature('oops') }.to raise_error(ArgumentError)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
context '#rpm_name' do
|
190
|
+
it 'returns rpm_name' do
|
191
|
+
expect( @rpm_obj.rpm_name ).to eq 'testpackage-1-0.noarch.rpm'
|
192
|
+
# expect( @signed_rpm_obj.rpm_name ).to eq 'testpackage-1-0.noarch.rpm'
|
193
|
+
expect( @spec_obj.rpm_name ).to eq 'testpackage-1-0.noarch.rpm'
|
194
|
+
expect( @m_spec_obj.rpm_name ).to eq 'testpackage-1-0.noarch.rpm'
|
195
|
+
expect( @m_spec_obj.rpm_name('testpackage') ).to eq 'testpackage-1-0.noarch.rpm'
|
196
|
+
expect( @m_spec_obj.rpm_name('testpackage-doc') ).to eq 'testpackage-doc-1.0.1-2.noarch.rpm'
|
197
|
+
end
|
198
|
+
|
199
|
+
it 'fails when invalid package specified' do
|
200
|
+
expect { @rpm_obj.rpm_name('oops') }.to raise_error(ArgumentError)
|
201
|
+
# expect { @signed_rpm_obj.rpm_name('oops') }.to raise_error(ArgumentError)
|
202
|
+
expect { @spec_obj.rpm_name('oops') }.to raise_error(ArgumentError)
|
203
|
+
expect { @m_spec_obj.rpm_name('oops') }.to raise_error(ArgumentError)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
context '#has_dist_tag?' do
|
208
|
+
it 'returns has_dist_tag?' do
|
209
|
+
expect( @rpm_obj.has_dist_tag?).to eq false
|
210
|
+
# expect( @signed_rpm_obj.has_dist_tag?).to eq false
|
211
|
+
expect( @d_rpm_obj.has_dist_tag?).to eq true
|
212
|
+
expect( @spec_obj.has_dist_tag?).to eq false
|
213
|
+
expect( @d_spec_obj.has_dist_tag?).to eq true
|
214
|
+
end
|
215
|
+
|
216
|
+
it 'fails when invalid package specified' do
|
217
|
+
expect { @rpm_obj.has_dist_tag?('oops') }.to raise_error(ArgumentError)
|
218
|
+
# expect { @signed_rpm_obj.has_dist_tag?('oops') }.to raise_error(ArgumentError)
|
219
|
+
expect { @d_rpm_obj.has_dist_tag?('oops') }.to raise_error(ArgumentError)
|
220
|
+
expect { @spec_obj.has_dist_tag?('oops') }.to raise_error(ArgumentError)
|
221
|
+
expect { @m_spec_obj.has_dist_tag?('oops') }.to raise_error(ArgumentError)
|
222
|
+
expect { @d_spec_obj.has_dist_tag?('oops') }.to raise_error(ArgumentError)
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
context '#dist' do
|
227
|
+
it 'returns dist' do
|
228
|
+
expect( @rpm_obj.dist ).to eq '.testdist'
|
229
|
+
expect( @d_rpm_obj.dist ).to eq '.el7'
|
230
|
+
expect( @spec_obj.dist ).to eq '.testdist'
|
231
|
+
expect( @d_spec_obj.dist ).to eq '.testdist'
|
232
|
+
end
|
233
|
+
|
234
|
+
it 'fails when invalid package specified' do
|
235
|
+
expect { @rpm_obj.dist('oops') }.to raise_error(ArgumentError)
|
236
|
+
# expect { @signed_rpm_obj.dist('oops') }.to raise_error(ArgumentError)
|
237
|
+
expect { @d_rpm_obj.dist('oops') }.to raise_error(ArgumentError)
|
238
|
+
expect { @spec_obj.dist('oops') }.to raise_error(ArgumentError)
|
239
|
+
expect { @m_spec_obj.dist('oops') }.to raise_error(ArgumentError)
|
240
|
+
expect { @d_spec_obj.dist('oops') }.to raise_error(ArgumentError)
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
=begin
|
246
|
+
describe '#newer? and #package_newer?' do
|
247
|
+
end
|
248
|
+
|
249
|
+
describe '#valid_package?' do
|
250
|
+
end
|
251
|
+
|
252
|
+
describe '.copy_wo_vcs?' do
|
29
253
|
end
|
30
254
|
|
31
|
-
describe
|
32
|
-
|
255
|
+
describe '.execute?' do
|
256
|
+
end
|
257
|
+
=end
|
258
|
+
|
259
|
+
|
260
|
+
describe '.get_info' do
|
261
|
+
it 'extracts correct information from a .spec file' do
|
33
262
|
info = Simp::RPM.get_info(@spec_file)
|
34
|
-
expect( info.fetch( :
|
263
|
+
expect( info.fetch( :basename ) ).to eq 'testpackage'
|
35
264
|
expect( info.fetch( :version ) ).to eq '1'
|
265
|
+
expect( info.fetch( :release ) ).to eq '0'
|
266
|
+
expect( info.fetch( :full_version ) ).to eq '1-0'
|
267
|
+
expect( info.fetch( :name ) ).to eq 'testpackage-1-0'
|
268
|
+
expect( info.fetch( :arch ) ).to eq 'noarch'
|
269
|
+
expect( info[:signature] ).to be nil
|
270
|
+
expect( info.fetch( :rpm_name ) ).to eq 'testpackage-1-0.noarch.rpm'
|
36
271
|
end
|
37
272
|
|
38
|
-
it
|
273
|
+
it 'extracts correct information from an .rpm file' do
|
39
274
|
info = Simp::RPM.get_info(@rpm_file)
|
40
|
-
expect( info.fetch( :
|
275
|
+
expect( info.fetch( :basename ) ).to eq 'testpackage'
|
41
276
|
expect( info.fetch( :version ) ).to eq '1'
|
277
|
+
expect( info.fetch( :release ) ).to eq '0'
|
278
|
+
expect( info.fetch( :full_version ) ).to eq '1-0'
|
279
|
+
expect( info.fetch( :name ) ).to eq 'testpackage-1-0'
|
280
|
+
expect( info.fetch( :arch ) ).to eq 'noarch'
|
281
|
+
expect( info[:signature] ).to be nil
|
282
|
+
expect( info.fetch( :rpm_name ) ).to eq 'testpackage-1-0.noarch.rpm'
|
42
283
|
end
|
43
284
|
|
44
|
-
it
|
285
|
+
it 'extracts correct information for all entries from a multi-package .spec file' do
|
45
286
|
info = Simp::RPM.get_info(@m_spec_file)
|
46
|
-
expect( info.
|
47
|
-
expect( info.fetch( :
|
287
|
+
expect( info.size ).to eq 2
|
288
|
+
expect( info[0].fetch( :basename ) ).to eq 'testpackage'
|
289
|
+
expect( info[0].fetch( :version ) ).to eq '1'
|
290
|
+
expect( info[0].fetch( :release ) ).to eq '0'
|
291
|
+
expect( info[0].fetch( :full_version ) ).to eq '1-0'
|
292
|
+
expect( info[0].fetch( :name ) ).to eq 'testpackage-1-0'
|
293
|
+
expect( info[0].fetch( :arch ) ).to eq 'noarch'
|
294
|
+
expect( info[0][:signature] ).to be nil
|
295
|
+
expect( info[0].fetch( :rpm_name ) ).to eq 'testpackage-1-0.noarch.rpm'
|
296
|
+
|
297
|
+
expect( info[1].fetch( :basename ) ).to eq 'testpackage-doc'
|
298
|
+
expect( info[1].fetch( :version ) ).to eq '1.0.1'
|
299
|
+
expect( info[1].fetch( :release ) ).to eq '2'
|
300
|
+
expect( info[1].fetch( :full_version ) ).to eq '1.0.1-2'
|
301
|
+
expect( info[1].fetch( :name ) ).to eq 'testpackage-doc-1.0.1-2'
|
302
|
+
expect( info[1].fetch( :arch ) ).to eq 'noarch'
|
303
|
+
expect( info[1][:signature] ).to be nil
|
304
|
+
expect( info[1].fetch( :rpm_name ) ).to eq 'testpackage-doc-1.0.1-2.noarch.rpm'
|
305
|
+
end
|
306
|
+
|
307
|
+
it 'fails to when rpm source cannot be opened ' do
|
308
|
+
expect{ Simp::RPM.get_info('/does/not/exist/') }.to raise_error(RuntimeError)
|
48
309
|
end
|
49
310
|
end
|
311
|
+
|
312
|
+
=begin
|
313
|
+
describe '.indent' do
|
314
|
+
end
|
315
|
+
|
316
|
+
describe '.create_rpm_build_metadata' do
|
317
|
+
end
|
318
|
+
|
319
|
+
describe '.load_key' do
|
320
|
+
end
|
321
|
+
|
322
|
+
describe '.signrpm' do
|
323
|
+
end
|
324
|
+
=end
|
50
325
|
end
|