### Package configuration example Source: https://github.com/libreelec/libreelec.tv/blob/master/packages/readme.md Demonstrates the use of lifecycle functions to configure scripts, patch files, set flags, and clean up install directories. ```bash configure_package() { # now we know where we're building, assign a value PKG_CONFIGURE_SCRIPT="${PKG_BUILD}/gettext-tools/configure" } post_patch() { # replace hardcoded stuff sed -i ${PKG_CONFIGURE_SCRIPT} 's|hardcoded stuff|variable stuff|' } pre_configure_target() { # add extra flag to toolchain default CFLAGS="$CFLAGS -DEXTRA_FLAG=yeah" } post_makeinstall_target() { # remove unused executable, install what remains rm $INSTALL/usr/bin/bigexecutable } ``` -------------------------------- ### Clone and Configure Repository Source: https://github.com/libreelec/libreelec.tv/blob/master/CONTRIBUTING.md Initial setup commands to clone a fork and link the upstream repository. ```bash # clone your fork of the repo into the current directory in terminal git clone git@github.com:/LibreELEC.tv.git # navigate to the newly cloned directory cd LibreELEC.tv # assign the original repo to a remote called "upstream" git remote add upstream https://github.com/LibreELEC/LibreELEC.tv.git ``` -------------------------------- ### Manage Kodi Add-ons Source: https://context7.com/libreelec/libreelec.tv/llms.txt Commands for building official, binary, or custom Kodi add-ons using the scripts/create_addon utility. ```bash # Build all available add-ons ./scripts/create_addon all # Build only official add-ons (from packages/addons) ./scripts/create_addon official # Build only binary add-ons (from packages/mediacenter/kodi-binary-addons) ./scripts/create_addon binary # Build specific add-on by name ./scripts/create_addon game.libretro.mgba # Build add-ons matching pattern (regex) ./scripts/create_addon 'audioencoder.*' ./scripts/create_addon 'audiodecoder.*' # Build all except binary add-ons ./scripts/create_addon all -binary # Show which add-ons would be built without building ./scripts/create_addon --show-only all # Build multiple specific add-ons ./scripts/create_addon vdr-addon pvr.vdr.vnsi ``` -------------------------------- ### Implement Custom Package Build Logic Source: https://context7.com/libreelec/libreelec.tv/llms.txt Define custom shell functions to override or extend default build steps like configuration, unpacking, compilation, and installation. Use hooks for late variable binding and post-installation tasks. ```bash # packages/example/package.mk # Called after package sourcing for late variable binding configure_package() { PKG_CMAKE_SCRIPT="${PKG_BUILD}/src/CMakeLists.txt" } # Called after source extraction post_unpack() { # Modify extracted sources rm -rf ${PKG_BUILD}/unwanted_directory } # Called before configure step pre_configure_target() { # Set additional environment variables export EXTRA_CFLAGS="-DFEATURE_ENABLED" CFLAGS="${CFLAGS} -O3" } # Override default configure behavior configure_target() { cd ${PKG_BUILD} ./custom_configure.sh --prefix=/usr } # Called after configure completes post_configure_target() { # Fix generated files sed -i 's/wrong/right/' ${PKG_BUILD}/config.h } # Override default build behavior make_target() { cd ${PKG_BUILD} make custom_target } # Override default install behavior makeinstall_target() { mkdir -p ${INSTALL}/usr/bin cp ${PKG_BUILD}/output/binary ${INSTALL}/usr/bin/ } # Called after installation completes post_makeinstall_target() { # Remove unnecessary files rm -rf ${INSTALL}/usr/share/doc rm -rf ${INSTALL}/usr/include # Create symlinks ln -sf binary ${INSTALL}/usr/bin/alias # Enable systemd service enable_service myservice.service } ``` -------------------------------- ### Define Project and Device Options Source: https://context7.com/libreelec/libreelec.tv/llms.txt Configuration files for hardware projects and devices define kernel, bootloader, and compiler flags. ```bash PROJECT_CFLAGS="-march=x86-64 -mtune=generic" KERNEL="default" BOOTLOADER="grub" DISPLAYSERVER="x11" MEDIACENTER="kodi" ``` ```bash KERNEL="bcm2712" BOOTLOADER="bcm2711-firmware" DEVICE_CFLAGS="-mcpu=cortex-a76" DEVICE_PACKAGES="firmware-raspberry-pi" ``` -------------------------------- ### Navigate to LibreELEC.tv Directory Source: https://github.com/libreelec/libreelec.tv/blob/master/tools/docker/README.md Change your current directory to the root of the LibreELEC.tv repository after cloning it. ```bash cd LibreELEC.tv ``` -------------------------------- ### Build Docker Image for LibreELEC Source: https://github.com/libreelec/libreelec.tv/blob/master/tools/docker/README.md Use this command to create a Docker image and tag it with 'libreelec'. Ensure you are in the correct directory. ```bash docker build --pull -t libreelec tools/docker/noble ``` -------------------------------- ### Build System Images with make Source: https://context7.com/libreelec/libreelec.tv/llms.txt Commands to generate system images for various hardware platforms and manage build artifacts. ```bash # Build a release image for Generic x86_64 (default) PROJECT=Generic ARCH=x86_64 make release # Build for Raspberry Pi 4 PROJECT=RPi DEVICE=RPi4 ARCH=aarch64 make release # Build for Raspberry Pi 5 PROJECT=RPi DEVICE=RPi5 ARCH=aarch64 make release # Build development image (includes version timestamp) PROJECT=Generic ARCH=x86_64 make # Build image only (skip tarball creation) PROJECT=Generic make image # Build NOOBS-compatible image for Raspberry Pi PROJECT=RPi DEVICE=RPi4 make noobs # Parallel build with specific concurrency level CONCURRENCY_MAKE_LEVEL=8 PROJECT=Generic make release # Debug build with symbols DEBUG=yes PROJECT=Generic make release # Clean all build artifacts make clean # Deep clean including downloaded sources make distclean ``` -------------------------------- ### Build LibreELEC Image for RK3576 (rock-4d) Source: https://github.com/libreelec/libreelec.tv/blob/master/projects/Rockchip/devices/RK3576/README.md Use this command to build a LibreELEC image for the RK3576 SoC with the UBOOT_SYSTEM set to 'rock-4d'. Ensure all environment variables are correctly set. ```bash PROJECT=Rockchip DEVICE=RK3576 ARCH=aarch64 UBOOT_SYSTEM=rock-4d make image ``` -------------------------------- ### Include Distro Configuration Source: https://github.com/libreelec/libreelec.tv/blob/master/packages/tools/bcm2835-bootloader/files/config.txt Includes the main distribution configuration file. Use 'distroconfig-composite.txt' to enable composite video output. ```config include distroconfig.txt ``` -------------------------------- ### Configure Distribution Settings Source: https://context7.com/libreelec/libreelec.tv/llms.txt Distribution-level settings define branding, versioning, and repository URLs. ```bash DISTRO_VERSION="devel" # Use "devel" for development, or "12.0.0" for release OS_VERSION="13.0" # Operating system version ADDON_VERSION="12.80.6" # Add-on repository version DISTRONAME="LibreELEC" DISTRO_HOME_URL="https://libreelec.tv" DISTRO_SRC="https://sources.libreelec.tv" DISTRO_MIRROR="https://sources.libreelec.tv/mirror" MEDIACENTER="kodi" GRAPHIC_DRIVERS="i915 i965 nvidia nouveau amdgpu radeonsi" ``` -------------------------------- ### Build LibreELEC Image for RK3576 (roc-pc) Source: https://github.com/libreelec/libreelec.tv/blob/master/projects/Rockchip/devices/RK3576/README.md Use this command to build a LibreELEC image for the RK3576 SoC with the UBOOT_SYSTEM set to 'roc-pc'. Ensure all environment variables are correctly set. ```bash PROJECT=Rockchip DEVICE=RK3576 ARCH=aarch64 UBOOT_SYSTEM=roc-pc make image ``` -------------------------------- ### Build RK3328 Image with U-Boot System Source: https://github.com/libreelec/libreelec.tv/blob/master/projects/Rockchip/devices/RK3328/README.md Use these commands to build a LibreELEC image for the RK3328 SoC with specific U-Boot systems. Ensure the correct PROJECT, DEVICE, and ARCH are set. ```bash PROJECT=Rockchip DEVICE=RK3328 ARCH=aarch64 UBOOT_SYSTEM=a1 make image ``` ```bash PROJECT=Rockchip DEVICE=RK3328 ARCH=aarch64 UBOOT_SYSTEM=roc-cc make image ``` ```bash PROJECT=Rockchip DEVICE=RK3328 ARCH=aarch64 UBOOT_SYSTEM=rock64 make image ``` -------------------------------- ### Build LibreELEC Image with Environment Variables Source: https://github.com/libreelec/libreelec.tv/blob/master/tools/docker/README.md Pass environment variables like PROJECT, DEVICE, and ARCH to the LibreELEC build process inside the container. This allows for specific build configurations. ```bash docker run --rm --log-driver none -v `pwd`:/build -w /build -it -e PROJECT=RPi -e DEVICE=RPi4 -e ARCH=arm libreelec make image ``` -------------------------------- ### Enable Legacy Boot for Android Devices Source: https://github.com/libreelec/libreelec.tv/blob/master/projects/Rockchip/README.md When building an image for a device that originally shipped with Android and has a vendor u-boot in EMMC or SPI, add this build flag to ensure proper booting. ```bash ROCKCHIP_LEGACY_BOOT=1 ``` -------------------------------- ### Build RK3399 Images Source: https://github.com/libreelec/libreelec.tv/blob/master/projects/Rockchip/devices/RK3399/README.md Commands to build LibreELEC images for specific RK3399 devices by setting the UBOOT_SYSTEM variable. ```bash PROJECT=Rockchip DEVICE=RK3399 ARCH=aarch64 UBOOT_SYSTEM=hugsun-x99 make image ``` ```bash PROJECT=Rockchip DEVICE=RK3399 ARCH=aarch64 UBOOT_SYSTEM=khadas-edge make image ``` ```bash PROJECT=Rockchip DEVICE=RK3399 ARCH=aarch64 UBOOT_SYSTEM=nanopc-t4 make image ``` ```bash PROJECT=Rockchip DEVICE=RK3399 ARCH=aarch64 UBOOT_SYSTEM=nanopi-m4 make image ``` ```bash PROJECT=Rockchip DEVICE=RK3399 ARCH=aarch64 UBOOT_SYSTEM=orangepi make image ``` ```bash PROJECT=Rockchip DEVICE=RK3399 ARCH=aarch64 UBOOT_SYSTEM=rock960 make image ``` ```bash PROJECT=Rockchip DEVICE=RK3399 ARCH=aarch64 UBOOT_SYSTEM=rock-pi-4 make image ``` ```bash PROJECT=Rockchip DEVICE=RK3399 ARCH=aarch64 UBOOT_SYSTEM=rock-pi-4-plus make image ``` ```bash PROJECT=Rockchip DEVICE=RK3399 ARCH=aarch64 UBOOT_SYSTEM=rock-4c-plus make image ``` ```bash PROJECT=Rockchip DEVICE=RK3399 ARCH=aarch64 UBOOT_SYSTEM=rock-pi-n10 make image ``` ```bash PROJECT=Rockchip DEVICE=RK3399 ARCH=aarch64 UBOOT_SYSTEM=rockpro64 make image ``` ```bash PROJECT=Rockchip DEVICE=RK3399 ARCH=aarch64 UBOOT_SYSTEM=roc-pc make image ``` ```bash PROJECT=Rockchip DEVICE=RK3399 ARCH=aarch64 UBOOT_SYSTEM=roc-pc-plus make image ``` ```bash PROJECT=Rockchip DEVICE=RK3399 ARCH=aarch64 UBOOT_SYSTEM=sapphire make image ``` -------------------------------- ### Utilize Build System Helper Functions Source: https://context7.com/libreelec/libreelec.tv/llms.txt Access package information, kernel module paths, file system utilities, user/group management, service enabling, Python compilation, and build flag checks. These functions simplify common build tasks. ```bash # Get package information PKG_DIR=$(get_pkg_directory ffmpeg) # Get package source directory PKG_BUILD=$(get_build_dir ffmpeg) # Get package build directory PKG_INSTALL=$(get_install_dir ffmpeg) # Get package install directory PKG_VERSION=$(get_pkg_version ffmpeg) # Get package version # Kernel module helpers KERNEL_VERSION=$(kernel_version) # Get Linux kernel version KERNEL_PATH=$(kernel_path) # Get kernel source path MODULE_DIR=$(get_module_dir) # Get kernel module directory FIRMWARE_DIR=$(get_full_firmware_dir) # Get firmware directory # File system helpers find_file_path config/myconfig.conf # Search for file in hierarchy # Sets FOUND_PATH if found in project/device/distro/package directories # System configuration helpers add_user "username" "password" 1000 1000 "User" "/home/user" "/bin/sh" add_group "groupname" 1000 "member1,member2" enable_service myservice.service # Enable systemd service # Python helpers python_compile ${INSTALL}/usr/lib/python3.11 # Compile Python files to .pyc python_remove_source ${INSTALL}/usr/lib/python3.11 # Remove .py source files # Build flag checking if flag_enabled "lto" "no"; then # LTO is enabled fi ``` -------------------------------- ### Build RK3588 Image Source: https://github.com/libreelec/libreelec.tv/blob/master/projects/Rockchip/devices/RK3588/README.md Use these commands to build a LibreELEC image for various RK3588-based devices. Ensure you have the correct U-Boot system configured for your target hardware. ```bash PROJECT=Rockchip DEVICE=RK3588 ARCH=aarch64 UBOOT_SYSTEM=armsom-sige7 make image ``` ```bash PROJECT=Rockchip DEVICE=RK3588 ARCH=aarch64 UBOOT_SYSTEM=cm3588-nas make image ``` ```bash PROJECT=Rockchip DEVICE=RK3588 ARCH=aarch64 UBOOT_SYSTEM=khadas-edge2 make image ``` ```bash PROJECT=Rockchip DEVICE=RK3588 ARCH=aarch64 UBOOT_SYSTEM=nanopc-t6 make image ``` ```bash PROJECT=Rockchip DEVICE=RK3588 ARCH=aarch64 UBOOT_SYSTEM=nanopi-r6c make image ``` ```bash PROJECT=Rockchip DEVICE=RK3588 ARCH=aarch64 UBOOT_SYSTEM=nanopi-r6s make image ``` ```bash PROJECT=Rockchip DEVICE=RK3588 ARCH=aarch64 UBOOT_SYSTEM=odroid-m2 make image ``` ```bash PROJECT=Rockchip DEVICE=RK3588 ARCH=aarch64 UBOOT_SYSTEM=orangepi-5 make image ``` ```bash PROJECT=Rockchip DEVICE=RK3588 ARCH=aarch64 UBOOT_SYSTEM=orangepi-5-max make image ``` ```bash PROJECT=Rockchip DEVICE=RK3588 ARCH=aarch64 UBOOT_SYSTEM=orangepi-5-plus make image ``` ```bash PROJECT=Rockchip DEVICE=RK3588 ARCH=aarch64 UBOOT_SYSTEM=quartzpro64 make image ``` ```bash PROJECT=Rockchip DEVICE=RK3588 ARCH=aarch64 UBOOT_SYSTEM=rock-5a make image ``` ```bash PROJECT=Rockchip DEVICE=RK3588 ARCH=aarch64 UBOOT_SYSTEM=rock-5b make image ``` ```bash PROJECT=Rockchip DEVICE=RK3588 ARCH=aarch64 UBOOT_SYSTEM=rock-5c make image ``` -------------------------------- ### Flash LibreELEC Image to SD Card Source: https://github.com/libreelec/libreelec.tv/blob/master/projects/Qualcomm/devices/Dragonboard/README.md Use this command to flash the uncompressed LibreELEC image to an SD card. Ensure you replace '/dev/sdx' with the correct device identifier for your SD card. ```bash gunzip LibreELEC-Dragonboard.arm-9.80-devel-20190706164625-ce7dc9b-410c.img.gz dd if=LibreELEC-Dragonboard.arm-9.80-devel-20190706164625-ce7dc9b-410c.img of=/dev/sdx bs=4M ``` -------------------------------- ### Create Topic Branch Source: https://github.com/libreelec/libreelec.tv/blob/master/CONTRIBUTING.md Command to initialize a new branch for specific features or fixes. ```bash git checkout -b ``` -------------------------------- ### Build LibreELEC Image Inside a Container Source: https://github.com/libreelec/libreelec.tv/blob/master/tools/docker/README.md Build LibreELEC images within a new container using the pre-built 'libreelec' Docker image. The current directory must contain the LibreELEC Makefile. ```bash docker run --rm --log-driver none -v `pwd`:/build -w /build -it libreelec make image ``` -------------------------------- ### Manage Package Sources with distro-tool Source: https://context7.com/libreelec/libreelec.tv/llms.txt The distro-tool utility handles downloading, verifying, and checking package source versions. ```bash ./tools/distro-tool -d ~/download -t ~/sources -m -a ``` ```bash ./tools/distro-tool -d ~/download -p ffmpeg ``` ```bash ./tools/distro-tool -d ~/download -p ffmpeg -r 6.0 ``` ```bash ./tools/distro-tool -d ~/download -t ~/sources --check-ver ``` ```bash ./tools/distro-tool -d ~/download --dry-run ``` ```bash ./tools/distro-tool -d ~/download -t ~/sources --verify-checksum ``` ```bash ./tools/distro-tool -d ~/download -T 32 -a ``` ```bash ./tools/distro-tool -d ~/download --path-filter packages/multimedia ``` -------------------------------- ### Define Package Configuration Source: https://context7.com/libreelec/libreelec.tv/llms.txt Standardized package.mk structure for defining build metadata, dependencies, and post-installation cleanup tasks. ```bash # packages/multimedia/ffmpeg/package.mk # SPDX-License-Identifier: GPL-2.0 # Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv) PKG_NAME="ffmpeg" PKG_VERSION="6.1.1" PKG_SHA256="8684f4b00f94b85461884eb55cc46ab30c01fa72c8cc14c9e2a4c67a83994dda" PKG_LICENSE="GPL-2.0-or-later" PKG_SITE="https://ffmpeg.org" PKG_URL="https://ffmpeg.org/releases/ffmpeg-${PKG_VERSION}.tar.xz" PKG_DEPENDS_TARGET="toolchain zlib bzip2 openssl libvorbis" PKG_LONGDESC="FFmpeg is a complete, cross-platform solution for audio/video." PKG_BUILD_FLAGS="-gold +lto" PKG_CONFIGURE_OPTS_TARGET="--enable-gpl \ --enable-version3 \ --enable-shared \ --disable-static \ --enable-openssl \ --enable-libvorbis" post_makeinstall_target() { # Remove unneeded files from installation rm -rf ${INSTALL}/usr/share/ffmpeg/examples safe_remove ${INSTALL}/usr/bin/ffplay } ``` -------------------------------- ### Mount First Partition Source: https://github.com/libreelec/libreelec.tv/blob/master/projects/Qualcomm/devices/Dragonboard/README.md Mount the first partition of the SD card to access its contents. Replace '/dev/sdx1' with the actual partition name. ```bash mount /dev/sdx1 /mnt (or similar) ``` -------------------------------- ### Define Package Build Variables Source: https://context7.com/libreelec/libreelec.tv/llms.txt Set supported architectures, dependencies, build system, and optimization flags for package builds. Customize source directory and patch locations as needed. ```bash # Optional base variables PKG_ARCH="x86_64 aarch64" # Supported architectures (default: any) PKG_DEPENDS_TARGET="toolchain zlib openssl" # Target dependencies PKG_DEPENDS_HOST="gcc:host" # Host toolchain dependencies PKG_DEPENDS_INIT="busybox" # Init ramdisk dependencies PKG_SECTION="virtual" # Set to "virtual" for meta-packages # Build control variables PKG_TOOLCHAIN="cmake" # Build system: auto, meson, cmake, cmake-make, # autotools, configure, ninja, make, manual PKG_BUILD_FLAGS="+lto -gold +pic" # Build optimization flags PKG_SOURCE_DIR="custom-dir" # Override unpacked directory name PKG_PATCH_DIRS="patches/custom" # Additional patch directories # Toolchain-specific options PKG_CMAKE_OPTS_TARGET="-DENABLE_FEATURE=ON" PKG_MESON_OPTS_TARGET="--option=value" PKG_CONFIGURE_OPTS_TARGET="--enable-feature" PKG_MAKE_OPTS_TARGET="EXTRA_FLAGS=1" ``` -------------------------------- ### Define a package with package.mk Source: https://github.com/libreelec/libreelec.tv/blob/master/packages/readme.md Template structure for a package.mk file defining metadata, dependencies, and build options for a LibreELEC package. ```bash # SPDX-License-Identifier: GPL-2.0 # Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv) PKG_NAME="mariadb-connector-c" PKG_VERSION="3.0.2" PKG_SHA256="f44f436fc35e081db3a56516de9e3bb11ae96838e75d58910be28ddd2bc56d88" PKG_LICENSE="LGPL" PKG_SITE="https://mariadb.org/" PKG_URL="https://github.com/MariaDB/mariadb-connector-c/archive/v$PKG_VERSION.tar.gz" PKG_DEPENDS_TARGET="toolchain zlib openssl" PKG_LONGDESC="mariadb-connector: library to connect to mariadb/mysql database server" PKG_BUILD_FLAGS="-gold" PKG_CMAKE_OPTS_TARGET="-DWITH_EXTERNAL_ZLIB=ON \ -DAUTH_CLEARTEXT=STATIC \ -DAUTH_DIALOG=STATIC \ -DAUTH_OLDPASSWORD=STATIC \ -DREMOTEIO=OFF" post_makeinstall_target() { # drop all unneeded rm -rf $INSTALL/usr } ```