1
0
mirror of https://github.com/jordansissel/fpm synced 2025-08-31 04:20:42 +02:00
fpm/templates/rpm.erb
Jordan Sissel 8f5666f454 Merge pull request #676 from robkinyon/rpm_arch
Fixes for RPM and --architecture
2014-04-22 17:46:38 -07:00

150 lines
4.5 KiB
Plaintext

# Hello packaging friend!
#
# If you find yourself using this 'fpm --edit' feature frequently, it is
# 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
# ------------------------------------------------------------------------
# Disable the stupid stuff rpm distros include in the build process by default:
<% %w(prep build install clean).each do |step| -%>
<%# 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 -%>
# Disable checking for unpackaged files ?
#%undefine __check_files
# Use <%= attributes[:rpm_digest] %> file digest method
%define _binary_filedigest_algorithm <%= digest_algorithm %>
# Use <%= attributes[:rpm_compression] %> payload compression
%define _binary_payload <%= payload_compression %>
<% (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 -%>
<% if !(attributes[:rpm_filter_from_requires] or []).empty? or !(attributes[:rpm_filter_from_provides] or []).empty?-%>
%filter_setup
<% end -%>
Name: <%= name %>
Version: <%= version %>
<% if epoch -%>
Epoch: <%= epoch %>
<% end -%>
Release: <%= iteration or 1 %>
<%# use the first line of the description as the summary -%>
Summary: <%= description.split("\n").first.empty? ? "_" : description.split("\n").first %>
<% if !attributes[:rpm_autoreqprov?] -%>
AutoReqProv: no
<% else -%>
AutoReqProv: yes
<% end -%>
<% if attributes[:rpm_autoreq?] -%>
AutoReq: yes
<% end -%>
<% if attributes[:rpm_autoprov?] -%>
AutoProv: yes
<% end -%>
# 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
# Add prefix, must not end with /
<% if !prefix.nil? and !prefix.empty? %>
Prefix: <%= prefix.gsub(/([^\/]+)(\/$)/, '') %>
<% end -%>
Group: <%= category %>
<%# 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", " ") %>
<% if !vendor.nil? and !vendor.empty? -%>
Vendor: <%= vendor %>
<% end -%>
<% if !url.nil? and !url.empty? -%>
URL: <%= url %>
<%else -%>
URL: http://nourlgiven.example.com/
<% end -%>
Packager: <%= maintainer %>
<% if !attributes[:no_depends?] -%>
<% dependencies.each do |req| -%>
Requires: <%= req %>
<% end -%>
<% end -%>
<% provides.each do |prov| -%>
Provides: <%= prov %>
<% end -%>
<% conflicts.each do |conflict| -%>
Conflicts: <%= conflict %>
<% end -%>
<% replaces.each do |repl| -%>
<%# The closes equivalent in RPM to "replaces" is "Obsoletes" -%>
Obsoletes: <%= repl %>
<% end -%>
<%# rpm rejects descriptions with blank lines (even between content), so hack
around it by replacing blank lines with ' .' -%>
%description
<%= description.gsub(/^\s*$/, " .") %>
%prep
# noop
%build
# noop
%install
# noop
%clean
# noop
<%# This next section puts any %pre, %post, %preun, or %postun scripts %>
<%
scriptmap = {
:before_install => "pre",
:after_install => "post",
:before_remove => "preun",
:after_remove => "postun",
}
scriptmap.each do |name, rpmname|
-%>
<% if script?(name) -%>
%<%= rpmname %>
<%= script(name) %>
<% end -%>
<% end -%>
%files
%defattr(<%= attributes[:rpm_defattrfile] %>,<%= attributes[:rpm_user] || "root" %>,<%= attributes[:rpm_group] || "root" %>,<%= attributes[:rpm_defattrdir] %>)
<%# Output config files and then regular files. -%>
<% config_files.each do |path| -%>
%config(noreplace) <%= rpm_file_entry(path) %>
<% end -%>
<%# list directories %>
<% directories.each do |path| -%>
%dir <%= rpm_file_entry(path) %>
<% end -%>
<%# list only files, not directories? -%>
# 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 -%>
%changelog
<%= attributes[:rpm_changelog] %>