def build_deb(version, src_archive_name, downloaded_modules, scripts_archive_name, control_file_params, revision, configure_params, patches): """ Сборка deb пакета :param version: :param src_archive_name: :param downloaded_modules: :param scripts_archive_name: :param control_file_params: :param revision: :param configure_params: :param patches: :return: """ logger.info("Building .deb package") common_utils.extract_archive(src_archive_name, config.SRC_PATH) common_utils.extract_archive(scripts_archive_name, config.SRC_PATH) source_dir = os.path.join(config.SRC_PATH, "nginx-{}".format(version)) modules_dir = os.path.join(config.SRC_PATH, "modules") scripts_dir = os.path.join(config.SRC_PATH, "debian") shutil.move(modules_dir, scripts_dir) shutil.move(scripts_dir, source_dir) scripts_dir = os.path.join(source_dir, "debian") modules_dir = os.path.join(scripts_dir, "modules") apply_patch(modules_dir, source_dir, patches) prepare_changelog(scripts_dir, version, revision) prepare_rules(scripts_dir, downloaded_modules, configure_params) prepare_nginx_dirs(scripts_dir) change_control(scripts_dir, control_file_params) logger.info("Running 'dh_make'...") dh_make_command = "dh_make --copyright {} -e {} --createorig -s -y -p nginx_{}".format( config.LICENSE_TYPE, config.EMAIL_CREATOR, version) common_utils.execute_command(dh_make_command, source_dir) logger.info("Running 'dpkg-buildpackage'...") build_package = "dpkg-buildpackage -b -us -uc" response, rc = common_utils.execute_command(build_package, source_dir) if rc == config.DPKG_FAIL_EXIT_CODE: sys.exit(1) package_name = None for file in os.listdir(config.SRC_PATH): if file.startswith( "nginx_{}".format(version)) and file.endswith(".deb"): package_name = file return os.path.join(config.SRC_PATH, package_name)
def download_openssl_src(openssl_version="1.1.1g"): logger.info("Downloading OpenSSL source...") common_utils.ensure_directory(os.path.join(config.SRC_PATH, "openssl")) file_name = "openssl-{}.tar.gz".format(openssl_version) with open(os.path.join(config.SRC_PATH, "openssl", file_name), "wb") as file: response = get("https://www.openssl.org/source/{}".format(file_name)) file.write(response.content) return common_utils.extract_archive( file_name, os.path.join(config.SRC_PATH, "openssl"))
def download_module_from_local(module): """ Загрузка модуля из локального архива :param module: :return: """ local_url = module.get('local_url') if not local_url: logger.error("local_url is undefined") sys.exit(1) module_name = set_module_name(module.get('name'), local_url) file_name = local_url[local_url.rfind("/") + 1:] shutil.copy(local_url, os.path.join(config.SRC_PATH, "modules", file_name)) module_name = common_utils.extract_archive(file_name, os.path.join(config.SRC_PATH, "modules")) return module_name
def download_module_from_web(module): """ Загрузка архива с модулем из web :param module: :return: """ web_url = module.get('web_url') if not web_url: logger.error("web_url is undefined") sys.exit(1) module_name = set_module_name(module.get('name'), web_url) file_name = web_url[web_url.rfind("/") + 1:] logger.info("Module {} will downloading".format(module_name)) with open(os.path.join(config.SRC_PATH, "modules", file_name), "wb") as file: response = get(web_url) file.write(response.content) module_name = common_utils.extract_archive(file_name, os.path.join(config.SRC_PATH, "modules")) return module_name