#
#   input:  arch
#           media manifest
#           installation manifest
#
#   Derive a installation template from the media manfest and the installation
#   manifest.
#
#      * Any component marked as installed in the media manifest, check
#        install in the installation template if it exists on the media.
#

/^arch / {
     instarch = $2
     next
}

#   As a feature, ignore the selected architecture; update everything.
#
#   Implement an architecture select on the command line, let that be the
#   selected architecture here in the next release.

/^component / {
     onmedia[$2] = $3
     next
}

#   The installed tag is part of the installation manifest.

/^installed / {
    if (onmedia[$2] != "") {
        # if onmedia[$2] < $3, attempting to install will cause a conflict.
        if (onmedia[$2] >= $3) {
           print "install " $2
        }
    }
    next
}

# Skip everything else. Notice we do nothing with links. This is by design.

{
   next
}
