def package_pack(args: List[str]) -> None: if len(args) != 1: raise PackageException("Usage: check_mk -P pack NAME") # Make sure, user is not in data directories of Checkmk abs_curdir = os.path.abspath(os.curdir) for directory in [cmk.utils.paths.var_dir] + [ p.path for p in get_package_parts() + get_config_parts() ]: if abs_curdir == directory or abs_curdir.startswith(directory + "/"): raise PackageException( "You are in %s!\n" "Please leave the directories of Check_MK before creating\n" "a packet file. Foreign files lying around here will mix up things." % abs_curdir) pacname = args[0] package = read_package_info(pacname) if not package: raise PackageException("Package %s not existing or corrupt." % pacname) tarfilename = packaging.format_file_name(name=pacname, version=package["version"]) logger.log(VERBOSE, "Packing %s into %s...", pacname, tarfilename) with Path(tarfilename).open("wb") as f: packaging.write_file(package, cast(BinaryIO, f)) logger.log(VERBOSE, "Successfully created %s", tarfilename)
def _install_and_disable_package(mkp_file): packaging.install_by_path(mkp_file) assert packaging._package_exists("aaa") is True package_info = packaging.read_package_info("aaa") assert package_info is not None package_file_name = packaging.format_file_name(name="aaa", version=package_info["version"]) packaging.disable("aaa", package_info) assert packaging._package_exists("aaa") is False assert cmk.utils.paths.disabled_packages_dir.joinpath(package_file_name).exists() assert not cmk.utils.paths.local_checks_dir.joinpath("aaa").exists() return package_file_name
"version.packaged": cmk_version.__version__, "version.min_required": cmk_version.__version__, "version.usable_until": None, "author": "tribe29 GmbH", "download_url": "https://checkmk.com/", "files": { "web": [ ntop_file.replace(ENTERPRISE_PREFIX, "") for ntop_file in MKP_ABLE_NTOP_FILES ] }, "git_hash_short": GIT_HASH_SHORT, } TARFILENAME = packaging.format_file_name(name="ntop", version=NTOP_PACKAGE_INFO["version"]) with Path(TARFILENAME).open("wb") as f: packaging.write_file( NTOP_PACKAGE_INFO, cast(BinaryIO, f), package_parts=packaging.get_repo_ntop_parts, config_parts=lambda: [], )