コード例 #1
0
    def __init__(
        self,
        config_file_path: Optional[str] = None,
        specfile_path: Optional[str] = None,
        synced_files: Optional[SyncFilesConfig] = None,
        dist_git_namespace: str = None,
        upstream_project_url: str = None,  # can be URL or path
        upstream_package_name: str = None,
        downstream_project_url: str = None,
        downstream_package_name: str = None,
        dist_git_base_url: str = None,
        create_tarball_command: List[str] = None,
        current_version_command: List[str] = None,
        actions: Dict[ActionName, Union[str, List[str]]] = None,
        upstream_ref: Optional[str] = None,
        allowed_gpg_keys: Optional[List[str]] = None,
        create_pr: bool = True,
        sync_changelog: bool = False,
        spec_source_id: str = "Source0",
        upstream_tag_template: str = "{version}",
        archive_root_dir_template: str = "{upstream_pkg_name}-{version}",
        patch_generation_ignore_paths: List[str] = None,
        notifications: Optional[NotificationsConfig] = None,
        copy_upstream_release_description: bool = False,
        sources: Optional[List[SourcesItem]] = None,
    ):
        self.config_file_path: Optional[str] = config_file_path
        self.specfile_path: Optional[str] = specfile_path
        self.synced_files: SyncFilesConfig = synced_files or SyncFilesConfig(
            [])
        self.patch_generation_ignore_paths = patch_generation_ignore_paths or []
        self.dist_git_namespace: str = dist_git_namespace or "rpms"
        self.upstream_project_url: Optional[str] = upstream_project_url
        self.upstream_package_name: Optional[str] = upstream_package_name
        # this is generated by us
        self.downstream_package_name: Optional[str] = downstream_package_name
        self.dist_git_base_url: str = dist_git_base_url or os.getenv(
            "DISTGIT_URL", PROD_DISTGIT_URL)
        self._downstream_project_url: str = downstream_project_url
        # path to a local git clone of the dist-git repo; None means to clone in a tmpdir
        self.dist_git_clone_path: Optional[str] = None
        self.actions = actions or {}
        self.upstream_ref: Optional[str] = upstream_ref
        self.allowed_gpg_keys = allowed_gpg_keys
        self.create_pr: bool = create_pr
        self.sync_changelog: bool = sync_changelog
        self.spec_source_id: str = spec_source_id
        self.notifications = notifications or NotificationsConfig(
            pull_request=PullRequestNotificationsConfig())

        # command to generate a tarball from the upstream repo
        # uncommitted changes will not be present in the archive
        self.create_tarball_command: List[str] = create_tarball_command
        # command to get current version of the project
        self.current_version_command: List[str] = current_version_command
        # template to create an upstream tag name (upstream may use different tagging scheme)
        self.upstream_tag_template = upstream_tag_template
        self.archive_root_dir_template = archive_root_dir_template
        self.copy_upstream_release_description = copy_upstream_release_description
        self.sources = sources or []
コード例 #2
0
ファイル: package_config.py プロジェクト: Zlopez/packit
    def __init__(
        self,
        config_file_path: Optional[str] = None,
        specfile_path: Optional[str] = None,
        synced_files: Optional[SyncFilesConfig] = None,
        jobs: Optional[List[JobConfig]] = None,
        dist_git_namespace: str = None,
        upstream_project_url: str = None,  # can be URL or path
        upstream_package_name: str = None,
        downstream_project_url: str = None,
        downstream_package_name: str = None,
        dist_git_base_url: str = None,
        create_tarball_command: List[str] = None,
        current_version_command: List[str] = None,
        actions: Dict[ActionName, Union[str, List[str]]] = None,
        upstream_ref: Optional[str] = None,
        allowed_gpg_keys: Optional[List[str]] = None,
        create_pr: bool = True,
        spec_source_id: str = "Source0",
        upstream_tag_template: str = "{version}",
        patch_generation_ignore_paths: List[str] = None,
        **kwargs,
    ):
        self.config_file_path: Optional[str] = config_file_path
        self.specfile_path: Optional[str] = specfile_path
        self.synced_files: SyncFilesConfig = synced_files or SyncFilesConfig(
            [])
        self.patch_generation_ignore_paths = patch_generation_ignore_paths or []
        self.jobs: List[JobConfig] = jobs or []
        self.dist_git_namespace: str = dist_git_namespace or "rpms"
        self.upstream_project_url: Optional[str] = upstream_project_url
        self.upstream_package_name: Optional[str] = upstream_package_name
        # this is generated by us
        self.downstream_package_name: Optional[str] = downstream_package_name
        self.dist_git_base_url: str = dist_git_base_url or PROD_DISTGIT_URL
        self._downstream_project_url: str = downstream_project_url
        # path to a local git clone of the dist-git repo; None means to clone in a tmpdir
        self.dist_git_clone_path: Optional[str] = None
        self.actions = actions or {}
        self.upstream_ref: Optional[str] = upstream_ref
        self.allowed_gpg_keys = allowed_gpg_keys
        self.create_pr: bool = create_pr
        self.spec_source_id: str = spec_source_id

        # command to generate a tarball from the upstream repo
        # uncommitted changes will not be present in the archive
        self.create_tarball_command: List[str] = create_tarball_command
        # command to get current version of the project
        self.current_version_command: List[str] = current_version_command or [
            "git",
            "describe",
            "--tags",
            "--match",
            "*",
        ]
        # template to create an upstream tag name (upstream may use different tagging scheme)
        self.upstream_tag_template = upstream_tag_template

        if kwargs:
            logger.warning(f"Following kwargs were not processed:" f"{kwargs}")
