vanagon 0.3.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +13 -0
  3. data/README.md +175 -0
  4. data/bin/build +33 -0
  5. data/bin/devkit +22 -0
  6. data/bin/repo +26 -0
  7. data/bin/ship +15 -0
  8. data/lib/vanagon.rb +8 -0
  9. data/lib/vanagon/common.rb +2 -0
  10. data/lib/vanagon/common/pathname.rb +87 -0
  11. data/lib/vanagon/common/user.rb +25 -0
  12. data/lib/vanagon/component.rb +157 -0
  13. data/lib/vanagon/component/dsl.rb +307 -0
  14. data/lib/vanagon/component/source.rb +66 -0
  15. data/lib/vanagon/component/source/git.rb +60 -0
  16. data/lib/vanagon/component/source/http.rb +158 -0
  17. data/lib/vanagon/driver.rb +112 -0
  18. data/lib/vanagon/engine/base.rb +82 -0
  19. data/lib/vanagon/engine/docker.rb +40 -0
  20. data/lib/vanagon/engine/local.rb +40 -0
  21. data/lib/vanagon/engine/pooler.rb +85 -0
  22. data/lib/vanagon/errors.rb +28 -0
  23. data/lib/vanagon/extensions/string.rb +11 -0
  24. data/lib/vanagon/optparse.rb +62 -0
  25. data/lib/vanagon/platform.rb +245 -0
  26. data/lib/vanagon/platform/deb.rb +71 -0
  27. data/lib/vanagon/platform/dsl.rb +293 -0
  28. data/lib/vanagon/platform/osx.rb +100 -0
  29. data/lib/vanagon/platform/rpm.rb +76 -0
  30. data/lib/vanagon/platform/rpm/wrl.rb +39 -0
  31. data/lib/vanagon/platform/solaris_10.rb +182 -0
  32. data/lib/vanagon/platform/solaris_11.rb +138 -0
  33. data/lib/vanagon/platform/swix.rb +35 -0
  34. data/lib/vanagon/project.rb +251 -0
  35. data/lib/vanagon/project/dsl.rb +218 -0
  36. data/lib/vanagon/utilities.rb +299 -0
  37. data/spec/fixures/component/invalid-test-fixture.json +3 -0
  38. data/spec/fixures/component/mcollective.service +1 -0
  39. data/spec/fixures/component/test-fixture.json +4 -0
  40. data/spec/lib/vanagon/common/pathname_spec.rb +103 -0
  41. data/spec/lib/vanagon/common/user_spec.rb +36 -0
  42. data/spec/lib/vanagon/component/dsl_spec.rb +443 -0
  43. data/spec/lib/vanagon/component/source/git_spec.rb +19 -0
  44. data/spec/lib/vanagon/component/source/http_spec.rb +43 -0
  45. data/spec/lib/vanagon/component/source_spec.rb +99 -0
  46. data/spec/lib/vanagon/component_spec.rb +22 -0
  47. data/spec/lib/vanagon/engine/base_spec.rb +40 -0
  48. data/spec/lib/vanagon/engine/docker_spec.rb +40 -0
  49. data/spec/lib/vanagon/engine/pooler_spec.rb +54 -0
  50. data/spec/lib/vanagon/platform/deb_spec.rb +60 -0
  51. data/spec/lib/vanagon/platform/dsl_spec.rb +128 -0
  52. data/spec/lib/vanagon/platform/rpm_spec.rb +41 -0
  53. data/spec/lib/vanagon/platform/solaris_11_spec.rb +44 -0
  54. data/spec/lib/vanagon/platform_spec.rb +53 -0
  55. data/spec/lib/vanagon/project/dsl_spec.rb +203 -0
  56. data/spec/lib/vanagon/project_spec.rb +44 -0
  57. data/spec/lib/vanagon/utilities_spec.rb +140 -0
  58. data/templates/Makefile.erb +116 -0
  59. data/templates/deb/changelog.erb +5 -0
  60. data/templates/deb/conffiles.erb +3 -0
  61. data/templates/deb/control.erb +21 -0
  62. data/templates/deb/dirs.erb +3 -0
  63. data/templates/deb/docs.erb +1 -0
  64. data/templates/deb/install.erb +3 -0
  65. data/templates/deb/postinst.erb +46 -0
  66. data/templates/deb/postrm.erb +15 -0
  67. data/templates/deb/prerm.erb +17 -0
  68. data/templates/deb/rules.erb +25 -0
  69. data/templates/osx/postinstall.erb +24 -0
  70. data/templates/osx/preinstall.erb +19 -0
  71. data/templates/osx/project-installer.xml.erb +19 -0
  72. data/templates/rpm/project.spec.erb +217 -0
  73. data/templates/solaris/10/depend.erb +3 -0
  74. data/templates/solaris/10/pkginfo.erb +13 -0
  75. data/templates/solaris/10/postinstall.erb +37 -0
  76. data/templates/solaris/10/preinstall.erb +7 -0
  77. data/templates/solaris/10/preremove.erb +6 -0
  78. data/templates/solaris/10/proto.erb +5 -0
  79. data/templates/solaris/11/p5m.erb +73 -0
  80. metadata +172 -0
@@ -0,0 +1,116 @@
1
+ <% dirnames = get_directories.map {|d| d.path } %>
2
+ export SHELL := $(shell which bash)
3
+
4
+ tempdir := $(shell mktemp -d -p /var/tmp 2>/dev/null || mktemp -d -t 'tmp')
5
+ workdir := $(PWD)
6
+
7
+ all: <%= package_name %>
8
+
9
+ <%= package_name %>: <%= @name %>-<%= @version %>.tar.gz
10
+ <%= generate_package.join("\n\t") %>
11
+
12
+ file-list-before-build:
13
+ <%- if dirnames.empty? -%>
14
+ touch file-list-before-build
15
+ <%- else -%>
16
+ (find -L <%= dirnames.join(' ') %> 2>/dev/null || find <%= dirnames.join(' ') %> -follow) | sort | uniq > file-list-before-build
17
+ <%- end -%>
18
+
19
+ file-list-after-build: <%= @components.map {|comp| comp.name }.join(" ") %>
20
+ <%- if dirnames.empty? -%>
21
+ touch file-list-after-build
22
+ <%- else -%>
23
+ (find -L <%= dirnames.join(' ') %> 2>/dev/null || find <%= dirnames.join(' ') %> -follow) | sort | uniq > file-list-after-build
24
+ <%- end -%>
25
+
26
+ <%= @name %>-<%= @version %>.tar.gz: file-list <%= @cleanup ? 'cleanup-components' : '' %>
27
+ <%= pack_tarball_command %>
28
+
29
+ file-list: <%= dirnames.join(' ') %> <%= @name %>-project <%= @version_file ? @version_file.path : '' %>
30
+ comm -23 file-list-after-build file-list-before-build > file-list
31
+ comm -23 file-list-after-build file-list-before-build | sed -e 's/\(^.*[[:space:]].*$$\)/"\1"/g' > file-list-for-rpm
32
+
33
+ <%- if @version_file -%>
34
+ <%= @version_file.path %>:
35
+ echo <%= @version %> > '<%= @version_file.path %>'
36
+ <%- end -%>
37
+
38
+ <%- dirnames.each do |dir| -%>
39
+ <%= dir %>:
40
+ mkdir -p <%= dir %>
41
+ <%- end %>
42
+
43
+ <%- if @cleanup -%>
44
+ cleanup-components: <%= @components.map {|comp| "#{comp.name}-cleanup" }.join(" ") %>
45
+ touch cleanup-components
46
+ <%- end -%>
47
+
48
+ <%= @name %>-project: file-list-after-build
49
+ touch <%= @name %>-project
50
+
51
+ <%- @components.each do |comp| -%>
52
+ <%= comp.name %>: <%= comp.name %>-install
53
+
54
+ <%- if @cleanup -%>
55
+ <%= comp.name %>-cleanup: <%= comp.name %>-install
56
+ <%= comp.cleanup_source %>
57
+ touch <%= comp.name %>-cleanup
58
+ <%- end -%>
59
+
60
+ <%= comp.name %>-unpack: file-list-before-build
61
+ <%= comp.extract_with %>
62
+ touch <%= comp.name %>-unpack
63
+
64
+ <%= comp.name %>-patch: <%= comp.name %>-unpack
65
+ <%- unless comp.patches.empty? -%>
66
+ cd <%= comp.dirname %> && \
67
+ <%- comp.patches.each do |patch| -%>
68
+ <%= @platform.patch %> --strip=<%= patch.strip %> --fuzz=<%= patch.fuzz %> --ignore-whitespace < ../patches/<%= File.basename(patch.path) %> && \
69
+ <%- end -%>
70
+ :
71
+ <%- end -%>
72
+
73
+ touch <%= comp.name %>-patch
74
+
75
+ <%= comp.name %>-configure: <%= comp.name %>-patch <%= list_component_dependencies(comp).join(" ") %>
76
+ <%- unless comp.configure.empty? -%>
77
+ cd <%= comp.dirname %> && \
78
+ <%= comp.get_environment %> && \
79
+ <%= comp.configure.join(" && \\\n\t") %>
80
+ <%- end -%>
81
+ touch <%= comp.name %>-configure
82
+
83
+ <%= comp.name %>-build: <%= comp.name %>-configure
84
+ <%- unless comp.build.empty? -%>
85
+ cd <%= comp.dirname %> && \
86
+ <%= comp.get_environment %> && \
87
+ <%= comp.build.join(" && \\\n\t") %>
88
+ <%- end -%>
89
+ touch <%= comp.name %>-build
90
+
91
+ <%= comp.name %>-install: <%= comp.name %>-build
92
+ <%- unless comp.install.empty? -%>
93
+ cd <%= comp.dirname %> && \
94
+ <%= comp.get_environment %> && \
95
+ <%= comp.install.join(" && \\\n\t") %>
96
+ <%- end -%>
97
+ touch <%= comp.name %>-install
98
+
99
+ <%= comp.name %>-clean:
100
+ [ -d <%= comp.dirname %> ] && cd <%= comp.dirname %> && \
101
+ <%= @platform[:make] %> clean
102
+ <%- ["configure", "build", "install"].each do |type| -%>
103
+ [ -e <%= comp.name %>-<%= type %> ] && rm <%= comp.name %>-<%= type %>
104
+ <%- end -%>
105
+
106
+ <%= comp.name %>-clobber: <%= comp.name %>-clean
107
+ [ -d <%= comp.dirname %> ] && rm -r <%= comp.dirname %>
108
+ [ -e <%= comp.name %>-unpack ] && rm <%= comp.name %>-unpack
109
+
110
+ <%- end -%>
111
+
112
+ clean: <%= @components.map {|comp| "#{comp.name}-clean" }.join(" ") %>
113
+
114
+ clobber: <%= @components.map {|comp| "#{comp.name}-clobber" }.join(" ") %>
115
+
116
+ .PHONY: clean clobber <%= @components.map {|comp| "#{comp.name}-clean #{comp.name}-clobber" }.join(" ") %>
@@ -0,0 +1,5 @@
1
+ <%= @name %> (<%= @version %>-<%= @release %><%= @platform.codename %>) <%= @platform.codename %>; urgency=low
2
+
3
+ * Update to version <%= @version %>
4
+
5
+ -- <%= @vendor %> <%= Time.now.strftime("%a, %d %b %Y %H:%M:%S %z")%>
@@ -0,0 +1,3 @@
1
+ <%- get_configfiles.map {|file| file.path }.reject {|conf| conf.match(/^\/etc\//) }.each do |configfile| -%>
2
+ <%= configfile %>
3
+ <%- end -%>
@@ -0,0 +1,21 @@
1
+ Source: <%= @name %>
2
+ Maintainer: <%= @vendor %>
3
+ Section: admin
4
+ Priority: optional
5
+ Build-Depends: debhelper (>= 7.0.0)
6
+ Standards-Version: 3.9.1
7
+ Homepage: <%= @homepage %>
8
+
9
+ Package: <%= @name %>
10
+ Architecture: <%= @noarch ? 'all' : 'any' %>
11
+ Section: admin
12
+ Priority: optional
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(", ") %>
15
+ Depends: <%= get_requires.join(", ") %>
16
+ Provides: <%= get_provides.map { |prov| prov.provide }.join(", ") %>
17
+ Description: <%= @description.lines.first.chomp %>
18
+ <%= @description.lines[1..-1].join("\n\s") -%>
19
+ .
20
+ Contains the following components:
21
+ <%= generate_bill_of_materials.join("\n\s") %>
@@ -0,0 +1,3 @@
1
+ <%- get_directories.map {|d| d.path.sub(/^\//,'')}.each do |dir| -%>
2
+ <%= dir %>
3
+ <%- end -%>
@@ -0,0 +1 @@
1
+ bill-of-materials
@@ -0,0 +1,3 @@
1
+ <%- (get_files + get_configfiles).map {|f| f.path.sub(/^\//,'')}.each do |file| -%>
2
+ <%= file %>
3
+ <%- end -%>
@@ -0,0 +1,46 @@
1
+ #!/bin/bash
2
+
3
+ <%- get_services.each do |service| -%>
4
+ # switch based on systemd vs systemv
5
+ #
6
+ <%- if @platform.servicetype == "systemd" -%>
7
+ if [ -z "$2" ]; then
8
+ systemctl enable <%= service.name %>.service >/dev/null || :
9
+ else
10
+ systemctl try-restart <%= service.name %>.service >/dev/null || :
11
+ fi
12
+ <%- elsif @platform.servicetype == "sysv" -%>
13
+ if [ -x "<%= service.service_file %>" ]; then
14
+ update-rc.d <%= service.name %> defaults > /dev/null
15
+
16
+ if [ -n "$2" ]; then
17
+ invoke-rc.d <%= service.name %> condrestart || true
18
+ fi
19
+ fi
20
+ <%- end -%>
21
+ <%- end -%>
22
+
23
+ <%- if @user -%>
24
+ # Add our user and group
25
+ <%= @platform.add_group(@user) %>
26
+ <%= @platform.add_user(@user) %>
27
+ <%- end -%>
28
+
29
+ # Set up any specific permissions needed...
30
+ <%- (get_directories + get_configfiles + get_files).select { |pathname| pathname.has_overrides? }.uniq.each do |file_or_directory| -%>
31
+ <%= "chmod '#{file_or_directory.mode}' '#{file_or_directory.path}'" if file_or_directory.mode %>
32
+ <%- if file_or_directory.owner -%>
33
+ if getent passwd '<%= file_or_directory.owner %>' &> /dev/null; then
34
+ chown '<%= file_or_directory.owner %>' '<%= file_or_directory.path %>'
35
+ else
36
+ echo "Error updating '<%= file_or_directory.path %>': user '<%= file_or_directory.owner %>' does not exist."
37
+ fi
38
+ <%- end -%>
39
+ <%- if file_or_directory.group -%>
40
+ if getent group '<%= file_or_directory.group %>' &> /dev/null; then
41
+ chgrp '<%= file_or_directory.group %>' '<%= file_or_directory.path %>'
42
+ else
43
+ echo "Error updating '<%= file_or_directory.path %>': group '<%= file_or_directory.group %>' does not exist."
44
+ fi
45
+ <%- end -%>
46
+ <%- end -%>
@@ -0,0 +1,15 @@
1
+ #!/bin/bash
2
+
3
+ <%- get_services.each do |service| -%>
4
+ # switch based on systemd vs systemv
5
+ #
6
+ <%- if @platform.servicetype == "systemd" -%>
7
+ systemctl daemon-reload >/dev/null 2>&1 || :
8
+ <%- elsif @platform.servicetype == "sysv" -%>
9
+ if [ "$1" = "purge" ] ; then
10
+ update-rc.d <%= service.name %> remove > /dev/null
11
+ fi
12
+ <%- end -%>
13
+ <%- end -%>
14
+
15
+
@@ -0,0 +1,17 @@
1
+ #!/bin/bash
2
+
3
+ <%- get_services.each do |service| -%>
4
+ # switch based on systemd vs systemv
5
+ #
6
+ <%- if @platform.servicetype == "systemd" -%>
7
+ if [ "$1" = remove ]; then
8
+ systemctl --no-reload disable <%= service.name %>.service > /dev/null 2>&1 || :
9
+ systemctl stop <%= service.name %>.service > /dev/null 2>&1 || :
10
+ fi
11
+
12
+ <%- elsif @platform.servicetype == "sysv" -%>
13
+ if [ -x "<%= service.service_file %>" ] && [ "$1" = remove ]; then
14
+ invoke-rc.d <%= service.name %> stop || true
15
+ fi
16
+ <%- end -%>
17
+ <%- end -%>
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/make -f
2
+ # Uncomment this to turn on verbose mode.
3
+ #export DH_VERBOSE=1
4
+
5
+ override_dh_auto_install:
6
+ install -d debian/tmp
7
+ # Copy each directory into place
8
+ <%- get_directories.map {|d| d.path.sub(/^\//,'')}.each do |dir| -%>
9
+ if [ -d <%= dir %> ]; then \
10
+ install -d debian/tmp/<%= File.dirname(dir) %>; \
11
+ cp -pr <%= dir %> debian/tmp/<%= File.dirname(dir) %>; \
12
+ else \
13
+ install -d debian/tmp/<%= dir %>; \
14
+ fi
15
+ <%- end -%>
16
+ # Copy each of the extra files into place
17
+ <%- get_files.map {|f| f.path.sub(/^\//,'')}.each do |file| -%>
18
+ install -d debian/tmp/<%= File.dirname(file) %>
19
+ cp -p <%= file %> debian/tmp/<%= File.dirname(file) %>
20
+ <%- end -%>
21
+
22
+ override_dh_shlibdeps:
23
+
24
+ %:
25
+ dh $@
@@ -0,0 +1,24 @@
1
+ #!/bin/bash
2
+
3
+ foundpkg=`/usr/sbin/pkgutil --volume "$3" --pkgs=<%= @identifier-%>.<%= @name -%>`
4
+
5
+ # Move any new configfiles into place
6
+ <%- get_configfiles.each do |config|
7
+ dest_file = config.path.gsub(/\.pristine$/, '') -%>
8
+
9
+ if [ -f "<%= dest_file %>" ]; then
10
+ echo "Detected file at '<%= dest_file %>'; updated file at '<%= config.path %>'."
11
+ else
12
+ mv '<%= config.path %>' '<%= dest_file %>'
13
+ fi
14
+ <%- end -%>
15
+
16
+ # If we appear to be in an upgrade load services.
17
+
18
+ if [ -n "$foundpkg" ]; then
19
+ <%- get_services.each do |service| -%>
20
+ /bin/launchctl load -F "<%= service.service_file %>"
21
+ <%- end -%>
22
+ fi
23
+
24
+ <%= File.read("resources/osx/postinstall-extras") if File.exist?("resources/osx/postinstall-extras") %>
@@ -0,0 +1,19 @@
1
+ #!/bin/bash
2
+
3
+ # If we appear to be in an upgrade unload services.
4
+
5
+ foundpkg=`/usr/sbin/pkgutil --volume "$3" --pkgs=<%= @identifier-%>.<%= @name -%>`
6
+ oldbom="/usr/share/doc/<%= @name %>/bill-of-materials"
7
+
8
+ if [ -n "$foundpkg" ]; then
9
+ <%- get_services.each do |service| -%>
10
+ if /bin/launchctl list "<%= service.name %>" &> /dev/null; then
11
+ /bin/launchctl unload "<%= service.service_file %>"
12
+ fi
13
+ if [ -f "$oldbom"]; then
14
+ /bin/rm "$oldbom"
15
+ fi
16
+ <%- end -%>
17
+ fi
18
+
19
+ <%= File.read("resources/osx/preinstall-extras") if File.exist?("resources/osx/preinstall-extras") %>
@@ -0,0 +1,19 @@
1
+ <installer-gui-script minSpecVersion="2">
2
+ <title><%= @name -%></title>
3
+ <background file="<%= @name -%>-Background.png" alignment="left" scaling="proportional"/>
4
+ <welcome file="<%= @name -%>-Welcome.rtf"/>
5
+ <license file="<%= @name -%>-License.rtf"/>
6
+ <domains enable_anywhere="true" enable_currentUserHome="false" enable_localSystem="true" />
7
+ <pkg-ref id="<%= @identifier-%>.<%= @name -%>"/>
8
+ <options customize="never" hostArchitectures="i386" require-scripts="false"/>
9
+ <choices-outline>
10
+ <line choice="default">
11
+ <line choice="<%= @identifier-%>.<%= @name -%>"/>
12
+ </line>
13
+ </choices-outline>
14
+ <choice id="default"/>
15
+ <choice id="<%= @identifier-%>.<%= @name -%>" visible="false">
16
+ <pkg-ref id="<%= @identifier-%>.<%= @name -%>"/>
17
+ </choice>
18
+ <pkg-ref id="<%= @identifier-%>.<%= @name -%>" version="<%= @version -%>" onConclusion="none"><%= @name -%>-<%= @version -%>-<%= @release -%>.pkg</pkg-ref>
19
+ </installer-gui-script>
@@ -0,0 +1,217 @@
1
+ %global debug_package %{nil}
2
+
3
+ # Turn off the brp-python-bytecompile script
4
+ %global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g')
5
+ #
6
+
7
+ Name: <%= @name %>
8
+ Version: <%= @version %>
9
+ Release: <%= @release %>%{?dist}
10
+ Summary: <%= @description.lines.first.chomp %>
11
+ Vendor: <%= @vendor.match(/^(.*) <.*>$/)[1] %>
12
+ License: <%= @license %>
13
+ Group: System Environment/Base
14
+ URL: <%= @homepage %>
15
+
16
+ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
17
+ <% if @noarch -%>
18
+ BuildArch: noarch
19
+ <% end -%>
20
+
21
+ Source0: %{name}-%{version}.tar.gz
22
+ Source1: file-list-for-rpm
23
+
24
+ # Don't provide anything so the system doesn't use our packages to resolve deps
25
+ Autoprov: 0
26
+ Autoreq: 0
27
+ <%- get_requires.each do |requires| -%>
28
+ Requires: <%= requires %>
29
+ <%- end -%>
30
+ <%- if has_services? -%>
31
+ <%- if @platform.servicetype == "systemd" -%>
32
+ <%- if @platform.is_sles? -%>
33
+ BuildRequires: systemd
34
+ %{?systemd_requires}
35
+ <%- else -%>
36
+ BuildRequires: systemd
37
+ Requires(post): systemd
38
+ Requires(preun): systemd
39
+ Requires(postun): systemd
40
+ <%- end -%>
41
+ <%- elsif @platform.servicetype == "sysv" -%>
42
+ <%- if @platform.is_sles? -%>
43
+ Requires: aaa_base
44
+ <%- elsif @platform.is_linux? -%>
45
+ Requires: chkconfig
46
+ <%- end -%>
47
+ <%- end -%>
48
+ <%- end -%>
49
+
50
+ <%- get_replaces.each do |replace| -%>
51
+ Conflicts: <%= replace.replacement %><%= replace.version ? " < #{replace.version}" : "" %>
52
+ Obsoletes: <%= replace.replacement %><%= replace.version ? " < #{replace.version}" : "" %>
53
+ <%- end -%>
54
+
55
+ <%- get_provides.each do |prov| -%>
56
+ Provides: <%= prov.provide %><%= prov.version ? " >= #{prov.version}" : "" %>
57
+ <%- end -%>
58
+
59
+ %description
60
+ <%= @description %>
61
+
62
+ Contains the following components:
63
+ <%= generate_bill_of_materials.join("\n") %>
64
+
65
+ %prep
66
+ %setup -q -n %{name}-%{version}
67
+
68
+ %build
69
+
70
+ %clean
71
+
72
+ %install
73
+ test -d /opt/freeware/bin && export PATH="/opt/freeware/bin:${PATH}"
74
+ rm -rf %{buildroot}
75
+ install -d %{buildroot}
76
+
77
+ # Copy each directory into place. Because empty directories won't make it into.
78
+ <%- get_directories.map {|d| d.path.sub(/^\//,'')}.each do |dir| -%>
79
+ if [ -d <%= dir %> ]; then
80
+ install -d %{buildroot}/<%= File.dirname(dir) %>
81
+ cp -pr <%= dir %> %{buildroot}/<%= File.dirname(dir) %>
82
+ else
83
+ install -d %{buildroot}/<%= dir %>
84
+ fi
85
+ <%- end -%>
86
+
87
+ # Copy each of the extra files into place
88
+ <%- (get_files + get_configfiles).map {|f| f.path.sub(/^\//,'')}.each do |file| -%>
89
+ install -d %{buildroot}/<%= File.dirname(file) %>
90
+ cp -p <%= file %> %{buildroot}/<%= File.dirname(file) %>
91
+ <%- end -%>
92
+
93
+ <%- if @platform.is_cisco_wrlinux? || @platform.is_huaweios? -%>
94
+ # Generate a list of directories and append it to the file list. RPMv4
95
+ # automatically does this implicitly, but RPMv5 is more strict and you
96
+ # need to list the dirs for them to be packaged properly.
97
+ <%- get_directories.map {|d| "%{buildroot}#{d.path}"}.each do |dir| -%>
98
+ find <%= dir %> -type d | sed -e "s#%{buildroot}##" | sed -e 's/\(^.*\s.*$\)/"\1"/g' >> dir-list-rpm
99
+ <%- end -%>
100
+ cat dir-list-rpm | sort | uniq >> %{SOURCE1}
101
+ <%- end -%>
102
+
103
+ # Here we explicitly remove the directories and files that we list in the
104
+ # %files section separately because rpm3 on aix errors on duplicate files in
105
+ # the package.
106
+ <%- (get_directories + get_files + get_configfiles).map do |filething| -%>
107
+ PATH=/opt/freeware/bin:$PATH sed -i 's|^<%= filething.path.include?(" ") ? %Q["#{filething.path}"] : filething.path %>$||g' %{SOURCE1}
108
+ <%- end -%>
109
+
110
+ # Here we turn all dirs in the file-list into %dir entries to avoid duplicate files
111
+ for entry in `cat %{SOURCE1}`; do
112
+ if [ -n "$entry" -a -d "$entry" ]; then
113
+ PATH=/opt/freeware/bin:$PATH sed -i "s|^\($entry\)\$|%dir \1|g" %{SOURCE1}
114
+ fi
115
+ done
116
+
117
+ %pre
118
+ <%- get_preinstall_actions.each do |task| -%>
119
+ <%= task %>
120
+ <%- end -%>
121
+
122
+ <%- if @user -%>
123
+ # Add our user and group
124
+ <%= @platform.add_group(@user) %>
125
+ <%= @platform.add_user(@user) %>
126
+ <%- end -%>
127
+
128
+ %post
129
+ <%- 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 -%>
134
+ <%- end -%>
135
+ <%- get_services.each do |service| -%>
136
+ # switch based on systemd vs systemv vs smf vs aix
137
+ #
138
+ <%- if @platform.servicetype == "systemd" -%>
139
+ <%- if @platform.is_sles? -%>
140
+ %service_add_post <%= service.name %>.service
141
+ <%- else -%>
142
+ %systemd_post <%= service.name %>.service
143
+ <%- end -%>
144
+ <%- elsif @platform.servicetype == "sysv" -%>
145
+ chkconfig --add <%= service.name %> >/dev/null 2>&1 || :
146
+ <%- elsif @platform.servicetype == "aix" -%>
147
+ /usr/bin/mkssys -p <%= service.service_command -%> -w 7 -S -n 15 -f 9 > /dev/null 2>&1 || :
148
+ if /bin/grep -q "^<%= service.name -%>:2:once:startsrc$" /etc/inittab; then
149
+ /usr/sbin/rmitab <%= service.name -%> > /dev/null 2>&1 || :
150
+ fi
151
+ /usr/sbin/mkitab "<%= service.name -%>:2:once:/usr/bin/startsrc -s <%= service.name -%>" > /dev/null 2>&1 || :
152
+ <%- end -%>
153
+ <%- end -%>
154
+
155
+ %postun
156
+ <%- get_services.each do |service| -%>
157
+ # switch based on systemd vs systemv vs smf vs aix
158
+ #
159
+ <%- if @platform.servicetype == "systemd" -%>
160
+ <%- if @platform.is_sles? -%>
161
+ %service_del_postun <%= service.name %>.service
162
+ <%- else -%>
163
+ %systemd_postun_with_restart <%= service.name %>.service
164
+ <%- end -%>
165
+ <%- elsif @platform.servicetype == "sysv" -%>
166
+ if [ $1 -ge 1 ]; then
167
+ /sbin/service <%= service.name %> condrestart || :
168
+ fi
169
+ <%- elsif @platform.servicetype == "aix" -%>
170
+ if [ $1 -eq 0 ]; then
171
+ /usr/bin/rmssys -s <%= service.name -%> > /dev/null 2>&1 || :
172
+ /usr/sbin/rmitab <%= service.name -%> > /dev/null 2>&1 || :
173
+ fi
174
+ <%- end -%>
175
+ <%- end -%>
176
+
177
+ %preun
178
+ <%- get_services.each do |service| -%>
179
+ <%- if @platform.servicetype == "systemd" -%>
180
+ <%- if @platform.is_sles? -%>
181
+ %service_del_preun <%= service.name %>.service
182
+ <%- else -%>
183
+ %systemd_preun <%= service.name %>.service
184
+ <%- end -%>
185
+ <%- elsif @platform.servicetype == "sysv" -%>
186
+ if [ $1 = 0 ]; then
187
+ /sbin/service <%= service.name %> stop >/dev/null 2>&1 || :
188
+ chkconfig --del <%= service.name %> || :
189
+ fi
190
+ <%- elsif @platform.servicetype == "aix" -%>
191
+ /usr/bin/stopsrc -s <%= service.name -%> > /dev/null 2>&1 || :
192
+ <%- end -%>
193
+ <%- end -%>
194
+
195
+ <%- unless @platform.is_aix? || (@platform.is_el? && @platform.os_version.to_i == 4) -%>
196
+ %posttrans
197
+ <%- get_postinstall_actions.each do |task| -%>
198
+ <%= task %>
199
+ <%- end -%>
200
+ <%- end -%>
201
+
202
+ %files -f %{SOURCE1}
203
+ %doc bill-of-materials
204
+ %defattr(-, root, root, 0755)
205
+ <%- get_directories.each do |dir| -%>
206
+ %dir %attr(<%= dir.mode || "-" %>, <%= dir.owner || "-" %>, <%= dir.group || "-" %>) <%= dir.path %>
207
+ <%- end -%>
208
+ <%- get_configfiles.each do |configfile| -%>
209
+ %config(noreplace) %attr(<%= configfile.mode || "-" %>, <%= configfile.owner || "-" %>, <%= configfile.group || "-" %>) <%= configfile.path %>
210
+ <%- end -%>
211
+ <%- get_files.each do |file| -%>
212
+ %attr(<%= file.mode || "-" %>, <%= file.owner || "-" %>, <%= file.group || "-" %>) <%= file.path %>
213
+ <%- end -%>
214
+
215
+ %changelog
216
+ * <%= Time.now.strftime("%a %b %d %Y") %> <%= @vendor %> - <%= @version %>-<%= @release %>
217
+ - Build for <%= @version %>-<%= @release %>