Permalink
Browse files

remove trailing slash from --prefix option in rpm-packages, fixes #819

  • Loading branch information...
1 parent 7a7d057 commit 3338aa8f4b5ba90c1314f3c4887b33cee1c36f7e @luto luto committed Jun 21, 2016
Showing with 24 additions and 3 deletions.
  1. +5 −1 lib/fpm/package/rpm.rb
  2. +18 −0 spec/fpm/package/rpm_spec.rb
  3. +1 −2 templates/rpm.erb
@@ -523,7 +523,11 @@ def output(output_path)
end # def output
def prefix
- return (attributes[:prefix] or "/")
+ if attributes[:prefix] and attributes[:prefix] != '/'
+ return attributes[:prefix].chomp('/')
+ else
+ return "/"
+ end
end # def prefix
def build_sub_dir
@@ -457,6 +457,24 @@ def subject.render_template; @rpmspec = template("rpm.erb").result(binding); end
end # dist
end # #output
+ describe "prefix attribute" do
+ it "should default to slash" do
+ insist { subject.prefix } == "/"
+ end
+ it "should leave a single slash as it is" do
+ subject.attributes[:prefix] = "/"
+ insist { subject.prefix } == "/"
+ end
+ it "should leave a path without trailing slash it is" do
+ subject.attributes[:prefix] = "/foo/bar"
+ insist { subject.prefix } == "/foo/bar"
+ end
+ it "should remove trailing slashes" do
+ subject.attributes[:prefix] = "/foo/bar/"
+ insist { subject.prefix } == "/foo/bar"
+ end
+ end
+
describe "regressions should not occur", :if => program_exists?("rpmbuild") do
before :each do
@tempfile_handle =
View
@@ -58,9 +58,8 @@ AutoProv: yes
# 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(/([^\/]+)(\/$)/, '') %>
+Prefix: <%= prefix %>
<% end -%>
Group: <%= category %>

0 comments on commit 3338aa8

Please sign in to comment.