Mon Dec 22 21:20:00 2014

Not an mstpan

It's christmas week, and I haven't drunk everything yet.

More seriously, I'm going to be away from keyboard all day tomorrow, and then it's Christmas Eve/Day/Boxing Day, and then it's the weekend. I may manage to post things, I may not, but they're unlikely to be 'real' articles.

For today's un-post, here's some sketched pseudocode that probably makes more sense if you've seen my LPW talk.

# Dependency resolution

rule satisfies_all {Requirements ProvidesMap Dists} {
  foreach {
    member_at Requirements ReqName ReqVersion
    not { core_module ReqName }
    index_dist_for ReqName ReqDist
  } {
    available_build_of ReqDist ReqBuild
    member_at Dists ReqDist ReqBuild
    provides_map_includes ProvidesMap ReqBuild
    conflicts_ok ProvidesMap ReqBuild
    satisfies_requirements_of Build ProvidesMap Dists
  }
}

rule satisfies_requirements_of {Build ProvidesMap Dists} {
  requirements_of Build TransitiveRequirements
  satisfies_all TransitiveRequirements ProvidesVia Dists
}

rule provides_map_includes {ProvidesMap Build} {
  provides_of Build Provides
  foreach {
    member_at Provides ProvidesName ProvidesVersion
  } {
    member_at ProvidesMap ProvidesName Build
  }
}

rule conflicts_ok {ProvidesMap Build} {
  member_at Build 'conflicts' Conflicts
  foreach {
    member_at Conflicts ConflictName ConflictingVersions
  } {
    not {
      member_at ProvidesMap ConflictName ProvidedBy
      provides_of ProvidedBy Provides
      member_at Provides ConflictName ProvidedVersion
      version_matches ProvidedVersion ConflictingVersions
    }
  }
}

rule provides_of {Build Provides} {
  member_at Build 'provides' Provides
}

rule core_module {Name} { member_at core_modules Name true }

rule available_build_of {Dist Build} {
  member_at available_builds Dist Builds
  member_of Builds Build
}

rule requirements_of {Build Requirements} {
  member_at Build 'runtime_requirements' Requirements
}

# Build process

rule build_dist {Dist Build} {
  configure_env_for Dist ConfigureEnv
  configured_tree Dist ConfigureEnv ConfiguredTree
  completion_env_for ConfiguredTree CompletionEnv
  completed_tree ConfiguredTree CompletionEnv CompletedTree
  installed_tree CompletedTree Build
}

rule configure_env_for {Dist Env} {
  configure_requirements_of Dist Requirements
  satisfies_all Requirements ProvidesMap Env
}

rule completion_env_for {Dist Env} {
  completion_requirements Dist Requriements
  satisfies_all Requirements ProvidesMap Env
}

rule configured_tree {Dist Env Tree} {
  member_at configured_trees Dist Trees
  member_of Trees Tree
  member_at Tree 'configured_against' Env
}

rule completed_tree {InTree Env Tree} {
  member_at InTree 'id' InTreeId
  member_at completed_trees InTreeId Trees
  member_of Trees Tree
  member_at Tree 'completed_against' Env
}

rule installed_tree {InTree Tree} {
  member_at InTree 'id' InTreeId
  member_at installed_trees InTreeId Trees
  member_of Trees Tree
}

-- mst, out.