#!/usr/bin/env python


"""
This script attemps to make it trivial to create install the packages
needed for the operation of an Autotest server
"""

import sys


try:
    import autotest.common as common  # pylint: disable=W0611
except ImportError:
    import common  # pylint: disable=W0611


from autotest.client.shared import software_manager
from autotest.frontend.pkgdeps import PKG_DEPS
from autotest.client.shared import logging_manager, logging_config


class AutotestInstallConfig(logging_config.LoggingConfig):

    def configure_logging(self, results_dir=None, verbose=False):
        super(AutotestInstallConfig, self).configure_logging(use_console=True,
                                                             verbose=verbose)

if __name__ == '__main__':
    import optparse
    option_parser = optparse.OptionParser()
    option_parser.add_option("-v", "--verbose",
                             action="store_true", dest="verbose",
                             help="Exhibit debug messages")
    options, args = option_parser.parse_args()
    logging_manager.configure_logging(AutotestInstallConfig(),
                                      verbose=options.verbose)
    install_successful = software_manager.install_distro_packages(PKG_DEPS)
    if install_successful:
        sys.exit(0)
    else:
        sys.exit(-1)
