[Pkg-puppet-devel] [facter] 126/352: 21760/22005 update preflight to delete old lib dir

Stig Sandbeck Mathisen ssm at debian.org
Sun Apr 6 22:21:38 UTC 2014


This is an automated email from the git hooks/post-receive script.

ssm pushed a commit to branch master
in repository facter.

commit 751a7fb9d7d261898ce6ae74325087b4078d14d4
Author: Clay Caviness <clay at boobah.com>
Date:   Thu Aug 8 14:21:18 2013 -0400

    21760/22005 update preflight to delete old lib dir
    
    In order to install in the top-level site_ruby directory, we need to clean out
    any installs in the old site_ruby/1.8 location. We're doing this by setting a
    variable in the package:apple task. If it's set, we remove all files there as
    well as files in the new location.
    
    While I'm here:
    * update erb to strip leading and trailing spaces
    * validate critical variables so a script is never generated with dangerous paths
    * only target top-level files/dirs in lib, since we're doing rm -RF anyway
---
 ext/osx/preflight.erb | 40 ++++++++++++++++++++++++----------------
 1 file changed, 24 insertions(+), 16 deletions(-)

diff --git a/ext/osx/preflight.erb b/ext/osx/preflight.erb
index 3cb271a..6e185f8 100755
--- a/ext/osx/preflight.erb
+++ b/ext/osx/preflight.erb
@@ -8,23 +8,31 @@
 # ${3} is the destination volume so that this works correctly
 # when being installed to volumes other than the current OS.
 
-<% begin %>
-<%  require 'rubygems' %>
-<% rescue LoadError %>
-<% end %>
-<% require 'rake' %>
+<%- begin -%>
+  <%- require 'rubygems' -%>
+<%- rescue LoadError -%>
+<%- end -%>
+<%- require 'rake' -%>
+
+<%- ["@apple_libdir", "@apple_sbindir", "@apple_bindir", "@apple_docdir", "@package_name"].each do |i| -%>
+  <%- val = eval(i) -%>
+  <%- raise "Critical variable #{i} is unset!" if val.nil? or val.empty? -%>
+<%- end -%>
+
+# remove ruby library files
+<%- Dir.chdir("lib") -%>
+<%- [@apple_old_libdir, @apple_libdir].select {|i| i}.each do |libdir| -%>
+  <%- FileList["*"].each do |file| -%>
+/bin/rm -Rf "${3}<%= libdir %>/<%= file %>"
+  <%- end -%>
+<%- end -%>
 
-# remove libdir
-<% Dir.chdir("lib") %>
-<% FileList["**/*"].select {|i| File.file?(i)}.each do |file| %>
-/bin/rm -Rf "${3}<%= @apple_libdir %>/<%=file%>"
-<% end %>
 # remove bin files
-<% Dir.chdir("../bin") %>
-<% FileList["**/*"].select {|i| File.file?(i)}.each do |file| %>
-/bin/rm -Rf "${3}<%= @apple_bindir %>/<%=file%>"
-<% end %>
-<% Dir.chdir("..") %>
+<%- Dir.chdir("../bin") -%>
+<%- FileList["*"].each do |file| -%>
+/bin/rm -Rf "${3}<%= @apple_bindir %>/<%= file %>"
+<%- end -%>
+<%- Dir.chdir("..") -%>
 
 # remove old doc files
-/bin/rm -Rf "${3}<%= @apple_docdir %>/<%=@package_name%>"
+/bin/rm -Rf "${3}<%= @apple_docdir %>/<%= @package_name %>"

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-puppet/facter.git



More information about the Pkg-puppet-devel mailing list