Permalink
Browse files

Merge pull request #1182 from liger1978/fix_1179

Fix #1179 Remove .packlist files and empty parent directories from CPAN packages
  • Loading branch information...
2 parents ab50185 + 5981a29 commit 99f5e52fda7577c93c1fe4f448e9117dc6ed8c3c @jordansissel committed on GitHub Aug 24, 2016
Showing with 16 additions and 0 deletions.
  1. +16 −0 lib/fpm/package/cpan.rb
View
16 lib/fpm/package/cpan.rb
@@ -3,6 +3,7 @@
require "fpm/util"
require "fileutils"
require "find"
+require "pathname"
class FPM::Package::CPAN < FPM::Package
# Flags '--foo' will be accessable as attributes[:npm_foo]
@@ -257,6 +258,21 @@ def input(package)
:path => path.gsub(staging_path, ""))
File.unlink(path)
end
+
+ # Remove useless .packlist files and their empty parent folders
+ # https://github.com/jordansissel/fpm/issues/1179
+ ::Dir.glob(File.join(staging_path, glob_prefix, "**/.packlist")).each do |path|
+ logger.debug("Removing useless file.",
+ :path => path.gsub(staging_path, ""))
+ File.unlink(path)
+ Pathname.new(path).parent.ascend do |parent|
+ if ::Dir.entries(parent).sort == ['.', '..'].sort
+ FileUtils.rmdir parent
+ else
+ break
+ end
+ end
+ end
end

0 comments on commit 99f5e52

Please sign in to comment.