diff --git a/advisors/check_licenses.py b/advisors/check_licenses.py index afe54b79bd4f0fe6f83e1fb480e57b5624ba7d2a..2b6688c6ff10c68254dc14c9e9b3dbdb5e65381b 100755 --- a/advisors/check_licenses.py +++ b/advisors/check_licenses.py @@ -20,12 +20,12 @@ 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, +(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 """ @@ -52,10 +49,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 +62,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 +99,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 @@ -238,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) @@ -332,7 +320,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 d73fe88b3482e95d15f2b5a6c1a8c8cdfa6d124f..0000000000000000000000000000000000000000 --- 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) - diff --git a/upstream-info/at-spi2-atk.yaml b/upstream-info/at-spi2-atk.yaml index 6c1f33229c42a5545bd3b84f43b00124535d086f..8d779b5928996b8d2adc2bc37bb491a103379783 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 096c3d5230ee3075d0f261560592364fc2b675a7..dbcdc2c8eb8a9be7d334009bd65be790f7bf8860 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 71ea32871066add4ae40326da1bf2e7d0cf434a9..22b90bb1c711e50eb9493bcfd1ef855ae5cf2af2 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 c035b8222b201feef560fd36812c6929566327cb..45f8bf6ae73770f25a57af47ebaa1e60f0a2de80 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 0000000000000000000000000000000000000000..40294a9e2ec89f1c89b808c8af197d91b2820c97 --- /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 0000000000000000000000000000000000000000..8a051313dd29309943182a4d46b89804b0573375 --- /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/libnfs.yaml b/upstream-info/libnfs.yaml index 326c1ce657b9115c8ed397f41ac08105f4c2dca1..f2c6023d3ccd61aaea2687ca09d1cb78789b76e1 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 d725507539ec1b18c4d664ab120e1d2392ba7560..bd2a9dece4a84483859326ee09a426b70c703b64 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: .