From 457d2bc393e3af08becee0c8291b372925cbc73f Mon Sep 17 00:00:00 2001 From: Shinwell Hu Date: Mon, 6 Jul 2020 03:10:10 +0000 Subject: [PATCH 1/4] update several packages' upstream yaml info --- upstream-info/at-spi2-atk.yaml | 4 ++-- upstream-info/at-spi2-core.yaml | 4 ++-- upstream-info/c-ares.yaml | 4 ++-- upstream-info/crontabs.yaml | 4 ++-- upstream-info/curl.yaml | 4 ++++ upstream-info/dlm.yaml | 4 ++++ upstream-info/grub2.yaml | 4 ++++ upstream-info/libnfs.yaml | 2 +- upstream-info/libselinux.yaml | 4 ++-- 9 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 upstream-info/curl.yaml create mode 100644 upstream-info/dlm.yaml create mode 100644 upstream-info/grub2.yaml diff --git a/upstream-info/at-spi2-atk.yaml b/upstream-info/at-spi2-atk.yaml index 6c1f3322..8d779b59 100644 --- a/upstream-info/at-spi2-atk.yaml +++ b/upstream-info/at-spi2-atk.yaml @@ -1,4 +1,4 @@ version_control: github src_repo: GNOME/at-spi2-atk -tag_prefix: ^v -separator: . +tag_prefix: AT_SPI2_ATK_ +separator: _ diff --git a/upstream-info/at-spi2-core.yaml b/upstream-info/at-spi2-core.yaml index 096c3d52..dbcdc2c8 100644 --- a/upstream-info/at-spi2-core.yaml +++ b/upstream-info/at-spi2-core.yaml @@ -1,4 +1,4 @@ version_control: github src_repo: GNOME/at-spi2-core -tag_prefix: ^v -separator: . +tag_prefix: AT_SPI2_CORE_ +separator: _ diff --git a/upstream-info/c-ares.yaml b/upstream-info/c-ares.yaml index 71ea3287..22b90bb1 100644 --- a/upstream-info/c-ares.yaml +++ b/upstream-info/c-ares.yaml @@ -1,4 +1,4 @@ version_control: github src_repo: c-ares/c-ares -tag_prefix: ^v -separator: . +tag_prefix: curl- +separator: _ diff --git a/upstream-info/crontabs.yaml b/upstream-info/crontabs.yaml index c035b822..45f8bf6a 100644 --- a/upstream-info/crontabs.yaml +++ b/upstream-info/crontabs.yaml @@ -1,4 +1,4 @@ version_control: github src_repo: cronie-crond/crontabs -tag_prefix: ^v -separator: . +tag_prefix: crontabs- +separator: "" diff --git a/upstream-info/curl.yaml b/upstream-info/curl.yaml new file mode 100644 index 00000000..40294a9e --- /dev/null +++ b/upstream-info/curl.yaml @@ -0,0 +1,4 @@ +version_control: github +src_repo: curl/curl +tag_prefix: curl- +separator: _ diff --git a/upstream-info/dlm.yaml b/upstream-info/dlm.yaml new file mode 100644 index 00000000..8a051313 --- /dev/null +++ b/upstream-info/dlm.yaml @@ -0,0 +1,4 @@ +version_control: git +src_repo: https://pagure.io/dlm.git +tag_prefix: dlm- +separator: . diff --git a/upstream-info/grub2.yaml b/upstream-info/grub2.yaml new file mode 100644 index 00000000..047942d4 --- /dev/null +++ b/upstream-info/grub2.yaml @@ -0,0 +1,4 @@ +version_control: git +src_repo: https://git.savannah.gnu.org/git/grub.git +tag_prefix: "" +separator: "." diff --git a/upstream-info/libnfs.yaml b/upstream-info/libnfs.yaml index 326c1ce6..f2c6023d 100644 --- a/upstream-info/libnfs.yaml +++ b/upstream-info/libnfs.yaml @@ -1,4 +1,4 @@ version_control: github src_repo: sahlberg/libnfs -tag_prefix: ^v +tag_prefix: libnfs- separator: . diff --git a/upstream-info/libselinux.yaml b/upstream-info/libselinux.yaml index d7255075..bd2a9dec 100644 --- a/upstream-info/libselinux.yaml +++ b/upstream-info/libselinux.yaml @@ -1,4 +1,4 @@ version_control: github -src_repo: https:/ -tag_prefix: ^v +src_repo: SELinuxProject/selinux +tag_prefix: ^libselinux- separator: . -- Gitee From 4c2c5420b8e2ecde9cfed35111250e97274f9c31 Mon Sep 17 00:00:00 2001 From: Shinwell Hu Date: Mon, 6 Jul 2020 09:54:12 +0000 Subject: [PATCH 2/4] update check_license --- advisors/check_licenses.py | 38 +++++++++---------------- advisors/download.py | 58 -------------------------------------- 2 files changed, 14 insertions(+), 82 deletions(-) delete mode 100755 advisors/download.py diff --git a/advisors/check_licenses.py b/advisors/check_licenses.py index afe54b79..b5a08906 100755 --- a/advisors/check_licenses.py +++ b/advisors/check_licenses.py @@ -20,10 +20,10 @@ This script is for information only. It's known to provide false result in situa (1) This is a script that checks whether the licenses in the LICENSE file in the tar package and the licenses in the SPEC file are the same. If they are the same, output: - "licenses from LICENSES are same as form SPEC:[xxx, yyy] <==> [xxx, zzz]" + "licenses from LICENSES are same as form SPEC:[xxx, yyy] == [xxx, zzz]" If they are not the same, output: - "licenses from LICENSES are not same as form SPEC:[xxx, yyy] <==> [xxx, yyy]" + "licenses from LICENSES are not same as form SPEC:[xxx, yyy] <=> [xxx, yyy]" (2) This script depends on download.py and license_translations, you can add keywords for licenses in license_translations. @@ -52,10 +52,10 @@ import hashlib import tarfile import bz2 import shutil -#import download import chardet import logging from pyrpm.spec import Spec, replace_macros +import subprocess logging.basicConfig(format='%(message)s', level=logging.INFO) @@ -65,36 +65,24 @@ license_translations = {} def main(): """ Entry point for check_licenses.""" parser = argparse.ArgumentParser() - parser.add_argument("-t", "--tarball", default="", nargs="?", + parser.add_argument("-t", "--tarball", default="", nargs="?", required=True, help="tarball path or url (e.g." "/home/test.tar.gz" " or http://example.com/test.tar.gz)") - parser.add_argument("-s", "--specfile", default="", nargs="?", + parser.add_argument("-s", "--specfile", default="", nargs="?", required=True, help="SPEC file path (e.g. /home/mytar.spec)") parser.add_argument("-w", "--writespec", dest="writespec", action="store_true", default=False, help="Overwrite the licenses of SPEC file") - parser.add_argument("-d", "--downloadpath", default="", nargs="?", + parser.add_argument("-d", "--downloadpath", default="/var/tmp/tmp_tarball", nargs="?", help="The dest download or extract path of tarball" " (e.g. /home/tmp_tarball default: /var/tmp/tmp_tarball)") args = parser.parse_args() - if not args.tarball: - parser.error(argparse.ArgumentTypeError( - "the tarball path or url argument['-t'] is required")) - - if not args.specfile: - parser.error(argparse.ArgumentTypeError( - "the spec file argument['-s'] is required")) - - if args.downloadpath: - download_path = args.downloadpath - else: - download_path = "/var/tmp/tmp_tarball" - if os.path.exists(download_path): - shutil.rmtree(download_path) - os.makedirs(download_path, exist_ok=True) - process_licenses(args, download_path) + if os.path.exists(args.downloadpath): + shutil.rmtree(args.downloadpath) + os.makedirs(args.downloadpath, exist_ok=True) + process_licenses(args, args.downloadpath) def get_contents(filename): @@ -114,7 +102,10 @@ def get_tarball_from_url(upstream_url, download_path, tarpackage): """ tarball_path = download_path + "/" + tarpackage if not os.path.isfile(tarball_path): - download.do_curl(upstream_url, dest=tarball_path) + subprocess.call(["curl", upstream_url, "-L", + "--connect-timeout", "10", + "--max-time", "600", + "-S", "-o", tarball_path]) return tarball_path @@ -332,7 +323,6 @@ def process_licenses(args, download_path): tarball_name = os.path.basename(tarball_path) extract_tar_name = os.path.splitext(tarball_name)[0] extract_file_name = os.path.splitext(extract_tar_name)[0] - #scan_licenses_in_LICENSE(os.path.join(download_path, extract_file_name)) scan_licenses_in_LICENSE(download_path) specfile = args.specfile diff --git a/advisors/download.py b/advisors/download.py deleted file mode 100755 index d73fe88b..00000000 --- a/advisors/download.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/true -""" -download tar package with url -""" -#****************************************************************************** -# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. -# licensed under the Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# http://license.coscl.org.cn/MulanPSL2 -# 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 v2 for more details. -# Author: wangchuangGG -# Create: 2020-06-27 -# Description: provide a tool to download tar package with url -# ******************************************************************************/ - -import os -import sys -import io -import pycurl - -def do_curl(url, dest=None): - """ - Perform a curl operation for url. - If perform failure or write to dest failure, - the program exiting with an error. - """ - c = pycurl.Curl() - c.setopt(c.URL, url) - c.setopt(c.FOLLOWLOCATION, True) - c.setopt(c.FAILONERROR, True) - c.setopt(c.CONNECTTIMEOUT, 10) - c.setopt(c.TIMEOUT, 600) - c.setopt(c.LOW_SPEED_LIMIT, 1) - c.setopt(c.LOW_SPEED_TIME, 10) - buf = io.BytesIO() - c.setopt(c.WRITEDATA, buf) - try: - c.perform() - except pycurl.error as e: - print("Unable to fetch {}: {} or tarball path is wrong".format(url, e)) - sys.exit(1) - finally: - c.close() - - if dest: - try: - with open(dest, 'wb') as fp: - fp.write(buf.getvalue()) - except IOError as e: - if os.path.exists(dest): - os.unlink(dest) - print("Unable to write to {}: {}".format(dest, e)) - sys.exit(1) - -- Gitee From 808da16b57407b99379bf5136383e3c70cb911f7 Mon Sep 17 00:00:00 2001 From: Shinwell Hu Date: Mon, 6 Jul 2020 09:59:32 +0000 Subject: [PATCH 3/4] update doc as well --- advisors/check_licenses.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/advisors/check_licenses.py b/advisors/check_licenses.py index b5a08906..f5c141d1 100755 --- a/advisors/check_licenses.py +++ b/advisors/check_licenses.py @@ -25,7 +25,7 @@ This script is for information only. It's known to provide false result in situa If they are not the same, output: "licenses from LICENSES are not same as form SPEC:[xxx, yyy] <=> [xxx, yyy]" -(2) This script depends on download.py and license_translations, +(2) This script depends on license_translations, you can add keywords for licenses in license_translations. (3) Command parameters @@ -36,9 +36,6 @@ This script is for information only. It's known to provide false result in situa (e.g. /home/test.spec) Optional parameters: - -w With this parameter, if the licenses in the tar - and the licenses in the spec file are are not the same, - modify the spec file directly. -d Specify the decompression path of the tar package, default: /var/tmp/tmp_tarball """ -- Gitee From b5c304c924d8475b83a48fd6bafb2f83618c7634 Mon Sep 17 00:00:00 2001 From: Shinwell Hu Date: Tue, 7 Jul 2020 01:39:24 +0000 Subject: [PATCH 4/4] rename license to licenses --- advisors/check_licenses.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/advisors/check_licenses.py b/advisors/check_licenses.py index f5c141d1..2b6688c6 100755 --- a/advisors/check_licenses.py +++ b/advisors/check_licenses.py @@ -226,15 +226,15 @@ def scan_licenses_in_SPEC(specfile): the program will exit with an error. """ s_spec = Spec.from_file(specfile) - license = replace_macros(s_spec.license, s_spec) + licenses = replace_macros(s_spec.license, s_spec) excludes = ["and", "AND"] - if license in license_translations: - real_words = license_translations.get(license, license) + if licenses in license_translations: + real_words = license_translations.get(licenses, licenses) add_license_from_spec_file(real_words) else: - words = clean_license_string(license).split() + words = clean_license_string(licenses).split() for word in words: if word not in excludes: real_word = license_translations.get(word, word) -- Gitee