Example #1
0
def deploy_with_domains(builder, target_dir, name, role_domains):
    """
    Register a file deployment.

    'role_domains' is a sequence of (role, domain) pairs. The deployment will
    take the roles and domains specified, and build them into a deployment at
    deploy/[name].

    More specifically, a rule will be created for label:

      "deployment:<name>/deployed"

    which depends on "package:(<domain>)*{<role}/postinstalled" for each
    (<role>, <domain>) pair in 'role_domains'.

    In other words, the deployment called 'name' will depend on the given roles
    in the appropriate domains having been "finished" (postinstalled).

    An "instructions applied" label "deployment:<name>/instructionsapplied"
    will also be created.

    The deployment should eventually be located at 'target_dir'.
    """

    the_action = FileDeploymentBuilder(role_domains, target_dir)

    dep_label = depend.Label(utils.LabelType.Deployment, name, None,
                             utils.LabelTag.Deployed)

    iapp_label = depend.Label(utils.LabelType.Deployment,
                              name,
                              None,
                              utils.LabelTag.InstructionsApplied,
                              transient=True)

    # We depend on every postinstall for every package in the roles

    deployment_rule = depend.Rule(dep_label, the_action)

    for role, domain in role_domains:
        role_label = depend.Label(utils.LabelType.Package,
                                  "*",
                                  role,
                                  utils.LabelTag.PostInstalled,
                                  domain=domain)
        deployment_rule.add(role_label)

    # The instructionsapplied label is standalone ..
    app_rule = depend.Rule(iapp_label, the_action)

    # Now add 'em ..
    builder.ruleset.add(deployment_rule)
    builder.ruleset.add(app_rule)

    # .. and deal with cleanup, which is entirely generic
    deployment.register_cleanup(builder, name)

    # .. and set the environment
    the_action.attach_env(builder)
Example #2
0
def deploy_with_domains(builder, target_dir, name, role_domains):
    """
    Register a file deployment.

    'role_domains' is a sequence of (role, domain) pairs. The deployment will
    take the roles and domains specified, and build them into a deployment at
    deploy/[name].

    More specifically, a rule will be created for label:

      "deployment:<name>/deployed"

    which depends on "package:(<domain>)*{<role}/postinstalled" for each
    (<role>, <domain>) pair in 'role_domains'.

    In other words, the deployment called 'name' will depend on the given roles
    in the appropriate domains having been "finished" (postinstalled).

    An "instructions applied" label "deployment:<name>/instructionsapplied"
    will also be created.

    The deployment should eventually be located at 'target_dir'.
    """

    the_action = FileDeploymentBuilder(role_domains, target_dir)

    dep_label = depend.Label(utils.LabelType.Deployment, name, None,
                             utils.LabelTag.Deployed)

    iapp_label = depend.Label(utils.LabelType.Deployment, name, None,
                              utils.LabelTag.InstructionsApplied,
                              transient = True)

    # We depend on every postinstall for every package in the roles

    deployment_rule = depend.Rule(dep_label, the_action)

    for role, domain in role_domains:
        role_label = depend.Label(utils.LabelType.Package, "*", role,
                                  utils.LabelTag.PostInstalled,
                                  domain = domain)
        deployment_rule.add(role_label)

    # The instructionsapplied label is standalone ..
    app_rule = depend.Rule(iapp_label, the_action)

    # Now add 'em ..
    builder.ruleset.add(deployment_rule)
    builder.ruleset.add(app_rule)

    # .. and deal with cleanup, which is entirely generic
    deployment.register_cleanup(builder, name)

    # .. and set the environment
    the_action.attach_env(builder)
Example #3
0
def deploy(builder, name, rolesThatUseThis = [ ], rolesNeededForThis = [ ]):
    """
    Register a tools deployment.

    This is used to:

    1. Set the environment for each role in 'rolesThatUseThis' so that
       PATH, LD_LIBRARY_PATH and PKG_CONFIG_PATH include the 'name'
       deployment

    2. Make deployment:<name>/deployed depend upon the 'rolesNeededForThis'

    3. Register cleanup for this deployment

    The intent is that we have a "tools" deployment, which provides useful
    host tools (for instance, something to mangle a file in a particular
    manner). Those roles which need to use such tools in their builds
    (normally in a Makefile.muddle) then need to have the environment set
    appropriately to allow them to find the tools (and ideally, not system
    provided tools which mighth have the same name).
    """

    tgt = depend.Label(utils.LabelType.Deployment,
                       name,
                       None,
                       utils.LabelTag.Deployed)

    for role in rolesThatUseThis:
        for tag in ( utils.LabelTag.PreConfig, utils.LabelTag.Configured, utils.LabelTag.Built,
                     utils.LabelTag.Installed, utils.LabelTag.PostInstalled) :
            lbl = depend.Label(utils.LabelType.Package,
                               "*",
                               role,
                               tag)
            env = builder.get_environment_for(lbl)
            attach_env(builder, role, env, name)

        deployment.role_depends_on_deployment(builder, role, name)

    the_rule = depend.Rule(tgt, ToolsDeploymentBuilder(rolesNeededForThis))
    builder.ruleset.add(the_rule)

    deployment.deployment_depends_on_roles(builder, name, rolesNeededForThis)

    deployment.register_cleanup(builder, name)
