diff --git a/README b/README index ffdd9fb..5efb0bc 100644 --- a/README +++ b/README @@ -11,6 +11,20 @@ URI: git://git.openembedded.org/openembedded-core branch: master revision: HEAD +CVE checking +------------ + +The layer no longer ships a CVE filter class: OE-Core dropped the +cve-check class it relied on. Use OE-Core's SBOM-based checker instead, +which reads the image SPDX and writes VEX-aware reports to the deploy +directory: + + bitbake-config-build enable-fragment core/yocto/sbom-cve-check + +or, in local.conf: + + OE_FRAGMENTS += "core/yocto/sbom-cve-check" + Contributing ------------ diff --git a/classes/cve-filter.bbclass b/classes/cve-filter.bbclass deleted file mode 100644 index aff2968..0000000 --- a/classes/cve-filter.bbclass +++ /dev/null @@ -1,109 +0,0 @@ -# nooelint: oelint.bbclass.underscores oelint.file.inlinesuppress_na no EXPORT_FUNCTIONS here, so the dash is harmless -# Copyright (c) 2024 O.S. Systems Software LTDA. -# Usage Instructions for the Yocto CVE Filter Class - -# This class is designed to filter CVEs (Common Vulnerabilities -# and Exposures) from CVE files. It should be used in conjunction -# with the cve-check class from the openembedded-core. - -# Steps to Use This Class - -# 1. Add the following lines to your distro configuration file: - -# include conf/distro/include/cve-extra-exclusions.inc -# INHERIT += "cve-check" - -# 2. Inherit the cve-filter class in the image recipe. -# -# -------- Configuration Variables ---------------------------- - -# The cve-filter class provides several configurable variables: - -# CVE_FILTER_PREVIOUS_FILE: Specifies the previous version of -# the CVE JSON file. If no file is provided, only the current -# file will be considered. -# Default: empty - -# CVE_FILTER_PREVIOUS_VERSION: Specifies the distro version of -# the previous CVE JSON file. The CVE_FILTER_PREVIOUS_FILE must -# be defined, otherwise the value 0 will be used. -# Example: "1.0.0" -# Default: "0.0.0" - -# CVE_FILTER_MARKDOWN_FILE_NAME: Specifies the name of the -# output Markdown file containing the list of detected CVEs. -# Default: "${IMAGE_NAME}.md" - -# CVE_FILTER_IGNORED_CVES: Lists the CVEs that should be ignored by the filter. -# Example: "CVE-2017-6264 CVE-2023-1234" -# Default: empty - -# CVE_FILTER_SCOREV2_CUTTOFF and CVE_FILTER_SCOREV3_CUTTOFF: -# Set the value of cut off CVE Score to SCOREV2 and V3. CVEs below the value -# set here will no be considered. -# Example: "9" -# Default: "0" - -# Set the PATH to find the old CVE Json list -CVE_FILTER_PREVIOUS_FILE ??= "" -CVE_FILTER_PREVIOUS_VERSION ??= "0.0.0" - -CVE_FILTER_CURRENT_FILE = "${IMGDEPLOYDIR}/${IMAGE_NAME}.json" -CVE_FILTER_CURRENT_VERSION = "${DISTRO_VERSION}" - -# Set the name of markdown output file -CVE_FILTER_MARKDOWN_FILE_NAME ?= "${IMAGE_NAME}.md" -CVE_FILTER_MARKDOWN_FILE = "${IMGDEPLOYDIR}/${CVE_FILTER_MARKDOWN_FILE_NAME}" - -# List of CVE should be ignored Eg: CVE-2023-1234 -CVE_FILTER_IGNORED_CVES ??= "" - -# Cut off score V2 and V3 value -CVE_FILTER_SCOREV2_CUTOFF ??= "0" -CVE_FILTER_SCOREV3_CUTOFF ??= "0" - -inherit python3native - -python do_cve_filter (){ - from ossystems.cve_filter import Cve - - previousFile = d.getVar("CVE_FILTER_PREVIOUS_FILE") - previousVersion = d.getVar("CVE_FILTER_PREVIOUS_VERSION") - cveIgnoreList = d.getVar("CVE_FILTER_IGNORED_CVES").split() - scoreV2CutOff = int(d.getVar("CVE_FILTER_SCOREV2_CUTOFF")) - scoreV3CutOff = int(d.getVar("CVE_FILTER_SCOREV3_CUTOFF")) - - cve_prev = Cve() - cve_prev.setMarkdonFileName(d.getVar("CVE_FILTER_MARKDOWN_FILE")) - cve_curr = Cve() - - if previousFile: - cve_prev.loadCVEfile(previousFile) - cve_prev.setCVEVersion(previousVersion) - cve_prev.setScoreV2CutOff(scoreV2CutOff) - cve_prev.setScoreV3CutOff(scoreV3CutOff) - cve_prev.setIgnoreCVEList(cveIgnoreList) - cve_prev.loadCVEData() - else: - bb.warn("Previous CVE File Not Defined!!!") - - cve_curr.loadCVEfile(d.getVar("CVE_FILTER_CURRENT_FILE")) - cve_curr.setCVEVersion(d.getVar("CVE_FILTER_CURRENT_VERSION")) - cve_curr.setScoreV2CutOff(scoreV2CutOff) - cve_curr.setScoreV3CutOff(scoreV3CutOff) - cve_curr.setIgnoreCVEList(cveIgnoreList) - cve_curr.loadCVEData() - cve_prev.compareCVes(cve_curr) - bb.plain("DONE!!") -} - -do_cve_filter[doc] = "Compare the image CVE report against a previous version and emit a filtered Markdown summary of the new CVEs." -addtask cve_filter after do_rootfs before do_image - -# nooelint: oelint.var.rootfspostcmd the trailing space keeps this prepend apart from the next function -ROOTFS_POSTPROCESS_COMMAND:prepend = "link_cvefilter_markdownfile " - -link_cvefilter_markdownfile[doc] = "Create a stable-named symlink to the CVE filter Markdown report in the deploy directory." -link_cvefilter_markdownfile () { - ln -sf ${CVE_FILTER_MARKDOWN_FILE_NAME} ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.md -} diff --git a/classes/mirrors.bbclass b/classes/mirrors.bbclass deleted file mode 100644 index 68ae9a6..0000000 --- a/classes/mirrors.bbclass +++ /dev/null @@ -1,23 +0,0 @@ -# nooelint: oelint.vars.bbvars.PREMIRRORS set here on purpose: this is the project mirror class -PREMIRRORS:append = " \ - git://sources.redhat.com/ git://sourceware.org/ \ -" - -# nooelint: oelint.vars.bbvars.MIRRORS set here on purpose: this is the project mirror class -MIRRORS += "\ - ${KERNELORG_MIRROR}/ https://kernel.googlesource.com/ \ - ${KERNELORG_MIRROR}/ http://mirror.nexcess.net/kernel.org/ \ - ${KERNELORG_MIRROR}/ http://mirror.gbxs.net/pub/ \ - ${APACHE_MIRROR}/ http://archive.apache.org/dist/ \ - ${DEBIAN_MIRROR}/ ftp://archive.debian.org/debian/pool/ \ - git://git.kernel.org/pub/ http://mirror.nexcess.net/kernel.org/ \ - \ - (ftp|https?)://.*/.* http://autobuilder.yoctoproject.org/sources/ \ - (ftp|https?)://.*/.* http://sources.openembedded.org/ \ - (ftp|https?)://.*/.* http://www.angstrom-distribution.org/unstable/sources/ \ - \ - (cvs|svn|git|gitsm|hg|bzr|osc|p4|svk)://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \ - (cvs|svn|git|gitsm|hg|bzr|osc|p4|svk)://.*/.* http://autobuilder.yoctoproject.org/sources/ \ - (cvs|svn|git|gitsm|hg|bzr|osc|p4|svk)://.*/.* http://sources.openembedded.org/ \ - (cvs|svn|git|gitsm|hg|bzr|osc|p4|svk)://.*/.* http://www.angstrom-distribution.org/unstable/sources/ \ -" diff --git a/classes/restore-dumped-headrevs.bbclass b/classes/restore-dumped-headrevs.bbclass deleted file mode 100644 index 48a9b43..0000000 --- a/classes/restore-dumped-headrevs.bbclass +++ /dev/null @@ -1,32 +0,0 @@ -# nooelint: oelint.bbclass.underscores oelint.file.inlinesuppress_na no EXPORT_FUNCTIONS here, so the dash is harmless -def copy_persist_domain(d, domain, other_db_path, restore=False): - import contextlib - - source_table = bb.persist_data.persist(domain, d) - dest_table = bb.persist_data.SQLTable(other_db_path, domain) - if restore: - source_table, dest_table = dest_table, source_table - - with contextlib.nested(source_table, dest_table): - dest_table.update(source_table) - -def dump_headrevs(d, dump_db_path): - copy_persist_domain(d, 'BB_URI_HEADREVS', dump_db_path) - -def restore_headrevs(d, dump_db_path): - copy_persist_domain(d, 'BB_URI_HEADREVS', dump_db_path, restore=True) - -DUMP_HEADREVS_DB ?= '${COREBASE}/saved_persist_data.db' -DUMP_HEADREVS_STAMP ?= '${STAMP}.restored_headrevs' - -restore_dumped_headrevs[doc] = "Restore dumped BB_URI_HEADREVS persistent data once, at config-parse time, when a dump database is present." -python restore_dumped_headrevs() { - stamp_path = d.getVar('DUMP_HEADREVS_STAMP') - dump_db_path = d.getVar('DUMP_HEADREVS_DB') - if not os.path.exists(stamp_path) and os.path.exists(dump_db_path): - restore_headrevs(d, dump_db_path) - bb.utils.mkdirhier(os.path.dirname(stamp_path)) - open(stamp_path, 'w').close() -} -restore_dumped_headrevs[eventmask] = "bb.event.ConfigParsed" -addhandler restore_dumped_headrevs diff --git a/conf/distro/include/oel.inc b/conf/distro/include/oel.inc index d15893f..fbe1f15 100644 --- a/conf/distro/include/oel.inc +++ b/conf/distro/include/oel.inc @@ -13,19 +13,12 @@ TARGET_VENDOR = "-oel" SDKMACHINE ?= "x86_64" -# Paths -OELDIR ?= "${COREBASE}/.." - SDK_NAME = "${DISTRO}-${TCLIBC}-${SDKMACHINE}-${IMAGE_BASENAME}-${TUNE_PKGARCH}-${MACHINE}" SDKPATHINSTALL = "/opt/${DISTRO}/${SDK_VERSION}" # Move the persist db up out of TMPDIR so it survives its removal PERSISTENT_DIR = "${TOPDIR}/db" -# Restore any available saved headrevs -DUMP_HEADREVS_DB ?= '${OELDIR}/${MACHINE}/saved_persist_data.db' -INHERIT += "restore-dumped-headrevs" - # Share the hashserv DB across builds using the same SSTATE_DIR. Weakest # assignment so a local.conf/site.conf ?= still wins. BB_HASHSERVE_DB_DIR ??= "${SSTATE_DIR}" @@ -76,11 +69,10 @@ INIT_MANAGER ?= "systemd" DISTRO_EXTRA_RDEPENDS += "${OEL_DEFAULT_EXTRA_RDEPENDS}" -DISTRO_FEATURES_OPTED_OUT ?= " \ - acl alsa bluetooth debuginfod ext2 \ - wifi xattr nfs zeroconf pci 3g nfc x11 vfat seccomp pulseaudio \ - gobject-introspection-data ldconfig opengl ptest multiarch wayland vulkan \ -" +# Opt in to OE-Core's default features explicitly instead of opting out of +# the rest: a feature OE-Core later adds to its defaults stays off in oel +# until it is listed here. +DISTRO_FEATURES_DEFAULTS ?= "ipv4 ipv6" # Exclude DATE from DISTRO/SDK_VERSION checksums DISTRO_VERSION[vardepsexclude] = "DATE" @@ -140,9 +132,6 @@ DISTRO_EXTRA_RRECOMMENDS += "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', #### Workarounds & Overrides #### -# Work around missing vardep bug in bitbake -sstate_stage_all[vardeps] += "sstate_stage_dirs" - # Layer name and path for the recipe RECIPE_LAYERNAME = "${@bb.utils.get_file_layer('${FILE}', d) or 'UNKNOWN'}" RECIPE_LAYERDIR = "${LAYERDIR_${RECIPE_LAYERNAME}}" diff --git a/conf/distro/oel-tiny.conf b/conf/distro/oel-tiny.conf index 96ae282..e4d5b09 100644 --- a/conf/distro/oel-tiny.conf +++ b/conf/distro/oel-tiny.conf @@ -68,8 +68,13 @@ DISTRO_FEATURES = " \ ${DISTRO_FEATURES_WIFI} \ " -DISTRO_FEATURES:class-native = "${DISTRO_FEATURES_DEFAULTS} ${OEL_DEFAULT_DISTRO_FEATURES}" -DISTRO_FEATURES:class-nativesdk = "${DISTRO_FEATURES_DEFAULTS} ${OEL_DEFAULT_DISTRO_FEATURES}" +# Native and nativesdk recipes take only the DISTRO_FEATURES_FILTER_NATIVE{,SDK} +# features from here (debuginfod opengl wayland), on top of +# DISTRO_FEATURES_NATIVE{,SDK}. Keep the ones OE-Core enables by default, as +# oel's DISTRO_FEATURES_DEFAULTS no longer carries them. +DISTRO_FEATURES_TINY_NATIVE = "debuginfod opengl wayland ${OEL_DEFAULT_DISTRO_FEATURES}" +DISTRO_FEATURES:class-native = "${DISTRO_FEATURES_TINY_NATIVE}" +DISTRO_FEATURES:class-nativesdk = "${DISTRO_FEATURES_TINY_NATIVE}" # Use tmpdevfs and the busybox runtime services VIRTUAL-RUNTIME_dev_manager = "" diff --git a/conf/layer.conf b/conf/layer.conf index 37efb68..347e4b5 100644 --- a/conf/layer.conf +++ b/conf/layer.conf @@ -10,8 +10,6 @@ BBFILE_PATTERN_ossystems-base := "^${LAYERDIR}/" BBFILE_PRIORITY_ossystems-base = "8" LAYERDEPENDS_ossystems-base = "core" -addpylib ${LAYERDIR}/lib ossystems - LAYERSERIES_COMPAT_ossystems-base = "wrynose" LICENSE_PATH += "${LAYERDIR}/conf/licenses" diff --git a/lib/oeqa/runtime/cases/ossystems_easysplash.py b/lib/oeqa/runtime/cases/ossystems_easysplash.py new file mode 100644 index 0000000..5e65781 --- /dev/null +++ b/lib/oeqa/runtime/cases/ossystems_easysplash.py @@ -0,0 +1,56 @@ +# +# Copyright (C) 2026 O.S. Systems Software LTDA. +# +# SPDX-License-Identifier: MIT +# + +from oeqa.runtime.case import OERuntimeTestCase +from oeqa.core.decorator.depends import OETestDepends +from oeqa.core.decorator.data import skipIfNotFeature +from oeqa.runtime.decorator.package import OEHasPackage + +RUNDIR = '/tmp/oeqa-easysplash' + + +class EasySplashTest(OERuntimeTestCase): + """easysplash: units installed and the open/client protocol works headless.""" + + def run_ok(self, cmd, timeout=None): + status, output = self.target.run(cmd, timeout=timeout) + self.assertEqual(status, 0, msg='%s\n%s' % (cmd, output)) + return output + + @OETestDepends(['ssh.SSHTest.test_ssh']) + @OEHasPackage(['easysplash']) + @skipIfNotFeature('systemd', 'Test requires systemd in DISTRO_FEATURES') + def test_easysplash_units(self): + for unit in ('easysplash-start.service', 'easysplash-quit.service'): + self.assertEqual(self.run_ok('systemctl is-enabled %s' % unit).strip(), 'enabled') + + @OETestDepends(['ssh.SSHTest.test_ssh']) + @OEHasPackage(['easysplash']) + def test_easysplash_open_stop(self): + """Play the installed animation into fakesink, then stop it as a client.""" + status, _ = self.target.run('test -e /usr/lib/easysplash/animation/animation.toml') + if status != 0: + self.skipTest('no animation installed') + try: + self.run_ok('rm -rf %s && mkdir -p %s' % (RUNDIR, RUNDIR)) + self.run_ok("(easysplash open --video-sink fakesink --runtime-dir %s/run " + "--log debug /usr/lib/easysplash/animation > %s/log 2>&1; " + "echo $? > %s/rc) > /dev/null 2>&1 &" % (RUNDIR, RUNDIR, RUNDIR)) + + # The server binds its socket only after the animation was loaded. + status, output = self.target.run( + 'for i in $(seq 1 60); do [ -S %s/run/ipc.socket ] && break; ' + '[ -e %s/rc ] && break; sleep 1; done; cat %s/log' + % (RUNDIR, RUNDIR, RUNDIR), timeout=90) + self.assertNotEqual(self.target.run('test -e %s/rc' % RUNDIR)[0], 0, + msg='easysplash exited before being stopped:\n%s' % output) + + self.run_ok('easysplash client --stop --runtime-dir %s/run' % RUNDIR) + output = self.run_ok('for i in $(seq 1 60); do [ -e %s/rc ] && break; sleep 1; done; ' + 'cat %s/log; cat %s/rc' % (RUNDIR, RUNDIR, RUNDIR), timeout=90) + self.assertEqual(output.splitlines()[-1].strip(), '0', msg=output) + finally: + self.target.run('killall easysplash 2>/dev/null; rm -rf %s' % RUNDIR) diff --git a/lib/oeqa/runtime/cases/ossystems_factory_defaults.py b/lib/oeqa/runtime/cases/ossystems_factory_defaults.py new file mode 100644 index 0000000..a8f1b63 --- /dev/null +++ b/lib/oeqa/runtime/cases/ossystems_factory_defaults.py @@ -0,0 +1,80 @@ +# +# Copyright (C) 2026 O.S. Systems Software LTDA. +# +# SPDX-License-Identifier: MIT +# + +from oeqa.runtime.case import OERuntimeTestCase +from oeqa.core.decorator.depends import OETestDepends +from oeqa.core.decorator.data import skipIfNotFeature +from oeqa.runtime.decorator.package import OEHasPackage + + +class FactoryDefaultsTest(OERuntimeTestCase): + """ossystems-factory-defaults: restore /data from the factory copy once.""" + + @classmethod + def setUpClass(cls): + td = cls.td + cls.runtime_dir = td.get('OSSYSTEMS_FACTORY_DEFAULTS_RUNTIME_DIR') or '/data' + cls.factory_dir = td.get('OSSYSTEMS_FACTORY_DEFAULTS_DIR') or '/usr/share/factory-defaults' + cls.hooks_dir = td.get('OSSYSTEMS_FACTORY_DEFAULTS_HOOKS_DIR') or '/etc/factory-defaults.d' + cls.anchor = cls.runtime_dir + '/.factory-defaults' + if 'systemd' in td.get('DISTRO_FEATURES', '').split(): + cls.program = '/usr/bin/factory-defaults' + else: + cls.program = '/etc/init.d/factory-defaults' + + def run_ok(self, cmd): + status, output = self.target.run(cmd) + self.assertEqual(status, 0, msg='%s\n%s' % (cmd, output)) + return output + + @OETestDepends(['ssh.SSHTest.test_ssh']) + @OEHasPackage(['ossystems-factory-defaults']) + def test_factory_defaults_ran_at_boot(self): + status, output = self.target.run('test -e %s' % self.anchor) + self.assertEqual(status, 0, + msg='%s missing: factory-defaults did not complete at boot' % self.anchor) + + @OETestDepends(['ssh.SSHTest.test_ssh']) + @OEHasPackage(['ossystems-factory-defaults']) + @skipIfNotFeature('systemd', 'Test requires systemd in DISTRO_FEATURES') + def test_factory_defaults_unit(self): + unit = 'ossystems-factory-defaults.service' + self.assertEqual(self.run_ok('systemctl is-enabled %s' % unit).strip(), 'enabled') + output = self.run_ok('systemctl show -p Result -p ExecMainStatus %s' % unit) + props = dict(l.split('=', 1) for l in output.splitlines() if '=' in l) + self.assertEqual(props.get('Result'), 'success', msg=output) + self.assertEqual(props.get('ExecMainStatus'), '0', msg=output) + + @OETestDepends(['ossystems_factory_defaults.FactoryDefaultsTest.test_factory_defaults_ran_at_boot']) + def test_factory_defaults_restore(self): + """Removing the anchor restores the factory files and runs the hooks, once.""" + probe = 'oeqa-factory-probe' + hook = self.hooks_dir + '/zz-oeqa' + marker = '/tmp/oeqa-factory-hook-ran' + setup = ' && '.join([ + 'mkdir -p %s %s' % (self.factory_dir, self.hooks_dir), + 'echo factory > %s/%s' % (self.factory_dir, probe), + 'printf "#!/bin/sh\\ntouch %s\\n" > %s' % (marker, hook), + 'chmod 0755 %s' % hook, + 'rm -f %s %s %s/%s' % (self.anchor, marker, self.runtime_dir, probe), + ]) + cleanup = 'rm -f %s %s %s/%s %s/%s; touch %s' % ( + hook, marker, self.factory_dir, probe, self.runtime_dir, probe, self.anchor) + try: + self.run_ok(setup) + self.run_ok(self.program) + self.assertEqual(self.run_ok('cat %s/%s' % (self.runtime_dir, probe)).strip(), 'factory') + self.run_ok('test -e %s' % marker) + self.run_ok('test -e %s' % self.anchor) + + # With the anchor in place a second run must leave /data alone. + self.run_ok('rm -f %s && echo changed > %s/%s' % (marker, self.runtime_dir, probe)) + self.run_ok(self.program) + self.assertEqual(self.run_ok('cat %s/%s' % (self.runtime_dir, probe)).strip(), 'changed') + status, _ = self.target.run('test -e %s' % marker) + self.assertNotEqual(status, 0, msg='hooks ran again although the anchor exists') + finally: + self.target.run(cleanup) diff --git a/lib/oeqa/runtime/cases/ossystems_net_persistent_mac.py b/lib/oeqa/runtime/cases/ossystems_net_persistent_mac.py new file mode 100644 index 0000000..995a55e --- /dev/null +++ b/lib/oeqa/runtime/cases/ossystems_net_persistent_mac.py @@ -0,0 +1,82 @@ +# +# Copyright (C) 2026 O.S. Systems Software LTDA. +# +# SPDX-License-Identifier: MIT +# + +from oeqa.runtime.case import OERuntimeTestCase +from oeqa.core.decorator.depends import OETestDepends +from oeqa.core.decorator.data import skipIfNotFeature +from oeqa.runtime.decorator.package import OEHasPackage + +DEFAULTS = '/etc/default/net-persistent-mac' + + +class NetPersistentMacTest(OERuntimeTestCase): + """net-persistent-mac: store each interface's MAC once, restore it after.""" + + def run_ok(self, cmd): + status, output = self.target.run(cmd) + self.assertEqual(status, 0, msg='%s\n%s' % (cmd, output)) + return output + + def config(self): + out = self.run_ok('. %s; echo "$INTERFACES"; echo "$MAC_DIR"' % DEFAULTS) + lines = out.splitlines() + return lines[0].split(), lines[1].strip() + + @OETestDepends(['ssh.SSHTest.test_ssh']) + @OEHasPackage(['net-persistent-mac']) + @skipIfNotFeature('systemd', 'Test requires systemd in DISTRO_FEATURES') + def test_net_persistent_mac_unit(self): + unit = 'net-persistent-mac.service' + self.assertEqual(self.run_ok('systemctl is-enabled %s' % unit).strip(), 'enabled') + output = self.run_ok('systemctl show -p Result -p ExecMainStatus %s' % unit) + props = dict(l.split('=', 1) for l in output.splitlines() if '=' in l) + self.assertEqual(props.get('Result'), 'success', msg=output) + self.assertEqual(props.get('ExecMainStatus'), '0', msg=output) + + @OETestDepends(['ssh.SSHTest.test_ssh']) + @OEHasPackage(['net-persistent-mac']) + def test_net_persistent_mac_stored(self): + """Every configured interface that exists has its MAC stored, nothing else.""" + interfaces, mac_dir = self.config() + expected = set() + for iface in interfaces: + status, current = self.target.run('cat /sys/class/net/%s/address' % iface) + if status != 0: + continue + expected.add('%s.mac' % iface) + stored = self.run_ok('cat %s/%s.mac' % (mac_dir, iface)).strip() + self.assertEqual(stored, current.strip()) + if not expected: + self.skipTest('none of %s exists on this target' % interfaces) + present = set(self.run_ok('ls -A %s' % mac_dir).split()) + self.assertEqual(present, expected, msg='unexpected files in %s' % mac_dir) + + @OETestDepends(['ssh.SSHTest.test_ssh']) + @OEHasPackage(['net-persistent-mac']) + def test_net_persistent_mac_restore(self): + """A stored MAC is applied to the interface (on a dummy interface).""" + iface = 'oeqa0' + wanted = '02:00:5e:10:20:30' + status, output = self.target.run('ip link add %s type dummy' % iface) + if status != 0: + self.skipTest('cannot create a dummy interface: %s' % output) + _, mac_dir = self.config() + try: + self.run_ok('cp %s /tmp/oeqa-npm.default' % DEFAULTS) + self.run_ok('sed -i "s/^INTERFACES=.*/INTERFACES=\\"%s\\"/" %s' % (iface, DEFAULTS)) + + # First run stores the current MAC. + current = self.run_ok('cat /sys/class/net/%s/address' % iface).strip() + self.run_ok('net-persistent-mac') + self.assertEqual(self.run_ok('cat %s/%s.mac' % (mac_dir, iface)).strip(), current) + + # A later run restores the stored one. + self.run_ok('echo %s > %s/%s.mac' % (wanted, mac_dir, iface)) + self.run_ok('net-persistent-mac') + self.assertEqual(self.run_ok('cat /sys/class/net/%s/address' % iface).strip(), wanted) + finally: + self.target.run('mv /tmp/oeqa-npm.default %s; ip link del %s; rm -f %s/%s.mac' + % (DEFAULTS, iface, mac_dir, iface)) diff --git a/lib/oeqa/runtime/cases/ossystems_zram_init.py b/lib/oeqa/runtime/cases/ossystems_zram_init.py new file mode 100644 index 0000000..68e728e --- /dev/null +++ b/lib/oeqa/runtime/cases/ossystems_zram_init.py @@ -0,0 +1,43 @@ +# +# Copyright (C) 2026 O.S. Systems Software LTDA. +# +# SPDX-License-Identifier: MIT +# + +from oeqa.runtime.case import OERuntimeTestCase +from oeqa.core.decorator.depends import OETestDepends +from oeqa.core.decorator.data import skipIfNotFeature +from oeqa.runtime.decorator.package import OEHasPackage + + +class ZramInitTest(OERuntimeTestCase): + """zram-init: zram_swap.service sets up a zram swap device at boot.""" + + @OETestDepends(['ssh.SSHTest.test_ssh']) + @OEHasPackage(['zram-init']) + @skipIfNotFeature('systemd', 'Test requires systemd in DISTRO_FEATURES') + def test_zram_swap(self): + status, output = self.target.run('modprobe zram 2>/dev/null; test -e /sys/class/zram-control') + if status != 0: + self.skipTest('kernel has no zram support') + + status, output = self.target.run('systemctl is-active zram_swap.service') + if status != 0: + output += self.target.run('systemctl status --full zram_swap.service')[1] + self.assertEqual(status, 0, msg=output) + + status, output = self.target.run('cat /proc/swaps') + self.assertIn('/dev/zram', output, msg='no zram swap active:\n%s' % output) + + # Stopping must tear the device down cleanly so it can start again. + status, output = self.target.run('systemctl stop zram_swap.service') + self.assertEqual(status, 0, msg=output) + status, output = self.target.run('systemctl is-failed zram_swap.service') + self.assertNotEqual(output.strip(), 'failed', + msg=self.target.run('systemctl status --full zram_swap.service')[1]) + status, output = self.target.run('cat /proc/swaps') + self.assertNotIn('/dev/zram', output, msg='zram swap still active after stop:\n%s' % output) + + status, output = self.target.run('systemctl start zram_swap.service') + self.assertEqual(status, 0, + msg=self.target.run('systemctl status --full zram_swap.service')[1]) diff --git a/lib/ossystems/__init__.py b/lib/ossystems/__init__.py deleted file mode 100644 index 8e5d5cb..0000000 --- a/lib/ossystems/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from pkgutil import extend_path -__path__ = extend_path(__path__, __name__) - -BBIMPORTS = ["cve_filter"] diff --git a/lib/ossystems/cve_filter.py b/lib/ossystems/cve_filter.py deleted file mode 100644 index 6ea3b34..0000000 --- a/lib/ossystems/cve_filter.py +++ /dev/null @@ -1,357 +0,0 @@ -import argparse -import json -import sys - - -# Class to store the CVE data -class Issue: - def __init__(self, id, summary, scorev2, scorev3, vector, status, link): - self.id = id - self.summary = summary - self.scorev2 = scorev2 - self.scorev3 = scorev3 - self.vector = vector - self.status = status - self.link = link - - def __eq__(self, other): - return self.id == other.id - - def __hash__(self): - return hash(self.id) - - def __str__(self): - return self.id - - def toTuple(self): - return ( - self.id, - self.summary, - self.scorev2, - self.scorev3, - self.vector, - self.status, - self.link, - ) - - -# Class to store the filtered and ready to print CVes -class CVEFilter: - def __init__(self, name, status): - self.name = name - self.status = status - self.both = [] - self.patched = [] - self.old = [] - self.new = [] - - def setVersion(self, version1, version2=0): - self.version1 = version1 - self.version2 = version2 - - def addCVEBoth(self, issue): - self.both.append(issue) - - def addCVEPatched(self, issue): - self.patched.append(issue) - - def addCVEOld(self, issue): - self.old.append(issue) - - def addCVENew(self, issue): - self.new.append(issue) - - -# Class to store the Package with the list of Issues -class Package: - def __init__(self, name, version): - self.name = name - self.version = version - self.cve = [] - - def addCVE(self, cve): - self.cve.append(cve) - - -# Class to handle CVEs -class Cve: - def __init__(self): - self.__markdownFileName = "output.md" - self.__packages = [] - self.__printIssues = [] - self.__ignored_cves = [] - self.__version = 0 - self.__scoreV2cf = 0 - self.__scoreV3cf = 0 - - # def __del__ (self): - # self.__cveJsonFile.close() - - def loadCVEfile(self, fileName): - try: - self.__cveJsonFile = open(fileName, "r") - try: - self.__jsonData = json.load(self.__cveJsonFile) - except ValueError as e: - print("Fail on JSON file: " + fileName) - print(e) - self.__jsonPackages = self.__jsonData["package"] - - except FileNotFoundError: - print("File not found or wrong file name! " + fileName) - exit(1) - except: - print("Error to open file!") - exit(1) - - def setMarkdonFileName(self, name): - if name: - self.__markdownFileName = name - - def setIgnoreCVEList(self, listcve): - self.__ignored_cves = list(listcve) - - def setCVEVersion(self, version=0): - self.__version = version - - def setScoreV2CutOff(self, score): - self.__scoreV2cf = score - - def setScoreV3CutOff(self, score): - self.__scoreV3cf = score - - def getCVEPackages(self): - return self.__packages - - def getCVEVersion(self): - return self.__version - - def printCVEs(self): - print(self.__jsonData["package"]) - - def loadCVEData(self): - for pack in self.__jsonPackages: - p = Package(pack["name"], pack["version"]) - entry = False - for id in pack["issue"]: - if (float(id["scorev2"]) >= self.__scoreV2cf or float(id["scorev3"]) >= self.__scoreV3cf) and id[ - "status" - ] != "Ignored": - if not (id["id"] in self.__ignored_cves): - p.addCVE( - Issue( - id["id"], - id["summary"], - id["scorev2"], - id["scorev3"], - id["vector"], - id["status"], - id["link"], - ) - ) - entry = True - if entry: - self.__packages.append(p) - - def __creatMarkdownFile(self): - try: - self.__markdownFile = open(self.__markdownFileName, "w") - except: - print("ERROR to create the Markdown output file") - exit(1) - - def printUnpatchedListCVEs(self): - for package in self.__packages: - print("--------------- PACKAGE -----------------") - print(package.name) - print(package.version) - print("=============== ISSUES ==================") - for id in package.cve: - if id.status != "Patched": - print(id.id) - print(id.scorev2) - print(id.scorev3) - print(id.status) - - def compareCVes(self, compCVE): - self.__creatMarkdownFile() - packagesNew = compCVE.getCVEPackages() - for packageOld in self.__packages: - contain = False - for packageNew in packagesNew: - if packageOld.name == packageNew.name: - # This case if the package has the same version - if packageOld.version == packageNew.version: - cveOutput = CVEFilter(packageOld.name, "Kept") - cveOutput.setVersion(packageOld.version) - self.__checkIssues(cveOutput, packageOld.cve, packageNew.cve) - self.__printIssues.append(cveOutput) - # remove package that has comparated - packagesNew.remove(packageNew) - contain = True - break - - # This case if the package was upgrated - elif packageOld.version < packageNew.version: - cveOutput = CVEFilter(packageOld.name, "Updated") - cveOutput.setVersion(packageOld.version, packageNew.version) - self.__checkIssues(cveOutput, packageOld.cve, packageNew.cve) - self.__printIssues.append(cveOutput) - # remove package that has comparated - packagesNew.remove(packageNew) - contain = True - break - - # This case if the package was Downgrade - else: - cveOutput = CVEFilter(packageOld.name, "Downgraded") - cveOutput.setVersion(packageOld.version, packageNew.version) - self.__checkIssues(cveOutput, packageOld.cve, packageNew.cve) - self.__printIssues.append(cveOutput) - # remove package that has comparated - packagesNew.remove(packageNew) - contain = True - break - - # This case is when the package was removed - if not contain: - cveOutput = CVEFilter(packageOld.name, "Removed") - cveOutput.setVersion(packageOld.version) - self.__checkIssues(cveOutput, packageOld.cve, []) - self.__printIssues.append(cveOutput) - # remove package that has comparated - # For all cases that packages was added - for newpackage in packagesNew: - cveOutput = CVEFilter(newpackage.name, "Added") - cveOutput.setVersion(newpackage.version) - self.__checkIssues(cveOutput, [], newpackage.cve) - self.__printIssues.append(cveOutput) - # remove package that has comparated - self.__printCVEs( - self.__printIssues, self.getCVEVersion(), compCVE.getCVEVersion() - ) - - def __checkIssues(self, cveOut, cveListOld, cveListNew): - cveOut.new = cveListNew.copy() - if cveListOld and cveListNew: - for cveold in cveListOld: - contain = False - for cvenew in cveOut.new: - if cveold.id == cvenew.id: - if (cveold.status == cvenew.status) and ( - cvenew.status == "Unpatched" - ): - cveOut.addCVEBoth(cveold) - cveOut.new.remove(cvenew) - contain = True - break - elif (cveold.status == cvenew.status) and ( - cvenew.status == "Patched" - ): - cveOut.new.remove(cvenew) - contain = True - break - elif (cveold.status != cvenew.status) and ( - cvenew.status == "Patched" - ): - cveOut.addCVEPatched(cvenew) - cveOut.new.remove(cvenew) - contain = True - break - elif (cveold.status != cvenew.status) and ( - cvenew.status == "Unpatched" - ): - cveOut.addCVENew(cvenew) - cveOut.new.remove(cvenew) - contain = True - break - if not contain: - cveOut.addCVEOld(cveold) - elif cveListNew: - for cveNew in cveListNew: - if cveNew.status == "Patched": - cveOut.new.remove(cveNew) - else: - for cveOld in cveListOld: - if cveOld.status != "Patched": - cveOut.addCVEOld(cveOld) - - def __printCVEs(self, cvePrint, v1, v2): - self.__markdownFile.write(f"# {v1} -> {v2}") - for cve in cvePrint: - if cve.old or cve.both or cve.patched or cve.new: - if cve.status == "Updated" or cve.status == "Downgraded": - self.__markdownFile.write("\n") - self.__markdownFile.write( - "## " - + cve.name - + ": " - + cve.version1 - + " -> " - + cve.version2 - + " : " - + cve.status - + "\n" - ) - else: - self.__markdownFile.write("\n") - self.__markdownFile.write( - "## " - + cve.name - + ": " - + cve.version1 - + " : " - + cve.status - + "\n" - ) - self.__printIs(cve) - - def __printIs(self, issue): - if issue.both: - if issue.status == "Updated" or issue.status == "Downgraded": - self.__markdownFile.write("\n### Affect both versions\n") - else: - self.__markdownFile.write("\n### Unsolved\n") - self.__markdownFile.write("| CVE | STATUS | SCORE V2 | SCORE V3 |\n") - self.__markdownFile.write("|:--|:--:|:--:|:---:|\n") - s = ' Vulnerable ' - for i in issue.both: - self.__markdownFile.write( - f"|[{i.id}]({i.link})|{s}|{i.scorev2}|{i.scorev3}|\n" - ) - - if issue.patched: - self.__markdownFile.write("\n### Fixed in new revision\n") - self.__markdownFile.write("| CVE | STATUS | SCORE V2 | SCORE V3 |\n") - self.__markdownFile.write("|:--|:--:|:--:|:---:|\n") - s = ' Patched ' - for i in issue.patched: - self.__markdownFile.write( - f"|[{i.id}]({i.link})|{s}|{i.scorev2}|{i.scorev3}|\n" - ) - - if issue.old: - if issue.status == "Removed": - self.__markdownFile.write("\n### Affected the removed version\n") - else: - self.__markdownFile.write("\n### Affect the old version\n") - self.__markdownFile.write("| CVE | STATUS | SCORE V2 | SCORE V3 |\n") - self.__markdownFile.write("|:--|:--:|:--:|:---:|\n") - s = ' Vulnerable ' - for i in issue.old: - self.__markdownFile.write( - f"|[{i.id}]({i.link})|{s}|{i.scorev2}|{i.scorev3}|\n" - ) - - if issue.new: - if issue.status == "Updated" or issue.status == "Downgraded": - self.__markdownFile.write("\n### New Issues added\n") - else: - self.__markdownFile.write("\n### Affect only new revision\n") - self.__markdownFile.write("| CVE | STATUS | SCORE V2 | SCORE V3 |\n") - self.__markdownFile.write("|:--|:--:|:--:|:---:|\n") - s = ' Vulnerable ' - for i in issue.new: - self.__markdownFile.write( - f"|[{i.id}]({i.link})|{s}|{i.scorev2}|{i.scorev3}|\n" - ) diff --git a/recipes-core/net-persistent-mac/net-persistent-mac/net-persistent-mac b/recipes-core/net-persistent-mac/net-persistent-mac/net-persistent-mac index ce748b3..495511a 100644 --- a/recipes-core/net-persistent-mac/net-persistent-mac/net-persistent-mac +++ b/recipes-core/net-persistent-mac/net-persistent-mac/net-persistent-mac @@ -6,8 +6,6 @@ set -e mkdir -p "$MAC_DIR" -IF_FILE="$MAC_DIR/$INTERFACE.mac" - for if in $INTERFACES; do mkdir -p "$MAC_DIR" IF_FILE="$MAC_DIR/$if.mac" @@ -28,25 +26,7 @@ for if in $INTERFACES; do WANTED_MAC=`cat $IF_FILE` if [ "$WANTED_MAC" != "`cat $IF_MAC`" ]; then echo "Setting MAC of $if to $WANTED_MAC." - ifconfig $if hw ether "$WANTED_MAC" + ip link set dev "$if" address "$WANTED_MAC" fi fi done -# Store MAC for reuse -if [ ! -r "$IF_FILE" ]; then - if [ -e "$IF_MAC" ]; then - echo "Storing MAC for $INTERFACE for future use." - cat "$IF_MAC" > "$IF_FILE" - else - echo "Failed to read MAC for $INTERFACE; skiping device." - fi -fi - -if [ -r "$IF_FILE" ]; then - # Restore MAC setting - WANTED_MAC=`cat $IF_FILE` - if [ "$WANTED_MAC" != "`cat $IF_MAC`" ]; then - echo "Setting MAC of $INTERFACE to $WANTED_MAC." - ifconfig $INTERFACE hw ether "$WANTED_MAC" - fi -fi diff --git a/recipes-extended/zram-init/zram-init/0001-zram_swap.service-Read-the-RAM-size-from-proc-meminf.patch b/recipes-extended/zram-init/zram-init/0001-zram_swap.service-Read-the-RAM-size-from-proc-meminf.patch new file mode 100644 index 0000000..7d54206 --- /dev/null +++ b/recipes-extended/zram-init/zram-init/0001-zram_swap.service-Read-the-RAM-size-from-proc-meminf.patch @@ -0,0 +1,32 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Luciano Dittgen +Date: Tue, 17 Nov 2026 15:31:20 -0300 +Subject: [PATCH] zram_swap.service: Read the RAM size from /proc/meminfo + +The unit sizes the swap device from "free -m". BusyBox free ignores -m +and prints KiB, so on a BusyBox system the device is requested 1024 +times too large (110880 MB on a 216 MiB machine). The kernel cannot +allocate it and zram-init fails with "cannot set zram0 size". + +Take MemTotal from /proc/meminfo, which is in KiB everywhere, and halve +it into MiB. This also drops the dependency on procps. + +Upstream-Status: Pending +Signed-off-by: Luciano Dittgen +--- + systemd/system/zram_swap.service | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/systemd/system/zram_swap.service b/systemd/system/zram_swap.service +index 99aae6e..19afea5 100644 +--- a/systemd/system/zram_swap.service ++++ b/systemd/system/zram_swap.service +@@ -14,7 +14,7 @@ RemainAfterExit=true + # zram_tmp.service and zram_var_tmp.service and that + # num_devices in modprobe.d/zram.conf contains the maximal used number + 1 + +-ExecStart=/bin/sh -c "exec /sbin/zram-init -azstd -Lzram_swap `LC_ALL=C free -m | awk '/^Mem:/{print int($2/2)}'`" ++ExecStart=/bin/sh -c "exec /sbin/zram-init -azstd -Lzram_swap `awk '/^MemTotal:/{print int($2/2048)}' /proc/meminfo`" + ExecStop=/sbin/zram-init 0 + + [Install] diff --git a/recipes-extended/zram-init/zram-init/0002-zram-init-Pass-the-device-number-to-hot_remove.patch b/recipes-extended/zram-init/zram-init/0002-zram-init-Pass-the-device-number-to-hot_remove.patch new file mode 100644 index 0000000..3de8f4d --- /dev/null +++ b/recipes-extended/zram-init/zram-init/0002-zram-init-Pass-the-device-number-to-hot_remove.patch @@ -0,0 +1,32 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Luciano Dittgen +Date: Tue, 17 Nov 2026 15:31:12 -0300 +Subject: [PATCH] zram-init: Pass the device number to hot_remove + +The zram-control hot_remove attribute takes the device id ("0"), not +the device node path. Writing "/dev/zram0" fails with EINVAL, so +"zram-init 0" reports "failed to reset zram0" and exits 1 even though +the swap was turned off and the device reset. Under systemd this makes +ExecStop of zram_swap.service fail. + +Write $dev instead of $devnode. + +Upstream-Status: Pending +Signed-off-by: Luciano Dittgen +--- + sbin/zram-init.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/sbin/zram-init.in b/sbin/zram-init.in +index f577cfc..56d9108 100755 +--- a/sbin/zram-init.in ++++ b/sbin/zram-init.in +@@ -346,7 +346,7 @@ then if $swap + then zramctl --reset -- "$devnode" || status=$? + else SysCtl 1 "$block/reset" || status=$? + if $umount && test -w "$zclass/hot_remove" +- then SysCtl "$devnode" "$zclass/hot_remove" \ ++ then SysCtl "$dev" "$zclass/hot_remove" \ + || status=$? + fi + fi diff --git a/recipes-extended/zram-init/zram-init/zram-init.init b/recipes-extended/zram-init/zram-init/zram-init.init new file mode 100644 index 0000000..4a4454a --- /dev/null +++ b/recipes-extended/zram-init/zram-init/zram-init.init @@ -0,0 +1,41 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: zram-init +# Required-Start: $local_fs +# Required-Stop: $local_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Swap on a compressed zram device +### END INIT INFO +# +# The sysvinit counterpart of zram_swap.service: a zram swap device of +# half the RAM. Override ZRAM_SIZE (MiB) and ZRAM_ALGO in +# /etc/default/zram-init. + +ZRAM_ALGO=zstd +ZRAM_SIZE= + +[ -r /etc/default/zram-init ] && . /etc/default/zram-init + +[ -n "$ZRAM_SIZE" ] || \ + ZRAM_SIZE=$(awk '/^MemTotal:/{print int($2/2048)}' /proc/meminfo) + +case "$1" in +start) + /sbin/zram-init ${ZRAM_ALGO:+-a"$ZRAM_ALGO"} -Lzram_swap "$ZRAM_SIZE" + ;; +stop) + /sbin/zram-init 0 + ;; +restart|force-reload) + "$0" stop + "$0" start + ;; +status) + grep -q '^/dev/zram0 ' /proc/swaps + ;; +*) + echo "Usage: $0 {start|stop|restart|force-reload|status}" >&2 + exit 2 + ;; +esac diff --git a/recipes-extended/zram-init/zram-init_13.3.bb b/recipes-extended/zram-init/zram-init_13.3.bb index 110cabd..a591138 100644 --- a/recipes-extended/zram-init/zram-init_13.3.bb +++ b/recipes-extended/zram-init/zram-init_13.3.bb @@ -12,7 +12,12 @@ inherit update-rc.d systemd DEPENDS += "gettext-native" PE = "1" -SRC_URI = "git://github.com/vaeth/zram-init;protocol=https;branch=main" +SRC_URI = "\ + git://github.com/vaeth/zram-init;protocol=https;branch=main \ + file://0001-zram_swap.service-Read-the-RAM-size-from-proc-meminf.patch \ + file://0002-zram-init-Pass-the-device-number-to-hot_remove.patch \ + file://zram-init.init \ +" SRCREV = "96579c79295da74cc1921270946b99baa035d0d3" EXTRA_OEMAKE += "SHEBANG='#!/bin/sh'" @@ -35,8 +40,7 @@ do_install () { install -Dm 0644 ${S}/systemd/system/zram_swap.service ${D}${systemd_unitdir}/system/zram_swap.service fi if ${@bb.utils.contains('DISTRO_FEATURES','sysvinit','true','false',d)}; then - install -Dm 0755 ${S}/openrc/init.d/${PN} ${D}/${sysconfdir}/init.d/${PN} - install -Dm 0644 ${S}/openrc/conf.d/${PN} ${D}${sysconfdir}/openrc/conf.d/${PN} + install -Dm 0755 ${UNPACKDIR}/zram-init.init ${D}${sysconfdir}/init.d/${PN} fi } diff --git a/recipes-staging/gstreamer/gstreamer1.0-plugins-base_%.bbappend b/recipes-staging/gstreamer/gstreamer1.0-plugins-base_%.bbappend deleted file mode 100644 index 414d584..0000000 --- a/recipes-staging/gstreamer/gstreamer1.0-plugins-base_%.bbappend +++ /dev/null @@ -1,2 +0,0 @@ -PACKAGECONFIG[viv-fb] = ",,virtual/libgles2 virtual/libg2d" -OPENGL_WINSYS:append:oel = " ${@bb.utils.contains('PACKAGECONFIG', 'viv-fb', 'viv-fb', '', d)}"