diff options
Diffstat (limited to 'meta/recipes-core/meta')
20 files changed, 542 insertions, 268 deletions
diff --git a/meta/recipes-core/meta/build-sysroots.bb b/meta/recipes-core/meta/build-sysroots.bb index ad22a75eb2..db05c111ab 100644 --- a/meta/recipes-core/meta/build-sysroots.bb +++ b/meta/recipes-core/meta/build-sysroots.bb @@ -1,5 +1,6 @@ -INHIBIT_DEFAULT_DEPS = "1" LICENSE = "MIT" +SUMMARY = "Build old style sysroot based on everything in the components directory that matches the current MACHINE" +INHIBIT_DEFAULT_DEPS = "1" STANDALONE_SYSROOT = "${STAGING_DIR}/${MACHINE}" STANDALONE_SYSROOT_NATIVE = "${STAGING_DIR}/${BUILD_ARCH}" @@ -16,6 +17,18 @@ deltask configure deltask compile deltask install deltask populate_sysroot +deltask create_spdx +deltask collect_spdx_deps +deltask create_runtime_spdx +deltask recipe_qa + +do_build_warn () { + bbwarn "Native or target sysroot population needs to be explicitly selected; please use +bitbake -c build_native_sysroot build-sysroots +bitbake -c build_target_sysroot build-sysroots +or both." +} +addtask do_build_warn before do_build python do_build_native_sysroot () { targetsysroot = d.getVar("STANDALONE_SYSROOT") @@ -26,7 +39,7 @@ python do_build_native_sysroot () { } do_build_native_sysroot[cleandirs] = "${STANDALONE_SYSROOT_NATIVE}" do_build_native_sysroot[nostamp] = "1" -addtask do_build_native_sysroot before do_build +addtask do_build_native_sysroot python do_build_target_sysroot () { targetsysroot = d.getVar("STANDALONE_SYSROOT") @@ -37,6 +50,6 @@ python do_build_target_sysroot () { } do_build_target_sysroot[cleandirs] = "${STANDALONE_SYSROOT}" do_build_target_sysroot[nostamp] = "1" -addtask do_build_target_sysroot before do_build +addtask do_build_target_sysroot do_clean[cleandirs] += "${STANDALONE_SYSROOT} ${STANDALONE_SYSROOT_NATIVE}" diff --git a/meta/recipes-core/meta/buildtools-docs-tarball.bb b/meta/recipes-core/meta/buildtools-docs-tarball.bb new file mode 100644 index 0000000000..72648e3b1c --- /dev/null +++ b/meta/recipes-core/meta/buildtools-docs-tarball.bb @@ -0,0 +1,18 @@ +require recipes-core/meta/buildtools-tarball.bb + +DESCRIPTION = "SDK type target for building a standalone tarball containing the tools needed to build the project docs." +SUMMARY = "SDK type target for building a standalone tarball containing the tools needed to build the project docs." +LICENSE = "MIT" + +# Add nativesdk equivalent of build-essentials +TOOLCHAIN_HOST_TASK += "\ + nativesdk-python3-sphinx \ + nativesdk-python3-sphinx-rtd-theme \ + nativesdk-python3-pyyaml \ + " + +TOOLCHAIN_OUTPUTNAME = "${SDK_ARCH}-buildtools-docs-nativesdk-standalone-${DISTRO_VERSION}" + +SDK_TITLE = "Docs Build tools tarball" + +TESTSDK_CASES = "buildtools-docs-cases" diff --git a/meta/recipes-core/meta/buildtools-extended-tarball.bb b/meta/recipes-core/meta/buildtools-extended-tarball.bb index c32d0107c3..633f8e6b99 100644 --- a/meta/recipes-core/meta/buildtools-extended-tarball.bb +++ b/meta/recipes-core/meta/buildtools-extended-tarball.bb @@ -28,8 +28,13 @@ TOOLCHAIN_HOST_TASK += "\ nativesdk-libtool \ nativesdk-pkgconfig \ nativesdk-glibc-utils \ + nativesdk-glibc-gconvs \ nativesdk-libxcrypt-dev \ + nativesdk-parted \ + nativesdk-dosfstools \ + nativesdk-gptfdisk \ " +# gconvs needed for iconv to work in vim builds TOOLCHAIN_OUTPUTNAME = "${SDK_ARCH}-buildtools-extended-nativesdk-standalone-${DISTRO_VERSION}" diff --git a/meta/recipes-core/meta/buildtools-make-tarball.bb b/meta/recipes-core/meta/buildtools-make-tarball.bb new file mode 100644 index 0000000000..3a9659076f --- /dev/null +++ b/meta/recipes-core/meta/buildtools-make-tarball.bb @@ -0,0 +1,15 @@ +require recipes-core/meta/buildtools-tarball.bb + +DESCRIPTION = "SDK type target for building a standalone make binary. The tarball can be used to run bitbake builds \ + on systems where make is broken (e.g. the 4.2.1 version on CentOS 8 based distros)." +SUMMARY = "Standalone tarball for running builds on systems with inadequate make" +LICENSE = "MIT" + +# Add nativesdk equivalent of build-essentials +TOOLCHAIN_HOST_TASK = "\ + nativesdk-sdk-provides-dummy \ + nativesdk-make \ + " +TOOLCHAIN_OUTPUTNAME = "${SDK_ARCH}-buildtools-make-nativesdk-standalone-${DISTRO_VERSION}" + +SDK_TITLE = "Make build tool" diff --git a/meta/recipes-core/meta/buildtools-tarball.bb b/meta/recipes-core/meta/buildtools-tarball.bb index 560b8d67b9..92fbda335d 100644 --- a/meta/recipes-core/meta/buildtools-tarball.bb +++ b/meta/recipes-core/meta/buildtools-tarball.bb @@ -7,13 +7,15 @@ TOOLCHAIN_TARGET_TASK ?= "" TOOLCHAIN_HOST_TASK ?= "\ nativesdk-sdk-provides-dummy \ - nativesdk-python3-core \ - nativesdk-python3-modules \ - nativesdk-python3-misc \ + nativesdk-python3 \ nativesdk-python3-git \ nativesdk-python3-jinja2 \ nativesdk-python3-testtools \ + nativesdk-python3-pip \ + nativesdk-python3-setuptools \ nativesdk-python3-subunit \ + nativesdk-python3-pyyaml \ + nativesdk-python3-websockets \ nativesdk-ncurses-terminfo-base \ nativesdk-chrpath \ nativesdk-tar \ @@ -29,6 +31,9 @@ TOOLCHAIN_HOST_TASK ?= "\ nativesdk-rpcsvc-proto \ nativesdk-patch \ nativesdk-mtools \ + nativesdk-zstd \ + nativesdk-lz4 \ + nativesdk-libacl \ " MULTIMACH_TARGET_SYS = "${SDK_ARCH}-nativesdk${SDK_VENDOR}-${SDK_OS}" @@ -47,7 +52,6 @@ RDEPENDS = "${TOOLCHAIN_HOST_TASK}" EXCLUDE_FROM_WORLD = "1" -inherit meta inherit populate_sdk inherit toolchain-scripts-base inherit nopackages @@ -59,7 +63,7 @@ do_populate_sdk[stamp-extra-info] = "${PACKAGE_ARCH}" REAL_MULTIMACH_TARGET_SYS = "none" -create_sdk_files_append () { +create_sdk_files:append () { rm -f ${SDK_OUTPUT}/${SDKPATH}/site-config-* rm -f ${SDK_OUTPUT}/${SDKPATH}/environment-setup-* rm -f ${SDK_OUTPUT}/${SDKPATH}/version-* @@ -67,10 +71,17 @@ create_sdk_files_append () { # Generate new (mini) sdk-environment-setup file script=${1:-${SDK_OUTPUT}/${SDKPATH}/environment-setup-${SDK_SYS}} touch $script - echo 'export PATH=${SDKPATHNATIVE}${bindir_nativesdk}:$PATH' >> $script + echo 'export PATH="${SDKPATHNATIVE}${bindir_nativesdk}:${SDKPATHNATIVE}${sbindir_nativesdk}:${SDKPATHNATIVE}${base_bindir_nativesdk}:${SDKPATHNATIVE}${base_sbindir_nativesdk}:$PATH"' >> $script echo 'export OECORE_NATIVE_SYSROOT="${SDKPATHNATIVE}"' >> $script - echo 'export GIT_SSL_CAINFO="${SDKPATHNATIVE}${sysconfdir}/ssl/certs/ca-certificates.crt"' >>$script - echo 'export SSL_CERT_FILE="${SDKPATHNATIVE}${sysconfdir}/ssl/certs/ca-certificates.crt"' >>$script + if [ -e "${SDK_OUTPUT}${SDKPATHNATIVE}${sysconfdir}/ssl/certs/ca-certificates.crt" ]; then + echo 'export GIT_SSL_CAINFO="${SDKPATHNATIVE}${sysconfdir}/ssl/certs/ca-certificates.crt"' >>$script + echo 'export SSL_CERT_FILE="${SDKPATHNATIVE}${sysconfdir}/ssl/certs/ca-certificates.crt"' >>$script + echo 'export REQUESTS_CA_BUNDLE="${SDKPATHNATIVE}${sysconfdir}/ssl/certs/ca-certificates.crt"' >>$script + echo 'export CURL_CA_BUNDLE="${SDKPATHNATIVE}${sysconfdir}/ssl/certs/ca-certificates.crt"' >>$script + fi + echo 'HOST_PKG_PATH=$(command -p pkg-config --variable=pc_path pkg-config 2>/dev/null)' >>$script + echo 'export PKG_CONFIG_LIBDIR=${SDKPATHNATIVE}/${libdir}/pkgconfig:${SDKPATHNATIVE}/${datadir}/pkgconfig:${HOST_PKG_PATH:-/usr/lib/pkgconfig:/usr/share/pkgconfig}' >>$script + echo 'unset HOST_PKG_PATH' toolchain_create_sdk_version ${SDK_OUTPUT}/${SDKPATH}/version-${SDK_SYS} @@ -87,8 +98,8 @@ EOF if [ "${SDKMACHINE}" = "i686" ]; then echo 'export NO32LIBS="0"' >>$script - echo 'echo "$BB_ENV_EXTRAWHITE" | grep -q "NO32LIBS"' >>$script - echo '[ $? != 0 ] && export BB_ENV_EXTRAWHITE="NO32LIBS $BB_ENV_EXTRAWHITE"' >>$script + echo 'echo "$BB_ENV_PASSTHROUGH_ADDITIONS" | grep -q "NO32LIBS"' >>$script + echo '[ $? != 0 ] && export BB_ENV_PASSTHROUGH_ADDITIONS="NO32LIBS $BB_ENV_PASSTHROUGH_ADDITIONS"' >>$script fi } @@ -97,3 +108,20 @@ TOOLCHAIN_NEED_CONFIGSITE_CACHE = "" # The recipe doesn't need any default deps INHIBIT_DEFAULT_DEPS = "1" + +# Directory in testsdk that contains testcases +TESTSDK_CASES = "buildtools-cases" + +python do_testsdk() { + import oeqa.sdk.testsdk + testsdk = oeqa.sdk.testsdk.TestSDK() + + cases_path = os.path.join(os.path.abspath(os.path.dirname(oeqa.sdk.testsdk.__file__)), d.getVar("TESTSDK_CASES")) + testsdk.context_executor_class.default_cases = cases_path + + testsdk.run(d) +} +addtask testsdk +do_testsdk[nostamp] = "1" +do_testsdk[network] = "1" +do_testsdk[depends] += "xz-native:do_populate_sysroot" diff --git a/meta/recipes-core/meta/cve-update-db-native.bb b/meta/recipes-core/meta/cve-update-db-native.bb deleted file mode 100644 index cf2b251e21..0000000000 --- a/meta/recipes-core/meta/cve-update-db-native.bb +++ /dev/null @@ -1,213 +0,0 @@ -SUMMARY = "Updates the NVD CVE database" -LICENSE = "MIT" - -INHIBIT_DEFAULT_DEPS = "1" - -inherit native - -deltask do_unpack -deltask do_patch -deltask do_configure -deltask do_compile -deltask do_install -deltask do_populate_sysroot - -python () { - if not bb.data.inherits_class("cve-check", d): - raise bb.parse.SkipRecipe("Skip recipe when cve-check class is not loaded.") -} - -python do_fetch() { - """ - Update NVD database with json data feed - """ - import bb.utils - import bb.progress - import sqlite3, urllib, urllib.parse, gzip - from datetime import date - - bb.utils.export_proxies(d) - - BASE_URL = "https://nvd.nist.gov/feeds/json/cve/1.1/nvdcve-1.1-" - YEAR_START = 2002 - - db_file = d.getVar("CVE_CHECK_DB_FILE") - db_dir = os.path.dirname(db_file) - - if os.path.exists("{0}-journal".format(db_file)): - # If a journal is present the last update might have been interrupted. In that case, - # just wipe any leftovers and force the DB to be recreated. - os.remove("{0}-journal".format(db_file)) - - if os.path.exists(db_file): - os.remove(db_file) - - # Don't refresh the database more than once an hour - try: - import time - if time.time() - os.path.getmtime(db_file) < (60*60): - bb.debug(2, "Recently updated, skipping") - return - except OSError: - pass - - bb.utils.mkdirhier(db_dir) - - # Connect to database - conn = sqlite3.connect(db_file) - c = conn.cursor() - - initialize_db(c) - - with bb.progress.ProgressHandler(d) as ph, open(os.path.join(d.getVar("TMPDIR"), 'cve_check'), 'a') as cve_f: - total_years = date.today().year + 1 - YEAR_START - for i, year in enumerate(range(YEAR_START, date.today().year + 1)): - bb.debug(2, "Updating %d" % year) - ph.update((float(i + 1) / total_years) * 100) - year_url = BASE_URL + str(year) - meta_url = year_url + ".meta" - json_url = year_url + ".json.gz" - - # Retrieve meta last modified date - try: - response = urllib.request.urlopen(meta_url) - except urllib.error.URLError as e: - cve_f.write('Warning: CVE db update error, Unable to fetch CVE data.\n\n') - bb.warn("Failed to fetch CVE data (%s)" % e.reason) - return - - if response: - for l in response.read().decode("utf-8").splitlines(): - key, value = l.split(":", 1) - if key == "lastModifiedDate": - last_modified = value - break - else: - bb.warn("Cannot parse CVE metadata, update failed") - return - - # Compare with current db last modified date - c.execute("select DATE from META where YEAR = ?", (year,)) - meta = c.fetchone() - if not meta or meta[0] != last_modified: - bb.debug(2, "Updating entries") - # Clear products table entries corresponding to current year - c.execute("delete from PRODUCTS where ID like ?", ('CVE-%d%%' % year,)) - - # Update db with current year json file - try: - response = urllib.request.urlopen(json_url) - if response: - update_db(c, gzip.decompress(response.read()).decode('utf-8')) - c.execute("insert or replace into META values (?, ?)", [year, last_modified]) - except urllib.error.URLError as e: - cve_f.write('Warning: CVE db update error, CVE data is outdated.\n\n') - bb.warn("Cannot parse CVE data (%s), update failed" % e.reason) - return - else: - bb.debug(2, "Already up to date (last modified %s)" % last_modified) - # Update success, set the date to cve_check file. - if year == date.today().year: - cve_f.write('CVE database update : %s\n\n' % date.today()) - - conn.commit() - conn.close() -} - -do_fetch[lockfiles] += "${CVE_CHECK_DB_FILE_LOCK}" -do_fetch[file-checksums] = "" -do_fetch[vardeps] = "" - -def initialize_db(c): - c.execute("CREATE TABLE IF NOT EXISTS META (YEAR INTEGER UNIQUE, DATE TEXT)") - - c.execute("CREATE TABLE IF NOT EXISTS NVD (ID TEXT UNIQUE, SUMMARY TEXT, \ - SCOREV2 TEXT, SCOREV3 TEXT, MODIFIED INTEGER, VECTOR TEXT)") - - c.execute("CREATE TABLE IF NOT EXISTS PRODUCTS (ID TEXT, \ - VENDOR TEXT, PRODUCT TEXT, VERSION_START TEXT, OPERATOR_START TEXT, \ - VERSION_END TEXT, OPERATOR_END TEXT)") - c.execute("CREATE INDEX IF NOT EXISTS PRODUCT_ID_IDX on PRODUCTS(ID);") - -def parse_node_and_insert(c, node, cveId): - # Parse children node if needed - for child in node.get('children', ()): - parse_node_and_insert(c, child, cveId) - - def cpe_generator(): - for cpe in node.get('cpe_match', ()): - if not cpe['vulnerable']: - return - cpe23 = cpe['cpe23Uri'].split(':') - vendor = cpe23[3] - product = cpe23[4] - version = cpe23[5] - - if version != '*' and version != '-': - # Version is defined, this is a '=' match - yield [cveId, vendor, product, version, '=', '', ''] - elif version == '-': - # no version information is available - yield [cveId, vendor, product, version, '', '', ''] - else: - # Parse start version, end version and operators - op_start = '' - op_end = '' - v_start = '' - v_end = '' - - if 'versionStartIncluding' in cpe: - op_start = '>=' - v_start = cpe['versionStartIncluding'] - - if 'versionStartExcluding' in cpe: - op_start = '>' - v_start = cpe['versionStartExcluding'] - - if 'versionEndIncluding' in cpe: - op_end = '<=' - v_end = cpe['versionEndIncluding'] - - if 'versionEndExcluding' in cpe: - op_end = '<' - v_end = cpe['versionEndExcluding'] - - yield [cveId, vendor, product, v_start, op_start, v_end, op_end] - - c.executemany("insert into PRODUCTS values (?, ?, ?, ?, ?, ?, ?)", cpe_generator()) - -def update_db(c, jsondata): - import json - root = json.loads(jsondata) - - for elt in root['CVE_Items']: - if not elt['impact']: - continue - - accessVector = None - cveId = elt['cve']['CVE_data_meta']['ID'] - cveDesc = elt['cve']['description']['description_data'][0]['value'] - date = elt['lastModifiedDate'] - try: - accessVector = elt['impact']['baseMetricV2']['cvssV2']['accessVector'] - cvssv2 = elt['impact']['baseMetricV2']['cvssV2']['baseScore'] - except KeyError: - cvssv2 = 0.0 - try: - accessVector = accessVector or elt['impact']['baseMetricV3']['cvssV3']['attackVector'] - cvssv3 = elt['impact']['baseMetricV3']['cvssV3']['baseScore'] - except KeyError: - accessVector = accessVector or "UNKNOWN" - cvssv3 = 0.0 - - c.execute("insert or replace into NVD values (?, ?, ?, ?, ?, ?)", - [cveId, cveDesc, cvssv2, cvssv3, date, accessVector]) - - configurations = elt['configurations']['nodes'] - for config in configurations: - parse_node_and_insert(c, config, cveId) - - -do_fetch[nostamp] = "1" - -EXCLUDE_FROM_WORLD = "1" diff --git a/meta/recipes-core/meta/cve-update-nvd2-native.bb b/meta/recipes-core/meta/cve-update-nvd2-native.bb new file mode 100644 index 0000000000..1901641965 --- /dev/null +++ b/meta/recipes-core/meta/cve-update-nvd2-native.bb @@ -0,0 +1,377 @@ +SUMMARY = "Updates the NVD CVE database" +LICENSE = "MIT" + +# Important note: +# This product uses the NVD API but is not endorsed or certified by the NVD. + +INHIBIT_DEFAULT_DEPS = "1" + +inherit native + +deltask do_unpack +deltask do_patch +deltask do_configure +deltask do_compile +deltask do_install +deltask do_populate_sysroot + +NVDCVE_URL ?= "https://services.nvd.nist.gov/rest/json/cves/2.0" + +# If you have a NVD API key (https://nvd.nist.gov/developers/request-an-api-key) +# then setting this to get higher rate limits. +NVDCVE_API_KEY ?= "" + +# CVE database update interval, in seconds. By default: once a day (24*60*60). +# Use 0 to force the update +# Use a negative value to skip the update +CVE_DB_UPDATE_INTERVAL ?= "86400" + +# CVE database incremental update age threshold, in seconds. If the database is +# older than this threshold, do a full re-download, else, do an incremental +# update. By default: the maximum allowed value from NVD: 120 days (120*24*60*60) +# Use 0 to force a full download. +CVE_DB_INCR_UPDATE_AGE_THRES ?= "10368000" + +# Number of attempts for each http query to nvd server before giving up +CVE_DB_UPDATE_ATTEMPTS ?= "5" + +CVE_DB_TEMP_FILE ?= "${CVE_CHECK_DB_DIR}/temp_nvdcve_2.db" + +python () { + if not bb.data.inherits_class("cve-check", d): + raise bb.parse.SkipRecipe("Skip recipe when cve-check class is not loaded.") +} + +python do_fetch() { + """ + Update NVD database with API 2.0 + """ + import bb.utils + import bb.progress + import shutil + + bb.utils.export_proxies(d) + + db_file = d.getVar("CVE_CHECK_DB_FILE") + db_dir = os.path.dirname(db_file) + db_tmp_file = d.getVar("CVE_DB_TEMP_FILE") + + cleanup_db_download(db_file, db_tmp_file) + # By default let's update the whole database (since time 0) + database_time = 0 + + # The NVD database changes once a day, so no need to update more frequently + # Allow the user to force-update + try: + import time + update_interval = int(d.getVar("CVE_DB_UPDATE_INTERVAL")) + if update_interval < 0: + bb.note("CVE database update skipped") + return + if time.time() - os.path.getmtime(db_file) < update_interval: + bb.note("CVE database recently updated, skipping") + return + database_time = os.path.getmtime(db_file) + + except OSError: + pass + + bb.utils.mkdirhier(db_dir) + if os.path.exists(db_file): + shutil.copy2(db_file, db_tmp_file) + + if update_db_file(db_tmp_file, d, database_time) == True: + # Update downloaded correctly, can swap files + shutil.move(db_tmp_file, db_file) + else: + # Update failed, do not modify the database + bb.warn("CVE database update failed") + os.remove(db_tmp_file) +} + +do_fetch[lockfiles] += "${CVE_CHECK_DB_FILE_LOCK}" +do_fetch[file-checksums] = "" +do_fetch[vardeps] = "" + +def cleanup_db_download(db_file, db_tmp_file): + """ + Cleanup the download space from possible failed downloads + """ + + # Clean up the updates done on the main file + # Remove it only if a journal file exists - it means a complete re-download + if os.path.exists("{0}-journal".format(db_file)): + # If a journal is present the last update might have been interrupted. In that case, + # just wipe any leftovers and force the DB to be recreated. + os.remove("{0}-journal".format(db_file)) + + if os.path.exists(db_file): + os.remove(db_file) + + # Clean-up the temporary file downloads, we can remove both journal + # and the temporary database + if os.path.exists("{0}-journal".format(db_tmp_file)): + # If a journal is present the last update might have been interrupted. In that case, + # just wipe any leftovers and force the DB to be recreated. + os.remove("{0}-journal".format(db_tmp_file)) + + if os.path.exists(db_tmp_file): + os.remove(db_tmp_file) + +def nvd_request_wait(attempt, min_wait): + return min ( ( (2 * attempt) + min_wait ) , 30) + +def nvd_request_next(url, attempts, api_key, args, min_wait): + """ + Request next part of the NVD database + NVD API documentation: https://nvd.nist.gov/developers/vulnerabilities + """ + + import urllib.request + import urllib.parse + import gzip + import http + import time + + request = urllib.request.Request(url + "?" + urllib.parse.urlencode(args)) + if api_key: + request.add_header("apiKey", api_key) + bb.note("Requesting %s" % request.full_url) + + for attempt in range(attempts): + try: + r = urllib.request.urlopen(request) + + if (r.headers['content-encoding'] == 'gzip'): + buf = r.read() + raw_data = gzip.decompress(buf) + else: + raw_data = r.read().decode("utf-8") + + r.close() + + except Exception as e: + wait_time = nvd_request_wait(attempt, min_wait) + bb.note("CVE database: received error (%s)" % (e)) + bb.note("CVE database: retrying download after %d seconds. attempted (%d/%d)" % (wait_time, attempt+1, attempts)) + time.sleep(wait_time) + pass + else: + return raw_data + else: + # We failed at all attempts + return None + +def update_db_file(db_tmp_file, d, database_time): + """ + Update the given database file + """ + import bb.utils, bb.progress + import datetime + import sqlite3 + import json + + # Connect to database + conn = sqlite3.connect(db_tmp_file) + initialize_db(conn) + + req_args = {'startIndex' : 0} + + incr_update_threshold = int(d.getVar("CVE_DB_INCR_UPDATE_AGE_THRES")) + if database_time != 0: + database_date = datetime.datetime.fromtimestamp(database_time, tz=datetime.timezone.utc) + today_date = datetime.datetime.now(tz=datetime.timezone.utc) + delta = today_date - database_date + if incr_update_threshold == 0: + bb.note("CVE database: forced full update") + elif delta < datetime.timedelta(seconds=incr_update_threshold): + bb.note("CVE database: performing partial update") + # The maximum range for time is 120 days + if delta > datetime.timedelta(days=120): + bb.error("CVE database: Trying to do an incremental update on a larger than supported range") + req_args['lastModStartDate'] = database_date.isoformat() + req_args['lastModEndDate'] = today_date.isoformat() + else: + bb.note("CVE database: file too old, forcing a full update") + else: + bb.note("CVE database: no preexisting database, do a full download") + + with bb.progress.ProgressHandler(d) as ph, open(os.path.join(d.getVar("TMPDIR"), 'cve_check'), 'a') as cve_f: + + bb.note("Updating entries") + index = 0 + url = d.getVar("NVDCVE_URL") + api_key = d.getVar("NVDCVE_API_KEY") or None + attempts = int(d.getVar("CVE_DB_UPDATE_ATTEMPTS")) + + # Recommended by NVD + wait_time = 6 + if api_key: + wait_time = 2 + + while True: + req_args['startIndex'] = index + raw_data = nvd_request_next(url, attempts, api_key, req_args, wait_time) + if raw_data is None: + # We haven't managed to download data + return False + + data = json.loads(raw_data) + + index = data["startIndex"] + total = data["totalResults"] + per_page = data["resultsPerPage"] + bb.note("Got %d entries" % per_page) + for cve in data["vulnerabilities"]: + update_db(conn, cve) + + index += per_page + ph.update((float(index) / (total+1)) * 100) + if index >= total: + break + + # Recommended by NVD + time.sleep(wait_time) + + # Update success, set the date to cve_check file. + cve_f.write('CVE database update : %s\n\n' % datetime.date.today()) + + conn.commit() + conn.close() + return True + +def initialize_db(conn): + with conn: + c = conn.cursor() + + c.execute("CREATE TABLE IF NOT EXISTS META (YEAR INTEGER UNIQUE, DATE TEXT)") + + c.execute("CREATE TABLE IF NOT EXISTS NVD (ID TEXT UNIQUE, SUMMARY TEXT, \ + SCOREV2 TEXT, SCOREV3 TEXT, MODIFIED INTEGER, VECTOR TEXT, VECTORSTRING TEXT)") + + c.execute("CREATE TABLE IF NOT EXISTS PRODUCTS (ID TEXT, \ + VENDOR TEXT, PRODUCT TEXT, VERSION_START TEXT, OPERATOR_START TEXT, \ + VERSION_END TEXT, OPERATOR_END TEXT)") + c.execute("CREATE INDEX IF NOT EXISTS PRODUCT_ID_IDX on PRODUCTS(ID);") + + c.close() + +def parse_node_and_insert(conn, node, cveId): + + def cpe_generator(): + for cpe in node.get('cpeMatch', ()): + if not cpe['vulnerable']: + return + cpe23 = cpe.get('criteria') + if not cpe23: + return + cpe23 = cpe23.split(':') + if len(cpe23) < 6: + return + vendor = cpe23[3] + product = cpe23[4] + version = cpe23[5] + + if cpe23[6] == '*' or cpe23[6] == '-': + version_suffix = "" + else: + version_suffix = "_" + cpe23[6] + + if version != '*' and version != '-': + # Version is defined, this is a '=' match + yield [cveId, vendor, product, version + version_suffix, '=', '', ''] + elif version == '-': + # no version information is available + yield [cveId, vendor, product, version, '', '', ''] + else: + # Parse start version, end version and operators + op_start = '' + op_end = '' + v_start = '' + v_end = '' + + if 'versionStartIncluding' in cpe: + op_start = '>=' + v_start = cpe['versionStartIncluding'] + + if 'versionStartExcluding' in cpe: + op_start = '>' + v_start = cpe['versionStartExcluding'] + + if 'versionEndIncluding' in cpe: + op_end = '<=' + v_end = cpe['versionEndIncluding'] + + if 'versionEndExcluding' in cpe: + op_end = '<' + v_end = cpe['versionEndExcluding'] + + if op_start or op_end or v_start or v_end: + yield [cveId, vendor, product, v_start, op_start, v_end, op_end] + else: + # This is no version information, expressed differently. + # Save processing by representing as -. + yield [cveId, vendor, product, '-', '', '', ''] + + conn.executemany("insert into PRODUCTS values (?, ?, ?, ?, ?, ?, ?)", cpe_generator()).close() + +def update_db(conn, elt): + """ + Update a single entry in the on-disk database + """ + + accessVector = None + vectorString = None + cveId = elt['cve']['id'] + if elt['cve']['vulnStatus'] == "Rejected": + c = conn.cursor() + c.execute("delete from PRODUCTS where ID = ?;", [cveId]) + c.execute("delete from NVD where ID = ?;", [cveId]) + c.close() + return + cveDesc = "" + for desc in elt['cve']['descriptions']: + if desc['lang'] == 'en': + cveDesc = desc['value'] + date = elt['cve']['lastModified'] + try: + accessVector = elt['cve']['metrics']['cvssMetricV2'][0]['cvssData']['accessVector'] + vectorString = elt['cve']['metrics']['cvssMetricV2'][0]['cvssData']['vectorString'] + cvssv2 = elt['cve']['metrics']['cvssMetricV2'][0]['cvssData']['baseScore'] + except KeyError: + cvssv2 = 0.0 + cvssv3 = None + try: + accessVector = accessVector or elt['cve']['metrics']['cvssMetricV30'][0]['cvssData']['attackVector'] + vectorString = vectorString or elt['cve']['metrics']['cvssMetricV30'][0]['cvssData']['vectorString'] + cvssv3 = elt['cve']['metrics']['cvssMetricV30'][0]['cvssData']['baseScore'] + except KeyError: + pass + try: + accessVector = accessVector or elt['cve']['metrics']['cvssMetricV31'][0]['cvssData']['attackVector'] + vectorString = vectorString or elt['cve']['metrics']['cvssMetricV31'][0]['cvssData']['vectorString'] + cvssv3 = cvssv3 or elt['cve']['metrics']['cvssMetricV31'][0]['cvssData']['baseScore'] + except KeyError: + pass + accessVector = accessVector or "UNKNOWN" + vectorString = vectorString or "UNKNOWN" + cvssv3 = cvssv3 or 0.0 + + conn.execute("insert or replace into NVD values (?, ?, ?, ?, ?, ?, ?)", + [cveId, cveDesc, cvssv2, cvssv3, date, accessVector, vectorString]).close() + + try: + # Remove any pre-existing CVE configuration. Even for partial database + # update, those will be repopulated. This ensures that old + # configuration is not kept for an updated CVE. + conn.execute("delete from PRODUCTS where ID = ?", [cveId]).close() + for config in elt['cve']['configurations']: + # This is suboptimal as it doesn't handle AND/OR and negate, but is better than nothing + for node in config["nodes"]: + parse_node_and_insert(conn, node, cveId) + except KeyError: + bb.note("CVE %s has no configurations" % cveId) + +do_fetch[nostamp] = "1" + +EXCLUDE_FROM_WORLD = "1" diff --git a/meta/recipes-core/meta/dummy-sdk-package.inc b/meta/recipes-core/meta/dummy-sdk-package.inc index bedde2965c..bd26e39ad3 100644 --- a/meta/recipes-core/meta/dummy-sdk-package.inc +++ b/meta/recipes-core/meta/dummy-sdk-package.inc @@ -13,7 +13,7 @@ python() { d.setVar('PACKAGE_ARCH', '${DUMMYARCH}') } -ALLOW_EMPTY_${PN} = "1" +ALLOW_EMPTY:${PN} = "1" PR[vardeps] += "DUMMYPROVIDES" PR[vardeps] += "DUMMYPROVIDES_PACKAGES" @@ -22,10 +22,10 @@ DUMMYPROVIDES_PACKAGES ??= "" DUMMYPROVIDES_PACKAGES_MULTILIB = "${@' '.join([multilib_pkg_extend(d, pkg) for pkg in d.getVar('DUMMYPROVIDES_PACKAGES').split()])}" DUMMYPROVIDES += "${DUMMYPROVIDES_PACKAGES_MULTILIB}" -python populate_packages_prepend() { +python populate_packages:prepend() { p = d.getVar("PN") - d.appendVar("RPROVIDES_%s" % p, "${DUMMYPROVIDES}") - d.appendVar("RCONFLICTS_%s" % p, "${DUMMYPROVIDES}") - d.appendVar("RREPLACES_%s" % p, "${DUMMYPROVIDES_PACKAGES_MULTILIB}") + d.appendVar("RPROVIDES:%s" % p, "${DUMMYPROVIDES}") + d.appendVar("RCONFLICTS:%s" % p, "${DUMMYPROVIDES}") + d.appendVar("RREPLACES:%s" % p, "${DUMMYPROVIDES_PACKAGES_MULTILIB}") } diff --git a/meta/recipes-core/meta/meta-environment-extsdk.bb b/meta/recipes-core/meta/meta-environment-extsdk.bb index 2076b56f25..706312b0d6 100644 --- a/meta/recipes-core/meta/meta-environment-extsdk.bb +++ b/meta/recipes-core/meta/meta-environment-extsdk.bb @@ -4,7 +4,7 @@ require meta-environment.bb PN = "meta-environment-extsdk-${MACHINE}" -create_sdk_files_append() { +create_sdk_files:append() { local sysroot=${SDKPATH}/tmp/${@os.path.relpath(d.getVar('STAGING_DIR'), d.getVar('TMPDIR'))}/${MACHINE} local sdkpathnative=${SDKPATH}/tmp/${@os.path.relpath(d.getVar('STAGING_DIR'), d.getVar('TMPDIR'))}/${BUILD_ARCH} diff --git a/meta/recipes-core/meta/meta-environment.bb b/meta/recipes-core/meta/meta-environment.bb index da1230bead..65436bc3e6 100644 --- a/meta/recipes-core/meta/meta-environment.bb +++ b/meta/recipes-core/meta/meta-environment.bb @@ -1,6 +1,5 @@ SUMMARY = "Package of environment files for SDK" LICENSE = "MIT" -PR = "r8" EXCLUDE_FROM_WORLD = "1" @@ -9,7 +8,7 @@ MODIFYTOS = "0" REAL_MULTIMACH_TARGET_SYS = "${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS}" inherit toolchain-scripts -TOOLCHAIN_NEED_CONFIGSITE_CACHE_append = " zlib" +TOOLCHAIN_NEED_CONFIGSITE_CACHE:append = " zlib" # Need to expand here before cross-candian changes HOST_ARCH -> SDK_ARCH TOOLCHAIN_CONFIGSITE_NOCACHE := "${TOOLCHAIN_CONFIGSITE_NOCACHE}" @@ -47,6 +46,11 @@ python do_generate_content() { } addtask generate_content before do_install after do_compile +python () { + sitefiles, searched = siteinfo_get_files(d, sysrootcache=False) + d.appendVarFlag("do_generate_content", "file-checksums", " " + " ".join(searched)) +} + create_sdk_files() { # Setup site file for external use toolchain_create_sdk_siteconfig ${SDK_OUTPUT}/${SDKPATH}/site-config-${REAL_MULTIMACH_TARGET_SYS} @@ -66,7 +70,7 @@ do_install() { PN = "meta-environment-${MACHINE}" PACKAGES = "${PN}" -FILES_${PN}= " \ +FILES:${PN}= " \ ${SDKPATH}/* \ " diff --git a/meta/recipes-core/meta/meta-go-toolchain.bb b/meta/recipes-core/meta/meta-go-toolchain.bb index dde385c1b1..c24518efe3 100644 --- a/meta/recipes-core/meta/meta-go-toolchain.bb +++ b/meta/recipes-core/meta/meta-go-toolchain.bb @@ -3,10 +3,10 @@ LICENSE = "MIT" inherit populate_sdk -TOOLCHAIN_HOST_TASK_append = " \ +TOOLCHAIN_HOST_TASK:append = " \ packagegroup-go-cross-canadian-${MACHINE} \ " -TOOLCHAIN_TARGET_TASK_append = " \ +TOOLCHAIN_TARGET_TASK:append = " \ ${@multilib_pkg_extend(d, 'packagegroup-go-sdk-target')} \ " diff --git a/meta/recipes-core/meta/meta-ide-support.bb b/meta/recipes-core/meta/meta-ide-support.bb index 768f6f4bb6..d85aa120c0 100644 --- a/meta/recipes-core/meta/meta-ide-support.bb +++ b/meta/recipes-core/meta/meta-ide-support.bb @@ -2,14 +2,39 @@ SUMMARY = "Integrated Development Environment support" DESCRIPTION = "Meta package for ensuring the build directory contains all appropriate toolchain packages for using an IDE" LICENSE = "MIT" -DEPENDS = "virtual/libc gdb-cross-${TARGET_ARCH} qemu-native qemu-helper-native unfs3-native cmake-native" -PR = "r3" +DEPENDS = "virtual/libc gdb-cross-${TARGET_ARCH} qemu-native qemu-helper-native unfs3-native cmake-native autoconf-native automake-native meson-native intltool-native pkgconfig-native" RM_WORK_EXCLUDE += "${PN}" -inherit meta toolchain-scripts nopackages +inherit toolchain-scripts nopackages deploy testsdk + +TESTSDK_CLASS_NAME = "oeqa.sdk.testmetaidesupport.TestSDK" do_populate_ide_support () { toolchain_create_tree_env_script } -addtask populate_ide_support before do_build after do_install +python () { + sitefiles, searched = siteinfo_get_files(d, sysrootcache=False) + d.setVar("CONFIG_SITE", " ".join(sitefiles)) + d.appendVarFlag("do_populate_ide_support", "file-checksums", " " + " ".join(searched)) +} + +addtask populate_ide_support before do_deploy after do_install + +python do_write_test_data() { + from oe.data import export2json + + out_dir = d.getVar('B') + testdata_name = os.path.join(out_dir, "%s.testdata.json" % d.getVar('PN')) + + export2json(d, testdata_name) +} +addtask write_test_data before do_deploy after do_install + +do_deploy () { + install ${B}/* ${DEPLOYDIR} +} + +addtask deploy before do_build + +do_build[deptask] += "do_prepare_recipe_sysroot" diff --git a/meta/recipes-core/meta/meta-toolchain.bb b/meta/recipes-core/meta/meta-toolchain.bb index b02b0665e6..260e03934e 100644 --- a/meta/recipes-core/meta/meta-toolchain.bb +++ b/meta/recipes-core/meta/meta-toolchain.bb @@ -1,6 +1,5 @@ SUMMARY = "Meta package for building a installable toolchain" LICENSE = "MIT" -PR = "r7" inherit populate_sdk diff --git a/meta/recipes-core/meta/meta-world-pkgdata.bb b/meta/recipes-core/meta/meta-world-pkgdata.bb index b299861375..0438bf6138 100644 --- a/meta/recipes-core/meta/meta-world-pkgdata.bb +++ b/meta/recipes-core/meta/meta-world-pkgdata.bb @@ -33,6 +33,8 @@ deltask do_patch deltask do_configure deltask do_compile deltask do_install +deltask do_create_spdx +deltask do_create_spdx_runtime do_prepare_recipe_sysroot[deptask] = "" diff --git a/meta/recipes-core/meta/nativesdk-buildtools-perl-dummy.bb b/meta/recipes-core/meta/nativesdk-buildtools-perl-dummy.bb index cfa41c4ae6..bb4e746237 100644 --- a/meta/recipes-core/meta/nativesdk-buildtools-perl-dummy.bb +++ b/meta/recipes-core/meta/nativesdk-buildtools-perl-dummy.bb @@ -17,20 +17,25 @@ DUMMYPROVIDES_PACKAGES = "\ nativesdk-perl-module-file-path \ nativesdk-perl-module-file-spec \ nativesdk-perl-module-file-stat \ + nativesdk-perl-module-file-temp \ nativesdk-perl-module-getopt-long \ nativesdk-perl-module-io-file \ + nativesdk-perl-module-list-util \ nativesdk-perl-module-overloading \ nativesdk-perl-module-posix \ + nativesdk-perl-module-scalar-util \ + nativesdk-perl-module-strict \ + nativesdk-perl-module-text-parsewords \ nativesdk-perl-module-thread-queue \ nativesdk-perl-module-threads \ nativesdk-perl-module-warnings \ + nativesdk-perl-module-vars \ " DUMMYPROVIDES = "\ /usr/bin/perl \ " -PR = "r2" require dummy-sdk-package.inc diff --git a/meta/recipes-core/meta/signing-keys.bb b/meta/recipes-core/meta/signing-keys.bb index 5bab94aa36..107a39d658 100644 --- a/meta/recipes-core/meta/signing-keys.bb +++ b/meta/recipes-core/meta/signing-keys.bb @@ -14,9 +14,11 @@ SYSROOT_DIRS += "${sysconfdir}/pki" PACKAGES =+ "${PN}-ipk ${PN}-rpm ${PN}-packagefeed" -FILES_${PN}-rpm = "${sysconfdir}/pki/rpm-gpg" -FILES_${PN}-ipk = "${sysconfdir}/pki/ipk-gpg" -FILES_${PN}-packagefeed = "${sysconfdir}/pki/packagefeed-gpg" +FILES:${PN}-rpm = "${sysconfdir}/pki/rpm-gpg" +FILES:${PN}-ipk = "${sysconfdir}/pki/ipk-gpg" +FILES:${PN}-packagefeed = "${sysconfdir}/pki/packagefeed-gpg" + +RDEPENDS:${PN}-dev = "" python do_get_public_keys () { from oe.gpg_sign import get_signer diff --git a/meta/recipes-core/meta/target-sdk-provides-dummy.bb b/meta/recipes-core/meta/target-sdk-provides-dummy.bb index e3beeb796c..849407cca5 100644 --- a/meta/recipes-core/meta/target-sdk-provides-dummy.bb +++ b/meta/recipes-core/meta/target-sdk-provides-dummy.bb @@ -58,4 +58,4 @@ DUMMYPROVIDES = "\ require dummy-sdk-package.inc -SSTATE_DUPWHITELIST += "${PKGDATA_DIR}/${PN} ${PKGDATA_DIR}/runtime/${PN}" +SSTATE_ALLOW_OVERLAP_FILES += "${PKGDATA_DIR}/${PN} ${PKGDATA_DIR}/runtime/${PN}" diff --git a/meta/recipes-core/meta/testexport-tarball.bb b/meta/recipes-core/meta/testexport-tarball.bb index daedd78cb4..abdd009252 100644 --- a/meta/recipes-core/meta/testexport-tarball.bb +++ b/meta/recipes-core/meta/testexport-tarball.bb @@ -4,7 +4,7 @@ DESCRIPTION = "SDK type target for standalone tarball containing packages define SUMMARY = "Standalone tarball for test systems with missing software" LICENSE = "MIT" -TEST_EXPORT_SDK_PACKAGES ??= "" +require conf/testexport.conf TOOLCHAIN_TARGET_TASK ?= "" @@ -26,7 +26,6 @@ RDEPENDS = "${TOOLCHAIN_HOST_TASK}" EXCLUDE_FROM_WORLD = "1" -inherit meta inherit populate_sdk inherit toolchain-scripts-base inherit nopackages @@ -38,7 +37,7 @@ do_populate_sdk[stamp-extra-info] = "${PACKAGE_ARCH}" REAL_MULTIMACH_TARGET_SYS = "none" -create_sdk_files_append () { +create_sdk_files:append () { rm -f ${SDK_OUTPUT}/${SDKPATH}/site-config-* rm -f ${SDK_OUTPUT}/${SDKPATH}/environment-setup-* rm -f ${SDK_OUTPUT}/${SDKPATH}/version-* @@ -58,8 +57,8 @@ create_sdk_files_append () { if [ "${SDKMACHINE}" = "i686" ]; then echo 'export NO32LIBS="0"' >>$script - echo 'echo "$BB_ENV_EXTRAWHITE" | grep -q "NO32LIBS"' >>$script - echo '[ $? != 0 ] && export BB_ENV_EXTRAWHITE="NO32LIBS $BB_ENV_EXTRAWHITE"' >>$script + echo 'echo "$BB_ENV_PASSTHROUGH_ADDITIONS" | grep -q "NO32LIBS"' >>$script + echo '[ $? != 0 ] && export BB_ENV_PASSTHROUGH_ADDITIONS="NO32LIBS $BB_ENV_PASSTHROUGH_ADDITIONS"' >>$script fi } diff --git a/meta/recipes-core/meta/uninative-tarball.bb b/meta/recipes-core/meta/uninative-tarball.bb index c4a6c96b4d..7eebcaf11a 100644 --- a/meta/recipes-core/meta/uninative-tarball.bb +++ b/meta/recipes-core/meta/uninative-tarball.bb @@ -3,22 +3,16 @@ LICENSE = "MIT" TOOLCHAIN_TARGET_TASK = "" -# ibm850 - mcopy from mtools -# iso8859-1 - guile -# utf-16, cp1252 - binutils-windres TOOLCHAIN_HOST_TASK = "\ nativesdk-glibc \ - nativesdk-glibc-gconv-ibm850 \ - nativesdk-glibc-gconv-iso8859-1 \ - nativesdk-glibc-gconv-utf-16 \ - nativesdk-glibc-gconv-cp1252 \ - nativesdk-glibc-gconv-euc-jp \ - nativesdk-glibc-gconv-libjis \ + nativesdk-glibc-dbg \ + nativesdk-glibc-gconvs \ nativesdk-patchelf \ nativesdk-libxcrypt \ nativesdk-libxcrypt-compat \ nativesdk-libnss-nis \ nativesdk-sdk-provides-dummy \ + nativesdk-libgcc \ " INHIBIT_DEFAULT_DEPS = "1" @@ -35,7 +29,6 @@ RDEPENDS = "${TOOLCHAIN_HOST_TASK}" EXCLUDE_FROM_WORLD = "1" -inherit meta inherit populate_sdk inherit nopackages diff --git a/meta/recipes-core/meta/wic-tools.bb b/meta/recipes-core/meta/wic-tools.bb index 3e7d0ed48d..76494e7fca 100644 --- a/meta/recipes-core/meta/wic-tools.bb +++ b/meta/recipes-core/meta/wic-tools.bb @@ -3,14 +3,16 @@ SUMMARY = "A meta recipe to build native tools used by wic." LICENSE = "MIT" DEPENDS = "\ - parted-native syslinux-native gptfdisk-native dosfstools-native \ - mtools-native bmap-tools-native grub-native cdrtools-native \ + parted-native gptfdisk-native dosfstools-native \ + mtools-native bmaptool-native grub-native cdrtools-native \ btrfs-tools-native squashfs-tools-native pseudo-native \ - e2fsprogs-native util-linux-native tar-native\ + e2fsprogs-native util-linux-native tar-native erofs-utils-native \ + virtual/${TARGET_PREFIX}binutils \ " -DEPENDS_append_x86 = " syslinux grub-efi systemd-boot" -DEPENDS_append_x86-64 = " syslinux grub-efi systemd-boot" -DEPENDS_append_x86-x32 = " syslinux grub-efi" +DEPENDS:append:x86 = " syslinux-native syslinux grub-efi systemd-boot" +DEPENDS:append:x86-64 = " syslinux-native syslinux grub-efi systemd-boot" +DEPENDS:append:x86-x32 = " syslinux-native syslinux grub-efi" +DEPENDS:append:aarch64 = " grub-efi systemd-boot" INHIBIT_DEFAULT_DEPS = "1" |