Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Replace % with [%] to make rpm not expand macros in file names #266

Merged
merged 2 commits into from

2 participants

@jwittkoski

File names can have percents in them and rpm is... rpm, so stop the macro replacement madness.

Macro replacement is usually not an issue unless your file name contains something like "%name%" or another defined macro. (I'm looking at you, rails.)

@jwittkoski

Should fix issue #222.

@jordansissel jordansissel merged commit 0ed0021 into jordansissel:master
@jordansissel

Thanks! I'll write a test case to make sure this works in future releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 2 deletions.
  1. +4 −2 templates/rpm.erb
View
6 templates/rpm.erb
@@ -69,9 +69,9 @@ Obsoletes: <%= repl %>
%install
<% files.each do |path| -%>
-<% source = Shellwords.shellescape(File.join(staging_path, path)) -%>
+<% source = Shellwords.shellescape(File.join(staging_path, path)).gsub("%", "%%") -%>
<% # Copy to the build_path/BUILD/ to make rpmbuild happy -%>
-<% target = Shellwords.shellescape(File.join(build_path, build_sub_dir, path)) -%>
+<% target = Shellwords.shellescape(File.join(build_path, build_sub_dir, path)).gsub("%", "%%") -%>
<% dir = File.dirname(target) %>
mkdir -p <%= dir %>
if [ -f <%= source %> ] || [ -h <%= source %> ] ; then
@@ -117,12 +117,14 @@ fi
# Replace [ with [\[] to make rpm not use globs
# Replace * with [*] to make rpm not use globs
# Replace ? with [?] to make rpm not use globs
+ # Replace % with [%] to make rpm not expand macros
files.collect { |f| "/#{f}" } \
.reject { |f| config_files.include?(f) } \
.collect { |f| f[/\s/] and "\"#{f}\"" or f } \
.collect { |f| f.gsub("[", "[\\[]") } \
.collect { |f| f.gsub("*", "[*]") } \
.collect { |f| f.gsub("?", "[?]") } \
+ .collect { |f| f.gsub("%", "[%]") } \
.join("\n")
#.collect { |f| File.join(prefix, f) } \
%>
Something went wrong with that request. Please try again.