Sha256: 12005c4d020e851ec76490b0997aa0eb52ccefb8ae7f6ef54f2f7cd6762d4f46
Contents?: true
Size: 1.99 KB
Versions: 3
Compression:
Stored size: 1.99 KB
Contents
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>. # Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved. # License:: LGPL # $Id: /w/fey/uttk/trunk/lib/uttk/strategies/PackageCollection.rb 8789 2005-09-27T14:49:49.088376Z ertai $ module Uttk module Strategies # This strategy takes a set of packages with their dependencies, it # computes the topological sort, and make all packages in the right order. # # * Dependencies are given as a Yaml file. # * Installation directories are propagated by with configure options. class PackageCollection < Composite include Concrete def prologue super @dependencies = Pathname.new(@dependencies) @deps = YAML::load(@dependencies.read) @order = @deps.tsort_from(@target) @order.each do |dep| @symtbl["#{dep}_install_dir".to_sym] = "<<pwd>>/#{dep}" create(Import) do |t| t.name = dep t.import = "#{dep}.yml" t.symtbl[:configure_flags] = @deps[dep].map { |d| "--with-#{d}=<<pwd>>/#{d}" }.join(' ') t.fatal = true end end end protected :prologue attribute :dependencies, 'the dependency file', :mandatory attribute :target, 'the target package name' end # class PackageCollection end # module Strategies end # module Uttk require 'tsort' class Hash include TSort alias tsort_each_node each_key def tsort_each_child(node, &block) fetch(node).each(&block) end def tsort_each_from ( node=nil, &block ) return tsort_each(&block) if node.nil? each_strongly_connected_component_from(node) do |component| if component.size == 1 block[component.first] else raise Cyclic, "topological sort failed: #{component.inspect}" end end end def tsort_from ( node=nil ) return tsort if node.nil? result = [] tsort_each_from(node) { |n| result << n } result end end # class Hash
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
uttk-0.4.5.0 | lib/uttk/strategies/PackageCollection.rb |
uttk-0.4.6.2 | lib/uttk/strategies/PackageCollection.rb |
uttk-0.4.6.1 | lib/uttk/strategies/PackageCollection.rb |