2013-05-08 00:32:45 +08:00
|
|
|
# Hello packaging friend!
|
|
|
|
|
#
|
2013-08-19 23:46:55 +08:00
|
|
|
# If you find yourself using this 'fpm --edit' feature frequently, it is
|
2013-05-08 00:32:45 +08:00
|
|
|
# a sign that fpm is missing a feature! I welcome your feature requests!
|
|
|
|
|
# Please visit the following URL and ask for a feature that helps you never
|
|
|
|
|
# need to edit this file again! :)
|
|
|
|
|
# https://github.com/jordansissel/fpm/issues
|
|
|
|
|
# ------------------------------------------------------------------------
|
|
|
|
|
|
2012-03-01 09:15:57 +08:00
|
|
|
# Disable the stupid stuff rpm distros include in the build process by default:
|
2012-03-02 15:17:38 +08:00
|
|
|
<% %w(prep build install clean).each do |step| -%>
|
2012-03-01 09:15:57 +08:00
|
|
|
<%# These definitions have to be non-empty... I guess... -%>
|
|
|
|
|
# Disable any <%= step %> shell actions. replace them with simply 'true'
|
|
|
|
|
%define __spec_<%= step %>_post true
|
|
|
|
|
%define __spec_<%= step %>_pre true
|
|
|
|
|
<% end -%>
|
2012-03-09 08:07:26 +08:00
|
|
|
# Disable checking for unpackaged files ?
|
|
|
|
|
#%undefine __check_files
|
2011-11-23 17:48:51 +08:00
|
|
|
|
2017-12-24 22:00:04 +08:00
|
|
|
# Allow building noarch packages that contain binaries
|
|
|
|
|
%define _binaries_in_noarch_packages_terminate_build 0
|
|
|
|
|
|
2015-04-14 15:05:49 +08:00
|
|
|
# Use <%= attributes[:rpm_digest] %> file digest method.
|
|
|
|
|
# The first macro is the one used in RPM v4.9.1.1
|
2012-03-30 10:23:25 +08:00
|
|
|
%define _binary_filedigest_algorithm <%= digest_algorithm %>
|
2015-04-14 15:05:49 +08:00
|
|
|
# This is the macro I find on OSX when Homebrew provides rpmbuild (rpm v5.4.14)
|
|
|
|
|
%define _build_binary_file_digest_algo <%= digest_algorithm %>
|
2012-03-30 09:55:27 +08:00
|
|
|
|
2012-03-30 10:23:25 +08:00
|
|
|
# Use <%= attributes[:rpm_compression] %> payload compression
|
|
|
|
|
%define _binary_payload <%= payload_compression %>
|
2012-03-30 09:55:27 +08:00
|
|
|
|
2013-05-03 04:53:04 +08:00
|
|
|
<% (attributes[:rpm_filter_from_requires] or []).each do |reqfilter| -%>
|
|
|
|
|
%filter_from_requires <%= reqfilter %>
|
|
|
|
|
<% end -%>
|
|
|
|
|
<% (attributes[:rpm_filter_from_provides] or []).each do |provfilter| -%>
|
|
|
|
|
%filter_from_provides <%= provfilter %>
|
|
|
|
|
<% end -%>
|
2013-05-07 15:01:38 +08:00
|
|
|
<% if !(attributes[:rpm_filter_from_requires] or []).empty? or !(attributes[:rpm_filter_from_provides] or []).empty?-%>
|
2013-05-03 04:53:04 +08:00
|
|
|
%filter_setup
|
|
|
|
|
<% end -%>
|
|
|
|
|
|
2011-05-05 15:02:27 +08:00
|
|
|
Name: <%= name %>
|
|
|
|
|
Version: <%= version %>
|
2011-06-19 14:22:39 +08:00
|
|
|
<% if epoch -%>
|
2011-05-05 15:02:27 +08:00
|
|
|
Epoch: <%= epoch %>
|
2011-06-19 14:22:39 +08:00
|
|
|
<% end -%>
|
2014-05-01 03:26:16 +08:00
|
|
|
Release: <%= iteration or 1 %><%= "%{?dist}" if attributes[:rpm_dist] %>
|
2011-06-19 14:22:39 +08:00
|
|
|
<%# use the first line of the description as the summary -%>
|
2015-07-27 17:35:05 +08:00
|
|
|
Summary: <%= summary %>
|
2013-05-03 09:22:21 +08:00
|
|
|
<% if !attributes[:rpm_autoreqprov?] -%>
|
2011-01-23 04:51:27 +08:00
|
|
|
AutoReqProv: no
|
2013-05-03 02:10:20 +08:00
|
|
|
<% else -%>
|
|
|
|
|
AutoReqProv: yes
|
|
|
|
|
<% end -%>
|
2013-05-03 04:53:04 +08:00
|
|
|
<% if attributes[:rpm_autoreq?] -%>
|
|
|
|
|
AutoReq: yes
|
|
|
|
|
<% end -%>
|
|
|
|
|
<% if attributes[:rpm_autoprov?] -%>
|
|
|
|
|
AutoProv: yes
|
|
|
|
|
<% end -%>
|
2012-03-31 01:38:26 +08:00
|
|
|
# Seems specifying BuildRoot is required on older rpmbuild (like on CentOS 5)
|
|
|
|
|
# fpm passes '--define buildroot ...' on the commandline, so just reuse that.
|
|
|
|
|
BuildRoot: %buildroot
|
2012-07-22 11:49:42 +08:00
|
|
|
<% if !prefix.nil? and !prefix.empty? %>
|
2016-06-22 01:33:31 +08:00
|
|
|
Prefix: <%= prefix %>
|
2012-05-30 04:17:37 +08:00
|
|
|
<% end -%>
|
2011-01-06 12:01:33 +08:00
|
|
|
|
2011-05-05 15:02:27 +08:00
|
|
|
Group: <%= category %>
|
2012-08-25 04:49:38 +08:00
|
|
|
<%# Sometimes the 'license' field has multiple lines... Hack around it.
|
|
|
|
|
# While technically yes this means we are 'modifying' the license,
|
|
|
|
|
# since the job of FPM is to get shit done and that this is only
|
|
|
|
|
# modifying whitespace, it should be reasonably OK. -%>
|
|
|
|
|
License: <%= license.gsub("\n", " ") %>
|
2012-06-20 03:26:02 +08:00
|
|
|
<% if !vendor.nil? and !vendor.empty? -%>
|
2012-02-19 00:43:15 +08:00
|
|
|
Vendor: <%= vendor %>
|
2012-06-20 03:26:02 +08:00
|
|
|
<% end -%>
|
2012-11-27 20:11:13 +08:00
|
|
|
<% if !url.nil? and !url.empty? -%>
|
|
|
|
|
URL: <%= url %>
|
|
|
|
|
<%else -%>
|
|
|
|
|
URL: http://nourlgiven.example.com/
|
|
|
|
|
<% end -%>
|
2012-02-07 19:38:49 +08:00
|
|
|
Packager: <%= maintainer %>
|
2011-01-06 12:01:33 +08:00
|
|
|
|
2012-11-15 09:28:05 +08:00
|
|
|
<% if !attributes[:no_depends?] -%>
|
2012-03-01 09:15:57 +08:00
|
|
|
<% dependencies.each do |req| -%>
|
|
|
|
|
Requires: <%= req %>
|
2011-06-19 14:22:39 +08:00
|
|
|
<% end -%>
|
2016-06-16 02:40:52 +08:00
|
|
|
<% (attributes[:rpm_tag] or []).each do |tag| -%>
|
2014-04-29 20:28:48 +08:00
|
|
|
<%= tag %>
|
|
|
|
|
<% end -%>
|
2012-11-15 06:29:07 +08:00
|
|
|
<% end -%>
|
2011-06-19 14:22:39 +08:00
|
|
|
<% provides.each do |prov| -%>
|
2011-04-26 04:40:47 +08:00
|
|
|
Provides: <%= prov %>
|
2011-06-19 14:22:39 +08:00
|
|
|
<% end -%>
|
2012-03-17 06:37:05 +08:00
|
|
|
<% conflicts.each do |conflict| -%>
|
|
|
|
|
Conflicts: <%= conflict %>
|
|
|
|
|
<% end -%>
|
2011-06-19 14:22:39 +08:00
|
|
|
<% replaces.each do |repl| -%>
|
|
|
|
|
<%# The closes equivalent in RPM to "replaces" is "Obsoletes" -%>
|
2011-05-19 03:06:52 +08:00
|
|
|
Obsoletes: <%= repl %>
|
2011-06-19 14:22:39 +08:00
|
|
|
<% end -%>
|
2011-05-12 06:52:59 +08:00
|
|
|
<%# rpm rejects descriptions with blank lines (even between content), so hack
|
2011-06-19 14:22:39 +08:00
|
|
|
around it by replacing blank lines with ' .' -%>
|
2011-01-06 12:01:33 +08:00
|
|
|
%description
|
2011-05-12 06:52:59 +08:00
|
|
|
<%= description.gsub(/^\s*$/, " .") %>
|
2011-01-06 12:01:33 +08:00
|
|
|
|
|
|
|
|
%prep
|
2011-06-10 00:48:01 +08:00
|
|
|
# noop
|
2011-01-06 12:01:33 +08:00
|
|
|
|
|
|
|
|
%build
|
2011-10-12 14:59:58 +08:00
|
|
|
# noop
|
|
|
|
|
|
|
|
|
|
%install
|
2013-09-14 17:04:50 +08:00
|
|
|
# noop
|
2011-01-06 12:01:33 +08:00
|
|
|
|
|
|
|
|
%clean
|
2012-03-01 09:15:57 +08:00
|
|
|
# noop
|
2011-01-06 12:01:33 +08:00
|
|
|
|
2014-03-18 23:00:50 +08:00
|
|
|
<%# This next section puts any %pre, %post, %preun, %postun, %verifyscript, %pretrans or %posttrans scripts %>
|
2014-09-19 21:23:15 +08:00
|
|
|
<%
|
|
|
|
|
scriptmap = {
|
|
|
|
|
:rpm_verifyscript => "verifyscript",
|
|
|
|
|
:rpm_posttrans => "posttrans",
|
|
|
|
|
:rpm_pretrans => "pretrans"
|
|
|
|
|
}
|
|
|
|
|
-%>
|
2014-09-15 21:08:34 +08:00
|
|
|
<% if script?(:before_upgrade) or script?(:after_upgrade) -%>
|
|
|
|
|
<% if script?(:before_upgrade) or script?(:before_install) -%>
|
2021-01-28 17:57:06 +08:00
|
|
|
%pre <% if attributes[:rpm_macro_expansion?] -%><%= " -e " %> <% end %>
|
2014-09-15 21:08:34 +08:00
|
|
|
upgrade() {
|
2015-04-10 13:00:25 +08:00
|
|
|
<%# Making sure that at least one command is in the function -%>
|
|
|
|
|
<%# avoids a lot of potential errors, including the case that -%>
|
|
|
|
|
<%# the script is non-empty, but just whitespace and/or comments -%>
|
|
|
|
|
:
|
2014-09-15 21:08:34 +08:00
|
|
|
<% if script?(:before_upgrade) -%>
|
|
|
|
|
<%= script(:before_upgrade) %>
|
|
|
|
|
<% end -%>
|
|
|
|
|
}
|
2017-11-06 23:20:27 +08:00
|
|
|
_install() {
|
2015-04-10 13:00:25 +08:00
|
|
|
<%# Making sure that at least one command is in the function -%>
|
|
|
|
|
<%# avoids a lot of potential errors, including the case that -%>
|
|
|
|
|
<%# the script is non-empty, but just whitespace and/or comments -%>
|
|
|
|
|
:
|
2014-09-15 21:08:34 +08:00
|
|
|
<% if script?(:before_install) -%>
|
|
|
|
|
<%= script(:before_install) %>
|
|
|
|
|
<% end -%>
|
|
|
|
|
}
|
|
|
|
|
if [ "${1}" -eq 1 ]
|
|
|
|
|
then
|
|
|
|
|
# "before install" goes here
|
2017-11-06 23:20:27 +08:00
|
|
|
_install
|
2014-09-15 21:08:34 +08:00
|
|
|
elif [ "${1}" -gt 1 ]
|
|
|
|
|
then
|
2015-04-10 13:00:25 +08:00
|
|
|
# "before upgrade" goes here
|
2014-09-15 21:08:34 +08:00
|
|
|
upgrade
|
|
|
|
|
fi
|
|
|
|
|
<% end -%>
|
|
|
|
|
<% if script?(:after_upgrade) or script?(:after_install) -%>
|
2021-01-28 17:57:06 +08:00
|
|
|
%post <% if attributes[:rpm_macro_expansion?] -%><%= " -e " %> <% end %>
|
2014-09-15 21:08:34 +08:00
|
|
|
upgrade() {
|
2015-04-10 13:00:25 +08:00
|
|
|
<%# Making sure that at least one command is in the function -%>
|
|
|
|
|
<%# avoids a lot of potential errors, including the case that -%>
|
|
|
|
|
<%# the script is non-empty, but just whitespace and/or comments -%>
|
|
|
|
|
:
|
2014-09-15 21:08:34 +08:00
|
|
|
<% if script?(:after_upgrade) -%>
|
|
|
|
|
<%= script(:after_upgrade) %>
|
|
|
|
|
<% end -%>
|
|
|
|
|
}
|
2017-11-06 23:20:27 +08:00
|
|
|
_install() {
|
2015-04-10 13:00:25 +08:00
|
|
|
<%# Making sure that at least one command is in the function -%>
|
|
|
|
|
<%# avoids a lot of potential errors, including the case that -%>
|
|
|
|
|
<%# the script is non-empty, but just whitespace and/or comments -%>
|
|
|
|
|
:
|
2014-09-15 21:08:34 +08:00
|
|
|
<% if script?(:after_install) -%>
|
|
|
|
|
<%= script(:after_install) %>
|
|
|
|
|
<% end -%>
|
|
|
|
|
}
|
|
|
|
|
if [ "${1}" -eq 1 ]
|
|
|
|
|
then
|
2014-12-10 04:00:27 +08:00
|
|
|
# "after install" goes here
|
2017-11-06 23:20:27 +08:00
|
|
|
_install
|
2014-09-15 21:08:34 +08:00
|
|
|
elif [ "${1}" -gt 1 ]
|
|
|
|
|
then
|
2015-04-10 13:00:25 +08:00
|
|
|
# "after upgrade" goes here
|
2014-09-15 21:08:34 +08:00
|
|
|
upgrade
|
|
|
|
|
fi
|
|
|
|
|
<% end -%>
|
|
|
|
|
<% if script?(:before_remove) -%>
|
2021-01-28 17:57:06 +08:00
|
|
|
%preun <% if attributes[:rpm_macro_expansion?] -%><%= " -e " %> <% end %>
|
2014-09-15 21:08:34 +08:00
|
|
|
if [ "${1}" -eq 0 ]
|
|
|
|
|
then
|
2015-05-03 01:50:41 +08:00
|
|
|
<%# Making sure that at least one command is in the function -%>
|
|
|
|
|
<%# avoids a lot of potential errors, including the case that -%>
|
|
|
|
|
<%# the script is non-empty, but just whitespace and/or comments -%>
|
|
|
|
|
:
|
2014-09-15 21:08:34 +08:00
|
|
|
<%= script(:before_remove) %>
|
|
|
|
|
fi
|
|
|
|
|
<% end -%>
|
|
|
|
|
<% if script?(:after_remove) -%>
|
2021-01-28 17:57:06 +08:00
|
|
|
%postun <% if attributes[:rpm_macro_expansion?] -%><%= " -e " %> <% end %>
|
2014-09-15 21:08:34 +08:00
|
|
|
if [ "${1}" -eq 0 ]
|
|
|
|
|
then
|
2015-05-03 01:50:41 +08:00
|
|
|
<%# Making sure that at least one command is in the function -%>
|
|
|
|
|
<%# avoids a lot of potential errors, including the case that -%>
|
|
|
|
|
<%# the script is non-empty, but just whitespace and/or comments -%>
|
|
|
|
|
:
|
2014-09-15 21:08:34 +08:00
|
|
|
<%= script(:after_remove) %>
|
|
|
|
|
fi
|
|
|
|
|
<% end -%>
|
2014-10-25 12:51:34 +08:00
|
|
|
<% else
|
|
|
|
|
other_scriptmap = {
|
|
|
|
|
:before_install => "pre",
|
|
|
|
|
:after_install => "post",
|
|
|
|
|
:before_remove => "preun",
|
|
|
|
|
:after_remove => "postun"
|
|
|
|
|
}
|
|
|
|
|
scriptmap.merge!(other_scriptmap)
|
|
|
|
|
end
|
2012-08-08 01:48:40 +08:00
|
|
|
-%>
|
2014-10-25 12:51:34 +08:00
|
|
|
<% scriptmap.each do |name, rpmname| -%>
|
2014-09-19 21:23:15 +08:00
|
|
|
<% if script?(name) -%>
|
2019-06-11 21:13:41 +08:00
|
|
|
%<%= rpmname -%> <%= ' -e' if attributes[:rpm_macro_expansion?] %>
|
2014-09-19 21:23:15 +08:00
|
|
|
<%= script(name) %>
|
2012-08-08 01:48:40 +08:00
|
|
|
<% end -%>
|
2011-06-19 14:22:39 +08:00
|
|
|
<% end -%>
|
2011-05-05 15:02:27 +08:00
|
|
|
|
2014-10-25 13:35:14 +08:00
|
|
|
<%# This section adds any triggers, as ordered in the command line -%>
|
|
|
|
|
<%
|
|
|
|
|
triggermap = {
|
|
|
|
|
:before_install => "prein",
|
|
|
|
|
:after_install => "in",
|
|
|
|
|
:before_uninstall => "un",
|
|
|
|
|
:after_target_uninstall => "postun"
|
|
|
|
|
}
|
|
|
|
|
triggermap.each do |name, rpmtype|
|
|
|
|
|
(attributes["rpm_trigger_#{name}".to_sym] or []).each do |trigger_name, trigger_script, trigger_scriptprog| -%>
|
|
|
|
|
%trigger<%= rpmtype -%> <%= trigger_scriptprog -%> -- <%= trigger_name %>
|
|
|
|
|
<%= trigger_script %>
|
|
|
|
|
<% end -%>
|
|
|
|
|
<% end -%>
|
|
|
|
|
|
2011-01-06 12:01:33 +08:00
|
|
|
%files
|
2014-04-23 02:43:37 +08:00
|
|
|
%defattr(<%= attributes[:rpm_defattrfile] %>,<%= attributes[:rpm_user] || "root" %>,<%= attributes[:rpm_group] || "root" %>,<%= attributes[:rpm_defattrdir] %>)
|
2011-11-25 06:44:05 +08:00
|
|
|
<%# Output config files and then regular files. -%>
|
2012-03-15 15:54:42 +08:00
|
|
|
<% config_files.each do |path| -%>
|
2013-07-05 21:32:05 +08:00
|
|
|
%config(noreplace) <%= rpm_file_entry(path) %>
|
2012-03-15 15:54:42 +08:00
|
|
|
<% end -%>
|
2013-04-17 22:49:01 +08:00
|
|
|
<%# list directories %>
|
2012-09-11 16:23:40 +08:00
|
|
|
<% directories.each do |path| -%>
|
2013-04-17 22:49:01 +08:00
|
|
|
%dir <%= rpm_file_entry(path) %>
|
2012-09-11 16:23:40 +08:00
|
|
|
<% end -%>
|
2012-03-15 15:54:42 +08:00
|
|
|
<%# list only files, not directories? -%>
|
2013-04-17 23:41:29 +08:00
|
|
|
# Reject config files already listed or parent directories, then prefix files
|
|
|
|
|
# with "/", then make sure paths with spaces are quoted. I hate rpm so much.
|
|
|
|
|
<% files.each do |path| -%>
|
|
|
|
|
<% path = "/#{path}" -%>
|
|
|
|
|
<% next if config_files.include?(path)-%>
|
|
|
|
|
<% next if directories.include?(path)-%>
|
|
|
|
|
<%= rpm_file_entry(path) %>
|
|
|
|
|
<% end -%>
|
2011-01-06 12:01:33 +08:00
|
|
|
|
|
|
|
|
%changelog
|
2012-11-29 15:58:54 +08:00
|
|
|
<%= attributes[:rpm_changelog] %>
|