1
0
mirror of https://github.com/jordansissel/fpm synced 2025-08-29 04:01:33 +02:00
fpm/templates/rpm.erb
2012-03-18 22:56:34 -07:00

107 lines
2.7 KiB
Plaintext

# 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
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 %>
BuildArch: <%= architecture %>
AutoReqProv: no
Group: <%= category %>
License: <%= license %>
Vendor: <%= vendor %>
URL: <%= url or "http://nourlgiven.example.com/" %>
Packager: <%= maintainer %>
<% dependencies.each do |req| -%>
Requires: <%= req %>
<% 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
<% files.each do |path| -%>
<% source = File.join(staging_path, path) -%>
<% # Copy to the build_path/BUILD/ to make rpmbuild happy -%>
<% target = File.join(build_path, "BUILD", path) -%>
<% dir = File.dirname(target) %>
mkdir -p "<%= dir %>"
if [ -f "<%= source %>" ] ; then
cp "<%= source %>" "<%= target %>"
elif [ -d "<%= source %>" ] ; then
mkdir "<%= target %>"
fi
<% end %>
%clean
# noop
<% if scripts[:before_install] -%>
%pre
<%= scripts[:before_install] %>
<% end -%>
<% if scripts[:after_install] -%>
%post
<%= scripts[:after_install] %>
<% end -%>
<% if scripts[:before_remove] -%>
%preun
<%= scripts[:before_remove] %>
<% end -%>
<% if scripts[:after_remove] -%>
%postun
<%= scripts[:after_remove] %>
<% end -%>
%files
%defattr(-,root,root,-)
<%# Output config files and then regular files. -%>
<% config_files.each do |path| -%>
%config <%= path %>
<% end -%>
<%# list only files, not directories? -%>
<%=
# Reject directories or config files already listed, then prefix files with
# "/", then make sure paths with spaces are quoted. I hate rpm so much.
files.reject { |f| File.directory?(File.join(staging_path, f)) } \
.collect { |f| "/#{f}" } \
.reject { |f| config_files.include?(f) } \
.collect { |f| f[/\s/] and "\"#{f}\"" or f } \
.join("\n")
%>
%changelog