Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a few CPAN issues #1610

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/fpm/package/cpan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ def input(package)
self.vendor = case metadata["author"]
when String; metadata["author"]
when Array; metadata["author"].join(", ")
# for Class::Data::Inheritable and others with blank 'author' field, fix "Invalid package configuration: Unexpected CPAN 'author' field type: NilClass. This is a bug."
when NilClass; "No Vendor Or Author Provided"
else
raise FPM::InvalidPackageConfiguration, "Unexpected CPAN 'author' field type: #{metadata["author"].class}. This is a bug."
end if metadata.include?("author")
Expand Down Expand Up @@ -304,7 +306,8 @@ def unpack(tarball)
directory = build_path("module")
::Dir.mkdir(directory)
args = [ "-C", directory, "-zxf", tarball,
"--strip-components", "1" ]
# "--strip-components", "1" ] # fails on removing leading ./Foo/ in tarball paths
%q{--transform=s,[./]*[^/]*/,,} ] # succeeds on removing leading ./Foo/ or /Foo/ or Foo/
safesystem("tar", *args)
return directory
end
Expand Down
12 changes: 8 additions & 4 deletions lib/fpm/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,10 @@ def execmd(*args)
process.io.stdout = stdout_w
process.io.stderr = stderr_w

if block_given? and opts[:stdin]
process.duplex = true
end
# Always use duplex mode because we will always
# want to either write to stdin (if block_given?)
# or we will want to close stdin to prevent subprocesses from blocking on it.
process.duplex = true

process.start

Expand All @@ -170,10 +171,13 @@ def execmd(*args)

yield(*args3)

process.io.stdin.close if opts[:stdin] and not process.io.stdin.closed?
process.io.stdin.close if not process.io.stdin.closed?
stdout_r.close unless stdout_r.closed?
stderr_r.close unless stderr_r.closed?
else
# If no block given (not interactive) we should close stdin.
process.io.stdin.close

# Log both stdout and stderr as 'info' because nobody uses stderr for
# actually reporting errors and as a result 'stderr' is a misnomer.
logger.pipe(stdout_r => :info, stderr_r => :info)
Expand Down