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)
def remove(package_names): for package_name in package_names: logger.info("Removing " + package_name) if package_name not in utils.DB["plugins"]: utils.fail("This package is not installed. Aborting!", 2) script_dir = utils.DB_DIRECTORY + "/" + package_name metadata = utils.DB["plugins"][package_name] if metadata['type'] == 'plugin' and 'jar-files' in metadata: for j in metadata['jar-files']: utils.jar_status(j, False) utils.run_script("prerm", script_dir, None) utils.remove_files(metadata) utils.run_script("postrm", script_dir, None) shutil.rmtree(script_dir) del utils.DB["plugins"][package_name] utils.db_save()
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)
def rudder_postupgrade(): for plugin in utils.DB["plugins"]: script_dir = utils.DB_DIRECTORY + "/" + plugin utils.run_script("postinst", script_dir, True)