Skip to content
  • Steven Danna's avatar
    Cache Builder#shasum before Builder#build to ensure consistent result · be342106
    Steven Danna authored
    The Builder#shasum is based, in-part, on the build_commands in the
    instance of Builder. This is problematic because the `block` DSL
    method allows users to use other Builder DSL methods inside of it, all
    of which mutate the build_command array when #build is called. Thus, a
    given builder will return a different shasum before and after build is
    called.
    
    Caching shashum at the beginning of build fixes this problem, but has
    a major drawback. Namely, two builders with the same shashum might
    execute different commands.
    
    This problem is partially mitigated by the fact that the builder
    shashum is just a part of the software shasum, which will typically
    include the actual text of the software definition as part of its
    digest.
    
    This will not catch software definitions where the build steps can
    produce different based on the system state, such as this:
    
      block do
        Dir.glob("#{install_dir}/embedded/apath/bin/*").sort.each do |f|
          link bin, "#{install_dir}/embedded/bin/#{File.basename(f)}"
        end
      end
    
    However, that will always be a problem since we allow pure Ruby in our
    build steps.
    
    Fixes #450
    be342106