Пример #1
0
def install_file(package_files, version, exit_on_error=True):
    for package_file in package_files:
        logger.info("Installing " + package_file)
        # First, check if file exists
        if not os.path.isfile(package_file):
            utils.fail("Error: Package file " + package_file +
                       " does not exist")
        metadata = utils.rpkg_metadata(package_file)
        exist = utils.package_check(metadata, version)
        # As dependencies are only displayed messages for now,
        # wait until the end to make them visible.
        # This should be moved before actual installation once implemented.
        if not utils.install_dependencies(metadata):
            if exit_on_error:
                exit(1)
        if exist:
            short_name = metadata['name'].replace("rudder-plugin-", "")
            # These don't have upgrade scripts for now
            if short_name.startswith("cis-") or short_name == "openscap":
                logger.info("Skipping update, this package cannot be updated")
                break
            logger.info("The package is already installed, I will upgrade it.")
        script_dir = utils.extract_scripts(metadata, package_file)
        utils.run_script("preinst",
                         script_dir,
                         exist,
                         exit_on_error=exit_on_error)
        utils.install(metadata, package_file, exist)
        utils.run_script("postinst",
                         script_dir,
                         exist,
                         exit_on_error=exit_on_error)
        if metadata['type'] == 'plugin' and 'jar-files' in metadata:
            for j in metadata['jar-files']:
                utils.jar_status(j, True)
Пример #2
0
def install_file(package_files):
    for package_file in package_files:
        logging.info("Installing " + package_file)
        # First, check if file exists
        if not os.path.isfile(package_file):
            utils.fail("Error: Package file " + package_file + " does not exist")
        metadata = utils.rpkg_metadata(package_file)
        exist = utils.package_check(metadata)
        # As dependencies are only displayed messages for now,
        # wait until the end to make them visible.
        # This should be moved before actual installation once implemented.
        if not utils.install_dependencies(metadata):
            exit(1)
        if exist:
            logging.info("The package is already installed, I will upgrade it.")
        script_dir = utils.extract_scripts(metadata, package_file)
        utils.run_script("preinst", script_dir, exist)
        utils.install(metadata, package_file, exist)
        utils.run_script("postinst", script_dir, exist)
        if metadata['type'] == 'plugin' and 'jar-files' in metadata:
            for j in metadata['jar-files']:
                utils.jar_status(j, True)