Merge branch 'master' of https://github.com/MITx/fpm into MITx-master

Conflicts:
	lib/fpm/command.rb
This commit is contained in:
Jordan Sissel 2012-03-30 09:42:39 -07:00
commit 64daffcbe3
2 changed files with 32 additions and 4 deletions

View File

@ -94,9 +94,11 @@ class FPM::Command < Clamp::Command
option ["-e", "--edit"], :flag,
"Edit the package spec before building.", :default => false
option ["-x", "--exclude"], "EXCLUDE_PATTERN",
"Exclude paths matching pattern (shell wildcard globs valid here)" do |val|
@exclude_pattern ||= []
@exclude_pattern << val
"Exclude paths matching pattern (shell wildcard globs valid here). " \
"Patterns are evaluated relative to the root of the working directory, " \
"or the directory specified by -C" do |val|
@excludes ||= []
@excludes << val
end # -x / --exclude
option "--description", "DESCRIPTION", "Add a description for this package.",
:default => "no description"
@ -172,6 +174,7 @@ class FPM::Command < Clamp::Command
@provides = []
@dependencies = []
@config_files = []
@excludes = []
end # def initialize
# Execute this command. See Clamp::Command#execute and Clamp's documentation
@ -295,7 +298,7 @@ class FPM::Command < Clamp::Command
setscript.call(:after_install)
setscript.call(:before_remove)
setscript.call(:after_remove)
# Convert to the output type
output = input.convert(output_class)

View File

@ -82,6 +82,9 @@ class FPM::Package
# (Not all packages support this)
attr_accessor :replaces
# Array of glob patterns to exclude from this package
attr_accessor :excludes
# a summary or description of the package
attr_accessor :description
@ -155,6 +158,7 @@ class FPM::Package
@dependencies = []
@scripts = {}
@config_files = []
@excludes = []
staging_path
build_path
@ -170,6 +174,9 @@ class FPM::Package
# Convert this package to a new package type
def convert(klass)
@logger.info("Converting #{self.type} to #{klass.type}")
exclude
pkg = klass.new
pkg.cleanup_staging # purge any directories that may have been created by klass.new
@ -325,6 +332,24 @@ class FPM::Package
end
end # def edit_file
def exclude()
# This method removes excluded files from the staging_path. Subclasses can
# remove the files during the input phase rather than deleting them here
if @attributes.include?(:prefix)
installdir = staging_path(@attributes[:prefix])
else
installdir = staging_path
end
@excludes.each do |path|
path = File.join(installdir, path)
::Dir.glob(path) do |rmpath|
@logger.debug("Removing", :path => rmpath)
FileUtils.remove_entry_secure(rmpath)
end
end
end # def exclude
class << self
# This method is invoked when subclass occurs.