vanagon 0.5.7 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b66b1395018a77daddbcfcaddc29f0b19481e5a
4
- data.tar.gz: 959fb7d6e6248d02942ba0b287f39f65bc738883
3
+ metadata.gz: eb77baf3c8dca42c4cec74d3a31c74af63ee37df
4
+ data.tar.gz: 32949fe6e83be1972bc91057b5a522b116de0bc2
5
5
  SHA512:
6
- metadata.gz: 4dcf74dd3a0c51d821906d3e4be702040878db7f563600f9fae257c7731fabcc2db81fcc32f23a0a04d0d649b37d3ec45a1b2d10f36521201dec3ec8715337b8
7
- data.tar.gz: 105fce81c259facb92659190ae9f458e9962f9f34dd1107adf61b11bd864a3b942ba0e5f373f70d97c2e416e3b412999c042de9dee1ac80b7aee347172ee416d
6
+ metadata.gz: e2a8b0411fc595f95b40c8f63229f73ed4324f9712c9c04dab01340a95fa27246e305cc0d44b7a7c7b7b2a5725ac6991971607d31eb7313a4953baf60fe7bb98
7
+ data.tar.gz: 5b6ee385067ff48a3befb3f2d5abc796a3b7589ef389534c2ab3d2a0840a85982f1eca22a3365c2a4f875a1619cc722fc1f7655118c273e47793d63f596d9c28
@@ -10,7 +10,7 @@ class Vanagon
10
10
  attr_accessor :name, :version, :source, :url, :configure, :build, :check, :install
11
11
  attr_accessor :environment, :extract_with, :dirname, :build_requires, :build_dir
12
12
  attr_accessor :settings, :platform, :patches, :requires, :service, :options
13
- attr_accessor :directories, :replaces, :provides, :cleanup_source
13
+ attr_accessor :directories, :replaces, :provides, :conflicts, :cleanup_source
14
14
  attr_accessor :sources, :preinstall_actions, :postinstall_actions
15
15
  attr_accessor :preremove_actions, :postremove_actions, :license
16
16
 
@@ -57,6 +57,7 @@ class Vanagon
57
57
  @directories = []
58
58
  @replaces = []
59
59
  @provides = []
60
+ @conflicts = []
60
61
  @environment = {}
61
62
  @sources = []
62
63
  @preinstall_actions = []
@@ -151,6 +151,16 @@ class Vanagon
151
151
  @component.provides << OpenStruct.new(:provide => provide, :version => version)
152
152
  end
153
153
 
154
+ # Indicates that this component conflicts with another package,
155
+ # so both cannot be installed at the same time. Conflicts can be
156
+ # collected and used by the project and package.
157
+ #
158
+ # @param pkgname [String] name of the package which conflicts with this component
159
+ # @param version [String] the version of the package that conflicts with this component
160
+ def conflicts(pkgname, version = nil)
161
+ @component.conflicts << OpenStruct.new(:pkgname => pkgname, :version => version)
162
+ end
163
+
154
164
  # install_service adds the commands to install the various files on
155
165
  # disk during the package build and registers the service with the project
156
166
  #
@@ -11,7 +11,7 @@ class Vanagon
11
11
  attr_accessor :version, :directories, :license, :description, :vendor
12
12
  attr_accessor :homepage, :requires, :user, :repo, :noarch, :identifier
13
13
  attr_accessor :cleanup, :version_file, :release, :replaces, :provides
14
- attr_accessor :bill_of_materials, :retry_count, :timeout
14
+ attr_accessor :conflicts, :bill_of_materials, :retry_count, :timeout
15
15
 
16
16
  # Loads a given project from the configdir
17
17
  #
@@ -50,6 +50,7 @@ class Vanagon
50
50
  @release = "1"
51
51
  @replaces = []
52
52
  @provides = []
53
+ @conflicts = []
53
54
  end
54
55
 
55
56
  # Magic getter to retrieve settings in the project
@@ -101,6 +102,21 @@ class Vanagon
101
102
  replaces.flatten.uniq
102
103
  end
103
104
 
105
+ def has_replaces?
106
+ !get_replaces.empty?
107
+ end
108
+
109
+ # Collects all of the conflicts for the project and its components
110
+ def get_conflicts
111
+ conflicts = @components.flat_map(&:conflicts) + @conflicts
112
+ # Mash the whole thing down into a flat Array
113
+ conflicts.flatten.uniq
114
+ end
115
+
116
+ def has_conflicts?
117
+ !get_conflicts.empty?
118
+ end
119
+
104
120
  # Grabs a specific service based on which name is passed in
