diff --git a/src/ac/acl/yaml/__init__.py b/src/ac/acl/yaml/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..054319cd51014650ac251515823879e185c4d0de --- /dev/null +++ b/src/ac/acl/yaml/__init__.py @@ -0,0 +1,17 @@ +# -*- encoding=utf-8 -*- +""" +# *********************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# [openeuler-jenkins] is licensed under the Mulan PSL v1. +# You can use this software according to the terms and conditions of the Mulan PSL v1. +# You may obtain a copy of Mulan PSL v1 at: +# http://license.coscl.org.cn/MulanPSL +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v1 for more details. +# Author: DisNight +# Create: 2020-09-17 +# Description: +# ***********************************************************************************/ +""" \ No newline at end of file diff --git a/src/ac/acl/yaml/check_repo.py b/src/ac/acl/yaml/check_repo.py new file mode 100644 index 0000000000000000000000000000000000000000..9541ea3923d2086cb0aa8bf868545481a2ac9c5a --- /dev/null +++ b/src/ac/acl/yaml/check_repo.py @@ -0,0 +1,540 @@ +# -*- encoding=utf-8 -*- +""" +# *********************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# [openeuler-jenkins] is licensed under the Mulan PSL v1. +# You can use this software according to the terms and conditions of the Mulan PSL v1. +# You may obtain a copy of Mulan PSL v1 at: +# http://license.coscl.org.cn/MulanPSL +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v1 for more details. +# Author: DisNight +# Create: 2020-09-22 +# Description: check yaml file in software package +# ***********************************************************************************/ +""" +# \ / /| /| /| / +# \ / /_| / | / | / +# / / | / | / | / +# / / | / |/ | /_____ + +import logging +import re +import urlparse +import requests +import json +import subprocess +import tldextract +import abc + +logging.getLogger("ac") + + +class AbsReleaseTags(object): + """ + 获取release tags的抽象类 + """ + + __metaclass__ = abc.ABCMeta + def __init__(self, version_control): + self.version_control = version_control + + @abc.abstractmethod + def url(self, repo): + """ + 抽象方法 + """ + pass + + @abc.abstractmethod + def get_tags(self, repo): + """ + 抽象方法 + """ + pass + + +class DefaultReleaseTags(AbsReleaseTags): + """ + 获取release tags的基类 + """ + def url(self, repo): + """ + 通过src_repo生成url + return: str + """ + return "" + + def get_tags(self, repo): + """ + 通过url获取上游社区的release tags + return: list + """ + logging.info("unsupported version control: {}".format(self.version_control)) + return [] + + +class HttpReleaseTagsMixin(object): + """ + 通过web请求形式获取release tags + """ + DEFAULT_REQ_HEADER = { + 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64)' + } + + def get_redirect_resp(self, url, response): + """ + 获取重定向的url和cookie + return: bool, str, list + """ + cookie = set() + href = "" + need_redirect = False + for line in response.text.splitlines(): + line = line.strip() + if line.startswith("Redirecting"): + logging.debug("Redirecting with document.cookie") + need_redirect = True + search_result = re.search(r"document\.cookie=\"(.*)\";", line) + if search_result: + cookie = cookie | set(search_result.group(1).split(';')) + search_result = re.search(r"document\.location\.href=\"(.*)\";", line) + if search_result: + href = search_result.group(1) + new_url = urlparse.urljoin(url, href) + if "" in cookie: + cookie.remove("") + return need_redirect, new_url, list(cookie) + + def get_request_response(self, url, timeout=30, headers=None): + """ + 获取url请求获取response + return: reponse + """ + headers = self.DEFAULT_REQ_HEADER if headers is None else headers + try: + response = requests.get(url, headers=headers, timeout=timeout) + need_redirect, new_url, cookies = self.get_redirect_resp(url, response) + if tldextract.extract(url).domain != tldextract.extract(new_url).domain: # 判断域名是否一致 预防csrf攻击 + logging.warning("domain of redirection link is different: {}".format(new_url)) + return "" + if need_redirect: + cookie_dict = {} + for cookie in cookies: + key, val = cookie.split("=") + cookie_dict[key] = val + url = new_url + response = requests.get(url, headers=headers, cookies=cookie_dict, timeout=timeout) + except requests.exceptions.SSLError as e: + logging.warning("requests {} ssl exception, {}".format(url, e)) + return "" + except requests.exceptions.Timeout as e: + logging.warning("requests timeout") + return "" + except requests.exceptions.RequestException as e: + logging.warning("requests exception, {}".format(e)) + return "" + return response + + +class HgReleaseTags(AbsReleaseTags, HttpReleaseTagsMixin): + """ + 获取hg上游社区release tags + """ + def url(self, repo): + """ + 通过src_repo生成url + return: str + """ + return urlparse.urljoin(repo + "/", "json-tags") if repo else "" + + def get_tags(self, repo): + """ + 通过url获取上游社区的release tags + return: list + """ + url = self.url(repo) + logging.debug("{repo} : get {vc} tags".format(repo=url, vc=self.version_control)) + if not url: + logging.warning("illegal url: \"\"") + return [] + response = self.get_request_response(url) + if not response: + logging.warning("unable to get response:") + return [] + try: + tags_json = json.loads(response.text) + temp_tags = tags_json.get("tags") + temp_tags.sort(reverse=True, key=lambda x: x["date"][0]) + release_tags = [tag["tag"] for tag in temp_tags] + except Exception as e: + logging.error("exception, {}".format(e)) + return [] + return release_tags + + +class HgRawReleaseTags(AbsReleaseTags, HttpReleaseTagsMixin): + """ + 获取hg raw上游社区release tags + """ + def url(self, repo): + """ + 通过src_repo生成url + return: str + """ + return urlparse.urljoin(repo + "/", "raw-tags") if repo else "" + + def get_tags(self, repo): + """ + 通过url获取上游社区的release tags + return: list + """ + url = self.url(repo) + logging.debug("{repo} : get {vc} tags".format(repo=url, vc=self.version_control)) + if not url: + logging.warning("illegal url: \"\"") + return [] + response = self.get_request_response(url) + release_tags = [] + for line in response.text.splitlines(): + release_tags.append(line.split()[0]) + return release_tags + + +class MetacpanReleaseTags(AbsReleaseTags, HttpReleaseTagsMixin): + """ + 获取metacpan上游社区release tags + """ + def url(self, repo): + """ + 通过src_repo生成url + return: str + """ + return urlparse.urljoin("https://metacpan.org/release/", repo) if repo else "" + + def get_tags(self, repo): + """ + 通过url获取上游社区的release tags + return: list + """ + url = self.url(repo) + logging.debug("{repo} : get {vc} tags".format(repo=url, vc=self.version_control)) + if not url: + logging.warning("illegal url: \"\"") + return [] + response = self.get_request_response(url) + resp_lines = response.text.splitlines() + release_tags = [] + tag_condition = "value=\"/release" + for index in range(len(resp_lines) - 1): + if tag_condition in resp_lines[index]: + tag = resp_lines[index + 1] + index += 1 + if "DEV" in tag: + continue + tag = tag.strip() + release_tags.append(tag) + return release_tags + + +class PypiReleaseTags(AbsReleaseTags, HttpReleaseTagsMixin): + """ + 获取pypi上游社区release tags + """ + def url(self, repo): + """ + 通过src_repo生成url + return: str + """ + return urlparse.urljoin("https://pypi.org/pypi/", repo + "/json") if repo else "" + + def get_tags(self, repo): + """ + 通过url获取上游社区的release tags + return: list + """ + url = self.url(repo) + logging.debug("{repo} : get {vc} tags".format(repo=url, vc=self.version_control)) + if not url: + logging.warning("illegal url: \"\"") + return [] + response = self.get_request_response(url) + try: + tags_json = response.json() + release_tags = [tag for tag in tags_json.get("releases")] + except Exception as e: + logging.error("exception, {}".format(e)) + return [] + return release_tags + + +class RubygemReleaseTags(AbsReleaseTags, HttpReleaseTagsMixin): + """ + 获取rubygem上游社区release tags + """ + def url(self, repo): + """ + 通过src_repo生成url + return: str + """ + return urlparse.urljoin("https://rubygems.org/api/v1/versions/", repo + ".json") if repo else "" + + def get_tags(self, repo): + """ + 通过url获取上游社区的release tags + return: list + """ + url = self.url(repo) + logging.debug("{repo} : get {vc} tags".format(repo=url, vc=self.version_control)) + if not url: + logging.warning("illegal url: \"\"") + return [] + response = self.get_request_response(url) + try: + tags_json = response.json() + release_tags = [] + for element in tags_json: + if element.get("number"): + release_tags.append(element.get("number")) + except Exception as e: + logging.error("exception, {}".format(e)) + return [] + return release_tags + + +class GnuftpReleaseTags(AbsReleaseTags, HttpReleaseTagsMixin): + """ + 获取gnu-ftp上游社区release tags + """ + def url(self, repo): + """ + 通过src_repo生成url + return: str + """ + return urlparse.urljoin("https://ftp.gnu.org/gnu/", repo) if repo else "" + + def get_tags(self, repo): + """ + 通过url获取上游社区的release tags + return: list + """ + url = self.url(repo) + logging.debug("{repo} : get {vc} tags".format(repo=url, vc=self.version_control)) + if not url: + logging.warning("illegal url: \"\"") + return [] + response = self.get_request_response(url) + pattern = re.compile("href=\"(.*)\">(.*)") + release_tags = [] + for line in response.text.splitlines(): + search_result = pattern.search(line) + if search_result: + release_tags.append(search_result.group(1)) # python2用法 python3不同 + return release_tags + + +class FtpReleaseTags(AbsReleaseTags, HttpReleaseTagsMixin): + """ + 获取ftp上游社区release tags + """ + def url(self, repo): + """ + 通过src_repo生成url + return: str + """ + return urlparse.urljoin('ftp', repo + "/") if repo else "" + + def get_tags(self, repo): + """ + 通过url获取上游社区的release tags + return: list + """ + url = self.url(repo) + logging.debug("{repo} : get {vc} tags".format(repo=url, vc=self.version_control)) + if not url: + logging.warning("illegal url: \"\"") + return [] + response = self.get_request_response(url) + pattern = re.compile("href=\"(.*)\">(.*)") + release_tags = [] + for line in response.text.splitlines(): + search_result = pattern.search(line) + if search_result: + release_tags.append(search_result.group(1)) # python2用法 python3不同 + return release_tags + + +class CmdReleaseTagsMixin(object): + """ + 通过shell命令获取上游社区的release tags + """ + def get_cmd_response(self, cmd_list): + """ + 获取shell命令的reponse + return: reponse + """ + sub_proc = subprocess.Popen(cmd_list, stdout=subprocess.PIPE) + response = sub_proc.stdout.read().decode("utf-8") + if sub_proc.wait(): + logging.warning("{cmd} > encount errors".format(cmd=" ".join(cmd_list))) + return response + + +class SvnReleaseTags(AbsReleaseTags, CmdReleaseTagsMixin): + """ + 通过shell svn命令获取上游社区的release tags + """ + def url(self, repo): + """ + 通过src_repo生成url + return: str + """ + return urlparse.urljoin(repo + "/", "tags") if repo else "" + + def get_response(self, url): + """ + 生成svn命令并获取reponse + return: response + """ + cmd_list = ["/usr/bin/svn", "ls", "-v", url] + return self.get_cmd_response(cmd_list) + + def get_tags(self, repo): + """ + 通过shell cmd访问远端获取上游社区的release tags + return: list + """ + url = self.url(repo) + logging.debug("{repo} : get svn tags".format(repo=url)) + if not url: + logging.warning("illegal url: \"\"") + return [] + response = self.get_response(url) + release_tags = [] + for line in response.splitlines(): + for item in line.split(): + if item and item[-1] == "/": + release_tags.append(item[:-1]) + break + return release_tags + + +class GitReleaseTags(AbsReleaseTags, CmdReleaseTagsMixin): + """ + 通过shell git命令获取上游社区的release tags + """ + def url(self, repo): + """ + 通过src_repo生成url + return: str + """ + return repo + + def get_response(self, url): + """ + 生成git命令并获取reponse + return: response + """ + cmd_list = ["git", "ls-remote", "--tags", url] + return self.get_cmd_response(cmd_list) + + def trans_reponse_tags(self, reponse): + """ + 解析git命令返回值为纯数字形式的tag + return: list + """ + release_tags = [] + pattern = re.compile(r"^([^ \t]*)[ \t]*refs\/tags\/([^ \t]*)") + for line in reponse.splitlines(): + match_result = pattern.match(line) + if match_result: + tag = match_result.group(2) + if not tag.endswith("^{}"): + release_tags.append(tag) + return release_tags + + def get_tags(self, repo): + """ + 通过shell cmd访问远端获取上游社区的release tags + return: list + """ + url = self.url(repo) + logging.debug("{repo} : get {vc} tags".format(repo=url, vc=self.version_control)) + if not url: + logging.warning("illegal url: \"\"") + return [] + response = self.get_response(url) + return self.trans_reponse_tags(response) + + +class GithubReleaseTags(GitReleaseTags): + """ + 获取github上游社区release tags + """ + def url(self, repo): + """ + 通过src_repo生成url + return: str + """ + return urlparse.urljoin("https://github.com/", repo + ".git") if repo else "" + + +class GiteeReleaseTags(GitReleaseTags): + """ + 获取gitee上游社区release tags + """ + def url(self, repo): + """ + 通过src_repo生成url + return: str + """ + return urlparse.urljoin("https://gitee.com/", repo) if repo else "" + + +class GitlabReleaseTags(GitReleaseTags): + """ + 获取gitlab.gnome上游社区release tags + """ + def url(self, repo): + """ + 通过src_repo生成url + return: str + """ + if not repo: + return "" + src_repos = repo.split("/") + if len(src_repos) == 1: + return urlparse.urljoin("https://gitlab.gnome.org/GNOME/", repo + ".git") + else: + return urlparse.urljoin("https://gitlab.gnome.org/", repo + ".git") + + +class ReleaseTagsFactory(object): + """ + ReleaseTags及其子类的工厂类 + """ + VERSION_CTRL_GETTER_MAPPING = { + "hg": HgReleaseTags, + "hg-raw": HgRawReleaseTags, + "github": GithubReleaseTags, + "git": GitReleaseTags, + "gitlab.gnome": GitlabReleaseTags, + "svn": SvnReleaseTags, + "metacpan": MetacpanReleaseTags, + "pypi": PypiReleaseTags, + "rubygem": RubygemReleaseTags, + "gitee": GiteeReleaseTags, + "gnu-ftp": GnuftpReleaseTags, + "ftp": FtpReleaseTags + } + + @staticmethod + def get_release_tags(version_control): + """ + 通过version control返回对应的ReleaseTags的子类 + return: class + """ + release_tags = ReleaseTagsFactory.VERSION_CTRL_GETTER_MAPPING.get(version_control, DefaultReleaseTags) + return release_tags(version_control) \ No newline at end of file diff --git a/src/ac/acl/yaml/check_yaml.py b/src/ac/acl/yaml/check_yaml.py new file mode 100644 index 0000000000000000000000000000000000000000..d4406fc7f33f82c29e43ffa4eb2353c7f349588c --- /dev/null +++ b/src/ac/acl/yaml/check_yaml.py @@ -0,0 +1,199 @@ +# -*- encoding=utf-8 -*- +""" +# *********************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# [openeuler-jenkins] is licensed under the Mulan PSL v1. +# You can use this software according to the terms and conditions of the Mulan PSL v1. +# You may obtain a copy of Mulan PSL v1 at: +# http://license.coscl.org.cn/MulanPSL +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v1 for more details. +# Author: DisNight +# Create: 2020-09-17 +# Description: check yaml file in software package +# ***********************************************************************************/ +""" + +import logging +import os +import yaml + +from src.proxy.git_proxy import GitProxy +from src.proxy.requests_proxy import do_requests +from src.ac.framework.ac_base import BaseCheck +from src.ac.framework.ac_result import FAILED, WARNING, SUCCESS +from src.ac.common.gitee_repo import GiteeRepo +from src.ac.acl.yaml.check_repo import ReleaseTagsFactory +from src.ac.common.rpm_spec_adapter import RPMSpecAdapter + +logger = logging.getLogger("ac") + +class CheckPackageYaml(BaseCheck): + """ + check yaml file + """ + + NOT_FOUND = "NA" + PACKAGE_YAML_NEEDED_KEY = [ + "version_control", + "src_repo", + "tag_prefix", + "seperator"] + + VERSION_CTRL_TRANS = { + "gitlab.gnome": "gnome", + "pypi": "pythonhosted" + } + + def __init__(self, workspace, repo, conf): + super(CheckPackageYaml, self).__init__(workspace, repo, conf) + + self._gp = GitProxy(self._work_dir) + self._gr = GiteeRepo(self._repo, self._work_dir, None) # don't care about decompress + if self._gr.spec_file: + self._spec = RPMSpecAdapter(self._gr.spec_file) + else: + self._spec = None + self._yaml_content = None + self._yaml_changed = True + self._is_standard = True + + def is_change_package_yaml(self, base="HEAD~1", head="HEAD~0"): + """ + 如果本次提交变更了yaml,则对yaml进行检查 + :param: + base:作为对比的提交点 + head:此次提交点 + :return: boolean + """ + diff_files = self._gp.diff_files_between_commits(base, head) + package_yaml = "{}.yaml".format(self._repo) # package yaml file name + + for change_file in diff_files: + if change_file == package_yaml: + logger.debug("diff files: {}".format(diff_files)) + return True + return False + + def check_fields(self): + """ + 检查yaml规定字段的完整性 + :return: + """ + if not self._yaml_changed: + return SUCCESS + yaml_path = self._gr.yaml_file + if yaml_path is None: + self._is_standard = False + logger.warning("yaml file missing") + return WARNING + try: + with open(os.path.join(self._work_dir, yaml_path), 'r') as yaml_data: # load yaml data + self._yaml_content = yaml.safe_load(yaml_data) + except IOError as e: + logging.warning("package yaml not exist. {}".format(str(e))) + return WARNING + except yaml.YAMLError as exc: + logging.warning("Error parsering YAML: {}".format(str(exc))) + return WARNING + + result = SUCCESS + for keyword in self.PACKAGE_YAML_NEEDED_KEY: + if keyword not in self._yaml_content: + logger.error("yaml field {} missing".format(keyword)) + self._is_standard = False + result = WARNING + return result + + def check_repo(self): + """ + 检查yaml的有效性,能否从上游社区获取版本信息 + :return: + """ + if not self._yaml_changed: + return SUCCESS + if not self._is_standard: + logger.warning("yaml does not comply with the rule") + return SUCCESS + # get value by key from yaml data + vc = self._yaml_content[self.PACKAGE_YAML_NEEDED_KEY[0]] # value of version_control + sr = self._yaml_content[self.PACKAGE_YAML_NEEDED_KEY[1]] # value of src_repo + + if vc == self.NOT_FOUND or sr == self.NOT_FOUND: + logger.warning("no info for upsteam") + return WARNING + + release_tags = ReleaseTagsFactory.get_release_tags(vc) + tags = release_tags.get_tags(sr) + + if not tags: + logger.warning("failed to get version by yaml, version_control: {t1}, src_repo: {t2}".format(t1=vc, t2=sr)) + return WARNING + return SUCCESS + + def check_repo_domain(self): + """ + 检查spec中source0域名是否包含yaml的version_control,仅做日志告警只返回SUCCESS(autoconf为特例) + :return: + """ + if not self._yaml_changed: + return SUCCESS + if not self._is_standard: + logger.warning("yaml does not comply with the rule") + return SUCCESS + if not self._spec: + logger.warning("spec does not exist") + return SUCCESS + + vc = self._yaml_content[self.PACKAGE_YAML_NEEDED_KEY[0]] + if vc == self.NOT_FOUND: + return SUCCESS + src_url = self._spec.get_source("Source0") + if not src_url: + src_url = self._spec.get_source("Source") + vc = self.VERSION_CTRL_TRANS.get(vc, vc) # 对特殊的版本控制对应的域名进行转换 + logger.debug("version control: {vctrl} source url: {url}".format(vctrl=vc, url=src_url)) + if vc not in src_url: # 通过判断版本控制字段是否在主页url中 判断一致性 + logger.warning("{vc} is not in url: {url}".format(vc=vc, url=src_url)) + return WARNING + return SUCCESS + + def check_repo_name(self): + """ + 检查spec中是否包含yaml中src_repo字段的软件名,仅做日志告警只返回SUCCESS + :return: + """ + if not self._yaml_changed: + return SUCCESS + if not self._is_standard: + logger.warning("yaml does not comply with the rule") + return SUCCESS + if not self._spec: + logger.warning("spec does not exist") + return SUCCESS + + sr = self._yaml_content[self.PACKAGE_YAML_NEEDED_KEY[1]] + if sr == self.NOT_FOUND: + return SUCCESS + + software_name_list = list(filter(None, sr.split("/"))) + if len(software_name_list) > 1 and software_name_list[-1] == "svn": # 处理svn仓库结尾为svn的特殊情况 + software_name = software_name_list[-2] + else: + software_name = software_name_list[-1] + src_url = self._spec.get_source("Source0") + if not src_url: + src_url = self._spec.get_source("Source") + logger.debug("software name: {name} source url: {url}".format(name=software_name, url=src_url)) + if software_name not in src_url: + logger.warning("{name} is not in source0: {url}".format(name=software_name, url=src_url)) + return WARNING + return SUCCESS + + def __call__(self, *args, **kwargs): + logger.info("check {} yaml ...".format(self._repo)) + self._yaml_changed = self.is_change_package_yaml() # yaml文件变更 进行检查 + return self.start_check_with_order("fields", "repo_domain", "repo_name", "repo") + diff --git a/src/ac/common/gitee_repo.py b/src/ac/common/gitee_repo.py index 696316caa5f447ef9b3f8b7c81ac142e4821f541..40e73ce4ccf6980ffaf5bf5e47f11d545f6c90bb 100644 --- a/src/ac/common/gitee_repo.py +++ b/src/ac/common/gitee_repo.py @@ -1,5 +1,6 @@ # -*- encoding=utf-8 -*- -# ********************************************************************************** +""" +# *********************************************************************************** # Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. # [openeuler-jenkins] is licensed under the Mulan PSL v1. # You can use this software according to the terms and conditions of the Mulan PSL v1. @@ -12,7 +13,8 @@ # Author: # Create: 2020-09-23 # Description: Gitee api proxy -# ********************************************************************************** +# ***********************************************************************************/ +""" import os import logging @@ -36,6 +38,7 @@ class GiteeRepo(object): self._compress_files = [] self.spec_file = None + self.yaml_file = None self.patch_dir_mapping = {} self.find_file_path() @@ -57,6 +60,9 @@ class GiteeRepo(object): elif self.is_spec_file(filename): logger.debug("find spec file: {}".format(rel_file_path)) spec_files.append(filename) + elif self.is_package_yaml_file(filename): + logger.debug("find yaml file: {}".format(rel_file_path)) + self.yaml_file = rel_file_path def guess_real_spec_file(): """ @@ -198,4 +204,18 @@ class GiteeRepo(object): @staticmethod def is_spec_file(filename): + """ + 功能描述:判断文件名是否以.spec结尾 + 参数:文件名 + 返回值:bool + """ return filename.endswith((".spec",)) + + @staticmethod + def is_package_yaml_file(filename): + """ + 功能描述:判断文件名是否以.yaml结尾 + 参数:文件名 + 返回值:bool + """ + return filename.endswith((".yaml",)) diff --git a/src/ac/common/rpm_spec_adapter.py b/src/ac/common/rpm_spec_adapter.py index 65db3aa241d64c8289463bc475a249fbe94e92f1..023f52f46c96346d8393fc994f3266383d7e63db 100644 --- a/src/ac/common/rpm_spec_adapter.py +++ b/src/ac/common/rpm_spec_adapter.py @@ -45,9 +45,24 @@ class RPMSpecAdapter(object): value = getattr(self._adapter, item) if isinstance(value, list): return [replace_macros(item, self._adapter) for item in value] - return replace_macros(value, self._adapter) if value else "" + def get_source(self, key): + """ + get source url from spec.source_dict by key + :return: + """ + src_url = self._adapter.sources_dict.get(key, "") + return replace_macros(src_url, self._adapter) if src_url else "" + + def get_patch(self, key): + """ + get source url from spec.source_dict by key + :return: + """ + patch = self._adapter.patches_dict.get(key, "") + return replace_macros(patch, self._adapter) if patch else "" + def include_x86_arch(self): """ check include x86-64 diff --git a/src/ac/framework/ac.yaml b/src/ac/framework/ac.yaml index 1785f2d14b5a012dbc7d769469c1af70ccc71ca5..18688a2623cf3f89fc268d9b3e37b2ca4bc440f0 100644 --- a/src/ac/framework/ac.yaml +++ b/src/ac/framework/ac.yaml @@ -9,3 +9,8 @@ code: entry: CheckCodeStyle #exclude: True ignored: [] +yaml: + hint: check_yaml_file + module: yaml.check_yaml + entry: CheckYaml + ignored: ["fields"] diff --git a/src/jenkinsfile/openeuler_jenkins_test.py b/src/jenkinsfile/openeuler_jenkins_test.py new file mode 100644 index 0000000000000000000000000000000000000000..88d5ee81306b3ceb6b88aa593a2773ca7cecc33e --- /dev/null +++ b/src/jenkinsfile/openeuler_jenkins_test.py @@ -0,0 +1,46 @@ +# -*- encoding=utf-8 -*- +""" +# *********************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# licensed under the Mulan PSL v1. +# You can use this software according to the terms and conditions of the Mulan PSL v1. +# You may obtain a copy of Mulan PSL v1 at: +# http://license.coscl.org.cn/MulanPSL +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v1 for more details. +# Author: DisNight +# Create: 2020-09-21 +# Description: run all test cases in test/ +# ***********************************************************************************/ +""" + +import os +import unittest +import logging.config +import logging +import mock +import shutil + +PATTERN_STR = 'test*.py' # 测试用例文件必须以test_开头 +TEST_DIR = os.path.realpath(os.path.join(os.path.realpath(__file__), '..', '..', '..', 'test')) +LOG_FILE = os.path.realpath(os.path.join(os.path.realpath(__file__), '..', 'test.log')) + +if __name__ == '__main__': + # mock所有logger为测试使用logger,输出为该文件同目录下的test.log + wordk_dir = os.getcwd() + _ = not os.path.exists("log") and os.mkdir("log") + logger_conf_path = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../conf/logger.conf")) + logging.config.fileConfig(logger_conf_path) + logger = logging.getLogger("test_logger") + + # 递归获取test目录下所有module的所有测试用例(需包含__init__.py) + discover_sets = unittest.defaultTestLoader.discover(start_dir=TEST_DIR, pattern=PATTERN_STR, top_level_dir=None) + suite = unittest.TestSuite() + suite.addTest(discover_sets) + # 运行所有测试用例 + test_runner = unittest.TextTestRunner() + test_runner.run(suite) + os.chdir(wordk_dir) + shutil.rmtree("log") \ No newline at end of file diff --git a/src/requirements b/src/requirements index 30e813f0c12d1fb314fa1391865566e27fe019df..2829e5c2736da41bc20842679f02706bdc7a1878 100644 --- a/src/requirements +++ b/src/requirements @@ -5,3 +5,5 @@ threadpool PyYAML gevent==1.2.2 jsonpath +mock +tldextract \ No newline at end of file diff --git a/test/__init__.py b/test/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..ed5bdad435b94b1475a582e9f6602dd020179de1 --- /dev/null +++ b/test/__init__.py @@ -0,0 +1,17 @@ +# -*- encoding=utf-8 -*- +""" +# *********************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# [openeuler-jenkins] is licensed under the Mulan PSL v1. +# You can use this software according to the terms and conditions of the Mulan PSL v1. +# You may obtain a copy of Mulan PSL v1 at: +# http://license.coscl.org.cn/MulanPSL +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v1 for more details. +# Author: DisNight +# Create: 2020-09-21 +# Description: +# ***********************************************************************************/ +""" \ No newline at end of file diff --git a/test/ac/__init__.py b/test/ac/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..ed5bdad435b94b1475a582e9f6602dd020179de1 --- /dev/null +++ b/test/ac/__init__.py @@ -0,0 +1,17 @@ +# -*- encoding=utf-8 -*- +""" +# *********************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# [openeuler-jenkins] is licensed under the Mulan PSL v1. +# You can use this software according to the terms and conditions of the Mulan PSL v1. +# You may obtain a copy of Mulan PSL v1 at: +# http://license.coscl.org.cn/MulanPSL +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v1 for more details. +# Author: DisNight +# Create: 2020-09-21 +# Description: +# ***********************************************************************************/ +""" \ No newline at end of file diff --git a/test/ac/acl/__init__.py b/test/ac/acl/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..ed5bdad435b94b1475a582e9f6602dd020179de1 --- /dev/null +++ b/test/ac/acl/__init__.py @@ -0,0 +1,17 @@ +# -*- encoding=utf-8 -*- +""" +# *********************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# [openeuler-jenkins] is licensed under the Mulan PSL v1. +# You can use this software according to the terms and conditions of the Mulan PSL v1. +# You may obtain a copy of Mulan PSL v1 at: +# http://license.coscl.org.cn/MulanPSL +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v1 for more details. +# Author: DisNight +# Create: 2020-09-21 +# Description: +# ***********************************************************************************/ +""" \ No newline at end of file diff --git a/test/ac/acl/yaml/__init__.py b/test/ac/acl/yaml/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..ed5bdad435b94b1475a582e9f6602dd020179de1 --- /dev/null +++ b/test/ac/acl/yaml/__init__.py @@ -0,0 +1,17 @@ +# -*- encoding=utf-8 -*- +""" +# *********************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# [openeuler-jenkins] is licensed under the Mulan PSL v1. +# You can use this software according to the terms and conditions of the Mulan PSL v1. +# You may obtain a copy of Mulan PSL v1 at: +# http://license.coscl.org.cn/MulanPSL +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v1 for more details. +# Author: DisNight +# Create: 2020-09-21 +# Description: +# ***********************************************************************************/ +""" \ No newline at end of file diff --git a/test/ac/acl/yaml/fields_test_sample/missing.yaml b/test/ac/acl/yaml/fields_test_sample/missing.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7bc47b74eb3f6e60296bc16169369c7172f90c36 --- /dev/null +++ b/test/ac/acl/yaml/fields_test_sample/missing.yaml @@ -0,0 +1,2 @@ +src_repo: a/b +tag_prefix: NA \ No newline at end of file diff --git a/test/ac/acl/yaml/fields_test_sample/standard.yaml b/test/ac/acl/yaml/fields_test_sample/standard.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5651f40d54d90fc9cc695f3905836be72bbc24b6 --- /dev/null +++ b/test/ac/acl/yaml/fields_test_sample/standard.yaml @@ -0,0 +1,4 @@ +version_control: testvc +src_repo: src/repo +tag_prefix: "v" +seperator: "." \ No newline at end of file diff --git a/test/ac/acl/yaml/repo_test_sample/git_test/git_test.spec b/test/ac/acl/yaml/repo_test_sample/git_test/git_test.spec new file mode 100644 index 0000000000000000000000000000000000000000..9aebd3154f4fbaeae9044dd72c2a87ffeb5ce72d --- /dev/null +++ b/test/ac/acl/yaml/repo_test_sample/git_test/git_test.spec @@ -0,0 +1,84 @@ +%global __requires_exclude ^perl\\(Autom4te:: +%global __provides_exclude ^perl\\(Autom4te:: + +Name: autoconf +Version: 2.69 +Release: 30 +Summary: An extensible package to automatically configure software source code packages +License: GPLv2+ and GPLv3+ and GFDL +URL: https://www.gnu.org/software/%{name}/ +Source0: http://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz +Source1: config.site +Source2: autoconf-el.el + +# four patches backport from upstream to solve test suite failure +Patch1: autoscan-port-to-perl-5.17.patch +Patch2: Port-tests-to-Bash-5.patch +Patch3: tests-avoid-spurious-test-failure-with-libtool-2.4.3.patch +#fix the failure of test 38 autotools and whitespace in file names +Patch4: Fix-test-suite-with-modern-Perl.patch + +Patch9000: skip-one-test-at-line-1616-of-autotest.patch + +BuildArch: noarch + +BuildRequires: m4 emacs perl perl-generators help2man +Requires: m4 emacs-filesystem +Requires(post): info +Requires(preun):info + +%package_help + +%description +Autoconf is an extensible package of M4 macros that produce shell scripts to automatically +configure software source code packages. These scripts can adapt the packages to many kinds +of UNIX-like systems without manual user intervention. Autoconf creates a configuration script +for a package from a template file that lists the operating system features that the package +can use, in the form of M4 macro calls. + +%prep +%autosetup -n %{name}-%{version} -p1 + +%build +export EMACS=%{_bindir}/emacs +%configure --with-lispdir=%{_emacs_sitelispdir}/autoconf +%make_build + +%check +make %{?_smp_mflags} check + +%install +%make_install +install -p -D %{SOURCE1} %{buildroot}%{_datadir} +install -p -D %{SOURCE2} %{buildroot}%{_emacs_sitestartdir}/autoconf-el.el + +%post help +/sbin/install-info %{_infodir}/autoconf.info %{_infodir}/dir || : + +%preun help +if [ "$1" = 0 ]; then + /sbin/install-info --delete %{_infodir}/autoconf.info %{_infodir}/dir || : +fi + +%files +%doc ChangeLog README THANKS +%license COPYING* AUTHORS doc/autoconf.info +%{_bindir}/* +%{_datadir}/autoconf/ +%{_datadir}/config.site +%{_datadir}/emacs/site-lisp/* +%exclude %{_infodir}/standards* + +%files help +%doc NEWS TODO +%{_infodir}/autoconf.info* +%{_mandir}/man1/* +%exclude %{_infodir}/dir + + +%changelog +* Sat Jan 4 2020 openEuler Buildteam - 2.69-30 +- Strengthen sources and patches + +* Fri Oct 11 2019 openEuler Buildteam - 2.69-29 +- Package Init diff --git a/test/ac/acl/yaml/repo_test_sample/git_test/git_test.yaml b/test/ac/acl/yaml/repo_test_sample/git_test/git_test.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c6e4d4f25a68f34b76b988d5403f3a2e5c9878f8 --- /dev/null +++ b/test/ac/acl/yaml/repo_test_sample/git_test/git_test.yaml @@ -0,0 +1,4 @@ +version_control: git +src_repo: https://git.savannah.gnu.org/git/autoconf.git +tag_prefix: "^v" +seperator: "." \ No newline at end of file diff --git a/test/ac/acl/yaml/repo_test_sample/gitee_test/gitee_test.spec b/test/ac/acl/yaml/repo_test_sample/gitee_test/gitee_test.spec new file mode 100644 index 0000000000000000000000000000000000000000..1da248dec3fff264c43608acd0bb8db6b77a4670 --- /dev/null +++ b/test/ac/acl/yaml/repo_test_sample/gitee_test/gitee_test.spec @@ -0,0 +1,263 @@ +%global _version 2.0.5 +%global _release 20200923.100811.git275398ce +%global is_systemd 1 + +Name: iSulad +Version: %{_version} +Release: %{_release} +Summary: Lightweight Container Runtime Daemon +License: Mulan PSL v2 +URL: https://gitee.com/openeuler/iSulad +Source: https://gitee.com/openeuler/iSulad/repository/archive/v%{version}.tar.gz +BuildRoot: {_tmppath}/iSulad-%{version} +ExclusiveArch: x86_64 aarch64 + +Patch6000: 0000-config-remove-unused-config.patch +Patch6001: 0001-fix-modify-quota-log-level-to-warning.patch +Patch6002: 0002-fix-memory-leak.patch +Patch6003: 0003-fix-security-opt-parsing-access-out-of-bounds.patch +Patch6004: 0004-fix-delete-rootfs-dir-when-rootfs-load-failed.patch +Patch6005: 0005-fix-code-review.patch +Patch6006: 0006-fix-pull-failure-caused-by-link-conflict.patch +Patch6007: 0007-image-clear-memory-if-failed.patch +Patch6008: 0008-fix-layer-remain-caused-by-hold-flag-not-clean.patch +Patch6009: 0009-fix-coredump-when-pull-image-with-lock-driver-image-.patch +Patch6010: 0010-fix-bad-formatting-placeholder-in-http-parse-module.patch +Patch6011: 0011-iSulad-fix-memory-leak.patch +Patch6012: 0012-fix-coredump-when-load-image-with-uid.patch + +%ifarch x86_64 aarch64 +Provides: libhttpclient.so()(64bit) +Provides: libisula.so()(64bit) +Provides: libisulad_img.so()(64bit) +%endif + +%if 0%{?is_systemd} +# Systemd 230 and up no longer have libsystemd-journal +BuildRequires: pkgconfig(systemd) +Requires: systemd-units +%else +Requires(post): chkconfig +Requires(preun): chkconfig +# This is for /sbin/service +Requires(preun): initscripts +%endif + +BuildRequires: cmake gcc-c++ lxc lxc-devel lcr-devel yajl-devel clibcni-devel +BuildRequires: grpc grpc-plugins grpc-devel protobuf-devel +BuildRequires: libcurl libcurl-devel sqlite-devel libarchive-devel device-mapper-devel +BuildRequires: http-parser-devel +BuildRequires: libseccomp-devel libcap-devel libselinux-devel libwebsockets libwebsockets-devel +BuildRequires: systemd-devel git + +Requires: lcr lxc clibcni +Requires: grpc protobuf +Requires: libcurl +Requires: sqlite http-parser libseccomp +Requires: libcap libselinux libwebsockets libarchive device-mapper +Requires: systemd + +%description +This is a umbrella project for gRPC-services based Lightweight Container +Runtime Daemon, written by C. + +%prep +%autosetup -n %{name} -Sgit -p1 + +%build +mkdir -p build +cd build +%cmake -DDEBUG=ON -DLIB_INSTALL_DIR=%{_libdir} -DCMAKE_INSTALL_PREFIX=/usr ../ +%make_build + +%install +rm -rf %{buildroot} +cd build +install -d $RPM_BUILD_ROOT/%{_libdir} +install -m 0644 ./src/libisula.so %{buildroot}/%{_libdir}/libisula.so +install -m 0644 ./src/utils/http/libhttpclient.so %{buildroot}/%{_libdir}/libhttpclient.so +install -m 0644 ./src/daemon/modules/image/libisulad_img.so %{buildroot}/%{_libdir}/libisulad_img.so +chmod +x %{buildroot}/%{_libdir}/libisula.so +chmod +x %{buildroot}/%{_libdir}/libhttpclient.so +chmod +x %{buildroot}/%{_libdir}/libisulad_img.so + +install -d $RPM_BUILD_ROOT/%{_libdir}/pkgconfig +install -m 0640 ./conf/isulad.pc %{buildroot}/%{_libdir}/pkgconfig/isulad.pc + +install -d $RPM_BUILD_ROOT/%{_bindir} +install -m 0755 ./src/isula %{buildroot}/%{_bindir}/isula +install -m 0755 ./src/isulad-shim %{buildroot}/%{_bindir}/isulad-shim +install -m 0755 ./src/isulad %{buildroot}/%{_bindir}/isulad +chrpath -d ./src/isula +chrpath -d ./src/isulad-shim +chrpath -d ./src/isulad + +install -d $RPM_BUILD_ROOT/%{_includedir}/isulad +install -m 0644 ../src/client/libisula.h %{buildroot}/%{_includedir}/isulad/libisula.h +install -m 0644 ../src/client/connect/isula_connect.h %{buildroot}/%{_includedir}/isulad/isula_connect.h +install -m 0644 ../src/utils/cutils/utils_timestamp.h %{buildroot}/%{_includedir}/isulad/utils_timestamp.h +install -m 0644 ../src/utils/cutils/error.h %{buildroot}/%{_includedir}/isulad/error.h +install -m 0644 ../src/daemon/modules/runtime/engines/engine.h %{buildroot}/%{_includedir}/isulad/engine.h +install -m 0644 ../src/daemon/modules/api/image_api.h %{buildroot}/%{_includedir}/isulad/image_api.h + +install -d $RPM_BUILD_ROOT/%{_sysconfdir}/isulad +install -m 0640 ../src/contrib/config/daemon.json %{buildroot}/%{_sysconfdir}/isulad/daemon.json +install -m 0640 ../src/contrib/config/seccomp_default.json %{buildroot}/%{_sysconfdir}/isulad/seccomp_default.json + +install -d $RPM_BUILD_ROOT/%{_sysconfdir}/default/isulad +install -m 0640 ../src/contrib/config/config.json %{buildroot}/%{_sysconfdir}/default/isulad/config.json +install -m 0640 ../src/contrib/config/systemcontainer_config.json %{buildroot}/%{_sysconfdir}/default/isulad/systemcontainer_config.json +install -m 0550 ../src/contrib/sysmonitor/isulad-check.sh %{buildroot}/%{_sysconfdir}/default/isulad/isulad-check.sh + +mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/sysmonitor/process +cp ../src/contrib/sysmonitor/isulad-monit $RPM_BUILD_ROOT/etc/sysmonitor/process + +install -d $RPM_BUILD_ROOT/%{_sysconfdir}/default/isulad/hooks +install -m 0640 ../src/contrib/config/hooks/default.json %{buildroot}/%{_sysconfdir}/default/isulad/hooks/default.json + +install -d $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig +install -p -m 0640 ../src/contrib/config/iSulad.sysconfig $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/iSulad + +%if 0%{?is_systemd} +install -d $RPM_BUILD_ROOT/%{_unitdir} +install -p -m 0640 ../src/contrib/init/isulad.service $RPM_BUILD_ROOT/%{_unitdir}/isulad.service +%else +install -d $RPM_BUILD_ROOT/%{_initddir} +install -p -m 0640 ../src/contrib/init/isulad.init $RPM_BUILD_ROOT/%{_initddir}/isulad.init +%endif + +%clean +rm -rf %{buildroot} + +%pre +# support update from lcrd to isulad, will remove in next version +if [ "$1" = "2" ]; then +%if 0%{?is_systemd} +systemctl stop lcrd +systemctl disable lcrd +if [ -e %{_sysconfdir}/isulad/daemon.json ];then + sed -i 's#/etc/default/lcrd/hooks#/etc/default/isulad/hooks#g' %{_sysconfdir}/isulad/daemon.json +fi +%else +/sbin/chkconfig --del lcrd +%endif +fi + +%post +if ! getent group isulad > /dev/null; then + groupadd --system isulad +fi + +if [ "$1" = "1" ]; then +%if 0%{?is_systemd} +systemctl enable isulad +systemctl start isulad +%else +/sbin/chkconfig --add isulad +%endif +elif [ "$1" = "2" ]; then +%if 0%{?is_systemd} +# support update from lcrd to isulad, will remove in next version +if [ -e %{_unitdir}/lcrd.service.rpmsave ]; then + mv %{_unitdir}/lcrd.service.rpmsave %{_unitdir}/isulad.service + sed -i 's/lcrd/isulad/g' %{_unitdir}/isulad.service +fi +systemctl status isulad | grep 'Active:' | grep 'running' +if [ $? -eq 0 ]; then + systemctl restart isulad +else + systemctl start isulad +fi +%else +/sbin/service isulad status | grep 'Active:' | grep 'running' +if [ $? -eq 0 ]; then + /sbin/service isulad restart +fi +%endif +fi + +if ! getent group isulad > /dev/null; then + groupadd --system isulad +fi + +%preun +%if 0%{?is_systemd} +%systemd_preun isulad +%else +if [ $1 -eq 0 ] ; then + /sbin/service isulad stop >/dev/null 2>&1 + /sbin/chkconfig --del isulad +fi +%endif + +%postun +%if 0%{?is_systemd} +%systemd_postun_with_restart isulad +%else +if [ "$1" -ge "1" ] ; then + /sbin/service isulad condrestart >/dev/null 2>&1 || : +fi +%endif + +%files +%attr(0600,root,root) %{_sysconfdir}/sysmonitor/process/isulad-monit +%attr(0550,root,root) %{_sysconfdir}/default/isulad/isulad-check.sh +%defattr(0640,root,root,0750) +%{_sysconfdir}/isulad +%{_sysconfdir}/isulad/* +%{_sysconfdir}/default/* +%defattr(-,root,root,-) +%if 0%{?is_systemd} +%{_unitdir}/isulad.service +%attr(0640,root,root) %{_unitdir}/isulad.service +%else +%{_initddir}/isulad.init +%attr(0640,root,root) %{_initddir}/isulad.init +%endif +%{_includedir}/isulad/* +%attr(0755,root,root) %{_libdir}/pkgconfig +%attr(0640,root,root) %{_libdir}/pkgconfig/isulad.pc +%defattr(0550,root,root,0750) +%{_bindir}/* +%{_libdir}/* +%attr(0640,root,root) %{_sysconfdir}/sysconfig/iSulad +%attr(0640,root,root) %{_sysconfdir}/isulad/daemon.json + +%config(noreplace,missingok) %{_sysconfdir}/sysconfig/iSulad +%config(noreplace,missingok) %{_sysconfdir}/isulad/daemon.json +%if 0%{?is_systemd} +%config(noreplace,missingok) %{_unitdir}/isulad.service +%else +%config(noreplace,missingok) %{_initddir}/isulad.init +%endif + +%changelog ++* Fri Sep 23 2020 - 2.0.5-20200923.100811.git275398ce ++- Type:bugfix ++- ID:NA ++- SUG:NA ++- DESC: fix some memory bugs + ++* Fri Sep 18 2020 - 2.0.5-20200918.112827.git9aea9b75 ++- Type:bugfix ++- ID:NA ++- SUG:NA ++- DESC: modify log level to warn + ++* Mon Sep 14 2020 - 2.0.5-20200914.172527.gitae86920a ++- Type:bugfix ++- ID:NA ++- SUG:NA ++- DESC: remove unused config + +* Tue Sep 10 2020 - 2.0.5-20200910.144345.git71b1055b +- Type:enhancement +- ID:NA +- SUG:NA +- DESC: add chrpath + +* Fri Sep 04 2020 zhangxiaoyu - 2.0.5-20200904.114315.gitff1761c3 +- Type:enhancement +- ID:NA +- SUG:NA +- DESC: upgrade from v2.0.3 to v2.0.5 diff --git a/test/ac/acl/yaml/repo_test_sample/gitee_test/gitee_test.yaml b/test/ac/acl/yaml/repo_test_sample/gitee_test/gitee_test.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a89bce307db9145097f78d28e8b5f93aafe967f0 --- /dev/null +++ b/test/ac/acl/yaml/repo_test_sample/gitee_test/gitee_test.yaml @@ -0,0 +1,4 @@ +version_control: gitee +src_repo: openEuler/iSulad +tag_prefix: "v" +seperator: "." \ No newline at end of file diff --git a/test/ac/acl/yaml/repo_test_sample/github_test/github_test.spec b/test/ac/acl/yaml/repo_test_sample/github_test/github_test.spec new file mode 100644 index 0000000000000000000000000000000000000000..e02588d51731ae4608c690a498fbcaa55a5b121a --- /dev/null +++ b/test/ac/acl/yaml/repo_test_sample/github_test/github_test.spec @@ -0,0 +1,107 @@ +%global _name pyinotify +%global _description Pyinotify is a Python module for monitoring filesystems changes. \ +Pyinotify relies on a Linux Kernel feature (merged in kernel 2.6.13) called inotify. \ +inotify is an event-driven notifier, its notifications are exported from kernel space \ +to user space through three system calls. pyinotify binds these system calls and provides \ +an implementation on top of them offering a generic and abstract way to manipulate those \ +functionalities. + +Name: python-inotify +Version: 0.9.6 +Release: 16 +Summary: A Python module for monitoring filesystems changes +License: MIT +URL: https://github.com/seb-m/pyinotify +Source0: https://github.com/seb-m/pyinotify/archive/%{version}.tar.gz#/%{_name}-%{version}.tar.gz + +Patch0: pyinotify-0.9.6-epoint.patch +BuildArch: noarch +BuildRequires: gmp-devel + +%description +%{_description} + +%package -n python2-inotify +Summary: python2 edition of %{name} + +BuildRequires: python2-devel + +Provides: python2-inotify-examples + +Obsoletes: python2-inotify-examples + +%{?python_provide:%python_provide python2-inotify} + +%description -n python2-inotify +This package is the python2 edition of %{name}. + +%package -n python3-inotify +Summary: python3 edition of %{name} + +BuildRequires: python3-devel + +%{?python_provide:%python_provide python3-inotify} + +%description -n python3-inotify +This package is the python3 edition of %{name}. + +%package_help + +%prep +%autosetup -n %{_name}-%{version} -p1 +sed -i '1c#! %{__python2}' python2/pyinotify.py +sed -i '1c#! %{__python3}' python3/pyinotify.py +sed -i '1c#! %{__python2}' python2/examples/*py +sed -i '1c#! %{__python3}' python3/examples/*py +cp -a . $RPM_BUILD_DIR/python3-%{_name}-%{version} + +%build +%py2_build +cd $RPM_BUILD_DIR/python3-%{_name}-%{version} +%py3_build + +%install +cd $RPM_BUILD_DIR/python3-%{_name}-%{version} +%py3_install +mv %{buildroot}%{_bindir}/%{_name} %{buildroot}%{_bindir}/python3-%{_name} +cd - +%py2_install + +%files -n python2-inotify +%defattr(-,root,root) +%doc ACKS +%license COPYING +%doc python2/examples/* +%{_bindir}/%{_name} +%{python2_sitelib}/*.py* +%{python2_sitelib}/%{_name}*info/ + +%files -n python3-inotify +%defattr(-,root,root) +%doc ACKS +%license COPYING +%doc python3/examples/* +%{_bindir}/*3-%{_name} +%{python3_sitelib}/*.py* +%{python3_sitelib}/%{_name}*info/ +%{python3_sitelib}/__pycache__/*.pyc + +%files help +%defattr(-,root,root) +%doc README.md PKG-INFO + +%changelog +* Mon Dec 23 2019 openEuler Buildteam - 0.9.6-16 +- Type:NA +- ID:NA +- SUG:NA +- DESC:delete unneeded comments + +* Fri Sep 27 2019 shenyangyang - 0.9.6-15 +- Type:enhancement +- ID:NA +- SUG:NA +- DESC:move license file + +* Thu Sep 12 2019 openEuler Buildteam - 0.9.6-14 +- Package init diff --git a/test/ac/acl/yaml/repo_test_sample/github_test/github_test.yaml b/test/ac/acl/yaml/repo_test_sample/github_test/github_test.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6808b8d01799b7e5a62888f76181533f23bf2b02 --- /dev/null +++ b/test/ac/acl/yaml/repo_test_sample/github_test/github_test.yaml @@ -0,0 +1,4 @@ +version_control: github +src_repo: seb-m/pyinotify +tag_prefix: "^" +seperator: "." \ No newline at end of file diff --git a/test/ac/acl/yaml/repo_test_sample/gitlab_gnome_test/gitlab_gnome_test.spec b/test/ac/acl/yaml/repo_test_sample/gitlab_gnome_test/gitlab_gnome_test.spec new file mode 100644 index 0000000000000000000000000000000000000000..40078cbda92824ab7d5ca57505930346ef3b7648 --- /dev/null +++ b/test/ac/acl/yaml/repo_test_sample/gitlab_gnome_test/gitlab_gnome_test.spec @@ -0,0 +1,58 @@ +Name: gnome-dictionary +Version: 3.26.1 +Release: 4 +Summary: A dictionary application for GNOME +License: GPLv3+ and LGPLv2+ and GFDL +URL: https://wiki.gnome.org/Apps/Dictionary +Source0: https://download.gnome.org/sources/%{name}/3.26/%{name}-%{version}.tar.xz + +BuildRequires: desktop-file-utils docbook-style-xsl gettext itstool libappstream-glib libxslt +BuildRequires: meson pkgconfig(gobject-introspection-1.0) pkgconfig(gtk+-3.0) +Obsoletes: gnome-utils <= 1:3.3 gnome-utils-libs <= 1:3.3 gnome-utils-devel <= 1:3.3 +Obsoletes: gnome-dictionary-devel < 3.26.0 gnome-dictionary-libs < 3.26.0 + +%description +GNOME Dictionary is a simple, clean, elegant application to look up words in +online dictionaries using the DICT protocol. + +%package help +Summary: Help package for gnome-dictionary + +%description help +This package contains some man help files for gnome-dictionary. + +%prep +%autosetup -n %{name}-%{version} -p1 + +%build +%meson +%meson_build + +%install +%meson_install +%find_lang %{name} --with-gnome + +%check +appstream-util validate-relax --nonet %{buildroot}/%{_datadir}/appdata/*.appdata.xml +desktop-file-validate %{buildroot}/%{_datadir}/applications/*.desktop + +%postun +if [ $1 -eq 0 ]; then + glib-compile-schemas %{_datadir}/glib-2.0/schemas &>/dev/null || : +fi + +%posttrans +glib-compile-schemas %{_datadir}/glib-2.0/schemas &>/dev/null || : + +%files -f %{name}.lang +%doc COPYING* NEWS README.md +%{_bindir}/gnome-dictionary +%{_datadir}/* +%exclude %{_datadir}/man* + +%files help +%{_mandir}/man1/gnome-dictionary.1* + +%changelog +* Wed Dec 11 2019 lingsheng - 3.26.1-4 +- Package init diff --git a/test/ac/acl/yaml/repo_test_sample/gitlab_gnome_test/gitlab_gnome_test.yaml b/test/ac/acl/yaml/repo_test_sample/gitlab_gnome_test/gitlab_gnome_test.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2e093dc19dde2f39b36079cca558fb58c3e57cb1 --- /dev/null +++ b/test/ac/acl/yaml/repo_test_sample/gitlab_gnome_test/gitlab_gnome_test.yaml @@ -0,0 +1,4 @@ +version_control: gitlab.gnome +src_repo: gnome-dictionary +tag_prefix: "^v" +seperator: "." \ No newline at end of file diff --git a/test/ac/acl/yaml/repo_test_sample/gnu_ftp_test/gnu_ftp_test.spec b/test/ac/acl/yaml/repo_test_sample/gnu_ftp_test/gnu_ftp_test.spec new file mode 100644 index 0000000000000000000000000000000000000000..80f2f0c41f29a5ec346725d521021e85cdf5dab2 --- /dev/null +++ b/test/ac/acl/yaml/repo_test_sample/gnu_ftp_test/gnu_ftp_test.spec @@ -0,0 +1,60 @@ +%bcond_with nls + +Name: help2man +Summary: Create simple man pages from --help output +Version: 1.47.11 +Release: 0 +License: GPLv3+ +URL: http://www.gnu.org/software/help2man +Source: ftp://ftp.gnu.org/gnu/help2man/help2man-%{version}.tar.xz + +%{!?with_nls:BuildArch: noarch} +BuildRequires: gcc perl-generators perl(Getopt::Long) perl(POSIX) perl(Text::ParseWords) perl(Text::Tabs) perl(strict) +%{?with_nls:BuildRequires: perl(Locale::gettext) /usr/bin/msgfmt} +%{?with_nls:BuildRequires: perl(Encode)} +%{?with_nls:BuildRequires: perl(I18N::Langinfo)} +Requires(post): /sbin/install-info +Requires(preun): /sbin/install-info + +%description +help2man is a tool for automatically generating simple manual pages from program output. + +%package_help + +%prep +%autosetup -n %{name}-%{version} + +%build +%configure --%{!?with_nls:disable}%{?with_nls:enable}-nls --libdir=%{_libdir}/help2man +%{make_build} + +%install +make install_l10n DESTDIR=$RPM_BUILD_ROOT +make install DESTDIR=$RPM_BUILD_ROOT +%find_lang %name --with-man + +%post +%install_info %{_infodir}/help2man.info + +%preun +if [ $1 -eq 0 ]; then + %install_info_rm %{_infodir}/help2man.info +fi + +%files -f %name.lang +%defattr(-,root,root) +%doc README NEWS THANKS +%license COPYING +%{_bindir}/help2man +%{_infodir}/* +%if %{with nls} + %{_libdir}/help2man +%endif + +%files help +%defattr(-,root,root) +%{_mandir}/man1/* + +%changelog +* Thu Nov 07 2019 openEuler Buildtam - 1.47.11-0 +- Package Init diff --git a/test/ac/acl/yaml/repo_test_sample/gnu_ftp_test/gnu_ftp_test.yaml b/test/ac/acl/yaml/repo_test_sample/gnu_ftp_test/gnu_ftp_test.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1bb03a75e96ca7d4caf59b4509d6820f7bf11c73 --- /dev/null +++ b/test/ac/acl/yaml/repo_test_sample/gnu_ftp_test/gnu_ftp_test.yaml @@ -0,0 +1,4 @@ +version_control: gnu-ftp +src_repo: help2man +tag_prefix: help2man-(.*).tar.xz(.sig)? +seperator: "." \ No newline at end of file diff --git a/test/ac/acl/yaml/repo_test_sample/hg_test/hg_test.spec b/test/ac/acl/yaml/repo_test_sample/hg_test/hg_test.spec new file mode 100644 index 0000000000000000000000000000000000000000..5158fb535f18a2e48a7ed7aea6a856e268f2d1b2 --- /dev/null +++ b/test/ac/acl/yaml/repo_test_sample/hg_test/hg_test.spec @@ -0,0 +1,381 @@ +%global _hardened_build 1 +%global nginx_user nginx + +%undefine _strict_symbol_defs_build + +%bcond_with geoip + +%global with_gperftools 1 + +%global with_mailcap_mimetypes 0 + +%global with_aio 1 + +Name: nginx +Epoch: 1 +Version: 1.18.0 +Release: 2 +Summary: A HTTP server, reverse proxy and mail proxy server +License: BSD +URL: http://nginx.org/ + +Source0: https://nginx.org/download/nginx-%{version}.tar.gz +Source10: nginx.service +Source11: nginx.logrotate +Source12: nginx.conf +Source13: nginx-upgrade +Source100: index.html +Source102: nginx-logo.png +Source103: 404.html +Source104: 50x.html +Source200: README.dynamic +Source210: UPGRADE-NOTES-1.6-to-1.10 + +Patch0: nginx-auto-cc-gcc.patch +Patch2: nginx-1.12.1-logs-perm.patch +BuildRequires: gcc openssl-devel pcre-devel zlib-devel systemd gperftools-devel +Requires: nginx-filesystem = %{epoch}:%{version}-%{release} openssl pcre +Requires: nginx-all-modules = %{epoch}:%{version}-%{release} +%if 0%{?with_mailcap_mimetypes} +Requires: nginx-mimetypes +%endif +Requires(pre): nginx-filesystem +Requires(post): systemd +Requires(preun): systemd +Requires(postun): systemd +Provides: webserver +Recommends: logrotate + +%description +NGINX is a free, open-source, high-performance HTTP server and reverse proxy, +as well as an IMAP/POP3 proxy server. + +%package all-modules +Summary: Nginx modules +BuildArch: noarch + +%if %{with geoip} +Requires: nginx-mod-http-geoip = %{epoch}:%{version}-%{release} +%endif +Requires: nginx-mod-http-image-filter = %{epoch}:%{version}-%{release} +Requires: nginx-mod-http-perl = %{epoch}:%{version}-%{release} +Requires: nginx-mod-http-xslt-filter = %{epoch}:%{version}-%{release} +Requires: nginx-mod-mail = %{epoch}:%{version}-%{release} +Requires: nginx-mod-stream = %{epoch}:%{version}-%{release} + +%description all-modules +NGINX is a free, open-source, high-performance HTTP server and reverse proxy, +as well as an IMAP/POP3 proxy server. +This package is a meta package that installs all available Nginx modules. + +%package filesystem +Summary: Filesystem for the Nginx server +BuildArch: noarch +Requires(pre): shadow-utils + +%description filesystem +NGINX is a free, open-source, high-performance HTTP server and reverse proxy, +as well as an IMAP/POP3 proxy server. +The package contains the basic directory layout for the Nginx server. + +%if %{with geoip} +%package mod-http-geoip +Summary: HTTP geoip module for nginx +BuildRequires: GeoIP-devel +Requires: nginx GeoIP + +%description mod-http-geoip +The package is the Nginx HTTP geoip module. +%endif + +%package mod-http-image-filter +Summary: HTTP image filter module for nginx +BuildRequires: gd-devel +Requires: nginx gd + +%description mod-http-image-filter +Nginx HTTP image filter module. + +%package mod-http-perl +Summary: HTTP perl module for nginx +BuildRequires: perl-devel perl(ExtUtils::Embed) +Requires: nginx perl(constant) +Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version)) + +%description mod-http-perl +Nginx HTTP perl module. + +%package mod-http-xslt-filter +Summary: XSLT module for nginx +BuildRequires: libxslt-devel +Requires: nginx + +%description mod-http-xslt-filter +Nginx XSLT module. + +%package mod-mail +Summary: mail modules for nginx +Requires: nginx + +%description mod-mail +Nginx mail modules + +%package mod-stream +Summary: stream modules for nginx +Requires: nginx + +%description mod-stream +Nginx stream modules. + +%package_help + +%prep +%autosetup -n %{name}-%{version} -p1 +cp %{SOURCE200} %{SOURCE210} %{SOURCE10} %{SOURCE12} . + +%build +export DESTDIR=%{buildroot} +nginx_ldopts="$RPM_LD_FLAGS -Wl,-E" +if ! ./configure \ + --prefix=%{_datadir}/nginx --sbin-path=%{_sbindir}/nginx --modules-path=%{_libdir}/nginx/modules \ + --conf-path=%{_sysconfdir}/nginx/nginx.conf --error-log-path=%{_localstatedir}/log/nginx/error.log \ + --http-log-path=%{_localstatedir}/log/nginx/access.log \ + --http-client-body-temp-path=%{_localstatedir}/lib/nginx/tmp/client_body \ + --http-fastcgi-temp-path=%{_localstatedir}/lib/nginx/tmp/fastcgi \ + --http-proxy-temp-path=%{_localstatedir}/lib/nginx/tmp/proxy \ + --http-scgi-temp-path=%{_localstatedir}/lib/nginx/tmp/scgi \ + --http-uwsgi-temp-path=%{_localstatedir}/lib/nginx/tmp/uwsgi \ + --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx \ + --user=%{nginx_user} --group=%{nginx_user} \ +%if 0%{?with_aio} + --with-file-aio \ +%endif + --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module \ + --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic \ +%if %{with geoip} + --with-http_geoip_module=dynamic \ +%endif + --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module \ + --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module \ + --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module \ + --with-http_perl_module=dynamic --with-http_auth_request_module \ + --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic \ + --with-stream_ssl_module --with-google_perftools_module --with-debug \ + --with-cc-opt="%{optflags} $(pcre-config --cflags)" --with-ld-opt="$nginx_ldopts"; then + : configure failed + cat objs/autoconf.err + exit 1 +fi + +%make_build + + +%install +%make_install INSTALLDIRS=vendor + +find %{buildroot} -type f -empty -exec rm -f '{}' \; +find %{buildroot} -type f -name .packlist -exec rm -f '{}' \; +find %{buildroot} -type f -name perllocal.pod -exec rm -f '{}' \; +find %{buildroot} -type f -iname '*.so' -exec chmod 0755 '{}' \; + +pushd %{buildroot} +install -p -D -m 0644 %{_builddir}/nginx-%{version}/nginx.service .%{_unitdir}/nginx.service +install -p -D -m 0644 %{SOURCE11} .%{_sysconfdir}/logrotate.d/nginx +install -p -d -m 0755 .%{_sysconfdir}/systemd/system/nginx.service.d +install -p -d -m 0755 .%{_unitdir}/nginx.service.d +install -p -d -m 0755 .%{_sysconfdir}/nginx/conf.d +install -p -d -m 0755 .%{_sysconfdir}/nginx/default.d +install -p -d -m 0700 .%{_localstatedir}/lib/nginx +install -p -d -m 0700 .%{_localstatedir}/lib/nginx/tmp +install -p -d -m 0700 .%{_localstatedir}/log/nginx +install -p -d -m 0755 .%{_datadir}/nginx/html +install -p -d -m 0755 .%{_datadir}/nginx/modules +install -p -d -m 0755 .%{_libdir}/nginx/modules +install -p -m 0644 %{_builddir}/nginx-%{version}/nginx.conf .%{_sysconfdir}/nginx +install -p -m 0644 %{SOURCE100} .%{_datadir}/nginx/html +install -p -m 0644 %{SOURCE102} .%{_datadir}/nginx/html +install -p -m 0644 %{SOURCE103} %{SOURCE104} .%{_datadir}/nginx/html + +%if 0%{?with_mailcap_mimetypes} +rm -f .%{_sysconfdir}/nginx/mime.types +%endif + +install -p -D -m 0644 %{_builddir}/nginx-%{version}/man/nginx.8 .%{_mandir}/man8/nginx.8 +install -p -D -m 0755 %{SOURCE13} .%{_bindir}/nginx-upgrade +popd + +for i in ftdetect indent syntax; do + install -p -D -m644 contrib/vim/${i}/nginx.vim %{buildroot}%{_datadir}/vim/vimfiles/${i}/nginx.vim +done + +%if %{with geoip} +echo 'load_module "%{_libdir}/nginx/modules/ngx_http_geoip_module.so";' \ + > %{buildroot}%{_datadir}/nginx/modules/mod-http-geoip.conf +%endif + +pushd %{buildroot} +echo 'load_module "%{_libdir}/nginx/modules/ngx_http_image_filter_module.so";' \ + > .%{_datadir}/nginx/modules/mod-http-image-filter.conf +echo 'load_module "%{_libdir}/nginx/modules/ngx_http_perl_module.so";' \ + > .%{_datadir}/nginx/modules/mod-http-perl.conf +echo 'load_module "%{_libdir}/nginx/modules/ngx_http_xslt_filter_module.so";' \ + > .%{_datadir}/nginx/modules/mod-http-xslt-filter.conf +echo 'load_module "%{_libdir}/nginx/modules/ngx_mail_module.so";' \ + > .%{_datadir}/nginx/modules/mod-mail.conf +echo 'load_module "%{_libdir}/nginx/modules/ngx_stream_module.so";' \ + > .%{_datadir}/nginx/modules/mod-stream.conf +popd + +%pre filesystem +getent group %{nginx_user} > /dev/null || groupadd -r %{nginx_user} +getent passwd %{nginx_user} > /dev/null || useradd -r -d %{_localstatedir}/lib/nginx -g %{nginx_user} \ + -s /sbin/nologin -c "Nginx web server" %{nginx_user} +exit 0 + +%post +%systemd_post nginx.service + +%if %{with geoip} +%post mod-http-geoip +if [ $1 -eq 1 ]; then + systemctl reload nginx.service >/dev/null 2>&1 || : +fi +%endif + +%post mod-http-image-filter +if [ $1 -eq 1 ]; then + systemctl reload nginx.service >/dev/null 2>&1 || : +fi + +%post mod-http-perl +if [ $1 -eq 1 ]; then + systemctl reload nginx.service >/dev/null 2>&1 || : +fi + +%post mod-http-xslt-filter +if [ $1 -eq 1 ]; then + systemctl reload nginx.service >/dev/null 2>&1 || : +fi + +%post mod-mail +if [ $1 -eq 1 ]; then + systemctl reload nginx.service >/dev/null 2>&1 || : +fi + +%post mod-stream +if [ $1 -eq 1 ]; then + systemctl reload nginx.service >/dev/null 2>&1 || : +fi + +%preun +%systemd_preun nginx.service + +%postun +%systemd_postun nginx.service +if [ $1 -ge 1 ]; then + /usr/bin/nginx-upgrade >/dev/null 2>&1 || : +fi + +%files +%defattr(-,root,root) +%license LICENSE +%config(noreplace) %{_sysconfdir}/nginx/* +%config(noreplace) %{_sysconfdir}/logrotate.d/nginx +%exclude %{_sysconfdir}/nginx/conf.d +%exclude %{_sysconfdir}/nginx/default.d +%if 0%{?with_mailcap_mimetypes} +%exclude %{_sysconfdir}/nginx/mime.types +%endif +%{_bindir}/nginx-upgrade +%{_sbindir}/nginx +%dir %{_libdir}/nginx/modules +%attr(770,%{nginx_user},root) %dir %{_localstatedir}/lib/nginx +%attr(770,%{nginx_user},root) %dir %{_localstatedir}/lib/nginx/tmp +%{_unitdir}/nginx.service +%{_datadir}/nginx/html/* +%{_datadir}/vim/vimfiles/ftdetect/nginx.vim +%{_datadir}/vim/vimfiles/syntax/nginx.vim +%{_datadir}/vim/vimfiles/indent/nginx.vim +%attr(770,%{nginx_user},root) %dir %{_localstatedir}/log/nginx + +%files all-modules + +%files filesystem +%dir %{_sysconfdir}/nginx +%dir %{_sysconfdir}/nginx/{conf.d,default.d} +%dir %{_sysconfdir}/systemd/system/nginx.service.d +%dir %{_unitdir}/nginx.service.d +%dir %{_datadir}/nginx +%dir %{_datadir}/nginx/html + +%if %{with geoip} +%files mod-http-geoip +%{_libdir}/nginx/modules/ngx_http_geoip_module.so +%{_datadir}/nginx/modules/mod-http-geoip.conf +%endif + +%files mod-http-image-filter +%{_libdir}/nginx/modules/ngx_http_image_filter_module.so +%{_datadir}/nginx/modules/mod-http-image-filter.conf + +%files mod-http-perl +%{_libdir}/nginx/modules/ngx_http_perl_module.so +%{_datadir}/nginx/modules/mod-http-perl.conf +%dir %{perl_vendorarch}/auto/nginx +%{perl_vendorarch}/nginx.pm +%{perl_vendorarch}/auto/nginx/nginx.so + +%files mod-http-xslt-filter +%{_libdir}/nginx/modules/ngx_http_xslt_filter_module.so +%{_datadir}/nginx/modules/mod-http-xslt-filter.conf + +%files mod-mail +%{_libdir}/nginx/modules/ngx_mail_module.so +%{_datadir}/nginx/modules/mod-mail.conf + +%files mod-stream +%{_libdir}/nginx/modules/ngx_stream_module.so +%{_datadir}/nginx/modules/mod-stream.conf + +%files help +%defattr(-,root,root) +%doc CHANGES README README.dynamic +%{_mandir}/man3/nginx.3pm* +%{_mandir}/man8/nginx.8* + +%changelog +* Thu Sep 3 2020 yanan li - 1:1.18.0-2 +- add mime.types file to nginx packages + +* Thu Jun 4 2020 huanghaitao - 1:1.18.0-1 +- Change source to latest update + +* Fri May 22 2020 wutao - 1:1.16.1-4 +- change and delete html + +* Mon May 11 2020 wutao - 1:1.16.1-3 +- modify patch and html + +* Wed Mar 18 2020 yuxiangyang - 1:1.16.1-2 +- delete http_stub_status_module.This configuration creates a simple + web page with basic status data,but it will affect cpu scale-out because + it use atomic cas. + +* Mon Mar 16 2020 likexin - 1:1.16.1-1 +- update to 1.16.1 + +* Mon Mar 16 2020 openEuler Buildteam - 1:1.12.1-17 +- Type:bugfix +- ID:NA +- SUG:restart +- DESC: fix CVE-2019-20372 + +* Sat Dec 28 2019 openEuler Buildteam - 1:1.12.1-16 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC: add the with_mailcap_mimetypes + +* Wed Dec 4 2019 openEuler Buildteam - 1:1.12.1-15 +- Package init + diff --git a/test/ac/acl/yaml/repo_test_sample/hg_test/hg_test.yaml b/test/ac/acl/yaml/repo_test_sample/hg_test/hg_test.yaml new file mode 100644 index 0000000000000000000000000000000000000000..afc21e088e955f92d0c65d2d2766c27e7efc0944 --- /dev/null +++ b/test/ac/acl/yaml/repo_test_sample/hg_test/hg_test.yaml @@ -0,0 +1,4 @@ +version_control: hg +src_repo: https://hg.nginx.org/nginx +tag_prefix: release- +seperator: "." \ No newline at end of file diff --git a/test/ac/acl/yaml/repo_test_sample/metacpan_test/metacpan_test.spec b/test/ac/acl/yaml/repo_test_sample/metacpan_test/metacpan_test.spec new file mode 100644 index 0000000000000000000000000000000000000000..2c119db61ad4230d6c4a6d33633e87d6ee7a897a --- /dev/null +++ b/test/ac/acl/yaml/repo_test_sample/metacpan_test/metacpan_test.spec @@ -0,0 +1,54 @@ +Name: perl-HTML-Tagset +Version: 3.20 +Release: 37 +Summary: HTML::Tagset - data tables useful in parsing HTML +License: GPL+ or Artistic +URL: https://metacpan.org/release/HTML-Tagset +Source0: https://cpan.metacpan.org/authors/id/P/PE/PETDANCE/HTML-Tagset-%{version}.tar.gz + +BuildArch: noarch + +BuildRequires: perl-generators perl-interpreter perl(:VERSION) >= 5.4 +BuildRequires: perl(ExtUtils::MakeMaker) >= 6.76 perl(strict) perl(vars) +BuildRequires: perl(Test) perl(Test::More) +BuildRequires: perl(Test::Pod) >= 1.14 + +Requires: perl(:MODULE_COMPAT_%(eval "`perl -V:version`"; echo $version)) + +%description +This module contains data tables useful in dealing with HTML. +It provides no functions or methods. + +%package help +Summary: Documentation for perl-HTML-Tagset + +%description help +Documentation for perl-HTML-Tagset. + +%prep +%autosetup -n HTML-Tagset-%{version} -p1 + +%build +perl Makefile.PL INSTALLDIRS=vendor NO_PACKLIST=1 +%make_build + +%install +make pure_install DESTDIR=%{buildroot} +%{_fixperms} %{buildroot} + +%check +make test + +%files +%{perl_vendorlib}/HTML/ +%exclude %{_libdir}/perl5/perllocal.pod + +%files help +%doc Changes README +%{_mandir}/man3/ + + +%changelog +* Tue Oct 22 2019 Zaiwang Li - 3.20-37 +- Init Package. + diff --git a/test/ac/acl/yaml/repo_test_sample/metacpan_test/metacpan_test.yaml b/test/ac/acl/yaml/repo_test_sample/metacpan_test/metacpan_test.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c935eee422b9c7b59ebb4e62faff7b61940150d4 --- /dev/null +++ b/test/ac/acl/yaml/repo_test_sample/metacpan_test/metacpan_test.yaml @@ -0,0 +1,4 @@ +version_control: metacpan +src_repo: HTML-Tagset +tag_prefix: "v" +seperator: "." \ No newline at end of file diff --git a/test/ac/acl/yaml/repo_test_sample/na_test/na.spec b/test/ac/acl/yaml/repo_test_sample/na_test/na.spec new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/test/ac/acl/yaml/repo_test_sample/na_test/na.yaml b/test/ac/acl/yaml/repo_test_sample/na_test/na.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4c9cc07bc6b08805f078f6175e89adabba93a0d4 --- /dev/null +++ b/test/ac/acl/yaml/repo_test_sample/na_test/na.yaml @@ -0,0 +1,4 @@ +version_control: NA +src_repo: NA +tag_prefix: NA +seperator: NA \ No newline at end of file diff --git a/test/ac/acl/yaml/repo_test_sample/pypi_test/pypi_test.spec b/test/ac/acl/yaml/repo_test_sample/pypi_test/pypi_test.spec new file mode 100644 index 0000000000000000000000000000000000000000..f73c2a10c9ca82f8acd3c1215deed72d5496e22f --- /dev/null +++ b/test/ac/acl/yaml/repo_test_sample/pypi_test/pypi_test.spec @@ -0,0 +1,110 @@ +Name: python-idna +Version: 2.10 +Release: 1 +Summary: Internationalized Domain Names in Applications (IDNA) +License: BSD and Python and Unicode +URL: https://github.com/kjd/idna +Source0: https://files.pythonhosted.org/packages/source/i/idna/idna-%{version}.tar.gz + +BuildArch: noarch +%if 0%{?with_python2} +BuildRequires: python2-devel python2-setuptools +%endif +%if 0%{?with_python3} +BuildRequires: python3-devel python3-setuptools +%endif + +%description +A library to support the Internationalised Domain Names in +Applications (IDNA) protocol as specified in RFC 5891 +http://tools.ietf.org/html/rfc5891. This version of the protocol +is often referred to as “IDNA2008” and can produce different +results from the earlier standard from 2003. + +The library is also intended to act as a suitable drop-in replacement +for the “encodings.idna” module that comes with the Python standard +library but currently only supports the older 2003 specification. + +%if 0%{?with_python2} +%package -n python2-idna +Summary: Python2 package for python-idna +Provides: python-idna = %{version}-%{release} +Obsoletes: python-idna < %{version}-%{release} + +%description -n python2-idna +Python2 package for python-idna +%endif + +%if 0%{?with_python3} +%package -n python3-idna +Summary: Python3 package for python-idna +%{?python_provide: %python_provide python3-idna} + +%description -n python3-idna +Python3 package for python-idna +%endif + +%prep +%autosetup -n idna-%{version} -p1 + +%build +%if 0%{?with_python2} +%py2_build +%endif + +%if 0%{?with_python3} +%py3_build +%endif + +%install +%if 0%{?with_python2} +%py2_install +%endif + +%if 0%{?with_python3} +%py3_install +%endif + +%check +%if 0%{?with_python2} +%{__python2} setup.py test +%endif + +%if 0%{?with_python3} +%{__python3} setup.py test +%endif + +%if 0%{?with_python2} +%files -n python2-idna +%defattr(-,root,root) +%doc README.rst HISTORY.rst +%license LICENSE.rst +%{python2_sitelib}/* +%endif + +%if 0%{?with_python3} +%files -n python3-idna +%defattr(-,root,root) +%doc README.rst HISTORY.rst +%license LICENSE.rst +%{python3_sitelib}/* +%endif + +%changelog +* Thu Jul 23 2020 zhouhaibo - 2.10-1 +- Package update + +* Wed Jan 15 2020 openEuler Buildteam - 2.8-3 +- Type:bugfix +- Id:NA +- SUG:NA +- DESC:delete the python-idna + +* Tue Jan 14 2020 openEuler Buildteam - 2.8-2 +- Type:bugfix +- Id:NA +- SUG:NA +- DESC:delete the python provides in python2 + +* Wed Sep 4 2019 openEuler Buildteam - 2.8-1 +- Package init diff --git a/test/ac/acl/yaml/repo_test_sample/pypi_test/pypi_test.yaml b/test/ac/acl/yaml/repo_test_sample/pypi_test/pypi_test.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ec232efc18d35e8a79c4083388f8c776c9eda4db --- /dev/null +++ b/test/ac/acl/yaml/repo_test_sample/pypi_test/pypi_test.yaml @@ -0,0 +1,4 @@ +version_control: pypi +src_repo: idna +tag_prefix: "v" +seperator: "." \ No newline at end of file diff --git a/test/ac/acl/yaml/repo_test_sample/repo_name_test/svn_test.spec b/test/ac/acl/yaml/repo_test_sample/repo_name_test/svn_test.spec new file mode 100644 index 0000000000000000000000000000000000000000..8c21ec669c733fb5f013b97dad5401180fedcc1f --- /dev/null +++ b/test/ac/acl/yaml/repo_test_sample/repo_name_test/svn_test.spec @@ -0,0 +1,87 @@ +Name: lame +Version: 3.100 +Release: 7 +Summary: Free MP3 audio compressor +License: GPLv2+ +URL: http://lame.sourceforge.net/ +Source0: http://downloads.sourceforge.net/sourceforge/lam/lam-3.100.tar.gz +Patch0001: lame-noexecstack.patch +Patch0002: libmp3lame-symbols.patch + +BuildRequires: ncurses-devel gtk+-devel + +Provides: %{name}-libs = %{version}-%{release} +Obsoletes: %{name}-libs < %{version}-%{release} + +%description +LAME is a high quality MPEG Audio Layer III (MP3) encoder. + +%package devel +Summary: Development files for lame +Requires: %{name} = %{version}-%{release} + +%description devel +The lame-devel package contains development files for lame. + +%package help +Summary: man info for lame + +%description help +The lame-help Package contains man info for lame. + +%package mp3x +Summary: MP3 frame analyzer +Requires: %{name} = %{version}-%{release} + +%description mp3x +The lame-mp3x package contains the mp3x frame analyzer. + + +%prep +%autosetup -p1 + + +%build +sed -i -e 's/^\(\s*hardcode_libdir_flag_spec\s*=\).*/\1/' configure +%configure \ + --disable-dependency-tracking --disable-static --enable-mp3x --enable-mp3rtp +%make_build + + +%install +%make_install +%delete_la +ln -sf lame/lame.h %{buildroot}%{_includedir}/lame.h + + +%check +make test + +%post +/sbin/ldconfig + +%postun +/sbin/ldconfig + + +%files +%exclude %{_docdir}/%{name} +%doc README TODO USAGE doc/html/*.html ChangeLog COPYING LICENSE +%{_bindir}/{lame,mp3rtp} +%{_libdir}/libmp3lame.so.0* + +%files devel +%exclude %{_docdir}/%{name} +%doc API HACKING STYLEGUIDE +%{_libdir}/libmp3lame.so +%{_includedir}/{lame,lame.h} + +%files help +%{_mandir}/man1/lame.1* + +%files mp3x +%{_bindir}/mp3x + +%changelog +* Thu Dec 12 2019 zoushuangshuang - 3.100-7 +- Package init diff --git a/test/ac/acl/yaml/repo_test_sample/repo_name_test/svn_test.yaml b/test/ac/acl/yaml/repo_test_sample/repo_name_test/svn_test.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a7c21635c9b034f52f0c694d31eec884b8d47ee1 --- /dev/null +++ b/test/ac/acl/yaml/repo_test_sample/repo_name_test/svn_test.yaml @@ -0,0 +1,4 @@ +version_control: svn +src_repo: https://svn.code.sf.net/p/lame/svn +tag_prefix: "^lame" +seperator: _ \ No newline at end of file diff --git a/test/ac/acl/yaml/repo_test_sample/rubygem_test/rubygem_test.spec b/test/ac/acl/yaml/repo_test_sample/rubygem_test/rubygem_test.spec new file mode 100644 index 0000000000000000000000000000000000000000..a7b69c26be5130c7f1206d08a6b708d1e325ea10 --- /dev/null +++ b/test/ac/acl/yaml/repo_test_sample/rubygem_test/rubygem_test.spec @@ -0,0 +1,64 @@ +%global gem_name idn +Name: rubygem-%{gem_name} +Version: 0.0.2 +Release: 1 +Summary: Ruby Bindings for the GNU LibIDN library +License: ASL 2.0 and LGPLv2+ +URL: https://rubygems.org/gems/idn +Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem +Patch0: rubygem-idn-0.0.2-Fix-for-ruby-1.9.x.patch +Patch1: rubygem-idn-0.0.2-ruby2-encoding-in-tests-fix.patch +BuildRequires: ruby(release) rubygems-devel ruby-devel gcc libidn-devel rubygem(test-unit) +%description +Ruby Bindings for the GNU LibIDN library, an implementation of the Stringprep, +Punycode and IDNA specifications defined by the IETF Internationalized Domain +Names (IDN) working group. + +%package doc +Summary: Documentation for %{name} +Requires: %{name} = %{version}-%{release} +BuildArch: noarch +%description doc +Documentation for %{name}. + +%prep +%setup -q -n %{gem_name}-%{version} +%patch0 -p0 +%patch1 -p1 + +%build +gem build ../%{gem_name}-%{version}.gemspec +%gem_install + +%install +mkdir -p %{buildroot}%{gem_dir} +cp -a .%{gem_dir}/* \ + %{buildroot}%{gem_dir}/ +mkdir -p %{buildroot}%{gem_extdir_mri} +cp -a .%{gem_extdir_mri}/{gem.build_complete,*.so} %{buildroot}%{gem_extdir_mri}/ +rm -rf %{buildroot}%{gem_instdir}/ext/ + +%check +pushd .%{gem_instdir} +ruby -I$(dirs +1)%{gem_extdir_mri} -e 'Dir.glob "./test/tc_*.rb", &method(:require)' +popd + +%files +%dir %{gem_instdir} +%{gem_extdir_mri} +%license %{gem_instdir}/LICENSE +%exclude %{gem_libdir} +%exclude %{gem_cache} +%{gem_spec} + +%files doc +%doc %{gem_docdir} +%doc %{gem_instdir}/CHANGES +%doc %{gem_instdir}/NOTICE +%doc %{gem_instdir}/README +%{gem_instdir}/Rakefile +%{gem_instdir}/test + +%changelog +* Sat Jul 25 2020 wutao - 0.0.2-1 +- package init diff --git a/test/ac/acl/yaml/repo_test_sample/rubygem_test/rubygem_test.yaml b/test/ac/acl/yaml/repo_test_sample/rubygem_test/rubygem_test.yaml new file mode 100644 index 0000000000000000000000000000000000000000..71d201d3e486e469a8aaf11ff6ff0cc62a3eaf34 --- /dev/null +++ b/test/ac/acl/yaml/repo_test_sample/rubygem_test/rubygem_test.yaml @@ -0,0 +1,4 @@ +version_control: rubygem +src_repo: idn +tag_prefix: "" +seperator: "." diff --git a/test/ac/acl/yaml/repo_test_sample/svn_test/svn_test.spec b/test/ac/acl/yaml/repo_test_sample/svn_test/svn_test.spec new file mode 100644 index 0000000000000000000000000000000000000000..fcd2463066774b3af9513a39dff239b88c7eaaee --- /dev/null +++ b/test/ac/acl/yaml/repo_test_sample/svn_test/svn_test.spec @@ -0,0 +1,87 @@ +Name: lame +Version: 3.100 +Release: 7 +Summary: Free MP3 audio compressor +License: GPLv2+ +URL: http://lame.sourceforge.net/ +Source0: http://downloads.sourceforge.net/sourceforge/lame/%{name}-%{version}.tar.gz +Patch0001: lame-noexecstack.patch +Patch0002: libmp3lame-symbols.patch + +BuildRequires: ncurses-devel gtk+-devel + +Provides: %{name}-libs = %{version}-%{release} +Obsoletes: %{name}-libs < %{version}-%{release} + +%description +LAME is a high quality MPEG Audio Layer III (MP3) encoder. + +%package devel +Summary: Development files for lame +Requires: %{name} = %{version}-%{release} + +%description devel +The lame-devel package contains development files for lame. + +%package help +Summary: man info for lame + +%description help +The lame-help Package contains man info for lame. + +%package mp3x +Summary: MP3 frame analyzer +Requires: %{name} = %{version}-%{release} + +%description mp3x +The lame-mp3x package contains the mp3x frame analyzer. + + +%prep +%autosetup -p1 + + +%build +sed -i -e 's/^\(\s*hardcode_libdir_flag_spec\s*=\).*/\1/' configure +%configure \ + --disable-dependency-tracking --disable-static --enable-mp3x --enable-mp3rtp +%make_build + + +%install +%make_install +%delete_la +ln -sf lame/lame.h %{buildroot}%{_includedir}/lame.h + + +%check +make test + +%post +/sbin/ldconfig + +%postun +/sbin/ldconfig + + +%files +%exclude %{_docdir}/%{name} +%doc README TODO USAGE doc/html/*.html ChangeLog COPYING LICENSE +%{_bindir}/{lame,mp3rtp} +%{_libdir}/libmp3lame.so.0* + +%files devel +%exclude %{_docdir}/%{name} +%doc API HACKING STYLEGUIDE +%{_libdir}/libmp3lame.so +%{_includedir}/{lame,lame.h} + +%files help +%{_mandir}/man1/lame.1* + +%files mp3x +%{_bindir}/mp3x + +%changelog +* Thu Dec 12 2019 zoushuangshuang - 3.100-7 +- Package init diff --git a/test/ac/acl/yaml/repo_test_sample/svn_test/svn_test.yaml b/test/ac/acl/yaml/repo_test_sample/svn_test/svn_test.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a7c21635c9b034f52f0c694d31eec884b8d47ee1 --- /dev/null +++ b/test/ac/acl/yaml/repo_test_sample/svn_test/svn_test.yaml @@ -0,0 +1,4 @@ +version_control: svn +src_repo: https://svn.code.sf.net/p/lame/svn +tag_prefix: "^lame" +seperator: _ \ No newline at end of file diff --git a/test/ac/acl/yaml/test_check_repo.py b/test/ac/acl/yaml/test_check_repo.py new file mode 100644 index 0000000000000000000000000000000000000000..d9ff73ca73644d6daa42a15032cf83be727f8354 --- /dev/null +++ b/test/ac/acl/yaml/test_check_repo.py @@ -0,0 +1,117 @@ +# -*- encoding=utf-8 -*- +""" +# *********************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# [openeuler-jenkins] is licensed under the Mulan PSL v1. +# You can use this software according to the terms and conditions of the Mulan PSL v1. +# You may obtain a copy of Mulan PSL v1 at: +# http://license.coscl.org.cn/MulanPSL +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v1 for more details. +# Author: DisNight +# Create: 2020-09-17 +# Description: test for check_repo.py +# ***********************************************************************************/ +""" + +import unittest +import mock +import os +import yaml +import logging.config +import logging +import shutil + +from src.ac.acl.yaml.check_repo import ReleaseTagsFactory + +logging.getLogger('test_logger') + +class TestGetReleaseTags(unittest.TestCase): + TEST_YAML_DIR = { + "hg": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/hg_test/hg_test.yaml"), + "github": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/github_test/github_test.yaml"), + "git": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/git_test/git_test.yaml"), + "gitlab.gnome": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/gitlab_gnome_test/gitlab_gnome_test.yaml"), + "svn": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/svn_test/svn_test.yaml"), + "metacpan": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/metacpan_test/metacpan_test.yaml"), + "pypi": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/pypi_test/pypi_test.yaml"), + "rubygem": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/rubygem_test/rubygem_test.yaml"), + "gitee": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/gitee_test/gitee_test.yaml"), + "gnu-ftp": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/gnu_ftp_test/gnu_ftp_test.yaml") + } + + def _load_yaml(self, filepath): + result = {} + try: + with open(filepath, 'r') as yaml_data: # load yaml data + result = yaml.safe_load(yaml_data) + except IOError as e: + logging.warning("package yaml not exist. {}".format(str(e))) + except yaml.YAMLError as exc: + logging.warning("Error parsering YAML: {}".format(str(exc))) + finally: + return result + + def _get_test_tags(self, version): + yaml_content = self._load_yaml(self.TEST_YAML_DIR[version]) + vc = yaml_content.get("version_control", "") + sr = yaml_content.get("src_repo", "") + release_tags = ReleaseTagsFactory.get_release_tags(vc) + return release_tags.get_tags(sr) + + def test_get_hg_release_tags(self): + release_tags = self._get_test_tags("hg") + self.assertEqual(len(release_tags) > 0, True) + + def test_get_github_release_tags(self): + release_tags = self._get_test_tags("github") + self.assertEqual(len(release_tags) > 0, True) + + def test_get_git_release_tags(self): + release_tags = self._get_test_tags("git") + self.assertEqual(len(release_tags) > 0, True) + + def test_get_gitlab_gnome_release_tags(self): + release_tags = self._get_test_tags("gitlab.gnome") + self.assertEqual(len(release_tags) > 0, True) + + def test_get_svn_release_tags(self): + release_tags = self._get_test_tags("svn") + self.assertEqual(len(release_tags) > 0, True) + + def test_get_metacpan_release_tags(self): + release_tags = self._get_test_tags("metacpan") + self.assertEqual(len(release_tags) > 0, True) + + def test_get_pypi_release_tags(self): + release_tags = self._get_test_tags("pypi") + self.assertEqual(len(release_tags) > 0, True) + + def test_get_rubygem_release_tags(self): + release_tags = self._get_test_tags("rubygem") + self.assertEqual(len(release_tags) > 0, True) + + def test_get_gitee_release_tags(self): + release_tags = self._get_test_tags("gitee") + self.assertEqual(len(release_tags) > 0, True) + + def test_get_gnu_ftp_release_tags(self): + release_tags = self._get_test_tags("gnu-ftp") + self.assertEqual(len(release_tags) > 0, True) + +if __name__ == '__main__': + work_dir = os.getcwd() + _ = not os.path.exists("log") and os.mkdir("log") + logger_conf_path = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../../../src/conf/logger.conf")) + logging.config.fileConfig(logger_conf_path) + logger = logging.getLogger("test_logger") + # Test get release tags + suite = unittest.makeSuite(TestGetReleaseTags) + unittest.TextTestRunner().run(suite) + os.chdir(work_dir) + shutil.rmtree("log") + + + diff --git a/test/ac/acl/yaml/test_check_yaml.py b/test/ac/acl/yaml/test_check_yaml.py new file mode 100644 index 0000000000000000000000000000000000000000..107ee192d86afae73a7b2cf574e344fc57f4ae51 --- /dev/null +++ b/test/ac/acl/yaml/test_check_yaml.py @@ -0,0 +1,358 @@ +# -*- encoding=utf-8 -*- +""" +# *********************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# [openeuler-jenkins] is licensed under the Mulan PSL v1. +# You can use this software according to the terms and conditions of the Mulan PSL v1. +# You may obtain a copy of Mulan PSL v1 at: +# http://license.coscl.org.cn/MulanPSL +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v1 for more details. +# Author: DisNight +# Create: 2020-09-17 +# Description: test for check_yaml.py +# ***********************************************************************************/ +""" + +import unittest +import mock +import sys +import os +import types +import logging.config +import logging +import shutil + +from src.ac.common.rpm_spec_adapter import RPMSpecAdapter +from src.proxy.git_proxy import GitProxy +from src.ac.common.gitee_repo import GiteeRepo +from src.ac.acl.yaml.check_yaml import CheckPackageYaml +from src.ac.framework.ac_result import FAILED, WARNING, SUCCESS +from src.ac.acl.yaml.check_repo import HgReleaseTags, GithubReleaseTags, GitReleaseTags, \ + GitlabReleaseTags, SvnReleaseTags, MetacpanReleaseTags, \ + PypiReleaseTags, RubygemReleaseTags, GiteeReleaseTags, \ + GnuftpReleaseTags + +logging.getLogger('test_logger') + +class TestCheckYamlField(unittest.TestCase): + + TEST_YAML_DIR = { + "missing": os.path.join(os.path.dirname(os.path.realpath(__file__)), "fields_test_sample/missing.yaml"), + "standard": os.path.join(os.path.dirname(os.path.realpath(__file__)), "fields_test_sample/standard.yaml") + } + + def setUp(self): + self.cy = CheckPackageYaml("", "", "") + def set_yaml(self, file): + self._gr.yaml_file = file + self.cy.set_yaml = types.MethodType(set_yaml, self.cy, CheckPackageYaml) # python3该接口有变化 为实例动态绑定接口 + + def test_none_file(self): + self.cy.set_yaml(None) + result = self.cy.check_fields() + self.assertEqual(result, WARNING) + + def test_missing_fields(self): + self.cy.set_yaml(self.TEST_YAML_DIR["missing"]) + result = self.cy.check_fields() + self.assertEqual(result, WARNING) + + def test_standard_fields(self): + self.cy.set_yaml(self.TEST_YAML_DIR["standard"]) + result = self.cy.check_fields() + self.assertEqual(result, SUCCESS) + + +class TestCheckYamlRepo(unittest.TestCase): + + SUCCESS_TAG_LIST = ["0.0.0", "0.0.1"] + FAILED_TAG_LIST = [] + TEST_YAML_DIR = { + "na": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/na_test/na.yaml"), + "hg": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/hg_test/hg_test.yaml"), + "github": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/github_test/github_test.yaml"), + "git": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/git_test/git_test.yaml"), + "gitlab.gnome": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/gitlab_gnome_test/gitlab_gnome_test.yaml"), + "svn": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/svn_test/svn_test.yaml"), + "metacpan": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/metacpan_test/metacpan_test.yaml"), + "pypi": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/pypi_test/pypi_test.yaml"), + "rubygem": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/rubygem_test/rubygem_test.yaml"), + "gitee": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/gitee_test/gitee_test.yaml"), + "gnu-ftp": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/gnu_ftp_test/gnu_ftp_test.yaml") + } + + TEST_SPEC_DIR = { + "na": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/na_test/na.spec"), + "hg": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/hg_test/hg_test.spec"), + "github": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/github_test/github_test.spec"), + "git": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/git_test/git_test.spec"), + "gitlab.gnome": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/gitlab_gnome_test/gitlab_gnome_test.spec"), + "svn": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/svn_test/svn_test.spec"), + "metacpan": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/metacpan_test/metacpan_test.spec"), + "pypi": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/pypi_test/pypi_test.spec"), + "rubygem": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/rubygem_test/rubygem_test.spec"), + "gitee": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/gitee_test/gitee_test.spec"), + "gnu-ftp": os.path.join(os.path.dirname(os.path.realpath(__file__)), "repo_test_sample/gnu_ftp_test/gnu_ftp_test.spec") + } + + def setUp(self): + self.cy = CheckPackageYaml("", "", "") + def set_yaml(self, file): + self._gr.yaml_file = file + def set_spec(self, file): + self._spec = RPMSpecAdapter(file) + self.cy.set_yaml = types.MethodType(set_yaml, self.cy, CheckPackageYaml) # python3该接口有变化 为实例动态绑定接口 + self.cy.set_spec = types.MethodType(set_spec, self.cy, CheckPackageYaml) # python3该接口有变化 为实例动态绑定接口 + + def test_none_file(self): + self.cy.set_yaml(None) + self.cy.check_fields() + result = self.cy.check_repo() + self.assertEqual(result, SUCCESS) + + def test_NA_repo(self): + self.cy.set_yaml(self.TEST_YAML_DIR["na"]) + self.cy.check_fields() + result = self.cy.check_repo() + self.assertEqual(result, WARNING) + + @mock.patch.object(HgReleaseTags, "get_tags") + def test_hg_repo_success(self, mock_get_tags): + self.cy.set_yaml(self.TEST_YAML_DIR["hg"]) + mock_get_tags.return_value = self.SUCCESS_TAG_LIST + self.cy.check_fields() + result = self.cy.check_repo() + self.assertEqual(result, SUCCESS) + + @mock.patch.object(HgReleaseTags, "get_tags") + def test_hg_repo_failed(self, mock_get_tags): + self.cy.set_yaml(self.TEST_YAML_DIR["hg"]) + mock_get_tags.return_value = self.FAILED_TAG_LIST + self.cy.check_fields() + result = self.cy.check_repo() + self.assertEqual(result, WARNING) + + @mock.patch.object(GithubReleaseTags, "get_tags") + def test_github_repo_success(self, mock_get_tags): + self.cy.set_yaml(self.TEST_YAML_DIR["github"]) + mock_get_tags.return_value = self.SUCCESS_TAG_LIST + self.cy.check_fields() + result = self.cy.check_repo() + self.assertEqual(result, SUCCESS) + + @mock.patch.object(GithubReleaseTags, "get_tags") + def test_github_repo_failed(self, mock_get_tags): + self.cy.set_yaml(self.TEST_YAML_DIR["github"]) + mock_get_tags.return_value = self.FAILED_TAG_LIST + self.cy.check_fields() + result = self.cy.check_repo() + self.assertEqual(result, WARNING) + + @mock.patch.object(GitReleaseTags, "get_tags") + def test_git_repo_success(self, mock_get_tags): + self.cy.set_yaml(self.TEST_YAML_DIR["git"]) + mock_get_tags.return_value = self.SUCCESS_TAG_LIST + self.cy.check_fields() + result = self.cy.check_repo() + self.assertEqual(result, SUCCESS) + + @mock.patch.object(GitReleaseTags, "get_tags") + def test_git_repo_failed(self, mock_get_tags): + self.cy.set_yaml(self.TEST_YAML_DIR["git"]) + mock_get_tags.return_value = self.FAILED_TAG_LIST + self.cy.check_fields() + result = self.cy.check_repo() + self.assertEqual(result, WARNING) + + @mock.patch.object(GitlabReleaseTags, "get_tags") + def test_gitlab_gnome_repo_success(self, mock_get_tags): + self.cy.set_yaml(self.TEST_YAML_DIR["gitlab.gnome"]) + mock_get_tags.return_value = self.SUCCESS_TAG_LIST + self.cy.check_fields() + result = self.cy.check_repo() + self.assertEqual(result, SUCCESS) + + @mock.patch.object(GitlabReleaseTags, "get_tags") + def test_gitlab_gnome_repo_failed(self, mock_get_tags): + self.cy.set_yaml(self.TEST_YAML_DIR["gitlab.gnome"]) + mock_get_tags.return_value = self.FAILED_TAG_LIST + self.cy.check_fields() + result = self.cy.check_repo() + self.assertEqual(result, WARNING) + + @mock.patch.object(SvnReleaseTags, "get_tags") + def test_svn_repo_success(self, mock_get_tags): + self.cy.set_yaml(self.TEST_YAML_DIR["svn"]) + mock_get_tags.return_value = self.SUCCESS_TAG_LIST + self.cy.check_fields() + result = self.cy.check_repo() + self.assertEqual(result, SUCCESS) + + @mock.patch.object(SvnReleaseTags, "get_tags") + def test_svn_repo_failed(self, mock_get_tags): + self.cy.set_yaml(self.TEST_YAML_DIR["svn"]) + mock_get_tags.return_value = self.FAILED_TAG_LIST + self.cy.check_fields() + result = self.cy.check_repo() + self.assertEqual(result, WARNING) + + @mock.patch.object(MetacpanReleaseTags, "get_tags") + def test_metacpan_repoo_success(self, mock_get_tags): + self.cy.set_yaml(self.TEST_YAML_DIR["metacpan"]) + mock_get_tags.return_value = self.SUCCESS_TAG_LIST + self.cy.check_fields() + result = self.cy.check_repo() + self.assertEqual(result, SUCCESS) + + @mock.patch.object(MetacpanReleaseTags, "get_tags") + def test_metacpan_repo_failed(self, mock_get_tags): + self.cy.set_yaml(self.TEST_YAML_DIR["metacpan"]) + mock_get_tags.return_value = self.FAILED_TAG_LIST + self.cy.check_fields() + result = self.cy.check_repo() + self.assertEqual(result, WARNING) + + @mock.patch.object(PypiReleaseTags, "get_tags") + def test_pypi_repo_success(self, mock_get_tags): + self.cy.set_yaml(self.TEST_YAML_DIR["pypi"]) + mock_get_tags.return_value = self.SUCCESS_TAG_LIST + self.cy.check_fields() + result = self.cy.check_repo() + self.assertEqual(result, SUCCESS) + + @mock.patch.object(PypiReleaseTags, "get_tags") + def test_pypi_repo_failed(self, mock_get_tags): + self.cy.set_yaml(self.TEST_YAML_DIR["pypi"]) + mock_get_tags.return_value = self.FAILED_TAG_LIST + self.cy.check_fields() + result = self.cy.check_repo() + self.assertEqual(result, WARNING) + + @mock.patch.object(RubygemReleaseTags, "get_tags") + def test_rubygem_repo_success(self, mock_get_tags): + self.cy.set_yaml(self.TEST_YAML_DIR["rubygem"]) + mock_get_tags.return_value = self.SUCCESS_TAG_LIST + self.cy.check_fields() + result = self.cy.check_repo() + self.assertEqual(result, SUCCESS) + + @mock.patch.object(RubygemReleaseTags, "get_tags") + def test_rubygem_repo_failed(self, mock_get_tags): + self.cy.set_yaml(self.TEST_YAML_DIR["rubygem"]) + mock_get_tags.return_value = self.FAILED_TAG_LIST + self.cy.check_fields() + result = self.cy.check_repo() + self.assertEqual(result, WARNING) + + @mock.patch.object(GiteeReleaseTags, "get_tags") + def test_gitee_repo_success(self, mock_get_tags): + self.cy.set_yaml(self.TEST_YAML_DIR["gitee"]) + mock_get_tags.return_value = self.SUCCESS_TAG_LIST + self.cy.check_fields() + result = self.cy.check_repo() + self.assertEqual(result, SUCCESS) + + @mock.patch.object(GiteeReleaseTags, "get_tags") + def test_gitee_repo_failed(self, mock_get_tags): + self.cy.set_yaml(self.TEST_YAML_DIR["gitee"]) + mock_get_tags.return_value = self.FAILED_TAG_LIST + self.cy.check_fields() + result = self.cy.check_repo() + self.assertEqual(result, WARNING) + + @mock.patch.object(GnuftpReleaseTags, "get_tags") + def test_gnu_ftp_repo_success(self, mock_get_tags): + self.cy.set_yaml(self.TEST_YAML_DIR["gnu-ftp"]) + mock_get_tags.return_value = self.SUCCESS_TAG_LIST + self.cy.check_fields() + result = self.cy.check_repo() + self.assertEqual(result, SUCCESS) + + @mock.patch.object(GnuftpReleaseTags, "get_tags") + def test_gnu_ftp_repo_failed(self, mock_get_tags): + self.cy.set_yaml(self.TEST_YAML_DIR["gnu-ftp"]) + mock_get_tags.return_value = self.FAILED_TAG_LIST + self.cy.check_fields() + result = self.cy.check_repo() + self.assertEqual(result, WARNING) + + +class TestCheckConsistency(unittest.TestCase): + DIR_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), + "repo_test_sample") + TEST_SAMPLE_DIR = { + "na": "na_test", + "hg": "hg_test", + "github": "github_test", + "git": "git_test", + "gitlab.gnome": "gitlab_gnome_test", + "svn": "svn_test", + "metacpan": "metacpan_test", + "pypi": "pypi_test", + "rubygem": "rubygem_test", + "gitee": "gitee_test", + "gnu-ftp": "gnu_ftp_test", + "reponame": "repo_name_test" + } + + def _test_repo_domain(self, dir_key, predict): + os.chdir(os.path.join(TestCheckConsistency.DIR_PATH, + TestCheckConsistency.TEST_SAMPLE_DIR[dir_key])) + self.cy = CheckPackageYaml(TestCheckConsistency.DIR_PATH, + TestCheckConsistency.TEST_SAMPLE_DIR[dir_key], + None) + self.cy.check_fields() + result = self.cy.check_repo_domain() + self.assertEqual(result, predict) + + def test_common_repo_domain_success(self): + self._test_repo_domain("gitee", SUCCESS) + + def test_common_repo_domain_failed(self): + self._test_repo_domain("svn", WARNING) + + def test_gnome_repo_domain(self): + self._test_repo_domain("gitlab.gnome", SUCCESS) + + def test_pypi_repo_domain(self): + self._test_repo_domain("pypi", SUCCESS) + + def _test_repo_name(self, dir_key, predict): + os.chdir(os.path.join(TestCheckConsistency.DIR_PATH, + TestCheckConsistency.TEST_SAMPLE_DIR[dir_key])) + self.cy = CheckPackageYaml(TestCheckConsistency.DIR_PATH, + TestCheckConsistency.TEST_SAMPLE_DIR[dir_key], + None) + self.cy.check_fields() + result = self.cy.check_repo_name() + self.assertEqual(result, predict) + + def test_common_repo_name_success(self): + self._test_repo_name("gitlab.gnome", SUCCESS) + + def test_common_repo_name_failed(self): + self._test_repo_name("reponame", WARNING) + + def test_svn_repo_name(self): + self._test_repo_name("svn", SUCCESS) + +if __name__ == '__main__': + work_dir = os.getcwd() + _ = not os.path.exists("log") and os.mkdir("log") + logger_conf_path = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../../../src/conf/logger.conf")) + logging.config.fileConfig(logger_conf_path) + logger = logging.getLogger("test_logger") + # Test check yaml fields + suite = unittest.makeSuite(TestCheckYamlField) + unittest.TextTestRunner().run(suite) + # Test check yaml repo + suite = unittest.makeSuite(TestCheckYamlRepo) + unittest.TextTestRunner().run(suite) + # Test check repo name and repo domain + suite = unittest.makeSuite(TestCheckConsistency) + unittest.TextTestRunner().run(suite) + os.chdir(work_dir) + shutil.rmtree("log") \ No newline at end of file