### BitBake Append (.bbappend) File Examples Source: https://context7.com/openembedded/meta-openembedded/llms.txt Demonstrates how to use .bbappend files to customize existing BitBake recipes. This includes adding or removing dependencies, modifying configurations, applying patches, and overriding installation steps, all within a layer-specific context. ```bitbake # meta-oe/dynamic-layers/meta-python/recipes-core/packagegroups/packagegroup-meta-oe.bbappend # Add Python-dependent packages only when meta-python layer is present: RDEPENDS:packagegroup-meta-oe-devtools += " python3-distutils-extra rwmem" # Remove packages incompatible with musl libc: RDEPENDS:packagegroup-meta-oe-extended:remove:libc-musl = "lcdproc" # Architecture-specific overrides: RDEPENDS:packagegroup-meta-oe-benchmark:remove:riscv64 = "fio" RDEPENDS:packagegroup-meta-oe-benchmark:remove:riscv32 = "fio" # Add conditional dependencies: RDEPENDS:${PN} += "${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'weston', '', d)}" # Modify configuration flags: PACKAGECONFIG:append = " ssl websockets" PACKAGECONFIG:remove = "systemd" # Add patches: SRC_URI += "file://custom-feature.patch" # Override install steps: do_install:append() { install -d ${D}${sysconfdir}/custom install -m 0644 ${WORKDIR}/custom.conf ${D}${sysconfdir}/custom/ } ``` -------------------------------- ### BitBake Recipe for Mosquitto MQTT Broker Source: https://context7.com/openembedded/meta-openembedded/llms.txt Defines metadata, dependencies, source, and build instructions for the Mosquitto MQTT broker using BitBake's declarative syntax. It includes configuration for SSL, websockets, systemd integration, and custom installation steps for services and scripts. ```bitbake SUMMARY = "Open source MQTT implementation" DESCRIPTION = "Mosquitto is an open source (Eclipse licensed) message broker that implements the MQ Telemetry Transport protocol version 3.1, 3.1.1 and 5, providing both an MQTT broker and several command-line clients. MQTT provides a lightweight method of carrying out messaging using a publish/subscribe model." HOMEPAGE = "http://mosquitto.org/" SECTION = "console/network" LICENSE = "EPL-2.0 | EDL-1.0" LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=ca9a8f366c6babf593e374d0d7d58749 file://edl-v10;md5=9f6accb1afcb570f8be65039e2fcd49e file://epl-v20;md5=2dd765ca47a05140be15ebafddbeadfe file://NOTICE.md;md5=a7a91b4754c6f7995020d1b49bc829c6" DEPENDS = "uthash cjson" SRC_URI = "http://mosquitto.org/files/source/mosquitto-${PV}.tar.gz file://mosquitto.init file://2895.patch" SRC_URI[sha256sum] = "2f752589ef7db40260b633fbdb536e9a04b446a315138d64a7ff3c14e2de6b68" inherit systemd update-rc.d useradd cmake pkgconfig PACKAGECONFIG ??= "ssl websockets ${@bb.utils.filter('DISTRO_FEATURES','systemd', d)}" PACKAGECONFIG[manpages] = "-DDOCUMENTATION=ON,-DDOCUMENTATION=OFF,libxslt-native docbook-xsl-stylesheets-native" PACKAGECONFIG[dns-srv] = "-DWITH_SRV=ON,-DWITH_SRV=OFF,c-ares" PACKAGECONFIG[ssl] = "-DWITH_TLS=ON -DWITH_TLS_PSK=ON -DWITH_EC=ON,-DWITH_TLS=OFF -DWITH_TLS_PSK=OFF -DWITH_EC=OFF,openssl" PACKAGECONFIG[systemd] = "-DWITH_SYSTEMD=ON,-DWITH_SYSTEMD=OFF,systemd" PACKAGECONFIG[websockets] = "-DWITH_WEBSOCKETS=ON,-DWITH_WEBSOCKETS=OFF,libwebsockets" EXTRA_OECMAKE = " -DWITH_BUNDLED_DEPS=OFF -DWITH_ADNS=ON" do_install:append() { install -d ${D}${systemd_unitdir}/system/ install -m 0644 ${S}/service/systemd/mosquitto.service.notify ${D}${systemd_unitdir}/system/mosquitto.service install -d ${D}${sysconfdir}/init.d/ install -m 0755 ${UNPACKDIR}/mosquitto.init ${D}${sysconfdir}/init.d/mosquitto sed -i -e 's,@SBINDIR@,${sbindir},g' -e 's,@LOCALSTATEDIR@,${localstatedir},g' ${D}${sysconfdir}/init.d/mosquitto } PACKAGES += "libmosquitto1 libmosquittopp1 ${PN}-clients" FILES:${PN} = "${sbindir}/mosquitto ${bindir}/mosquitto_passwd ${bindir}/mosquitto_ctrl ${sysconfdir}/mosquitto ${systemd_unitdir}/system/mosquitto.service" FILES:libmosquitto1 = "${libdir}/libmosquitto.so.*" FILES:${PN}-clients = "${bindir}/mosquitto_pub ${bindir}/mosquitto_sub ${bindir}/mosquitto_rr" SYSTEMD_SERVICE:${PN} = "mosquitto.service" INITSCRIPT_NAME = "mosquitto" INITSCRIPT_PARAMS = "defaults 30" USERADD_PACKAGES = "${PN}" USERADD_PARAM:${PN} = "--system --no-create-home --shell /bin/false --user-group mosquitto" BBCLASSEXTEND = "native" ``` -------------------------------- ### Create XFCE Minimal Demo Image with BitBake Source: https://context7.com/openembedded/meta-openembedded/llms.txt This BitBake recipe defines a minimal XFCE desktop image by installing core boot, X11, and XFCE base package groups. It requires the 'x11' DISTRO_FEATURE and allows for customization by adding extra packages like Firefox, GIMP, or VLC. The image is built using `bitbake core-image-minimal-xfce`. ```bitbake DESCRIPTION = "A XFCE minimal demo image." IMAGE_INSTALL = "packagegroup-core-boot \ packagegroup-core-x11 \ packagegroup-xfce-base \ kernel-modules" inherit features_check REQUIRED_DISTRO_FEATURES = "x11" IMAGE_LINGUAS ?= " " LICENSE = "MIT" export IMAGE_BASENAME = "core-image-minimal-xfce" inherit core-image SYSTEMD_DEFAULT_TARGET = "graphical.target" # Build the image: # bitbake core-image-minimal-xfce # Customize by adding packages: IMAGE_INSTALL += "firefox gimp vlc" # Or create derived image: require recipes-xfce/images/core-image-minimal-xfce.bb IMAGE_INSTALL += "development-tools networking-tools" ``` -------------------------------- ### FUSE Filesystem Integration (BitBake Recipe) Source: https://context7.com/openembedded/meta-openembedded/llms.txt This BitBake recipe provides instructions for building and installing FUSE (Filesystem in Userspace) support. It includes metadata, source URI, build system integration (autotools, pkgconfig), and package management details for the FUSE utilities and libraries. It also handles systemd integration if enabled. ```bitbake SUMMARY = "Implementation of a fully functional filesystem in a userspace program" DESCRIPTION = "FUSE (Filesystem in Userspace) is a simple interface for userspace \ programs to export a virtual filesystem to the Linux kernel. FUSE \ also aims to provide a secure method for non privileged users to \ create and mount their own filesystem implementations." HOMEPAGE = "https://github.com/libfuse/libfuse" SECTION = "libs" LICENSE = "GPL-2.0-only & LGPL-2.0-only" LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \ file://COPYING.LIB;md5=4fbd65380cdd255951079008b364516c" SRC_URI = "https://github.com/libfuse/libfuse/releases/download/${BP}/${BP}.tar.gz \ file://aarch64.patch \ file://0001-fuse-fix-the-return-value-of-help-option.patch \ file://fuse.conf" SRC_URI[sha256sum] = "d0e69d5d608cc22ff4843791ad097f554dd32540ddc9bed7638cc6fea7c1b4b5" inherit autotools pkgconfig update-rc.d systemd INITSCRIPT_NAME = "fuse" INITSCRIPT_PARAMS = "start 3 S . stop 20 0 6 ." DEPENDS = "gettext-native" PACKAGES =+ "fuse-utils libulockmgr libulockmgr-dev" RRECOMMENDS:${PN}:class-target = "kernel-module-fuse libulockmgr fuse-utils" FILES:${PN} += "${libdir}/libfuse.so.*" FILES:libulockmgr = "${libdir}/libulockmgr.so.*" FILES:fuse-utils = "${bindir} ${base_sbindir}" do_configure:prepend() { export MOUNT_FUSE_PATH="${base_sbindir}" } do_install:append() { rm -rf ${D}/dev if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then install -d ${D}${sysconfdir}/modules-load.d install -m 0644 ${UNPACKDIR}/fuse.conf ${D}${sysconfdir}/modules-load.d fi } BBCLASSEXTEND = "native nativesdk" ``` -------------------------------- ### Define Base XFCE Package Group with BitBake Source: https://context7.com/openembedded/meta-openembedded/llms.txt This BitBake recipe defines the base package group for XFCE, requiring the 'x11' DISTRO_FEATURE. It lists core XFCE components and plugins as dependencies, such as 'xfwm4', 'xfce4-session', and various 'xfce4-panel-plugin' packages. This group is intended for installation in an image recipe. ```bitbake SUMMARY = "All packages required for a base installation of XFCE" SECTION = "x11/wm" PACKAGE_ARCH = "${TUNE_PKGARCH}" inherit packagegroup features_check REQUIRED_DISTRO_FEATURES = "x11" RDEPENDS:${PN} = " \ xfwm4 \ xfce4-session \ xfconf \ xfdesktop \ xfce4-panel \ librsvg-gtk \ xfce4-panel-plugin-actions \ xfce4-panel-plugin-applicationsmenu \ xfce4-panel-plugin-clock \ xfce4-panel-plugin-directorymenu \ xfce4-panel-plugin-launcher \ xfce4-panel-plugin-pager \ xfce4-panel-plugin-separator \ xfce4-panel-plugin-showdesktop \ xfce4-panel-plugin-systray \ xfce4-panel-plugin-tasklist \ xfce4-panel-plugin-windowmenu \ xfce4-settings \ xfce4-notifyd \ xfce4-terminal \ thunar \ thunar-volman" ``` -------------------------------- ### Get Git Package Version (BitBake Class) Source: https://context7.com/openembedded/meta-openembedded/llms.txt Defines a BitBake class 'gitpkgv' to dynamically generate package versions based on Git repository information. It can extract versions from tags or generate a version based on commit count and revision. Dependencies include the 'bb' module and 'shlex.quote'. ```bitbake # Implementation (gitpkgv.bbclass): GITPKGV = "${@get_git_pkgv(d, False)}" GITPKGVTAG = "${@get_git_pkgv(d, True)}" # Customize tag regex for version extraction: GITPKGV_TAG_REGEXP ??= "v(\d.*)" def get_git_pkgv(d, use_tags): import os import bb from shlex import quote src_uri = d.getVar('SRC_URI').split() unpackdir = d.getVar('UNPACKDIR') fetcher = bb.fetch2.Fetch(src_uri, d) ud = fetcher.ud for url in ud.values(): if url.type == 'git' or url.type == 'gitsm': destsuffix = url.parm.get("destsuffix", "git/") destdir = os.path.join(unpackdir, destsuffix) vars = {'repodir': quote(destdir), 'rev': quote(url.revision)} commits = bb.fetch2.runfetchcmd( "git -C %(repodir)s rev-list %(rev)s -- 2>/dev/null | wc -l" % vars, d, quiet=True).strip() if use_tags: try: output = bb.fetch2.runfetchcmd( "git -C %(repodir)s describe %(rev)s --tags --exact-match" % vars, d, quiet=True).strip() ver = gitpkgv_drop_tag_prefix(d, output) except Exception: ver = "0.0-%s-g%s" % (commits, vars['rev'][:7]) else: ver = "%s+%s" % (commits, vars['rev'][:7]) return ver return '0+0' # Real-world example - FIO benchmark tool: SUMMARY = "Filesystem and hardware benchmark and stress tool" LICENSE = "GPL-2.0-only" DEPENDS = "libaio zlib coreutils-native" SRC_URI = "git://git.kernel.org/pub/scm/linux/kernel/git/axboe/fio.git;protocol=git;branch=master" SRCREV = "a6e474c9e896e4ba1eb40066a03402afb040710a" inherit gitpkgv PV = "3.39+git" PKGV = "${GITPKGV}" # Becomes sortable version like 3821+a6e474c9 UPSTREAM_CHECK_GITTAGREGEX = "fio-(?P\d+(\.\d+)+)" ``` -------------------------------- ### Python Package Recipe with Setuptools (BitBake) Source: https://context7.com/openembedded/meta-openembedded/llms.txt This BitBake recipe demonstrates how to build Python packages that use setuptools for their build system. It specifies package metadata, source URI, and automatically inherits build system integration through 'python_setuptools_build_meta' and 'pypi'. It also lists runtime dependencies. ```bitbake SUMMARY = "Async http client/server framework" DESCRIPTION = "Asynchronous HTTP client/server framework for asyncio and Python" HOMEPAGE = "https://github.com/aio-libs/aiohttp" LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=748073912af33aa59430d3702aa32d41" SRC_URI[sha256sum] = "4fc61385e9c98d72fcdf47e6dd81833f47b2f77c114c29cd64a361be57a763a2" inherit python_setuptools_build_meta pypi DEPENDS = "python3-pkgconfig-native" RDEPENDS:${PN} = " python3-aiohappyeyeballs python3-aiosignal python3-async-timeout python3-attrs python3-frozenlist python3-misc python3-multidict python3-yarl python3-aiodns" CFLAGS:append:toolchain-gcc:arm = " -flax-vector-conversions" # Alternative build backends: # For Poetry-based packages: # inherit python_poetry_core pypi # For flit-based packages: # inherit python_flit_core pypi # For packages requiring native build dependencies: ``` -------------------------------- ### Manage GNOME Help Files with BitBake Class Source: https://context7.com/openembedded/meta-openembedded/llms.txt The gnome-help.bbclass handles localized GNOME help files, splitting them by locale into separate packages to reduce image size. It automatically removes help files if 'helpfiles' is not in DISTRO_FEATURES and recommends 'yelp' as a viewer. The class includes a Python function to dynamically create per-locale help packages. ```bitbake PACKAGES:append = " ${PN}-help" FILES:${PN}-help = "${datadir}/help" RRECOMMENDS:${PN}-help = "${@bb.utils.contains('DISTRO_FEATURES','helpfiles','yelp','',d)}" do_install:append() { if ${@bb.utils.contains('DISTRO_FEATURES','helpfiles','false','true',d)}; then rm -rf ${D}${datadir}/help/* fi } python gnome_do_split_help() { if not bb.utils.contains('DISTRO_FEATURES', 'helpfiles', True, False, d): return if d.getVar('PACKAGE_NO_HELP_SPLIT') == '1': return packages = (d.getVar('PACKAGES') or "").split() datadir = d.getVar('datadir') dvar = d.getVar('PKGD') pn = d.getVar('PN') helpdir = os.path.join(dvar + datadir, 'help') helps = os.listdir(helpdir) summary = d.getVar('SUMMARY') or pn description = d.getVar('DESCRIPTION') or "" for l in sorted(helps): ln = legitimize_package_name(l) pkg = pn + '-help-' + ln packages.append(pkg) d.setVar('FILES:' + pkg, os.path.join(datadir, 'help', l)) d.setVar('RRECOMMENDS:' + pkg, 'yelp') d.setVar('SUMMARY:' + pkg, '%s - %s help' % (summary, l)) d.setVar('DESCRIPTION:' + pkg, '%s This package contains language help files for the %s locale.' % (description, l)) d.setVar('PACKAGES', ' '.join(packages)) } PACKAGESPLITFUNCS:prepend = "gnome_do_split_help " # Example: gedit recipe with help files SUMMARY = "GNOME text editor" inherit gnome-help # Results in packages: # gedit-help-en, gedit-help-de, gedit-help-fr, gedit-help-es, etc. ``` -------------------------------- ### Yocto Build Workflow with Meta-OpenEmbedded Source: https://context7.com/openembedded/meta-openembedded/llms.txt A command-line workflow for integrating meta-openembedded layers into a Yocto build. It covers cloning the repository, adding layers to bblayers.conf, specifying packages in local.conf, building individual packages or images, and performing basic package testing. ```bash # 1. Add meta-openembedded to your build cd /path/to/yocto git clone https://github.com/openembedded/meta-openembedded.git cd build # 2. Edit conf/bblayers.conf to add required layers: bitbake-layers add-layer ../meta-openembedded/meta-oe bitbake-layers add-layer ../meta-openembedded/meta-python bitbake-layers add-layer ../meta-openembedded/meta-networking # 3. Add packages to conf/local.conf: echo 'IMAGE_INSTALL:append = " mosquitto python3-aiohttp nginx"' >> conf/local.conf # 4. Build specific package: bitbake mosquitto # 5. Build complete image with packages: bitbake core-image-minimal # 6. Check package dependencies: bitbake -g mosquitto && cat pn-depends.dot | grep mosquitto # 7. Search for recipes: bitbake-layers show-recipes | grep -i mqtt bitbake-layers show-recipes 'python3-*' # 8. Get recipe information: bitbake -e mosquitto | grep ^DEPENDS= bitbake -e mosquitto | grep ^PACKAGECONFIG= # 9. Test package on target: # Copy tmp/deploy/ipk/*/mosquitto_*.ipk to target opkg install mosquitto_2.0.22-r0_cortexa9hf-neon.ipk # 10. Run MQTT broker: mosquitto -c /etc/mosquitto/mosquitto.conf mosquitto_pub -t "test/topic" -m "Hello from embedded Linux" mosquitto_sub -t "test/topic" ``` -------------------------------- ### Define Extended XFCE Package Group with BitBake Source: https://context7.com/openembedded/meta-openembedded/llms.txt This BitBake recipe defines an extended package group for XFCE, including optional packages like a PulseAudio plugin depending on DISTRO_FEATURES. It lists dependencies such as 'xfce4-screenshooter', 'xfce4-taskmanager', and 'mousepad'. This group can be included in an image recipe using `IMAGE_INSTALL += "packagegroup-xfce-extended"`. ```bitbake SUMMARY = "Extended XFCE packages" inherit packagegroup RDEPENDS:${PN} = " \ ${@bb.utils.contains('DISTRO_FEATURES', 'pulseaudio', 'xfce4-pulseaudio-plugin', '', d)} \ xfce4-screenshooter \ xfce4-taskmanager \ xfce4-appfinder \ xfce4-mixer \ xfce4-power-manager \ xarchiver \ mousepad" ``` -------------------------------- ### Python Script for BitBake Recipe Styling (oe-stylize.py) Source: https://context7.com/openembedded/meta-openembedded/llms.txt A Python script designed to enforce OpenEmbedded style guidelines for BitBake recipes. It standardizes the order of variables within a recipe file, improving consistency and maintainability. ```python #!/usr/bin/env python3 """ Sanitize a bitbake file following the OpenEmbedded style guidelines Usage: ./oe-stylize.py recipe.bb """ # Standard variable ordering enforced: OE_vars = [ 'SUMMARY', 'DESCRIPTION', 'AUTHOR', 'HOMEPAGE', 'SECTION', 'LICENSE', 'LIC_FILES_CHKSUM', 'DEPENDS', 'PROVIDES', 'SRCREV', 'SRCDATE', 'PE', 'PV', 'PR', 'SRC_URI', 'S', 'inherit', 'PACKAGECONFIG', 'EXTRA_OECONF', 'do_configure', 'do_compile', 'do_install', 'PACKAGES', 'FILES', 'RDEPENDS', 'RRECOMMENDS', 'BBCLASSEXTEND' ] # Example usage: # python3 contrib/oe-stylize.py meta-networking/recipes-connectivity/mosquitto/mosquitto_2.0.22.bb # Before stylization: """ LICENSE = "EPL-2.0 | EDL-1.0" SUMMARY = "Open source MQTT implementation" SRC_URI = "http://mosquitto.org/files/source/mosquitto-${PV}.tar.gz" DEPENDS = "uthash cjson" DESCRIPTION = "Message broker for MQTT protocol" """ # After stylization: """ SUMMARY = "Open source MQTT implementation" DESCRIPTION = "Message broker for MQTT protocol" LICENSE = "EPL-2.0 | EDL-1.0" DEPENDS = "uthash cjson" SRC_URI = "http://mosquitto.org/files/source/mosquitto-${PV}.tar.gz" """ ``` -------------------------------- ### Git-Based Package Versioning with gitpkgv.bbclass Source: https://context7.com/openembedded/meta-openembedded/llms.txt A BitBake class that automatically generates sortable version strings for packages sourced from Git repositories. It can derive versions from commit counts and hashes, or incorporate Git tags for more descriptive versioning. ```python # Usage in recipe: inherit gitpkgv PV = "1.0+git" PKGV = "1.0+git${GITPKGV}" # Expands to 1.0+git31337+4c1c21d7d # Or with tags: PKGV = "${GITPKGVTAG}" # Expands to v1.0-31337+g4c1c21d ``` -------------------------------- ### Configure OpenEmbedded Layer Dependencies with Makefile Source: https://context7.com/openembedded/meta-openembedded/llms.txt This configuration file for an OpenEmbedded layer (`meta-networking/conf/layer.conf`) defines the layer's path, the location of recipes, its collection name, pattern, and priority. It specifies the layer version and is written in a Makefile-like syntax. ```makefile # meta-networking/conf/layer.conf BBPATH .= ":${LAYERDIR}" BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \ ${LAYERDIR}/recipes-*/*/*.bbappend" BBFILE_COLLECTIONS += "networking-layer" BBFILE_PATTERN_networking-layer := "^${LAYERDIR}/" BBFILE_PRIORITY_networking-layer = "5" LAYERVERSION_networking-layer = "1" ``` -------------------------------- ### BitBake Layer Configuration and Dynamic Layers Source: https://context7.com/openembedded/meta-openembedded/llms.txt Configuration snippets for meta-openembedded layers, including setting layer dependencies, compatibility, and dynamic layer activation based on the presence of other layers. These are typically placed in a .conf file. ```bitbake LAYERDEPENDS_networking-layer = "core meta-python openembedded-layer" LAYERSERIES_COMPAT_networking-layer = "walnascar whinlatter" BBFILES_DYNAMIC += " meta-python:${LAYERDIR}/dynamic-layers/meta-python/recipes-*/*/*.bb" LICENSE_PATH += "${LAYERDIR}/licenses" SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS += " wireguard-tools->wireguard-module mdio-tools->mdio-netlink" # Add to bblayers.conf: # BBLAYERS += "/path/to/meta-openembedded/meta-networking" # Check layer dependencies: # bitbake-layers show-layers # bitbake-layers show-depends ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.