CentOS 7, minimal install. Make sure the ruby packages are NOT installed. Enable the Sensu repo following these instructions: http://sensuapp.org/docs/latest/install-repositories
Run "yum install sensu". Enable the path to the embedded Ruby in Sensu:
$ export PATH=/opt/sensu/embedded/bin:$PATH
$ which gem
/opt/sensu/embedded/bin/gem
Try and build the sys-filesystem gem:
fpm -s gem -t rpm --iteration 1.el7 --epoch 1 \
--depends sensu \
--provides "rubygem(ffi)" \
--license GPL --maintainer "A <[email protected]>" \
--vendor [email protected] --url "https://github.com/djberg96/sys-filesystem" \
--description "A Ruby library for getting filesystem information" \
sys-filesystem
(the --provides line is technically wrong, but ffi is provided by the embedded Ruby in Sensu, and this gem depends on Sensu and will always be installed with Sensu, so it's not a huge crime)
If $PATH is set correctly, the package will be built for the embedded Ruby in Sensu.
When you install the generated package, it will conflict with Sensu:
# rpm -ivh rubygem-sys-filesystem-1.1.4-1.el7.noarch.rpm
Preparing... ################################# [100%]
file /opt/sensu/embedded/lib/ruby/gems/2.0.0/build_info from install of rubygem-sys-filesystem-1:1.1.4-1.el7.noarch conflicts with file from package sensu-1:0.17.2-1.x86_64
file /opt/sensu/embedded/lib/ruby/gems/2.0.0/doc from install of rubygem-sys-filesystem-1:1.1.4-1.el7.noarch conflicts with file from package sensu-1:0.17.2-1.x86_64
So rebuild the gem to exclude those paths:
fpm -s gem -t rpm --iteration 1.el7 --epoch 1 \
--depends sensu \
--exclude /opt/sensu/embedded/lib/ruby/gems/2.0.0/build_info \
--exclude /opt/sensu/embedded/lib/ruby/gems/2.0.0/doc \
--provides "rubygem(ffi)" \
--license GPL --maintainer "A <[email protected]>" \
--vendor [email protected] --url "https://github.com/djberg96/sys-filesystem" \
--description "A Ruby library for getting filesystem information" \
sys-filesystem
But if you look at the package, it still contains those paths:
$ rpm -qpl rubygem-sys-filesystem-1.1.4-1.el7.noarch.rpm
/opt/sensu/embedded/lib/ruby/gems/2.0.0/build_info
/opt/sensu/embedded/lib/ruby/gems/2.0.0/cache/sys-filesystem-1.1.4.gem
/opt/sensu/embedded/lib/ruby/gems/2.0.0/doc
/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sys-filesystem-1.1.4/CHANGES
/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sys-filesystem-1.1.4/MANIFEST
/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sys-filesystem-1.1.4/README
/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sys-filesystem-1.1.4/Rakefile
/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sys-filesystem-1.1.4/examples/example_stat.rb
/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sys-filesystem-1.1.4/lib/sys/filesystem.rb
/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sys-filesystem-1.1.4/lib/unix/sys/filesystem.rb
/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sys-filesystem-1.1.4/lib/unix/sys/filesystem/constants.rb
/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sys-filesystem-1.1.4/lib/unix/sys/filesystem/functions.rb
/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sys-filesystem-1.1.4/lib/unix/sys/filesystem/structs.rb
/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sys-filesystem-1.1.4/lib/windows/sys/filesystem.rb
/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sys-filesystem-1.1.4/lib/windows/sys/filesystem/constants.rb
/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sys-filesystem-1.1.4/lib/windows/sys/filesystem/functions.rb
/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sys-filesystem-1.1.4/lib/windows/sys/filesystem/helper.rb
/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sys-filesystem-1.1.4/sys-filesystem.gemspec
/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sys-filesystem-1.1.4/test/test_sys_filesystem.rb
/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sys-filesystem-1.1.4/test/test_sys_filesystem_unix.rb
/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sys-filesystem-1.1.4/test/test_sys_filesystem_windows.rb
/opt/sensu/embedded/lib/ruby/gems/2.0.0/specifications/sys-filesystem-1.1.4.gemspec
Is there a way to exclude those files, other than using --edit?
Hi,
we found a workaround that might exclude too much:
fpm -x "*build_info" -x "*doc" ...
But we are also interested in a real solution...
I am having the same problem.. '-x' is not excluding anything. fpm-1.3.3 here.
seems to be working fine for me.
-x "*/.git" or -x "*/v2/.git"
fpm-1.4.0
Ran into this issue while building an RPM for PM2.
The issue for me appeared to be that excluding absolute paths does not work as I expected. I needed to exclude relative to the build prefix.
So for example when the FPM output displayed:
Setting default npm install prefix {:prefix=>"/usr", :level=>:info}
I needed to exclude relative to /usr. So to stop /usr/etc from appearing in my RPM I added the following:
-x etc
Using fpm-1.4.0. Hope that helps.
I've got the same issues when building sensu plugins with fpm.
It seems that the leading slash should be omitted in absolute paths.
Here is what works for me:
/opt/sensu/embedded/bin/fpm -s gem -t rpm --gem-package-name-prefix sensu_rubygem \
--exclude opt/sensu/embedded/lib/ruby/gems/*/build_info \
--exclude opt/sensu/embedded/lib/ruby/gems/*/doc \
--exclude opt/sensu/embedded/lib/ruby/gems/*/extensions \
--gem-disable-dependency mixlib-cli \
--gem-disable-dependency sensu-plugin \
--no-gem-env-shebang --verbose ./cache/sensu-plugins-graphite-1.1.0.gem
And there is a hint on how --exclude works in the verbose output:
Removing excluded path {:path=>"opt/sensu/embedded/lib/ruby/gems/2.3.0/build_info", :matches=>"opt/sensu/embedded/lib/ruby/gems/*/build_info", :level=>:info}
Removing excluded path {:path=>"opt/sensu/embedded/lib/ruby/gems/2.3.0/doc", :matches=>"opt/sensu/embedded/lib/ruby/gems/*/doc", :level=>:info}
Removing excluded path {:path=>"opt/sensu/embedded/lib/ruby/gems/2.3.0/extensions", :matches=>"opt/sensu/embedded/lib/ruby/gems/*/extensions", :level=>:info}
I tried a bunch of different patterns in an attempt to exclude the .git directory but none of them seems to work - either it just includes it anyway or throws this error when I try to exclude .git/*.
Invalid package configuration: Cannot package the path './ ', does it exist? {:level=>:error}
As a workaround, I updated my build script to move .git to dot_git, run FPM excluding that directory, then moving it back. The, the following exclude patterns work:
--exclude="*.deb" \
--exclude="deb/*" \
--exclude="dot_git/*" \
fpm --version
1.11.0
I was able to get it to exclude my .git directory but only by using a wildcard at the start of the expression.
Worked:
--exclude="*/.git"
Did not work:
--exclude=".git"
--exclude="/.git"
--exclude="./.git"
Getting it to match .deb was a lot easier.
Worked:
--exclude="*.deb"
--exclude="*/*.deb"
I only have .deb files in the root of my project so it's possible that the lack of directory wildcard would change behavior.
Most helpful comment
I've got the same issues when building sensu plugins with fpm.
It seems that the leading slash should be omitted in absolute paths.
Here is what works for me:
And there is a hint on how
--excludeworks in the verbose output: