Fpm: Cannot exclude anything

Created on 25 Apr 2016  路  4Comments  路  Source: jordansissel/fpm

Ubuntu 16.04 4.4.0-21
fpm 1.5.0

I tried to exclude a file and a directory with multiple syntaxes, none of them works:

  • --exclude "/usr/lib/go/AUTHORS"
  • --exclude "./usr/lib/go/AUTHORS"
  • --exclude "/usr/lib/go/.git/"
  • --exclude "./usr/lib/go/.git/"
  • --exclude "/usr/lib/go/.git/*"
  • --exclude "./usr/lib/go/.git/*"

Most helpful comment

As per the output of --help, exclude takes a pattern to match, not a relative/absolute file name or path. You can also provide a file of patterns to exclude via --exclude-file which takes a path to said file.

All 4 comments

@jean-christophe-manciot I got the same problem, and once I got it working using -x "*/.git" I saw the following output (on verbose mode)

Removing excluded path {:path=>"opt/rbenv/.git", :matches=>"*/.git", :level=>:info}

So I suggest you to remove AUTHORS file using --exclude "usr/lib/go/AUTHORS" and git using mine version or usr/lib/go/.git

Hope it helps you

As per the output of --help, exclude takes a pattern to match, not a relative/absolute file name or path. You can also provide a file of patterns to exclude via --exclude-file which takes a path to said file.

OK. With fpm 1.6.0, I was able to exclude a specific file with --exclude "./usr/lib/go/pkg/linux_amd64/libguestfs.org/guestfs/guestfs.a", so I guess the option has been adjusted to a more common behavior.

That behaviour hasn't changed since 2013, it's still an expression. Under the hood it's just calling File.fnmatch. After checking the Ruby docs it says expression (like a regex) but actually uses globbing. The exclude phase runs at both staging and later if any specific packagers want to exclude extra things during their input phases. See lib/fpm/package.rb.

The pattern is applied to the sub-path of the staging directory so a leading slash or period is not required. I can't see any reason your above example would work in 1.6 but your original examples don't work in 1.5. To me it seems none of them should work. @jean-christophe-manciot's suggestion of losing the leading slashes is the normal behaviour.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

leandro-lucarella-sociomantic picture leandro-lucarella-sociomantic  路  10Comments

jameshfisher picture jameshfisher  路  7Comments

weakcamel picture weakcamel  路  6Comments

rdegges picture rdegges  路  4Comments

hellosputnik picture hellosputnik  路  4Comments