build_packages

Builds for the expected_operations' OperationSettings entries.

This function is intentionaly blind, dumb and stupid to produce what it can.
However, it should also exit with a non-zero when an error does occur to keep
from the caller thinking that things are 'okay' when they are not.

def build_packages(config):
    """build_packages

Builds for the expected_operations' OperationSettings entries.

This function is intentionaly blind, dumb and stupid to produce what it can.
However, it should also exit with a non-zero when an error does occur to keep
from the caller thinking that things are 'okay' when they are not.
    """
    error = 0
    print("Building packages...")
    for operation in expected_operations:
        if operation.os_category == 'redhat':
            print("For Redhat...")
            function = build_redhat
        elif operation.os_category == 'debian':
            print("For Debian...")
            function = build_debian
        else:
            # can overwrite a previous error statement, but this does need to
            # be preserved...
            error = BuildError(operation, msg="Unexpected operation specified",
                               frame=gfi(cf()))
            function = Error.print_msg
        # preserve a previous iteration's error, if needed
        for os_version in operation.versions:
            error = function(config, os_version) if not error else error
            if error:
                break
        if error:
            print("A Failure occurred...", str(error))
            break
    if not error:
        print("Completed package builds...")
    return error