Example #4
0
def _inside_of_deploy(builder, name, the_action):
    """This implements the common code from the public 'deploy()' function.
    """
    dep_label = Label(utils.LabelType.Deployment,
                      name, None, utils.LabelTag.Deployed)

    deployment_rule = depend.Rule(dep_label, the_action)

    # We need to clean it as well, annoyingly ..
    deployment.register_cleanup(builder, name)

    builder.ruleset.add(deployment_rule)

    # InstructionsApplied is a standalone rule, invoked by the deployment
    iapp_label = Label(utils.LabelType.Deployment, name, None,
                       utils.LabelTag.InstructionsApplied,
                       transient = True)
    iapp_rule = depend.Rule(iapp_label, the_action)
    builder.ruleset.add(iapp_rule)
Example #5
0
def deploy(builder, name, rolesThatUseThis=[], rolesNeededForThis=[]):
    """
    Register a tools deployment.

    This is used to:

    1. Set the environment for each role in 'rolesThatUseThis' so that
       PATH, LD_LIBRARY_PATH and PKG_CONFIG_PATH include the 'name'
       deployment

    2. Make deployment:<name>/deployed depend upon the 'rolesNeededForThis'

    3. Register cleanup for this deployment

    The intent is that we have a "tools" deployment, which provides useful
    host tools (for instance, something to mangle a file in a particular
    manner). Those roles which need to use such tools in their builds
    (normally in a Makefile.muddle) then need to have the environment set
    appropriately to allow them to find the tools (and ideally, not system
    provided tools which mighth have the same name).
    """

    tgt = depend.Label(utils.LabelType.Deployment, name, None,
                       utils.LabelTag.Deployed)

    for role in rolesThatUseThis:
        for tag in (utils.LabelTag.PreConfig, utils.LabelTag.Configured,
                    utils.LabelTag.Built, utils.LabelTag.Installed,
                    utils.LabelTag.PostInstalled):
            lbl = depend.Label(utils.LabelType.Package, "*", role, tag)
            env = builder.get_environment_for(lbl)
            attach_env(builder, role, env, name)

        deployment.role_depends_on_deployment(builder, role, name)

    the_rule = depend.Rule(tgt, ToolsDeploymentBuilder(rolesNeededForThis))
    builder.ruleset.add(the_rule)

    deployment.deployment_depends_on_roles(builder, name, rolesNeededForThis)

    deployment.register_cleanup(builder, name)
Example #6
0
def _inside_of_deploy(builder, name, the_action):
    """This implements the common code from the public 'deploy()' function.
    """
    dep_label = Label(utils.LabelType.Deployment, name, None,
                      utils.LabelTag.Deployed)

    deployment_rule = depend.Rule(dep_label, the_action)

    # We need to clean it as well, annoyingly ..
    deployment.register_cleanup(builder, name)

    builder.ruleset.add(deployment_rule)

    # InstructionsApplied is a standalone rule, invoked by the deployment
    iapp_label = Label(utils.LabelType.Deployment,
                       name,
                       None,
                       utils.LabelTag.InstructionsApplied,
                       transient=True)
    iapp_rule = depend.Rule(iapp_label, the_action)
    builder.ruleset.add(iapp_rule)
Example #7
0
def create(builder, target_file, name, compressionMethod = None,
           pruneFunc = None):
    """
    Create a CPIO deployment and return it.

    * 'builder' is the muddle builder that is driving us

    * 'target_file' is the name of the CPIO file we want to create.
      Note that this may include a sub-path (for instance, "fred/file.cpio"
      or even "/fred/file.cpio").

    * 'name' is either:

        1. The name of the deployment that will contain this CPIO file
           (in the builder's default domain), or
        2. A deployment or package label, ditto

    * 'comporessionMethod' is the compression method to use:

        * None means no compression
        * 'gzip' means gzip
        * 'bzip2' means bzip2

    * if 'pruneFunc' is not None, it is a function to be called like
      pruneFunc(Hierarchy) to prune the hierarchy prior to packing. Usually
      something like deb.deb_prune, it's intended to remove spurious stuff like
      manpages from initrds and the like.

    Normal usage is thus something like::

        fw = cpio.create(builder, 'firmware.cpio', deployment)
        fw.copy_from_role(role1, '', '/')
        fw.copy_from_role(role2, 'bin', '/bin')
        fw.done()

    or::

        fw = cpio.create(builder, 'firmware.cpio', package('firmware', role))
        fw.copy_from_role(role, '', '/')
        fw.done()

    """

    if isinstance(name, basestring):
        label = depend.Label(LabelType.Deployment, name, None,
                             LabelTag.Deployed,
                             domain = builder.default_domain)
    elif isinstance(name, depend.Label):
        label = name
        if label.type not in (LabelType.Deployment, LabelType.Package):
            raise GiveUp("Third argument to muddled.deployments.cpio.create()"
                         " should be a string or a deployment/package label,"
                         " not a %s label"%label.type)

        if label.type == LabelType.Deployment and label.tag != LabelTag.Deployed:
            label = label.copy_with_tag(LabelTag.Deployed)
        elif label.type == LabelType.Package and label.tag != LabelTag.PostInstalled:
            label = label.copy_with_tag(LabelTag.PostInstalled)

    else:
        raise GiveUp("Third argument to muddled.deployments.cpio.create()"
                     " should be a string or a package/deployment label,"
                     " not %s"%type(name))

    the_action = CpioDeploymentBuilder(target_file, [], compressionMethod, pruneFunc)

    the_rule = depend.Rule(label, the_action)

    builder.ruleset.add(the_rule)

    if label.type == LabelType.Deployment:
        deployment.register_cleanup(builder, name)

    return CpioWrapper(builder, the_action, label)