コード例 #3
0
    def get_all_files_to_sync(self):
        """
        Adds the default files (config file, spec file) to synced files when doing propose-update.
        :return: SyncFilesConfig with default files
        """
        files = self.synced_files.files_to_sync

        if self.specfile_path not in (item.src for item in files):
            files.append(
                SyncFilesItem(src=self.specfile_path, dest=self.specfile_path))

        if self.config_file_path not in (item.src for item in files):
            files.append(
                SyncFilesItem(src=self.config_file_path,
                              dest=self.config_file_path))

        return SyncFilesConfig(files)
コード例 #4
0
    def get_all_files_to_sync(self):
        """
        Adds the default files (config file, spec file) to synced files when doing propose-update.
        :return: SyncFilesConfig with default files
        """
        files = self.synced_files.files_to_sync

        if self.specfile_path not in (item.src for item in files):
            files.append(self.get_specfile_sync_files_item())

        if self.config_file_path and self.config_file_path not in (
                item.src for item in files):
            # this relative because of glob: "Non-relative patterns are unsupported"
            files.append(
                SyncFilesItem(src=self.config_file_path,
                              dest=self.config_file_path))

        return SyncFilesConfig(files)
コード例 #5
0
    def get_from_dict(cls,
                      raw_dict: dict,
                      config_file_path: str = None,
                      validate=True) -> "PackageConfig":
        if validate:
            cls.validate(raw_dict)

        synced_files = raw_dict.get("synced_files", None)
        actions = raw_dict.get("actions", {})
        raw_jobs = raw_dict.get("jobs", [])
        create_tarball_command = raw_dict.get("create_tarball_command", None)
        current_version_command = raw_dict.get("current_version_command", None)

        upstream_package_name = cls.get_deprecated_key(
            raw_dict, "upstream_package_name",
            "upstream_project_name") or cls.get_deprecated_key(
                raw_dict, "upstream_package_name", "upstream_name")
        upstream_project_url = raw_dict.get("upstream_project_url", None)

        if raw_dict.get("dist_git_url", None):
            logger.warning(
                "dist_git_url is no longer being processed, "
                "it is generated from dist_git_base_url and downstream_package_name"
            )
        downstream_package_name = cls.get_deprecated_key(
            raw_dict, "downstream_package_name", "package_name")
        specfile_path = raw_dict.get("specfile_path", None)
        if not specfile_path:
            if downstream_package_name:
                specfile_path = f"{downstream_package_name}.spec"
                logger.info(f"We guess that spec file is at {specfile_path}")
            else:
                # guess it?
                logger.warning("Path to spec file is not set.")

        dist_git_base_url = raw_dict.get("dist_git_base_url")
        dist_git_namespace = raw_dict.get("dist_git_namespace")
        upstream_ref = raw_dict.get("upstream_ref")

        allowed_gpg_keys = raw_dict.get("allowed_gpg_keys")
        create_pr = raw_dict.get("create_pr", False)
        upstream_tag_template = raw_dict.get("upstream_tag_template",
                                             "{version}")

        # it can be int as well
        spec_source_id = raw_dict.get("spec_source_id", "Source0")
        try:
            spec_source_id = int(spec_source_id)
        except ValueError:
            # not a number
            pass
        else:
            # is a number!
            spec_source_id = f"Source{spec_source_id}"

        pc = PackageConfig(
            config_file_path=config_file_path,
            specfile_path=specfile_path,
            synced_files=SyncFilesConfig.get_from_dict(synced_files,
                                                       validate=False),
            actions={ActionName(a): cmd
                     for a, cmd in actions.items()},
            jobs=[
                JobConfig.get_from_dict(raw_job, validate=False)
                for raw_job in raw_jobs
            ],
            upstream_package_name=upstream_package_name,
            downstream_package_name=downstream_package_name,
            upstream_project_url=upstream_project_url,
            dist_git_base_url=dist_git_base_url,
            dist_git_namespace=dist_git_namespace,
            create_tarball_command=create_tarball_command,
            current_version_command=current_version_command,
            upstream_ref=upstream_ref,
            allowed_gpg_keys=allowed_gpg_keys,
            create_pr=create_pr,
            spec_source_id=spec_source_id,
            upstream_tag_template=upstream_tag_template,
        )
        return pc