diff options
-rw-r--r-- | classes/scancode-tk.bbclass | 222 | ||||
-rw-r--r-- | recipes-devtools/scancode-toolkit/scancode-toolkit-native_3.1.1.bb | 40 |
2 files changed, 0 insertions, 262 deletions
diff --git a/classes/scancode-tk.bbclass b/classes/scancode-tk.bbclass deleted file mode 100644 index c442ae0..0000000 --- a/classes/scancode-tk.bbclass +++ /dev/null @@ -1,222 +0,0 @@ -# This class integrates real-time license scanning, generation of SPDX standard -# output and verifiying license info during the building process. -# It is a combination of efforts from the OE-Core, SPDX and ScanCode projects. -# -# For more information on ScanCode: -# https://github.com/nexB/scancode-toolkit -# -# For more information on SPDX: -# http://www.spdx.org -# -# Note: -# 1) By default,spdx files will be output to the path which is defined as[SPDX_DEPLOY_DIR] -# 2) By default, SPDX_DEPLOY_DIR is tmp/deploy -# - -HOSTTOOLS += "python" - -COPYLEFT_RECIPE_TYPES ?= 'target nativesdk' -inherit copyleft_filter - -inherit spdx-common - -#SPDXEPENDENCY += "scancode-toolkit-native:do_populate_sysroot" - -CREATOR_TOOL = "scancode-tk.bbclass in meta-spdxscanner" - -python () { - - if bb.data.inherits_class('nopackages', d): - return - - pn = d.getVar('PN') - assume_provided = (d.getVar("ASSUME_PROVIDED") or "").split() - if pn in assume_provided: - for p in d.getVar("PROVIDES").split(): - if p != pn: - pn = p - break - - # glibc-locale: do_fetch, do_unpack and do_patch tasks have been deleted, - # so avoid archiving source here. - if pn.startswith('glibc-locale'): - return - if (d.getVar('PN') == "libtool-cross"): - return - if (d.getVar('PN') == "libgcc-initial"): - return - if (d.getVar('PN') == "shadow-sysroot"): - return - - # We just archive gcc-source for all the gcc related recipes - if d.getVar('BPN') in ['gcc', 'libgcc']: - bb.debug(1, 'spdx: There is bug in scan of %s is, do nothing' % pn) - return - - spdx_outdir = d.getVar('SPDX_OUTDIR') - spdx_workdir = d.getVar('SPDX_WORKDIR') - spdx_temp_dir = os.path.join(spdx_workdir, "temp") - temp_dir = os.path.join(d.getVar('WORKDIR'), "temp") - - info = {} - info['workdir'] = (d.getVar('WORKDIR') or "") - info['pn'] = (d.getVar( 'PN') or "") - info['pv'] = (d.getVar( 'PV') or "") - - manifest_dir = (d.getVar('SPDX_DEPLOY_DIR') or "") - if not os.path.exists( manifest_dir ): - bb.utils.mkdirhier( manifest_dir ) - - info['outfile'] = os.path.join(manifest_dir, info['pn'] + "-" + info['pv'] + ".spdx" ) - sstatefile = os.path.join(spdx_outdir, info['pn'] + "-" + info['pv'] + ".spdx" ) - if os.path.exists(info['outfile']): - bb.note(info['pn'] + "spdx file has been exist, do nothing") - return - if os.path.exists( sstatefile ): - bb.note(info['pn'] + "spdx file has been exist, do nothing") - create_manifest(info,sstatefile) - return - - d.appendVarFlag('do_get_report', 'depends', ' scancode-toolkit-native:do_populate_sysroot') - d.appendVarFlag('do_spdx', 'depends', ' %s:do_get_report' % pn) - bb.build.addtask('do_get_report', 'do_configure', 'do_patch' , d) - bb.build.addtask('do_spdx', 'do_configure', 'do_get_report', d) -} - -python do_get_report () { - import os, sys, json, shutil - - if bb.data.inherits_class('nopackages', d): - return - - pn = d.getVar('PN') - assume_provided = (d.getVar("ASSUME_PROVIDED") or "").split() - if pn in assume_provided: - for p in d.getVar("PROVIDES").split(): - if p != pn: - pn = p - break - if d.getVar('BPN') in ['gcc', 'libgcc']: - bb.debug(1, 'spdx: There is bug in scan of %s is, do nothing' % pn) - return - - # glibc-locale: do_fetch, do_unpack and do_patch tasks have been deleted, - # so avoid archiving source here. - if pn.startswith('glibc-locale'): - return - if (d.getVar('PN') == "libtool-cross"): - return - if (d.getVar('PN') == "libgcc-initial"): - return - if (d.getVar('PN') == "shadow-sysroot"): - return - - spdx_outdir = d.getVar('SPDX_OUTDIR') - spdx_workdir = d.getVar('SPDX_WORKDIR') - spdx_temp_dir = os.path.join(spdx_workdir, "temp") - temp_dir = os.path.join(d.getVar('WORKDIR'), "temp") - - info = {} - info['workdir'] = (d.getVar('WORKDIR', True) or "") - info['pn'] = (d.getVar( 'PN', True ) or "") - info['pv'] = (d.getVar( 'PV', True ) or "") - info['package_download_location'] = (d.getVar( 'SRC_URI', True ) or "") - if info['package_download_location'] != "": - info['package_download_location'] = info['package_download_location'].split()[0] - info['spdx_version'] = (d.getVar('SPDX_VERSION', True) or '') - info['data_license'] = (d.getVar('DATA_LICENSE', True) or '') - info['creator'] = {} - info['creator']['Tool'] = (d.getVar('CREATOR_TOOL', True) or '') - info['license_list_version'] = (d.getVar('LICENSELISTVERSION', True) or '') - info['package_homepage'] = (d.getVar('HOMEPAGE', True) or "") - info['package_summary'] = (d.getVar('SUMMARY', True) or "") - info['package_summary'] = info['package_summary'].replace("\n","") - info['package_summary'] = info['package_summary'].replace("'"," ") - info['package_contains'] = (d.getVar('CONTAINED', True) or "") - info['package_static_link'] = (d.getVar('STATIC_LINK', True) or "") - info['modified'] = "false" - srcuri = d.getVar("SRC_URI", False).split() - length = len("file://") - for item in srcuri: - if item.startswith("file://"): - item = item[length:] - if item.endswith(".patch") or item.endswith(".diff"): - info['modified'] = "true" - - manifest_dir = (d.getVar('SPDX_DEPLOY_DIR', True) or "") - if not os.path.exists( manifest_dir ): - bb.utils.mkdirhier( manifest_dir ) - info['outfile'] = os.path.join(manifest_dir, info['pn'] + "-" + info['pv'] + ".spdx" ) - sstatefile = os.path.join(spdx_outdir, info['pn'] + "-" + info['pv'] + ".spdx" ) - # if spdx has been exist - if os.path.exists(info['outfile']): - bb.note(info['pn'] + "spdx file has been exist, do nothing") - return - if os.path.exists( sstatefile ): - bb.note(info['pn'] + "spdx file has been exist, do nothing") - create_manifest(info,sstatefile) - return - spdx_get_src(d) - - bb.note('SPDX: Archiving the patched source...') - if os.path.isdir(spdx_temp_dir): - for f_dir, f in list_files(spdx_temp_dir): - temp_file = os.path.join(spdx_temp_dir,f_dir,f) - shutil.copy(temp_file, temp_dir) - #shutil.rmtree(spdx_temp_dir) - if not os.path.exists(spdx_outdir): - bb.utils.mkdirhier(spdx_outdir) - cur_ver_code = get_ver_code(spdx_workdir).split()[0] - ## Get spdx file - bb.note(' run scanCode ...... ') - d.setVar('WORKDIR', d.getVar('SPDX_WORKDIR', True)) - info['sourcedir'] = spdx_workdir - git_path = "%s/git/.git" % info['sourcedir'] - if os.path.exists(git_path): - remove_dir_tree(git_path) - invoke_scancode(info['sourcedir'],sstatefile) - bb.warn("source dir = " + info['sourcedir']) - if get_cached_spdx(sstatefile) != None: - write_cached_spdx( info,sstatefile,cur_ver_code ) - ## CREATE MANIFEST(write to outfile ) - create_manifest(info,sstatefile) - else: - bb.warn('Can\'t get the spdx file ' + info['pn'] + '. Please check your.') -} - -def invoke_scancode( OSS_src_dir, spdx_file): - import subprocess - import string - import json - import codecs - import logging - - logger = logging.getLogger() - logger.setLevel(logging.INFO) - logging.basicConfig(level=logging.INFO) - - path = os.getenv('PATH') - scancode_cmd = bb.utils.which(os.getenv('PATH'), "scancode") - scancode_cmd = scancode_cmd + " -lpci --spdx-tv " + spdx_file + " " + OSS_src_dir - print(scancode_cmd) - try: - subprocess.check_output(scancode_cmd, - stderr=subprocess.STDOUT, - shell=True) - except subprocess.CalledProcessError as e: - bb.fatal("Could not invoke scancode Command " - "'%s' returned %d:\n%s" % (scancode_cmd, e.returncode, e.output)) - -SSTATETASKS += "do_spdx" -python do_spdx_setscene () { - sstate_setscene(d) -} -addtask do_spdx_setscene -do_spdx () { - echo "Create spdx file." -} -addtask do_get_report after do_patch -addtask do_spdx -do_build[recrdeptask] += "do_spdx" -do_populate_sdk[recrdeptask] += "do_spdx" - diff --git a/recipes-devtools/scancode-toolkit/scancode-toolkit-native_3.1.1.bb b/recipes-devtools/scancode-toolkit/scancode-toolkit-native_3.1.1.bb deleted file mode 100644 index d308dd4..0000000 --- a/recipes-devtools/scancode-toolkit/scancode-toolkit-native_3.1.1.bb +++ /dev/null @@ -1,40 +0,0 @@ -SUMMARY = "ScanCode toolkit" -DESCRIPTION = "A typical software project often reuses hundreds of third-party \ -packages. License and origin information is not always easy to find and not \ -normalized: ScanCode discovers and normalizes this data for you." -HOMEPAGE = "https://github.com/nexB/scancode-toolkit" -SECTION = "devel" - -LICENSE = "Apache-2.0" -LIC_FILES_CHKSUM = "file://NOTICE;md5=1b6f6f8c3c1cdf360ee512a29241127b" - -inherit native - - -DEPENDS = "xz-native zlib-native libxml2-native \ - libxslt-native bzip2-native \ - " - -SRC_URI = "git://github.com/nexB/scancode-toolkit;branch=develop \ - " - -SRCREV = "ba4bbf216c6f44572662d16c76214a08b0a69e7e" - -S = "${WORKDIR}/git" -B = "${S}" - -export PYTHON_EXE="${HOSTTOOLS_DIR}/python" - -do_configure(){ - ./scancode --help -} - -do_install:append(){ - install -d ${D}${bindir}/bin - install -d ${D}${bindir}/include - install -d ${D}${bindir}/local - - install ${S}/scancode ${D}${bindir}/ - cp -rf ${S}/bin/* ${D}${bindir}/bin/ -} - |