Created
November 24, 2014 12:06
-
-
Save alanfranz/d6cc438d7e5efde59706 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 4636da988c13325eb1167ca474113711d939969d Mon Sep 17 00:00:00 2001 | |
From: Alan Franzoni <[email protected]> | |
Date: Sun, 23 Nov 2014 22:02:26 +0100 | |
Subject: [PATCH] Fix: don't stumble with source directories permissions - see | |
#807 | |
--- | |
lib/fpm/package.rb | 2 +- | |
lib/fpm/package/dir.rb | 16 ++++++++++++---- | |
2 files changed, 13 insertions(+), 5 deletions(-) | |
diff --git a/lib/fpm/package.rb b/lib/fpm/package.rb | |
index 17e8d33..fced64b 100644 | |
--- a/lib/fpm/package.rb | |
+++ b/lib/fpm/package.rb | |
@@ -277,7 +277,7 @@ class FPM::Package | |
def cleanup_staging | |
if File.directory?(staging_path) | |
logger.debug("Cleaning up staging path", :path => staging_path) | |
- FileUtils.rm_r(staging_path) | |
+ FileUtils.rm_rf(staging_path) | |
end | |
end # def cleanup_staging | |
diff --git a/lib/fpm/package/dir.rb b/lib/fpm/package/dir.rb | |
index 54b0947..90f1e0d 100644 | |
--- a/lib/fpm/package/dir.rb | |
+++ b/lib/fpm/package/dir.rb | |
@@ -142,10 +142,20 @@ class FPM::Package::Dir < FPM::Package | |
elsif fileinfo.symlink? | |
copy(source, destination) | |
else | |
- # Copy all files from 'path' into staging_path | |
+ # Copy all files from 'path' into staging_path, | |
+ # without stumbling on permissions | |
+ sources_and_destinations = [] | |
Find.find(source) do |path| | |
target = File.join(destination, path) | |
- copy(path, target) | |
+ sources_and_destinations.push([path, target]) | |
+ end | |
+ | |
+ sources_and_destinations.each do |sourcepath, targetpath| | |
+ copy(sourcepath, targetpath) | |
+ end | |
+ | |
+ sources_and_destinations.reverse.each do |sourcepath, targetpath| | |
+ copy_metadata(sourcepath, targetpath) | |
end | |
end | |
end # def clone | |
@@ -190,8 +200,6 @@ class FPM::Package::Dir < FPM::Package | |
logger.error("Cannot copy file, the destination path is probably a directory and I attempted to write a file.", :path => sane_path, :staging => staging_path) | |
end | |
end | |
- | |
- copy_metadata(source, destination) | |
end # def copy | |
def copy_metadata(source, destination) | |
-- | |
2.1.3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment