class FPM::Fry::Plugin::Config::Callback
@api private
Public Instance Methods
call(_, package)
click to toggle source
# File lib/fpm/fry/plugin/config.rb, line 18 def call(_, package) chroot = FPM::Fry::Chroot.new(package.staging_path) prefix_length = package.staging_path.size + 1 candidates = [] # Sorting is important so that more specific rules override more generic # rules. keys = files.keys.sort_by(&:size) keys.each do | key | if files[key] # Inclusion rule. Crawl file system for candidates begin lstat = chroot.lstat( key ) if lstat.symlink? package.logger.warn("Config file is a symlink", path: key, plugin: 'config', documentation: 'https://github.com/xing/fpm-fry/wiki/Plugin-config#config-path-not-foun://github.com/xing/fpm-fry/wiki/Plugin-config#config-file-is-a-symlink') next end chroot.find( key ) do | path | lstat = chroot.lstat(path) if lstat.symlink? package.logger.debug("Ignoring symlink", path: path, plugin: 'config') throw :prune elsif lstat.file? candidates << path end end rescue Errno::ENOENT package.logger.warn("Config path not found", path: key, plugin: 'config', documentation: 'https://github.com/xing/fpm-fry/wiki/Plugin-config#config-path-not-found') end else # Exclusion rule. Remove matching candidates keydir = key + "/" candidates.reject!{ |can| can.start_with?(keydir) || can == key } end end package.config_files |= candidates end