class Vanagon::Patch

Attributes

after[R]

@!attribute [r] after

@return [String] What step should this patch be applied to, one of ["unpack", "install"]
assembly_path[R]

@!attribute [r] assembly_path

@return [String] The path to the patch inside the assembly
destination[R]

@!attribute [r] destination

@return [String] The working directory where this patch will be applied.
  Only used for post-installation patches.
fuzz[R]

@!attribute [r] fuzz

@return [Integer] The fuzz factor for applying the patch
namespace[R]

@!attribute [r] namespace

@return [String] The namespace for the patch
origin_path[R]

@!attribute [r] origin_path

@return [String] The path to the patch before assembly
strip[R]

@!attribute [r] strip

@return [Integer] the number of path components to strip from the patch path

Public Class Methods

new(origin_path, component, options) click to toggle source
# File lib/vanagon/patch.rb, line 34
def initialize(origin_path, component, options) # rubocop:disable Metrics/AbcSize,Metrics/PerceivedComplexity
  valid_keys = %i[namespace destination strip fuzz after]
  bad_keys = options.each_key.reject { |k| valid_keys.include? k }

  unless bad_keys.empty?
    raise Vanagon::Error, "Bad options in patch initialization: #{bad_keys}."
  end

  @origin_path = origin_path
  @namespace = options[:namespace] || component.name
  @assembly_path = "patches/#{@namespace}/#{File.basename(@origin_path)}"
  @strip = options[:strip] || 1
  @fuzz = options[:fuzz] || 0
  @after = options[:after] || 'unpack'
  unless ['unpack', 'install'].include?(@after)
    raise Vanagon::Error, 'Only "unpack" or "install" permitted for "after" option.'
  end
  @destination = options[:destination] || component.dirname
end

Public Instance Methods

cmd(platform) click to toggle source
# File lib/vanagon/patch.rb, line 54
def cmd(platform)
  return "#{platform.patch} --strip=#{@strip} --fuzz=#{@fuzz} --ignore-whitespace --no-backup-if-mismatch < $(workdir)/#{@assembly_path}"
end