105
121
  # note that if the name is wrong or there was no
106
122
  # @component.install_service call in the component, this
@@ -127,6 +143,10 @@ class Vanagon
127
143
  provides.flatten.uniq
128
144
  end
129
145
 
146
+ def has_provides?
147
+ !get_provides.empty?
148
+ end
149
+
130
150
  # Collects the preinstall packaging actions for the project and it's components
131
151
  # for the specified packaging state
132
152
  #
@@ -199,6 +219,10 @@ class Vanagon
199
219
  @components.map(&:configfiles).flatten.uniq
200
220
  end
201
221
 
222
+ def has_configfiles?
223
+ !get_configfiles.empty?
224
+ end
225
+
202
226
  # Collects any directories declared by the project and components
203
227
  #
204
228
  # @return [Array] the directories in the project and components
@@ -108,6 +108,16 @@ class Vanagon
108
108
  @project.provides << OpenStruct.new(:provide => provide, :version => version)
109
109
  end
110
110
 
111
+ # Indicates that this component conflicts with another package,
112
+ # so both cannot be installed at the same time. Conflicts can be
113
+ # collected and used by the project and package.
114
+ #
115
+ # @param pkgname [String] name of the package which conflicts with this component
116
+ # @param version [String] the version of the package that conflicts with this component
117
+ def conflicts(pkgname, version = nil)
118
+ @project.conflicts << OpenStruct.new(:pkgname => pkgname, :version => version)
119
+ end
120
+
111
121
  # Sets the version for the project. Mainly for use in packaging.
112
122
  #
113
123
  # @param ver [String] version of the project
@@ -11,7 +11,7 @@ Architecture: <%= @noarch ? 'all' : 'any' %>
11
11
  Section: admin
12
12
  Priority: optional
