vanagon 0.3.19 → 0.4.0

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.
@@ -1,8 +1,7 @@
1
- require 'vanagon/platform/rpm'
1
+ require 'vanagon/platform'
2
2
 
3
3
  describe "Vanagon::Platform::RPM" do
4
- let(:platforms) do
5
- [
4
+ platforms =[
6
5
  {
7
6
  :name => "el-5-i386",
8
7
  :os_name => "el",
@@ -10,6 +9,7 @@ describe "Vanagon::Platform::RPM" do
10
9
  :architecture => "i386",
11
10
  :output_dir => "el/5/products/i386",
12
11
  :output_dir_with_target => "el/5/thing/i386",
12
+ :block => %Q[ platform "el-5-i386" do |plat| end ]
13
13
  },
14
14
  {
15
15
  :name => "fedora-21-x86_64",
@@ -18,24 +18,44 @@ describe "Vanagon::Platform::RPM" do
18
18
  :architecture => "x86_64",
19
19
  :output_dir => "fedora/21/products/x86_64",
20
20
  :output_dir_with_target => "fedora/21/thing/x86_64",
21
+ :block => %Q[ platform "fedora-21-x86_64" do |plat| end ]
22
+ },
23
+ {
24
+ :name => "cisco-wrlinux-7-x86_64",
25
+ :os_name => "fedora",
26
+ :os_version => "21",
27
+ :architecture => "x86_64",
28
+ :output_dir => "cisco-wrlinux/7/products/x86_64",
29
+ :output_dir_with_target => "cisco-wrlinux/7/thing/x86_64",
30
+ :block => %Q[ platform "cisco-wrlinux-7-x86_64" do |plat| end ]
21
31
  },
22
32
  ]
23
- end
24
33
 
25
- describe "#output_dir" do
26
- it "returns an output dir consistent with the packaging repo" do
27
- platforms.each do |plat|
28
- cur_plat = Vanagon::Platform::RPM.new(plat[:name])
29
- expect(cur_plat.output_dir).to eq(plat[:output_dir])
34
+ platforms.each do |plat|
35
+ context "on #{plat[:name]} we should behave ourselves" do
36
+ let(:platform) { plat }
37
+ let(:cur_plat) { Vanagon::Platform::DSL.new(plat[:name]) }
38
+
39
+ before do
40
+ cur_plat.instance_eval(plat[:block])
30
41
  end
31
- end
32
42
 
33
- it "adds the target repo in the right way" do
34
- platforms.each do |plat|
35
- cur_plat = Vanagon::Platform::RPM.new(plat[:name])
36
- expect(cur_plat.output_dir('thing')).to eq(plat[:output_dir_with_target])
43
+ describe "#output_dir" do
44
+ it "returns an output dir consistent with the packaging repo" do
45
+ expect(cur_plat._platform.output_dir).to eq(plat[:output_dir])
46
+ end
47
+
48
+ it "adds the target repo in the right way" do
49
+ expect(cur_plat._platform.output_dir('thing')).to eq(plat[:output_dir_with_target])
50
+ end
51
+ end
52
+
53
+ describe '#rpm_defines' do
54
+ it "removes dashes from the dist macro" do
55
+ expected_dist = "--define 'dist .#{cur_plat._platform.os_name.gsub('-', '_')}#{cur_plat._platform.os_version}'"
56
+ expect(cur_plat._platform.rpm_defines).to include(expected_dist)
57
+ end
37
58
  end
38
59
  end
39
60
  end
40
61
  end
41
-
@@ -4,7 +4,7 @@ export SHELL := $(shell which bash)
4
4
  tempdir := $(shell mktemp -d -p /var/tmp 2>/dev/null || mktemp -d -t 'tmp')
5
5
  workdir := $(PWD)
6
6
 
7
- all: <%= package_name %>
7
+ all: file-list-before-build <%= package_name %>
8
8
 
9
9
  <%= package_name %>: <%= @name %>-<%= @version %>.tar.gz
10
10
  <%= generate_package.join("\n\t") %>
@@ -13,20 +13,20 @@ file-list-before-build:
13
13
  <%- if dirnames.empty? -%>
14
14
  touch file-list-before-build
15
15
  <%- else -%>
16
- (find -L <%= dirnames.join(' ') %> 2>/dev/null || find <%= dirnames.join(' ') %> -follow) | sort | uniq > file-list-before-build
16
+ (find -L <%= dirnames.join(' ') %> 2>/dev/null || find <%= dirnames.join(' ') %> -follow 2>/dev/null) | sort | uniq > file-list-before-build
17
17
  <%- end -%>
18
18
 
19
19
  file-list-after-build: <%= @components.map {|comp| comp.name }.join(" ") %>
20
20
  <%- if dirnames.empty? -%>
21
21
  touch file-list-after-build
22
22
  <%- else -%>
23
- (find -L <%= dirnames.join(' ') %> 2>/dev/null || find <%= dirnames.join(' ') %> -follow) | sort | uniq > file-list-after-build
23
+ (find -L <%= dirnames.join(' ') %> 2>/dev/null || find <%= dirnames.join(' ') %> -follow 2>/dev/null) | sort | uniq > file-list-after-build
24
24
  <%- end -%>
25
25
 
26
26
  <%= @name %>-<%= @version %>.tar.gz: file-list <%= @cleanup ? 'cleanup-components' : '' %>
27
27
  <%= pack_tarball_command %>
28
28
 
29
- file-list: <%= dirnames.join(' ') %> <%= @name %>-project <%= @version_file ? @version_file.path : '' %>
29
+ file-list: file-list-before-build <%= @name %>-project
30
30
  comm -23 file-list-after-build file-list-before-build > file-list
31
31
  comm -23 file-list-after-build file-list-before-build | sed -e 's/\(^.*[[:space:]].*$$\)/"\1"/g' > file-list-for-rpm
32
32
 
@@ -35,8 +35,14 @@ file-list: <%= dirnames.join(' ') %> <%= @name %>-project <%= @version_file ? @v
35
35
  echo <%= @version %> > '<%= @version_file.path %>'
36
36
  <%- end -%>
37
37
 
38
+ <%- if @bill_of_materials -%>
39
+ <%= @bill_of_materials %>:
40
+ mkdir -p '<%= @bill_of_materials.path %>'
41
+ mv bill-of-materials '<%= @bill_of_materials.path %>'
42
+ <%- end -%>
43
+
38
44
  <%- dirnames.each do |dir| -%>
39
- <%= dir %>:
45
+ <%= dir %>: file-list-before-build
40
46
  mkdir -p <%= dir %>
41
47
  <%- end %>
42
48
 
@@ -45,7 +51,7 @@ cleanup-components: <%= @components.map {|comp| "#{comp.name}-cleanup" }.join("
45
51
  touch cleanup-components
46
52
  <%- end -%>
47
53
 
48
- <%= @name %>-project: file-list-after-build
54
+ <%= @name %>-project: <%= dirnames.join(' ') %> <%= @version_file ? @version_file.path : '' %> <%= @bill_of_materials ? @bill_of_materials.path : '' %> file-list-after-build
49
55
  touch <%= @name %>-project
50
56
 
51
57
  <%- @components.each do |comp| -%>
@@ -15,7 +15,7 @@ Conflicts: <%= get_replaces.map { |replace| "#{replace.replacement} #{replace.ve
15
15
  Depends: <%= get_requires.join(", ") %>
16
16
  Provides: <%= get_provides.map { |prov| prov.provide }.join(", ") %>
17
17
  Description: <%= @description.lines.first.chomp %>
18
- <%= @description.lines[1..-1].join("\n\s") -%>
18
+ <%= @description.lines[1..-1].join("\s") -%>
19
19
  .
20
20
  Contains the following components:
21
21
  <%= generate_bill_of_materials.join("\n\s") %>
@@ -1 +1,3 @@
1
+ <%- unless @bill_of_materials -%>
1
2
  bill-of-materials
3
+ <%- end -%>
@@ -1,5 +1,4 @@
1
1
  #!/bin/bash
2
-
3
2
  <%- get_services.each do |service| -%>
4
3
  # switch based on systemd vs systemv
5
4
  #
@@ -44,3 +43,13 @@ fi
44
43
  fi
45
44
  <%- end -%>
46
45
  <%- end -%>
46
+
47
+ # Run postinstall scripts on install if defined
48
+ if [ $1 = configure ] && [ -z $2 ] ; then
49
+ <%= get_postinstall_actions("install") %>
50
+ fi
51
+
52
+ # Run postinstall scripts on upgrade if defined
53
+ if [ $1 = configure ] && [ -n $2 ] ; then
54
+ <%= get_postinstall_actions("upgrade") %>
55
+ fi
@@ -1,5 +1,15 @@
1
1
  #!/bin/bash
2
2
 
3
+ # Run post-removal scripts on upgrade if defined
4
+ if [ $1 = upgrade ] && [ -n $2 ] ; then
5
+ <%= get_postremove_actions("upgrade") %>
6
+ fi
7
+
8
+ # Run post-removal scripts on removal if defined
9
+ if [ $1 = remove ] && [ -z $2 ] ; then
10
+ <%= get_postremove_actions("removal") %>
11
+ fi
12
+
3
13
  <%- get_services.each do |service| -%>
4
14
  # switch based on systemd vs systemv
5
15
  #
@@ -11,5 +21,3 @@ if [ "$1" = "purge" ] ; then
11
21
  fi
12
22
  <%- end -%>
13
23
  <%- end -%>
14
-
15
-
@@ -0,0 +1,11 @@
1
+ #!/bin/bash
2
+
3
+ # Run preinstall scripts on install if defined
4
+ if [ $1 = install ] && [ -z $2 ] ; then
5
+ <%= get_preinstall_actions("install") %>
6
+ fi
7
+
8
+ # Run preinstall scripts on upgrade if defined
9
+ if [ $1 = upgrade ] && [ -n $2 ] ; then
10
+ <%= get_preinstall_actions("upgrade") %>
11
+ fi
@@ -1,5 +1,15 @@
1
1
  #!/bin/bash
2
2
 
3
+ # Run pre-removal scripts on upgrade if defined
4
+ if [ $1 = upgrade ] && [ -n $2 ] ; then
5
+ <%= get_preremove_actions("upgrade") %>
6
+ fi
7
+
8
+ # Run pre-removal scripts on removal if defined
9
+ if [ $1 = remove ] && [ -z $2 ] ; then
10
+ <%= get_preremove_actions("removal") %>
11
+ fi
12
+
3
13
  <%- get_services.each do |service| -%>
4
14
  # switch based on systemd vs systemv
5
15
  #
@@ -14,9 +14,9 @@ override_dh_auto_install:
14
14
  fi
15
15
  <%- end -%>
16
16
  # Copy each of the extra files into place
17
- <%- get_files.map {|f| f.path.sub(/^\//,'')}.each do |file| -%>
17
+ <%- (get_files + get_configfiles).map {|f| f.path.sub(/^\//,'')}.each do |file| -%>
18
18
  install -d debian/tmp/<%= File.dirname(file) %>
19
- cp -p <%= file %> debian/tmp/<%= File.dirname(file) %>
19
+ cp -Rp <%= file %> debian/tmp/<%= File.dirname(file) %>
20
20
  <%- end -%>
21
21
 
22
22
  override_dh_shlibdeps:
@@ -87,7 +87,7 @@ install -d %{buildroot}
87
87
  # Copy each of the extra files into place
88
88
  <%- (get_files + get_configfiles).map {|f| f.path.sub(/^\//,'')}.each do |file| -%>
89
89
  install -d %{buildroot}/<%= File.dirname(file) %>
90
- cp -p <%= file %> %{buildroot}/<%= File.dirname(file) %>
90
+ cp -Rp <%= file %> %{buildroot}/<%= File.dirname(file) %>
91
91
  <%- end -%>
92
92
 
93
93
  <%- if @platform.is_cisco_wrlinux? || @platform.is_huaweios? -%>
@@ -114,10 +114,16 @@ for entry in `cat %{SOURCE1}`; do
114
114
  fi
115
115
  done
116
116
 
117
+
117
118
  %pre
118
- <%- get_preinstall_actions.each do |task| -%>
119
- <%= task %>
120
- <%- end -%>
119
+ # Save state so we know later if this is an upgrade or an install
120
+ mkdir -p %{_localstatedir}/lib/rpm-state/%{name}
121
+ if [ $1 -eq 1 ] ; then
122
+ touch %{_localstatedir}/lib/rpm-state/%{name}/install
123
+ fi
124
+ if [ $1 -eq 2 ] ; then
125
+ touch %{_localstatedir}/lib/rpm-state/%{name}/upgrade
126
+ fi
121
127
 
122
128
  <%- if @user -%>
123
129
  # Add our user and group
@@ -125,12 +131,29 @@ done
125
131
  <%= @platform.add_user(@user) %>
126
132
  <%- end -%>
127
133
 
134
+ # Run preinstall scripts on install if defined
135
+ if [ $1 -eq 1 ] ; then
136
+ <%= get_preinstall_actions("install") %>
137
+ fi
138
+
139
+ # Run preinstall scripts on upgrade if defined
140
+ if [ $1 -eq 2 ] ; then
141
+ <%= get_preinstall_actions("upgrade") %>
142
+ fi
143
+
144
+
128
145
  %post
129
146
  <%- if @platform.is_aix? || (@platform.is_el? && @platform.os_version.to_i == 4) -%>
130
- ## EL-4 and AIX RPM don't have %posttrans, so we'll put them here
131
- <%- get_postinstall_actions.each do |task| -%>
132
- <%= task %>
133
- <%- end -%>
147
+ ## EL-4 and AIX RPM don't have %posttrans, so we'll put them here
148
+ # Run postinstall scripts on install if defined
149
+ if [ $1 -eq 1 ] ; then
150
+ <%= get_postinstall_actions("install") %>
151
+ fi
152
+
153
+ # Run postinstall scripts on upgrade if defined
154
+ if [ $1 -eq 2 ] ; then
155
+ <%= get_postinstall_actions("upgrade") %>
156
+ fi
134
157
  <%- end -%>
135
158
  <%- get_services.each do |service| -%>
136
159
  # switch based on systemd vs systemv vs smf vs aix
@@ -152,7 +175,18 @@ done
152
175
  <%- end -%>
153
176
  <%- end -%>
154
177
 
178
+
155
179
  %postun
180
+ # Run post-uninstall scripts on upgrade if defined
181
+ if [ $1 -eq 1 ] ; then
182
+ <%= get_postremove_actions("upgrade") %>
183
+ fi
184
+
185
+ # Run post-uninstall scripts on removal if defined
186
+ if [ $1 -eq 0 ] ; then
187
+ <%= get_postremove_actions("removal") %>
188
+ fi
189
+
156
190
  <%- get_services.each do |service| -%>
157
191
  # switch based on systemd vs systemv vs smf vs aix
158
192
  #
@@ -174,7 +208,18 @@ done
174
208
  <%- end -%>
175
209
  <%- end -%>
176
210
 
211
+
177
212
  %preun
213
+ # Run pre-uninstall scripts on upgrade if defined
214
+ if [ $1 -eq 1 ] ; then
215
+ <%= get_preremove_actions("upgrade") %>
216
+ fi
217
+
218
+ # Run pre-uninstall scripts on removal if defined
219
+ if [ $1 -eq 0 ] ; then
220
+ <%= get_preremove_actions("removal") %>
221
+ fi
222
+
178
223
  <%- get_services.each do |service| -%>
179
224
  <%- if @platform.servicetype == "systemd" -%>
180
225
  <%- if @platform.is_sles? -%>
@@ -192,15 +237,26 @@ done
192
237
  <%- end -%>
193
238
  <%- end -%>
194
239
 
240
+
195
241
  <%- unless @platform.is_aix? || (@platform.is_el? && @platform.os_version.to_i == 4) -%>
196
242
  %posttrans
197
- <%- get_postinstall_actions.each do |task| -%>
198
- <%= task %>
199
- <%- end -%>
243
+ # Run post-transaction scripts on install if defined
244
+ if [ -e %{_localstatedir}/lib/rpm-state/%{name}/install ] ; then
245
+ <%= get_postinstall_actions("install") %>
246
+ rm %{_localstatedir}/lib/rpm-state/%{name}/install
247
+ fi
248
+
249
+ # Run post-transaction scripts on upgrade if defined
250
+ if [ -e %{_localstatedir}/lib/rpm-state/%{name}/upgrade ] ; then
251
+ <%= get_postinstall_actions("upgrade") %>
252
+ rm %{_localstatedir}/lib/rpm-state/%{name}/upgrade
253
+ fi
200
254
  <%- end -%>
201
255
 
202
256
  %files -f %{SOURCE1}
257
+ <%- unless @bill_of_materials -%>
203
258
  %doc bill-of-materials
259
+ <%- end -%>
204
260
  %defattr(-, root, root, 0755)
205
261
  <%- get_directories.each do |dir| -%>
206
262
  %dir %attr(<%= dir.mode || "-" %>, <%= dir.owner || "-" %>, <%= dir.group || "-" %>) <%= dir.path %>
@@ -21,6 +21,18 @@ set name=variant.opensolaris.zone value=global value=nonglobal
21
21
  depend fmri=pkg:/<%= requirement %> type=require
22
22
  <%- end -%>
23
23
 
24
+ # Always drop /etc, /usr, and /var, it will cause conflicts with other system packages
25
+ <transform dir path=etc$ -> drop>
26
+ <transform dir path=usr$ -> drop>
27
+ <transform dir path=var$ -> drop>
28
+
29
+ # (CPR-251) In solaris 11, /var/run is a symlink to /system/volatile, which
30
+ # causes conflicts during package installation. To avoid this, we transform any
31
+ # directory under /var/run to repoint under /system/volatile and drop
32
+ # /system/volatile itself to avoid conflicts.
33
+ <transform dir -> edit path var/run system/volatile>
34
+ <transform dir path=system/volatile$ -> drop>
35
+
24
36
  <%- get_root_directories.each do |dir| -%>
25
37
  <transform dir path=<%= strip_and_escape(dir.split('/')[0..-2].join('/')) %>$ -> drop>
26
38
  <%- end -%>
@@ -35,8 +47,10 @@ depend fmri=pkg:/<%= requirement %> type=require
35
47
  set name=org.opensolaris.smf.fmri <%= get_services.map {|service| "value=svc:/#{service.name}"}.join(" ") %>
36
48
  <%- end -%>
37
49
 
50
+ <%- unless @bill_of_materials -%>
38
51
  # Move the bill-of-materials into a docdir for the package to avoid conflicts
39
52
  <transform file path=bill-of-materials$ -> set path usr/share/doc/<%= @name %>/bill-of-materials>
53
+ <%- end -%>
40
54
 
41
55
  <%- get_configfiles.each do |config| -%>
42
56
  # Preserve the old conf file on upgrade
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.3.19
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet Labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-16 00:00:00.000000000 Z
11
+ date: 2015-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -77,6 +77,8 @@ files:
77
77
  - lib/vanagon/platform/dsl.rb
78
78
  - lib/vanagon/platform/osx.rb
79
79
  - lib/vanagon/platform/rpm.rb
80
+ - lib/vanagon/platform/rpm/aix.rb
81
+ - lib/vanagon/platform/rpm/sles.rb
80
82
  - lib/vanagon/platform/rpm/wrl.rb
81
83
  - lib/vanagon/platform/solaris_10.rb
82
84
  - lib/vanagon/platform/solaris_11.rb
@@ -99,6 +101,7 @@ files:
99
101
  - spec/lib/vanagon/engine/pooler_spec.rb
100
102
  - spec/lib/vanagon/platform/deb_spec.rb
101
103
  - spec/lib/vanagon/platform/dsl_spec.rb
104
+ - spec/lib/vanagon/platform/rpm/aix_spec.rb
102
105
  - spec/lib/vanagon/platform/rpm_spec.rb
103
106
  - spec/lib/vanagon/platform/solaris_11_spec.rb
104
107
  - spec/lib/vanagon/platform_spec.rb
@@ -114,6 +117,7 @@ files:
114
117
  - templates/deb/install.erb
115
118
  - templates/deb/postinst.erb
116
119
  - templates/deb/postrm.erb
120
+ - templates/deb/preinst.erb
117
121
  - templates/deb/prerm.erb
118
122
  - templates/deb/rules.erb
119
123
  - templates/osx/postinstall.erb
@@ -137,9 +141,9 @@ require_paths:
137
141
  - lib
138
142
  required_ruby_version: !ruby/object:Gem::Requirement
139
143
  requirements:
140
- - - ">="
144
+ - - "~>"
141
145
  - !ruby/object:Gem::Version
142
- version: '0'
146
+ version: 2.1.0
143
147
  required_rubygems_version: !ruby/object:Gem::Requirement
144
148
  requirements:
145
149
  - - ">="
@@ -147,9 +151,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
151
  version: '0'
148
152
  requirements: []
149
153
  rubyforge_project:
150
- rubygems_version: 2.4.5.1
154
+ rubygems_version: 2.4.5
151
155
  signing_key:
152
- specification_version: 4
156
+ specification_version: 3
153
157
  summary: All of your packages will fit into this van with this one simple trick.
154
158
  test_files:
155
159
  - spec/lib/vanagon/common/pathname_spec.rb
@@ -164,9 +168,11 @@ test_files:
164
168
  - spec/lib/vanagon/engine/pooler_spec.rb
165
169
  - spec/lib/vanagon/platform/deb_spec.rb
166
170
  - spec/lib/vanagon/platform/dsl_spec.rb
171
+ - spec/lib/vanagon/platform/rpm/aix_spec.rb
167
172
  - spec/lib/vanagon/platform/rpm_spec.rb
168
173
  - spec/lib/vanagon/platform/solaris_11_spec.rb
169
174
  - spec/lib/vanagon/platform_spec.rb
170
175
  - spec/lib/vanagon/project/dsl_spec.rb
171
176
  - spec/lib/vanagon/project_spec.rb
172
177
  - spec/lib/vanagon/utilities_spec.rb
178
+ has_rdoc: