fpm-itchio 1.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.
- checksums.yaml +7 -0
- data/CHANGELIST +629 -0
- data/CONTRIBUTORS +26 -0
- data/LICENSE +21 -0
- data/bin/fpm +8 -0
- data/lib/fpm.rb +18 -0
- data/lib/fpm/command.rb +642 -0
- data/lib/fpm/errors.rb +4 -0
- data/lib/fpm/namespace.rb +4 -0
- data/lib/fpm/package.rb +524 -0
- data/lib/fpm/package/cpan.rb +378 -0
- data/lib/fpm/package/deb.rb +887 -0
- data/lib/fpm/package/dir.rb +207 -0
- data/lib/fpm/package/empty.rb +13 -0
- data/lib/fpm/package/gem.rb +224 -0
- data/lib/fpm/package/npm.rb +120 -0
- data/lib/fpm/package/osxpkg.rb +164 -0
- data/lib/fpm/package/p5p.rb +124 -0
- data/lib/fpm/package/pacman.rb +397 -0
- data/lib/fpm/package/pear.rb +117 -0
- data/lib/fpm/package/pkgin.rb +35 -0
- data/lib/fpm/package/puppet.rb +120 -0
- data/lib/fpm/package/pyfpm/__init__.py +1 -0
- data/lib/fpm/package/pyfpm/get_metadata.py +104 -0
- data/lib/fpm/package/python.rb +317 -0
- data/lib/fpm/package/rpm.rb +583 -0
- data/lib/fpm/package/sh.rb +69 -0
- data/lib/fpm/package/solaris.rb +95 -0
- data/lib/fpm/package/tar.rb +74 -0
- data/lib/fpm/package/virtualenv.rb +145 -0
- data/lib/fpm/package/zip.rb +63 -0
- data/lib/fpm/rake_task.rb +59 -0
- data/lib/fpm/util.rb +253 -0
- data/lib/fpm/version.rb +3 -0
- data/templates/deb.erb +52 -0
- data/templates/deb/changelog.erb +5 -0
- data/templates/deb/ldconfig.sh.erb +13 -0
- data/templates/deb/postinst_upgrade.sh.erb +62 -0
- data/templates/deb/postrm_upgrade.sh.erb +46 -0
- data/templates/deb/preinst_upgrade.sh.erb +41 -0
- data/templates/deb/prerm_upgrade.sh.erb +39 -0
- data/templates/osxpkg.erb +11 -0
- data/templates/p5p_metadata.erb +12 -0
- data/templates/pacman.erb +47 -0
- data/templates/pacman/INSTALL.erb +41 -0
- data/templates/puppet/package.pp.erb +34 -0
- data/templates/puppet/package/remove.pp.erb +13 -0
- data/templates/rpm.erb +261 -0
- data/templates/rpm/filesystem_list +14514 -0
- data/templates/sh.erb +367 -0
- data/templates/solaris.erb +15 -0
- metadata +265 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
after_remove() {
|
3
|
+
<%# Making sure that at least one command is in the function -%>
|
4
|
+
<%# avoids a lot of potential errors, including the case that -%>
|
5
|
+
<%# the script is non-empty, but just whitespace and/or comments -%>
|
6
|
+
:
|
7
|
+
<% if script?(:after_remove) -%>
|
8
|
+
<%= script(:after_remove) %>
|
9
|
+
<% end -%>
|
10
|
+
}
|
11
|
+
|
12
|
+
dummy() {
|
13
|
+
:
|
14
|
+
}
|
15
|
+
|
16
|
+
|
17
|
+
if [ "${1}" = "remove" -o "${1}" = "abort-install" ]
|
18
|
+
then
|
19
|
+
# "after remove" goes here
|
20
|
+
# "abort-install" happens when the pre-installation script failed.
|
21
|
+
# In that case, this script, which should be idemptoent, is run
|
22
|
+
# to ensure a clean roll-back of the installation.
|
23
|
+
after_remove
|
24
|
+
elif [ "${1}" = "purge" -a -z "${2}" ]
|
25
|
+
then
|
26
|
+
# like "on remove", but executes after dpkg deletes config files
|
27
|
+
# 'apt-get purge' runs 'on remove' section, then this section.
|
28
|
+
# Maybe we ignore this; it seems really fine-grained.
|
29
|
+
# There is no equivalent in RPM or ARCH. A debian-specific argument
|
30
|
+
# might perhaps be used here, but most people
|
31
|
+
# probably don't need it.
|
32
|
+
dummy
|
33
|
+
elif [ "${1}" = "upgrade" ]
|
34
|
+
then
|
35
|
+
# This represents the case where the old package's postrm is called after
|
36
|
+
# the 'preinst' script is called.
|
37
|
+
# We should ignore this and just use 'preinst upgrade' and
|
38
|
+
# 'postinst configure'. The newly installed package should do the
|
39
|
+
# upgrade, not the uninstalled one, since it can't anticipate what new
|
40
|
+
# things it will have to do to upgrade for the new version.
|
41
|
+
dummy
|
42
|
+
elif echo "${1}" | grep -E -q '(fail|abort)'
|
43
|
+
then
|
44
|
+
echo "Failed to install before the post-removal script was run." >&2
|
45
|
+
exit 1
|
46
|
+
fi
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
before_upgrade() {
|
3
|
+
<%# Making sure that at least one command is in the function -%>
|
4
|
+
<%# avoids a lot of potential errors, including the case that -%>
|
5
|
+
<%# the script is non-empty, but just whitespace and/or comments -%>
|
6
|
+
:
|
7
|
+
<% if script?(:before_upgrade) -%>
|
8
|
+
<%= script(:before_upgrade) %>
|
9
|
+
<% end -%>
|
10
|
+
}
|
11
|
+
|
12
|
+
before_install() {
|
13
|
+
<%# Making sure that at least one command is in the function -%>
|
14
|
+
<%# avoids a lot of potential errors, including the case that -%>
|
15
|
+
<%# the script is non-empty, but just whitespace and/or comments -%>
|
16
|
+
:
|
17
|
+
<% if script?(:before_install) -%>
|
18
|
+
<%= script(:before_install) %>
|
19
|
+
<% end -%>
|
20
|
+
}
|
21
|
+
|
22
|
+
if [ "${1}" = "install" -a -z "${2}" ]
|
23
|
+
then
|
24
|
+
before_install
|
25
|
+
elif [ "${1}" = "upgrade" -a -n "${2}" ]
|
26
|
+
then
|
27
|
+
upgradeFromVersion="${2}"
|
28
|
+
before_upgrade "${upgradeFromVersion}"
|
29
|
+
elif [ "${1}" = "install" -a -n "${2}" ]
|
30
|
+
then
|
31
|
+
upgradeFromVersion="${2}"
|
32
|
+
# Executed when a package is removed but its config files aren't,
|
33
|
+
# and a new version is installed.
|
34
|
+
# Looks a _lot_ like an upgrade case, I say we just execute the
|
35
|
+
# same "before upgrade" script as in the previous case
|
36
|
+
before_upgrade "${upgradeFromVersion}"
|
37
|
+
elif echo "${1}" | grep -E -q '(fail|abort)'
|
38
|
+
then
|
39
|
+
echo "Failed to install before the pre-installation script was run." >&2
|
40
|
+
exit 1
|
41
|
+
fi
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
before_remove() {
|
3
|
+
<%# Making sure that at least one command is in the function -%>
|
4
|
+
<%# avoids a lot of potential errors, including the case that -%>
|
5
|
+
<%# the script is non-empty, but just whitespace and/or comments -%>
|
6
|
+
:
|
7
|
+
<% if script?(:before_remove) -%>
|
8
|
+
<%= script(:before_remove) %>
|
9
|
+
<% end -%>
|
10
|
+
|
11
|
+
<%# Removing the systemd service-%>
|
12
|
+
<% if attributes[:deb_systemd] -%>
|
13
|
+
systemctl stop <%= attributes[:deb_systemd] %> >/dev/null || true
|
14
|
+
systemctl disable <%= attributes[:deb_systemd] %> >/dev/null || true
|
15
|
+
systemctl --system daemon-reload >/dev/null || true
|
16
|
+
<% end -%>
|
17
|
+
}
|
18
|
+
|
19
|
+
dummy() {
|
20
|
+
:
|
21
|
+
}
|
22
|
+
|
23
|
+
if [ "${1}" = "remove" -a -z "${2}" ]
|
24
|
+
then
|
25
|
+
# "before remove" goes here
|
26
|
+
before_remove
|
27
|
+
elif [ "${1}" = "upgrade" ]
|
28
|
+
then
|
29
|
+
# Executed before the old version is removed
|
30
|
+
# upon upgrade.
|
31
|
+
# We should generally not do anything here. The newly installed package
|
32
|
+
# should do the upgrade, not the uninstalled one, since it can't anticipate
|
33
|
+
# what new things it will have to do to upgrade for the new version.
|
34
|
+
dummy
|
35
|
+
elif echo "${1}" | grep -E -q "(fail|abort)"
|
36
|
+
then
|
37
|
+
echo "Failed to install before the pre-removal script was run." >&2
|
38
|
+
exit 1
|
39
|
+
fi
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<pkg-info
|
2
|
+
<% if !attributes[:osxpkg_postinstall_action].nil? -%>postinstall-action="<%= attributes[:osxpkg_postinstall_action] %>"<% end -%>
|
3
|
+
>
|
4
|
+
<% if !attributes[:osxpkg_dont_obsolete].nil? -%>
|
5
|
+
<dont-obsolete>
|
6
|
+
<% attributes[:osxpkg_dont_obsolete].each do |filepath| -%>
|
7
|
+
<file path="<%= filepath %>"/>
|
8
|
+
<% end -%>
|
9
|
+
</dont-obsolete>
|
10
|
+
<% end -%>
|
11
|
+
</pkg-info>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
set name=pkg.fmri value="<%=@name%>@<%=@version%>"
|
2
|
+
set name=pkg.summary value="<%=@description%>"
|
3
|
+
set name=pkg.human-version value="<%=@version%>"
|
4
|
+
set name=pkg.description value="<%=@description%>"
|
5
|
+
set name=info.classification value="org.opensolaris.category.2008:<%=@category%>"
|
6
|
+
set name=variant.opensolaris.zone <%= attributes[:p5p_zonetype] %>
|
7
|
+
set name=variant.arch value=<%=@architecture%>
|
8
|
+
<transform file dir -> set owner <%= attributes[:p5p_user] %>>
|
9
|
+
<transform file dir -> set group <%= attributes[:p5p_group] %>>
|
10
|
+
<transform dir path=opt$->drop>
|
11
|
+
<transform dir path=etc$->drop>
|
12
|
+
<transform dir path=usr(?:|/bin)$->drop>
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# Generated by fpm
|
2
|
+
# Hello packaging friend!
|
3
|
+
#
|
4
|
+
# If you find yourself using this 'fpm --edit' feature frequently, it is
|
5
|
+
# a sign that fpm is missing a feature! I welcome your feature requests!
|
6
|
+
# Please visit the following URL and ask for a feature that helps you never
|
7
|
+
# need to edit this file again! :)
|
8
|
+
# https://github.com/jordansissel/fpm/issues
|
9
|
+
# ------------------------------------------------------------------------
|
10
|
+
#
|
11
|
+
pkgname = <%= name %>
|
12
|
+
<% if !epoch.nil? -%>
|
13
|
+
pkgver = <%= epoch %>:<%= version %>-<%= iteration %>
|
14
|
+
<% else -%>
|
15
|
+
pkgver = <%= version %>-<%= iteration %>
|
16
|
+
<% end -%>
|
17
|
+
pkgdesc = <%= description %>
|
18
|
+
<% if !url.nil? and !url.empty? -%>
|
19
|
+
url = <%= url %>
|
20
|
+
<% else -%>
|
21
|
+
url = http://nourlgiven.example.com/
|
22
|
+
<% end -%>
|
23
|
+
builddate = <%= builddate %>
|
24
|
+
packager = <%= maintainer %>
|
25
|
+
size = <%= size %>
|
26
|
+
arch = <%= architecture %>
|
27
|
+
license = <%= license %>
|
28
|
+
<% replaces.each do |repl| -%>
|
29
|
+
replaces = <%= repl %>
|
30
|
+
<% end -%>
|
31
|
+
group = <%= category %>
|
32
|
+
<% conflicts.each do |confl| -%>
|
33
|
+
conflict = <%= confl %>
|
34
|
+
<% end -%>
|
35
|
+
<% provides.each do |prov| -%>
|
36
|
+
provides = <%= prov %>
|
37
|
+
<% end -%>
|
38
|
+
<% config_files.each do |conf| -%>
|
39
|
+
<% conf.gsub(/^\/+/, "") -%>
|
40
|
+
backup = <%= conf %>
|
41
|
+
<% end -%>
|
42
|
+
<% dependencies.each do |req| -%>
|
43
|
+
depend = <%= req %>
|
44
|
+
<% end -%>
|
45
|
+
<% attributes.fetch(:pacman_opt_depends, []).each do |opt| -%>
|
46
|
+
optdepend = <%= opt %>
|
47
|
+
<% end -%>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<%# In each function, a `:` is the first command. -%>
|
2
|
+
<%# This makes sure that at least one command is in the function -%>
|
3
|
+
<%# This avoids a lot of potential errors, including the case that -%>
|
4
|
+
<%# the script is non-empty, but just whitespace and/or comments -%>
|
5
|
+
<%# see issue #875 for more details -%>
|
6
|
+
<% if script?(:before_install) -%>
|
7
|
+
pre_install() {
|
8
|
+
:
|
9
|
+
<%= script(:before_install) %>
|
10
|
+
}
|
11
|
+
<% end -%>
|
12
|
+
<% if script?(:after_install) -%>
|
13
|
+
post_install() {
|
14
|
+
:
|
15
|
+
<%= script(:after_install) %>
|
16
|
+
}
|
17
|
+
<% end -%>
|
18
|
+
<% if script?(:before_upgrade) -%>
|
19
|
+
pre_upgrade() {
|
20
|
+
:
|
21
|
+
<%= script(:before_upgrade) %>
|
22
|
+
}
|
23
|
+
<% end -%>
|
24
|
+
<% if script?(:after_upgrade) -%>
|
25
|
+
post_upgrade() {
|
26
|
+
:
|
27
|
+
<%= script(:after_upgrade) %>
|
28
|
+
}
|
29
|
+
<% end -%>
|
30
|
+
<% if script?(:before_remove) -%>
|
31
|
+
pre_remove() {
|
32
|
+
:
|
33
|
+
<%= script(:before_remove) %>
|
34
|
+
}
|
35
|
+
<% end -%>
|
36
|
+
<% if script?(:after_remove) -%>
|
37
|
+
post_remove() {
|
38
|
+
:
|
39
|
+
<%= script(:after_remove) %>
|
40
|
+
}
|
41
|
+
<% end -%>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# TODO(sissel): implement 'anti' class for this package.
|
2
|
+
class <%= name %>::package {
|
3
|
+
$version = "<%= version %>"
|
4
|
+
$iteration = "<%= iteration %>"
|
5
|
+
|
6
|
+
file {
|
7
|
+
<% paths.each do |path|
|
8
|
+
stat = File.lstat(path)
|
9
|
+
params = {}
|
10
|
+
if stat.directory?
|
11
|
+
params[:ensure] = "directory"
|
12
|
+
elsif stat.symlink?
|
13
|
+
params[:ensure] = "link"
|
14
|
+
params[:target] = File.readlink(path)
|
15
|
+
stat = File.stat(path)
|
16
|
+
else
|
17
|
+
params[:ensure] = "file"
|
18
|
+
params[:source] = "puppet:///modules/#{name}/#{path}"
|
19
|
+
end
|
20
|
+
|
21
|
+
if params[:ensure] != "link"
|
22
|
+
params[:owner] = uid2user(stat.uid)
|
23
|
+
params[:group] = gid2group(stat.gid)
|
24
|
+
params[:mode] = sprintf("%04o", stat.mode & 0777)
|
25
|
+
end
|
26
|
+
|
27
|
+
settings = puppetsort(params).collect { |k,v| "#{k} => \"#{v}\"" }.join(",\n ")
|
28
|
+
-%>
|
29
|
+
# <%= stat.inspect %>
|
30
|
+
"<%= fixpath(path) %>":
|
31
|
+
<%= settings %>;
|
32
|
+
<% end # paths.each -%>
|
33
|
+
}
|
34
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class <%= name %>::package::remove {
|
2
|
+
$version = "<%= version %>"
|
3
|
+
$iteration = "<%= iteration %>"
|
4
|
+
|
5
|
+
fail("DO NOT USE THIS. IT IS NOT WELL DEFINED YET.")
|
6
|
+
|
7
|
+
file {
|
8
|
+
<% paths.each do |path| -%>
|
9
|
+
"<%= fixpath(path) %>":
|
10
|
+
ensure => absent;
|
11
|
+
<% end # paths.each -%>
|
12
|
+
}
|
13
|
+
}
|
data/templates/rpm.erb
ADDED
@@ -0,0 +1,261 @@
|
|
1
|
+
# Hello packaging friend!
|
2
|
+
#
|
3
|
+
# If you find yourself using this 'fpm --edit' feature frequently, it is
|
4
|
+
# a sign that fpm is missing a feature! I welcome your feature requests!
|
5
|
+
# Please visit the following URL and ask for a feature that helps you never
|
6
|
+
# need to edit this file again! :)
|
7
|
+
# https://github.com/jordansissel/fpm/issues
|
8
|
+
# ------------------------------------------------------------------------
|
9
|
+
|
10
|
+
# Disable the stupid stuff rpm distros include in the build process by default:
|
11
|
+
<% %w(prep build install clean).each do |step| -%>
|
12
|
+
<%# These definitions have to be non-empty... I guess... -%>
|
13
|
+
# Disable any <%= step %> shell actions. replace them with simply 'true'
|
14
|
+
%define __spec_<%= step %>_post true
|
15
|
+
%define __spec_<%= step %>_pre true
|
16
|
+
<% end -%>
|
17
|
+
# Disable checking for unpackaged files ?
|
18
|
+
#%undefine __check_files
|
19
|
+
|
20
|
+
# Use <%= attributes[:rpm_digest] %> file digest method.
|
21
|
+
# The first macro is the one used in RPM v4.9.1.1
|
22
|
+
%define _binary_filedigest_algorithm <%= digest_algorithm %>
|
23
|
+
# This is the macro I find on OSX when Homebrew provides rpmbuild (rpm v5.4.14)
|
24
|
+
%define _build_binary_file_digest_algo <%= digest_algorithm %>
|
25
|
+
|
26
|
+
# Use <%= attributes[:rpm_compression] %> payload compression
|
27
|
+
%define _binary_payload <%= payload_compression %>
|
28
|
+
|
29
|
+
<% (attributes[:rpm_filter_from_requires] or []).each do |reqfilter| -%>
|
30
|
+
%filter_from_requires <%= reqfilter %>
|
31
|
+
<% end -%>
|
32
|
+
<% (attributes[:rpm_filter_from_provides] or []).each do |provfilter| -%>
|
33
|
+
%filter_from_provides <%= provfilter %>
|
34
|
+
<% end -%>
|
35
|
+
<% if !(attributes[:rpm_filter_from_requires] or []).empty? or !(attributes[:rpm_filter_from_provides] or []).empty?-%>
|
36
|
+
%filter_setup
|
37
|
+
<% end -%>
|
38
|
+
|
39
|
+
Name: <%= name %>
|
40
|
+
Version: <%= version %>
|
41
|
+
<% if epoch -%>
|
42
|
+
Epoch: <%= epoch %>
|
43
|
+
<% end -%>
|
44
|
+
Release: <%= iteration or 1 %><%= "%{?dist}" if attributes[:rpm_dist] %>
|
45
|
+
<%# use the first line of the description as the summary -%>
|
46
|
+
Summary: <%= summary %>
|
47
|
+
<% if !attributes[:rpm_autoreqprov?] -%>
|
48
|
+
AutoReqProv: no
|
49
|
+
<% else -%>
|
50
|
+
AutoReqProv: yes
|
51
|
+
<% end -%>
|
52
|
+
<% if attributes[:rpm_autoreq?] -%>
|
53
|
+
AutoReq: yes
|
54
|
+
<% end -%>
|
55
|
+
<% if attributes[:rpm_autoprov?] -%>
|
56
|
+
AutoProv: yes
|
57
|
+
<% end -%>
|
58
|
+
# Seems specifying BuildRoot is required on older rpmbuild (like on CentOS 5)
|
59
|
+
# fpm passes '--define buildroot ...' on the commandline, so just reuse that.
|
60
|
+
BuildRoot: %buildroot
|
61
|
+
# Add prefix, must not end with /
|
62
|
+
<% if !prefix.nil? and !prefix.empty? %>
|
63
|
+
Prefix: <%= prefix.gsub(/([^\/]+)(\/$)/, '') %>
|
64
|
+
<% end -%>
|
65
|
+
|
66
|
+
Group: <%= category %>
|
67
|
+
<%# Sometimes the 'license' field has multiple lines... Hack around it.
|
68
|
+
# While technically yes this means we are 'modifying' the license,
|
69
|
+
# since the job of FPM is to get shit done and that this is only
|
70
|
+
# modifying whitespace, it should be reasonably OK. -%>
|
71
|
+
License: <%= license.gsub("\n", " ") %>
|
72
|
+
<% if !vendor.nil? and !vendor.empty? -%>
|
73
|
+
Vendor: <%= vendor %>
|
74
|
+
<% end -%>
|
75
|
+
<% if !url.nil? and !url.empty? -%>
|
76
|
+
URL: <%= url %>
|
77
|
+
<%else -%>
|
78
|
+
URL: http://nourlgiven.example.com/
|
79
|
+
<% end -%>
|
80
|
+
Packager: <%= maintainer %>
|
81
|
+
|
82
|
+
<% if !attributes[:no_depends?] -%>
|
83
|
+
<% dependencies.each do |req| -%>
|
84
|
+
Requires: <%= req %>
|
85
|
+
<% end -%>
|
86
|
+
<% (attributes[:rpm_tags] or []).each do |tag| -%>
|
87
|
+
<%= tag %>
|
88
|
+
<% end -%>
|
89
|
+
<% end -%>
|
90
|
+
<% provides.each do |prov| -%>
|
91
|
+
Provides: <%= prov %>
|
92
|
+
<% end -%>
|
93
|
+
<% conflicts.each do |conflict| -%>
|
94
|
+
Conflicts: <%= conflict %>
|
95
|
+
<% end -%>
|
96
|
+
<% replaces.each do |repl| -%>
|
97
|
+
<%# The closes equivalent in RPM to "replaces" is "Obsoletes" -%>
|
98
|
+
Obsoletes: <%= repl %>
|
99
|
+
<% end -%>
|
100
|
+
<%# rpm rejects descriptions with blank lines (even between content), so hack
|
101
|
+
around it by replacing blank lines with ' .' -%>
|
102
|
+
%description
|
103
|
+
<%= description.gsub(/^\s*$/, " .") %>
|
104
|
+
|
105
|
+
%prep
|
106
|
+
# noop
|
107
|
+
|
108
|
+
%build
|
109
|
+
# noop
|
110
|
+
|
111
|
+
%install
|
112
|
+
# noop
|
113
|
+
|
114
|
+
%clean
|
115
|
+
# noop
|
116
|
+
|
117
|
+
<%# This next section puts any %pre, %post, %preun, %postun, %verifyscript, %pretrans or %posttrans scripts %>
|
118
|
+
<%
|
119
|
+
scriptmap = {
|
120
|
+
:rpm_verifyscript => "verifyscript",
|
121
|
+
:rpm_posttrans => "posttrans",
|
122
|
+
:rpm_pretrans => "pretrans"
|
123
|
+
}
|
124
|
+
-%>
|
125
|
+
<% if script?(:before_upgrade) or script?(:after_upgrade) -%>
|
126
|
+
<% if script?(:before_upgrade) or script?(:before_install) -%>
|
127
|
+
%pre
|
128
|
+
upgrade() {
|
129
|
+
<%# Making sure that at least one command is in the function -%>
|
130
|
+
<%# avoids a lot of potential errors, including the case that -%>
|
131
|
+
<%# the script is non-empty, but just whitespace and/or comments -%>
|
132
|
+
:
|
133
|
+
<% if script?(:before_upgrade) -%>
|
134
|
+
<%= script(:before_upgrade) %>
|
135
|
+
<% end -%>
|
136
|
+
}
|
137
|
+
install() {
|
138
|
+
<%# Making sure that at least one command is in the function -%>
|
139
|
+
<%# avoids a lot of potential errors, including the case that -%>
|
140
|
+
<%# the script is non-empty, but just whitespace and/or comments -%>
|
141
|
+
:
|
142
|
+
<% if script?(:before_install) -%>
|
143
|
+
<%= script(:before_install) %>
|
144
|
+
<% end -%>
|
145
|
+
}
|
146
|
+
if [ "${1}" -eq 1 ]
|
147
|
+
then
|
148
|
+
# "before install" goes here
|
149
|
+
install
|
150
|
+
elif [ "${1}" -gt 1 ]
|
151
|
+
then
|
152
|
+
# "before upgrade" goes here
|
153
|
+
upgrade
|
154
|
+
fi
|
155
|
+
<% end -%>
|
156
|
+
<% if script?(:after_upgrade) or script?(:after_install) -%>
|
157
|
+
%post
|
158
|
+
upgrade() {
|
159
|
+
<%# Making sure that at least one command is in the function -%>
|
160
|
+
<%# avoids a lot of potential errors, including the case that -%>
|
161
|
+
<%# the script is non-empty, but just whitespace and/or comments -%>
|
162
|
+
:
|
163
|
+
<% if script?(:after_upgrade) -%>
|
164
|
+
<%= script(:after_upgrade) %>
|
165
|
+
<% end -%>
|
166
|
+
}
|
167
|
+
install() {
|
168
|
+
<%# Making sure that at least one command is in the function -%>
|
169
|
+
<%# avoids a lot of potential errors, including the case that -%>
|
170
|
+
<%# the script is non-empty, but just whitespace and/or comments -%>
|
171
|
+
:
|
172
|
+
<% if script?(:after_install) -%>
|
173
|
+
<%= script(:after_install) %>
|
174
|
+
<% end -%>
|
175
|
+
}
|
176
|
+
if [ "${1}" -eq 1 ]
|
177
|
+
then
|
178
|
+
# "after install" goes here
|
179
|
+
install
|
180
|
+
elif [ "${1}" -gt 1 ]
|
181
|
+
then
|
182
|
+
# "after upgrade" goes here
|
183
|
+
upgrade
|
184
|
+
fi
|
185
|
+
<% end -%>
|
186
|
+
<% if script?(:before_remove) -%>
|
187
|
+
%preun
|
188
|
+
if [ "${1}" -eq 0 ]
|
189
|
+
then
|
190
|
+
<%# Making sure that at least one command is in the function -%>
|
191
|
+
<%# avoids a lot of potential errors, including the case that -%>
|
192
|
+
<%# the script is non-empty, but just whitespace and/or comments -%>
|
193
|
+
:
|
194
|
+
<%= script(:before_remove) %>
|
195
|
+
fi
|
196
|
+
<% end -%>
|
197
|
+
<% if script?(:after_remove) -%>
|
198
|
+
%postun
|
199
|
+
if [ "${1}" -eq 0 ]
|
200
|
+
then
|
201
|
+
<%# Making sure that at least one command is in the function -%>
|
202
|
+
<%# avoids a lot of potential errors, including the case that -%>
|
203
|
+
<%# the script is non-empty, but just whitespace and/or comments -%>
|
204
|
+
:
|
205
|
+
<%= script(:after_remove) %>
|
206
|
+
fi
|
207
|
+
<% end -%>
|
208
|
+
<% else
|
209
|
+
other_scriptmap = {
|
210
|
+
:before_install => "pre",
|
211
|
+
:after_install => "post",
|
212
|
+
:before_remove => "preun",
|
213
|
+
:after_remove => "postun"
|
214
|
+
}
|
215
|
+
scriptmap.merge!(other_scriptmap)
|
216
|
+
end
|
217
|
+
-%>
|
218
|
+
<% scriptmap.each do |name, rpmname| -%>
|
219
|
+
<% if script?(name) -%>
|
220
|
+
%<%= rpmname %>
|
221
|
+
<%= script(name) %>
|
222
|
+
<% end -%>
|
223
|
+
<% end -%>
|
224
|
+
|
225
|
+
<%# This section adds any triggers, as ordered in the command line -%>
|
226
|
+
<%
|
227
|
+
triggermap = {
|
228
|
+
:before_install => "prein",
|
229
|
+
:after_install => "in",
|
230
|
+
:before_uninstall => "un",
|
231
|
+
:after_target_uninstall => "postun"
|
232
|
+
}
|
233
|
+
triggermap.each do |name, rpmtype|
|
234
|
+
(attributes["rpm_trigger_#{name}".to_sym] or []).each do |trigger_name, trigger_script, trigger_scriptprog| -%>
|
235
|
+
%trigger<%= rpmtype -%> <%= trigger_scriptprog -%> -- <%= trigger_name %>
|
236
|
+
<%= trigger_script %>
|
237
|
+
<% end -%>
|
238
|
+
<% end -%>
|
239
|
+
|
240
|
+
%files
|
241
|
+
%defattr(<%= attributes[:rpm_defattrfile] %>,<%= attributes[:rpm_user] || "root" %>,<%= attributes[:rpm_group] || "root" %>,<%= attributes[:rpm_defattrdir] %>)
|
242
|
+
<%# Output config files and then regular files. -%>
|
243
|
+
<% config_files.each do |path| -%>
|
244
|
+
%config(noreplace) <%= rpm_file_entry(path) %>
|
245
|
+
<% end -%>
|
246
|
+
<%# list directories %>
|
247
|
+
<% directories.each do |path| -%>
|
248
|
+
%dir <%= rpm_file_entry(path) %>
|
249
|
+
<% end -%>
|
250
|
+
<%# list only files, not directories? -%>
|
251
|
+
# Reject config files already listed or parent directories, then prefix files
|
252
|
+
# with "/", then make sure paths with spaces are quoted. I hate rpm so much.
|
253
|
+
<% files.each do |path| -%>
|
254
|
+
<% path = "/#{path}" -%>
|
255
|
+
<% next if config_files.include?(path)-%>
|
256
|
+
<% next if directories.include?(path)-%>
|
257
|
+
<%= rpm_file_entry(path) %>
|
258
|
+
<% end -%>
|
259
|
+
|
260
|
+
%changelog
|
261
|
+
<%= attributes[:rpm_changelog] %>
|