13
13
  Replaces: <%= get_replaces.map { |replace| "#{replace.replacement} #{replace.version ? "(<< #{replace.version})" : ""}" }.join(", ") %>
14
- Conflicts: <%= get_replaces.map { |replace| "#{replace.replacement} #{replace.version ? "(<< #{replace.version})" : ""}" }.join(", ") %>
14
+ Conflicts: <%= get_conflicts.map { |conflict| "#{conflict.pkgname} #{conflict.version ? "(<< #{conflict.version})" : ""}" }.join(", ") %>
15
15
  Depends: <%= get_requires.join(", ") %>
16
16
  Provides: <%= get_provides.map { |prov| prov.provide }.join(", ") %>
17
17
  Description: <%= @description.lines.first.chomp %>
@@ -1,5 +1,6 @@
1
1
  #!/bin/bash
2
2
 
3
+ <%- if has_configfiles? -%>
3
4
  # Move any new configfiles into place
4
5
  <%- get_configfiles.each do |config|
5
6
  dest_file = config.path.gsub(/\.pristine$/, '') -%>
@@ -10,7 +11,9 @@ else
10
11
  mv '<%= config.path %>' '<%= dest_file %>'
11
12
  fi
12
13
  <%- end -%>
14
+ <%- end -%>
13
15
 
16
+ <%- if has_services? -%>
14
17
  if [ -d "/tmp/.<%= @name %>.upgrade" ]; then
15
18
  <%- get_services.each do |service| -%>
16
19
  if [ -f "/tmp/.<%= @name %>.upgrade/<%= service.name %>" ]; then
@@ -18,6 +21,7 @@ if [ -d "/tmp/.<%= @name %>.upgrade" ]; then
18
21
  fi
19
22
  <%- end -%>
20
23
  fi
24
+ <%- end -%>
21
25
 
22
26
  <%= File.read("resources/osx/postinstall-extras") if File.exist?("resources/osx/postinstall-extras") %>
23
27
 
@@ -13,6 +13,7 @@ if [ -n "$foundpkg" ]; then
13
13
  mkdir -p "/tmp/.<%= @name %>.upgrade"
14
14
  chmod 0700 "/tmp/.<%= @name %>.upgrade"
15
15
 
16
+ <%- if has_services? -%>
16
17
  <%- get_services.each do |service| -%>
17
18
  if /bin/launchctl list "<%= service.name %>" &> /dev/null; then
18
19
  touch "/tmp/.<%= @name %>.upgrade/<%= service.name %>"
@@ -22,6 +23,8 @@ if [ -n "$foundpkg" ]; then
22
23
  /bin/rm "$oldbom"
23
24
  fi
24
25
  <%- end -%>
26
+ <%- end -%>
25
27
  fi
26
28
 
29
+
27
30
  <%= File.read("resources/osx/preinstall-extras") if File.exist?("resources/osx/preinstall-extras") %>
@@ -48,10 +48,13 @@ Requires: chkconfig
48
48
  <%- end -%>
49
49
 
50
50
  <%- get_replaces.each do |replace| -%>
51
- Conflicts: <%= replace.replacement %><%= replace.version ? " < #{replace.version}" : "" %>
52
51
  Obsoletes: <%= replace.replacement %><%= replace.version ? " < #{replace.version}" : "" %>
53
52
  <%- end -%>
54
53
 
54
+ <%- get_conflicts.each do |conflict| -%>
55
+ Conflicts: <%= conflict.pkgname %><%= conflict.version ? " < #{conflict.version}" : "" %>
56
+ <%- end -%>
57
+
55
58
  <%- get_provides.each do |prov| -%>
56
59
  Provides: <%= prov.provide %><%= prov.version ? " >= #{prov.version}" : "" %>
57
60
  <%- end -%>
@@ -269,6 +269,23 @@ end" }
269
269
  end
270
270
  end
271
271
 
272
+ describe '#conflicts' do
273
+ it 'adds the package conflict to the list of conflicts' do
274
+ comp = Vanagon::Component::DSL.new('conflicts-test', {}, {})
275
+ comp.conflicts('thing1')
276
+ comp.conflicts('thing2')
277
+ expect(comp._component.conflicts.first.pkgname).to eq('thing1')
278
+ expect(comp._component.conflicts.last.pkgname).to eq('thing2')
279
+ end
280
+
281
+ it 'supports versioned conflicts' do
282
+ comp = Vanagon::Component::DSL.new('conflicts-test', {}, {})
283
+ comp.conflicts('thing1', '1.2.3')
284
+ expect(comp._component.conflicts.first.pkgname).to eq('thing1')
285
+ expect(comp._component.conflicts.first.version).to eq('1.2.3')
286
+ end
287
+ end
288
+
272
289
  describe '#add_actions' do
273
290
  it 'adds the corect preinstall action to the component' do
274
291
  comp = Vanagon::Component::DSL.new('action-test', {}, dummy_platform_sysv)
@@ -167,6 +167,37 @@ end" }
167
167
  end
168
168
  end
169
169
 
170
+ describe "#conflicts" do
171
+ it 'adds the package conflict to the list of conflicts' do
172
+ proj = Vanagon::Project::DSL.new('test-fixture', {})
173
+ proj.instance_eval(project_block)
174
+ proj.conflicts('thing1')
175
+ proj.conflicts('thing2')
176
+ expect(proj._project.get_conflicts.count).to eq(2)
177
+ expect(proj._project.get_conflicts.first.pkgname).to eq('thing1')
178
+ expect(proj._project.get_conflicts.last.pkgname).to eq('thing2')
179
+ end
180
+
181
+ it 'supports versioned conflicts' do
182
+ proj = Vanagon::Project::DSL.new('test-fixture', {})
183
+ proj.instance_eval(project_block)
184
+ proj.conflicts('thing1', '1.2.3')
185
+ expect(proj._project.get_conflicts.count).to eq(1)
186
+ expect(proj._project.get_conflicts.first.pkgname).to eq('thing1')
187
+ expect(proj._project.get_conflicts.first.version).to eq('1.2.3')
188
+ end
189
+
190
+ it 'gets rid of duplicates' do
191
+ proj = Vanagon::Project::DSL.new('test-fixture', {})
192
+ proj.instance_eval(project_block)
193
+ proj.conflicts('thing1', '1.2.3')
194
+ proj.conflicts('thing1', '1.2.3')
195
+ expect(proj._project.get_conflicts.count).to eq(1)
196
+ expect(proj._project.get_conflicts.first.pkgname).to eq('thing1')
197
+ expect(proj._project.get_conflicts.first.version).to eq('1.2.3')
198
+ end
199
+ end
200
+
170
201
  describe "#component" do
171
202
  let(:project_block) {
172
203
  "project 'test-fixture' do |proj|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vanagon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.7
4
+ version: 0.5.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet Labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-23 00:00:00.000000000 Z
11
+ date: 2016-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec