fpm 0.4.12 → 0.4.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/CHANGELIST +5 -0
  2. data/lib/fpm/package.rb +30 -10
  3. metadata +2 -2
data/CHANGELIST CHANGED
@@ -1,3 +1,8 @@
1
+ 0.4.13 (August 14, 2012)
2
+ - Make --exclude accept path prefixes as well. If you have a files in
3
+ 'usr/share/man' in your package, you can now exclude all of a subdir
4
+ by doing '--exclude usr/share/man'
5
+
1
6
  0.4.12 (August 10, 2012)
2
7
  - Fix a major bug introduced in 0.4.11 that caused all deb packages to
3
8
  contain empty maintainer scripts if not otherwise specified, which made
@@ -343,23 +343,43 @@ class FPM::Package
343
343
  installdir = staging_path
344
344
  end
345
345
 
346
+ exclude_path = proc do |file|
347
+ FileUtils.remove_entry_secure(staging_path(file))
348
+ Pathname.new(staging_path(file)).parent.ascend do |d|
349
+ if (::Dir.entries(d) - %w[ . .. ]).empty?
350
+ ::Dir.rmdir(d)
351
+ @logger.info("Deleting empty directory left by removing exluded file", :path => d)
352
+ else
353
+ break
354
+ end
355
+ end
356
+ end # exclude_path
357
+
346
358
  attributes[:excludes].each do |wildcard|
347
359
  @logger.debug("Checking for things to exclude", :wildcard => wildcard)
348
360
  files.each do |file|
361
+ @logger.debug("Checking path against wildcard", :path => file, :wildcard => wildcard)
349
362
  if File.fnmatch(wildcard, file)
350
363
  @logger.info("Removing excluded file", :path => file, :matches => wildcard)
351
- FileUtils.remove_entry_secure(staging_path(file))
352
- Pathname.new(staging_path(file)).parent.ascend do |d|
353
- if (::Dir.entries(d) - %w[ . .. ]).empty?
354
- ::Dir.rmdir(d)
355
- @logger.info("Deleting empty directory left by removing exluded file", :path => d)
356
- else
357
- break
358
- end
364
+ exclude_path.call(file)
365
+ next
366
+ end
367
+
368
+ @logger.debug("Checking if path is a child of an excluded directory",
369
+ :path => file, :wildcard => wildcard,
370
+ :directory? => File.directory?(staging_path(wildcard)))
371
+ if File.directory?(staging_path(wildcard))
372
+ # issue #248, if the excludes entry is a directory, ignore that
373
+ # directory and anything inside it.
374
+ exclude_re = Regexp.new("^#{Regexp.escape(wildcard)}($|/)")
375
+ if exclude_re.match(file)
376
+ @logger.info("Removing excluded file which has a parent excluded directory",
377
+ :path => file, :excluded => wildcard)
378
+ exclude_path.call(file)
359
379
  end
360
380
  end
361
- end
362
- end
381
+ end
382
+ end # files.each
363
383
  end # def exclude
364
384
 
365
385
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fpm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.12
4
+ version: 0.4.13
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-10 00:00:00.000000000 Z
12
+ date: 2012-08-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json