├── .gitignore ├── yocto └── meta-klipper │ ├── recipes-kernel │ └── linux │ │ ├── linux-mainline │ │ ├── usbserial_ftdi.cfg │ │ └── usbserial_ch341.cfg │ │ ├── linux-yocto │ │ ├── usbserial_ch341.cfg │ │ └── usbserial_ftdi.cfg │ │ ├── linux-yocto_%.bbappend │ │ └── linux-mainline_%.bbappend │ ├── recipes-devtools │ ├── python │ │ ├── python-nose_1.3.7.bb │ │ ├── python-nose.inc │ │ ├── python-pytest │ │ │ ├── 0001-setup.py-remove-setup_requires-for-setuptools-scm.patch │ │ │ └── pytest_version_fix.patch │ │ └── python-pytest_4.6.6.bb │ ├── cmake │ │ └── cmake-native_%.bbappend │ ├── python-numpy │ │ ├── python-numpy_1.16.6.bb │ │ ├── files │ │ │ ├── 0001-numpy-random-setup.py-remove-the-detection-of-x86-ta.patch │ │ │ └── 0001-Don-t-search-usr-and-so-on-for-libraries-by-default-.patch │ │ └── python-numpy.inc │ └── gcc │ │ └── gcc-configure-common.inc │ ├── recipes-extended │ └── lighttpd │ │ ├── files │ │ ├── lighttpd.user │ │ ├── lighttpd.run │ │ ├── 0001-Use-pkg-config-for-pcre-dependency-instead-of-config.patch │ │ ├── htdigest.sh │ │ └── lighttpd.conf │ │ └── lighttpd_1.4.55.bb │ ├── recipes-printing │ └── klipper │ │ ├── files │ │ ├── klipper.default │ │ ├── .klipper-start.sh.swp │ │ ├── klipper.run │ │ └── 0001-Allow-to-package-klippy-using-setuptools.patch │ │ └── klipper_git.bb │ ├── recipes-core │ ├── util-linux │ │ └── util-linux_%.bbappend │ ├── busybox │ │ ├── files │ │ │ ├── runit.cfg │ │ │ └── runit.init │ │ └── busybox_%.bbappend │ ├── images │ │ ├── klipper-image-tinker-board-s.bb │ │ ├── klipper-image.bb │ │ ├── cubietruck-installer-image.bb │ │ └── klipper-linux-rootfs.bb │ └── packagegroups │ │ └── packagegroup-klipper-image.bb │ ├── scripts │ └── lib │ │ └── wic │ │ ├── canned-wks │ │ ├── qemuriscv.wks │ │ ├── common.wks.inc │ │ ├── efi-bootdisk.wks.in │ │ ├── qemux86-directdisk.wks │ │ ├── directdisk.wks │ │ ├── mkhybridiso.wks │ │ ├── directdisk-bootloader-config.wks │ │ ├── sdimage-bootpart.wks │ │ ├── directdisk-gpt.wks │ │ ├── mkefidisk.wks │ │ ├── systemd-bootdisk.wks │ │ ├── directdisk-bootloader-config.cfg │ │ └── directdisk-multi-rootfs.wks │ │ ├── __init__.py │ │ ├── plugins │ │ └── source │ │ │ ├── rawcopy.py │ │ │ ├── bootimg-partition.py │ │ │ ├── bootimg-biosplusefi.py │ │ │ ├── bootimg-pcbios.py │ │ │ ├── rootfs.py │ │ │ └── bootimg-efi.py │ │ ├── pluginbase.py │ │ ├── misc.py │ │ ├── ksparser.py │ │ └── partition.py │ ├── recipes-python │ ├── frozendict │ │ └── python-frozendict_1.2.bb │ ├── sentry-sdk │ │ └── python-sentry-sdk_0.13.2.bb │ ├── emoji │ │ └── python-emoji_0.5.4.bb │ ├── rsa │ │ └── python-rsa_4.0.bb │ ├── cachelib │ │ └── python-cachelib_0.1.bb │ ├── pylru │ │ └── python-pylru_1.2.0.bb │ ├── semantic-version │ │ └── python-semantic-version_2.8.5.bb │ ├── sarge │ │ └── python-sarge_0.1.5.post0.bb │ ├── filetype │ │ └── python-filetype_1.0.7.bb │ ├── pkginfo │ │ └── python-pkginfo_1.5.0.1.bb │ ├── unidecode │ │ └── python-unidecode_0.04.21.bb │ ├── pathtools │ │ └── python-pathtools_0.1.2.bb │ ├── websocket-client │ │ └── python-websocket-client_0.56.0.bb │ ├── argh │ │ └── python-argh_0.26.2.bb │ ├── webassets │ │ └── python-webassets_2.0.bb │ ├── watchdog │ │ └── python-watchdog_0.9.0.bb │ ├── sphinx │ │ └── python-sphinx_1.8.5.bb │ ├── regex │ │ └── python-regex_2020.5.14.bb │ ├── markdown │ │ └── python-markdown_3.1.1.bb │ ├── sphinxcontrib-httpdomain │ │ └── python-sphinxcontrib-httpdomain_1.7.0.bb │ ├── flask-assets │ │ └── python-flask-assets_0.12.bb │ ├── certifi │ │ └── python-certifi_2020.4.5.1.bb │ ├── flask │ │ └── python-flask_0.12.5.bb │ ├── awesome-slugify │ │ └── python-awesome-slugify_1.6.5.bb │ ├── chainmap │ │ └── python-chainmap_1.0.3.bb │ ├── jinja2 │ │ └── python-jinja2_2.8.1.bb │ └── tornado │ │ └── python-tornado_4.5.3.bb │ ├── conf │ ├── site.conf │ ├── layer.conf │ └── distro │ │ └── klipper-linux.conf │ ├── recipes-support │ └── create-certificate │ │ ├── files │ │ ├── create-certificate.cron │ │ └── create-cert │ │ └── create-certificate_0.1.0.bb │ ├── recipes-webui │ └── octoprint │ │ ├── files │ │ ├── octoprint.run │ │ └── config.yaml │ │ └── octoprint_1.4.0.bb │ ├── recipes-bsp │ └── u-boot │ │ ├── files │ │ └── cubietruck │ │ │ └── cubietruck_nand.cfg │ │ └── u-boot_%.bbappend │ ├── wic │ ├── cubietruck.wks.in │ └── tinker-board-s.wks.in │ └── classes │ └── runit-service.bbclass ├── targets ├── tinker-board-s │ └── conf │ │ ├── local.conf │ │ └── bblayers.conf └── cubietruck │ └── conf │ ├── local.conf │ └── bblayers.conf ├── .gitmodules ├── setup.sh └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | downloads/ 2 | klipper-linux-build/ 3 | auto.conf 4 | bitbake-cookerdaemon.log 5 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-kernel/linux/linux-mainline/usbserial_ftdi.cfg: -------------------------------------------------------------------------------- 1 | USB_SERIAL_FTDI_SIO=y 2 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-devtools/python/python-nose_1.3.7.bb: -------------------------------------------------------------------------------- 1 | inherit setuptools 2 | require python-nose.inc 3 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-extended/lighttpd/files/lighttpd.user: -------------------------------------------------------------------------------- 1 | printer:klipper:8e6fa75a2a3d867ffedbed31908ee5e8 2 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-devtools/cmake/cmake-native_%.bbappend: -------------------------------------------------------------------------------- 1 | CMAKE_EXTRACONF += "-DCMAKE_USE_SYSTEM_LIBRARIES=0" 2 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-devtools/python-numpy/python-numpy_1.16.6.bb: -------------------------------------------------------------------------------- 1 | inherit setuptools 2 | require python-numpy.inc 3 | 4 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-kernel/linux/linux-mainline/usbserial_ch341.cfg: -------------------------------------------------------------------------------- 1 | CONFIG_USB_SERIAL=y 2 | CONFIG_USB_SERIAL_CH341=y 3 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-kernel/linux/linux-yocto/usbserial_ch341.cfg: -------------------------------------------------------------------------------- 1 | CONFIG_USB_SERIAL=y 2 | CONFIG_USB_SERIAL_CH341=y 3 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-kernel/linux/linux-yocto/usbserial_ftdi.cfg: -------------------------------------------------------------------------------- 1 | CONFIG_USB_SERIAL_GENERIC=y 2 | CONFIG_USB_SERIAL_FTDI_SIO=y 3 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-printing/klipper/files/klipper.default: -------------------------------------------------------------------------------- 1 | # Configuration for /etc/init.d/klipper 2 | 3 | PRINTER_CONFIG="printer.cfg" 4 | 5 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-core/util-linux/util-linux_%.bbappend: -------------------------------------------------------------------------------- 1 | # otherwise util-linux-native fails to find magic.h on Centos 8 2 | DEPENDS += "file" 3 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-core/busybox/files/runit.cfg: -------------------------------------------------------------------------------- 1 | # Runit Utilities 2 | # 3 | CONFIG_RUNSV=y 4 | CONFIG_RUNSVDIR=y 5 | CONFIG_SV=y 6 | CONFIG_SV_DEFAULT_SERVICE_DIR="/var/service" 7 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-printing/klipper/files/.klipper-start.sh.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jin-eld/klipper-linux/HEAD/yocto/meta-klipper/recipes-printing/klipper/files/.klipper-start.sh.swp -------------------------------------------------------------------------------- /yocto/meta-klipper/scripts/lib/wic/canned-wks/qemuriscv.wks: -------------------------------------------------------------------------------- 1 | # short-description: Create qcow2 image for RISC-V QEMU machines 2 | 3 | part / --source rootfs --fstype=ext4 --label root --align 4096 --size 5G 4 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-kernel/linux/linux-yocto_%.bbappend: -------------------------------------------------------------------------------- 1 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" 2 | 3 | SRC_URI += "\ 4 | file://usbserial_ch341.cfg \ 5 | file://usbserial_ftdi.cfg \ 6 | " 7 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-kernel/linux/linux-mainline_%.bbappend: -------------------------------------------------------------------------------- 1 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" 2 | 3 | SRC_URI += "file://usbserial_ch341.cfg \ 4 | file://usbserial_ftdi.cfg \ 5 | " 6 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-extended/lighttpd/files/lighttpd.run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | CONFIG=/etc/lighttpd/lighttpd.conf 4 | mkdir -p /var/log/lighttpd 5 | mkdir -p /var/run/lighttpd 6 | 7 | exec 2>&1 8 | exec /usr/sbin/lighttpd -D -f $CONFIG 9 | -------------------------------------------------------------------------------- /yocto/meta-klipper/scripts/lib/wic/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2007 Red Hat, Inc. 4 | # Copyright (c) 2011 Intel, Inc. 5 | # 6 | # SPDX-License-Identifier: GPL-2.0-only 7 | # 8 | 9 | class WicError(Exception): 10 | pass 11 | -------------------------------------------------------------------------------- /yocto/meta-klipper/scripts/lib/wic/canned-wks/common.wks.inc: -------------------------------------------------------------------------------- 1 | # This file is included into 3 canned wks files from this directory 2 | part /boot --source bootimg-pcbios --ondisk sda --label boot --active --align 1024 3 | part / --source rootfs --use-uuid --fstype=ext4 --label platform --align 1024 4 | -------------------------------------------------------------------------------- /yocto/meta-klipper/scripts/lib/wic/canned-wks/efi-bootdisk.wks.in: -------------------------------------------------------------------------------- 1 | bootloader --ptable gpt 2 | part /boot --source rootfs --rootfs-dir=${IMAGE_ROOTFS}/boot --fstype=vfat --label boot --active --align 1024 --use-uuid --overhead-factor 1.0 3 | part / --source rootfs --fstype=ext4 --label root --align 1024 --exclude-path boot/ 4 | -------------------------------------------------------------------------------- /targets/tinker-board-s/conf/local.conf: -------------------------------------------------------------------------------- 1 | DISTRO = "klipper-linux" 2 | MACHINE = "tinker-board-s" 3 | 4 | #BBMULTICONFIG = "avr" 5 | 6 | PRSERV_HOST = "localhost:0" 7 | 8 | PACKAGE_CLASSES = " package_ipk " 9 | 10 | INHERIT += "rm_work" 11 | 12 | TOPDIR = "${YOCTO_TOPDIR}/${DISTRO}-build" 13 | TMPDIR = "${TOPDIR}/build" 14 | 15 | IMAGE_FEATURES += "debug-tweaks" 16 | -------------------------------------------------------------------------------- /yocto/meta-klipper/scripts/lib/wic/canned-wks/qemux86-directdisk.wks: -------------------------------------------------------------------------------- 1 | # short-description: Create a qemu machine 'pcbios' direct disk image 2 | # long-description: Creates a partitioned legacy BIOS disk image that the user 3 | # can directly use to boot a qemu machine. 4 | 5 | include common.wks.inc 6 | 7 | bootloader --timeout=0 --append="rw oprofile.timer=1 rootfstype=ext4 " 8 | 9 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-python/frozendict/python-frozendict_1.2.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "python-frozendict recipe" 2 | 3 | LICENSE = "BSD" 4 | LIC_FILES_CHKSUM = "file://${S}/LICENSE.txt;md5=f4da037a49c09b456fdbbc7a5bd36132" 5 | 6 | PYPI_PACKAGE = "frozendict" 7 | 8 | SRC_URI[sha256sum] = "774179f22db2ef8a106e9c38d4d1f8503864603db08de2e33be5b778230f6e45" 9 | 10 | inherit pypi setuptools 11 | 12 | -------------------------------------------------------------------------------- /yocto/meta-klipper/scripts/lib/wic/canned-wks/directdisk.wks: -------------------------------------------------------------------------------- 1 | # short-description: Create a 'pcbios' direct disk image 2 | # long-description: Creates a partitioned legacy BIOS disk image that the user 3 | # can directly dd to boot media. 4 | 5 | include common.wks.inc 6 | 7 | bootloader --timeout=0 --append="rootwait rootfstype=ext4 video=vesafb vga=0x318 console=tty0 console=ttyS0,115200n8" 8 | 9 | -------------------------------------------------------------------------------- /targets/cubietruck/conf/local.conf: -------------------------------------------------------------------------------- 1 | DISTRO = "klipper-linux" 2 | MACHINE = "cubietruck" 3 | 4 | PRSERV_HOST = "localhost:0" 5 | 6 | PACKAGE_CLASSES = " package_ipk " 7 | 8 | INHERIT += "rm_work" 9 | 10 | TOPDIR = "${YOCTO_TOPDIR}/${DISTRO}-build" 11 | TMPDIR = "${TOPDIR}/build" 12 | 13 | IMAGE_FEATURES += "debug-tweaks" 14 | 15 | IMAGE_BOOT_FILES = "boot.scr sun7i-a20-cubietruck.dtb uImage" 16 | -------------------------------------------------------------------------------- /yocto/meta-klipper/scripts/lib/wic/canned-wks/mkhybridiso.wks: -------------------------------------------------------------------------------- 1 | # short-description: Create a hybrid ISO image 2 | # long-description: Creates an EFI and legacy bootable hybrid ISO image 3 | # which can be used on optical media as well as USB media. 4 | 5 | part /boot --source isoimage-isohybrid --sourceparams="loader=grub-efi,image_name=HYBRID_ISO_IMG" --ondisk cd --label HYBRIDISO 6 | 7 | bootloader --timeout=15 --append="" 8 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-core/images/klipper-image-tinker-board-s.bb: -------------------------------------------------------------------------------- 1 | COMPATIBLE_MACHINE = "tinker-board-s" 2 | 3 | inherit image 4 | 5 | WKS_FILE = "tinker-board-s.wks.in" 6 | 7 | IMAGE_FSTYPES = "wic.bz2 wic.bmap" 8 | 9 | IMAGE_BASENAME = "klipper-image" 10 | 11 | do_image_wic[depends] += "\ 12 | virtual/bootloader:do_deploy \ 13 | virtual/kernel:do_deploy \ 14 | klipper-linux-rootfs:do_image_complete" 15 | 16 | -------------------------------------------------------------------------------- /yocto/meta-klipper/scripts/lib/wic/canned-wks/directdisk-bootloader-config.wks: -------------------------------------------------------------------------------- 1 | # short-description: Create a 'pcbios' direct disk image with custom bootloader config 2 | # long-description: Creates a partitioned legacy BIOS disk image that the user 3 | # can directly dd to boot media. The bootloader configuration source is a user file. 4 | 5 | include common.wks.inc 6 | 7 | bootloader --configfile="directdisk-bootloader-config.cfg" 8 | 9 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-python/sentry-sdk/python-sentry-sdk_0.13.2.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "Sentry-Python is an SDK for Sentry." 2 | LICENSE = "BSD-2-Clause" 3 | LIC_FILES_CHKSUM = "file://LICENSE;md5=0c79f8d3c91fc847350efd28bfe0a341" 4 | 5 | SRC_URI[sha256sum] = "ff1fa7fb85703ae9414c8b427ee73f8363232767c9cd19158f08f6e4f0b58fc7" 6 | 7 | inherit pypi setuptools 8 | 9 | PYPI_PACKAGE = "sentry-sdk" 10 | 11 | BBCLASSEXTEND = "native nativesdk" 12 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-python/emoji/python-emoji_0.5.4.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "Emoji for Python" 2 | HOMEPAGE = "https://github.com/carpedm20/emoji/" 3 | LICENSE = "BSD" 4 | SECTION = "devel/python" 5 | LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=9d99980d85e5f81e38ee21f7f4f730d4" 6 | 7 | PYPI_PACKAGE = "emoji" 8 | 9 | SRC_URI[sha256sum] = "60652d3a2dcee5b8af8acb097c31776fb6d808027aeb7221830f72cdafefc174" 10 | 11 | inherit setuptools pypi 12 | 13 | -------------------------------------------------------------------------------- /yocto/meta-klipper/scripts/lib/wic/canned-wks/sdimage-bootpart.wks: -------------------------------------------------------------------------------- 1 | # short-description: Create SD card image with a boot partition 2 | # long-description: Creates a partitioned SD card image. Boot files 3 | # are located in the first vfat partition. 4 | 5 | part /boot --source bootimg-partition --ondisk mmcblk0 --fstype=vfat --label boot --active --align 4 --size 16 6 | part / --source rootfs --ondisk mmcblk0 --fstype=ext4 --label root --align 4 7 | -------------------------------------------------------------------------------- /yocto/meta-klipper/conf/site.conf: -------------------------------------------------------------------------------- 1 | CONF_VERSION="1" 2 | 3 | MODULE_TARBALL_DEPLOY = "0" 4 | 5 | # we want a persistent /var/log 6 | VOLATILE_LOG_DIR = "no" 7 | 8 | # https://bugzilla.yoctoproject.org/show_bug.cgi?id=12070 9 | do_image_complete[deptask] += "do_populate_lic" 10 | 11 | BB_NUMBER_PARSE_THREADS ?= "${@min(oe.utils.cpu_count(),3)}" 12 | 13 | # util-linux-native fails to find magic.h 14 | ASSUME_PROVIDED_remove = "file-native" 15 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-python/rsa/python-rsa_4.0.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "Pure-Python RSA implementation" 2 | SECTION = "devel/python" 3 | 4 | HOMEPAGE = "https://pypi.python.org/pypi/rsa/" 5 | 6 | LICENSE = "Apache-2.0" 7 | LIC_FILES_CHKSUM = "file://LICENSE;md5=c403f6882d4f97a9cd927df987d55634" 8 | 9 | SRC_URI[sha256sum] = "1a836406405730121ae9823e19c6e806c62bbad73f890574fff50efa4122c487" 10 | 11 | inherit pypi setuptools 12 | 13 | PYPI_PACKAGE = "rsa" 14 | -------------------------------------------------------------------------------- /yocto/meta-klipper/conf/layer.conf: -------------------------------------------------------------------------------- 1 | # prepend to BBPATH so that our classes have higher prio 2 | BBPATH =. "${LAYERDIR}:" 3 | 4 | BBFILES += "${LAYERDIR}/recipes*/*/*.bb ${LAYERDIR}/recipes*/*/*.bbappend" 5 | 6 | BBFILE_COLLECTIONS += "meta-klipper" 7 | BBFILE_PATTERN_meta-klipper := "^${LAYERDIR}/" 8 | BBFILE_PRIORITY_meta-klipper = "10" 9 | 10 | LAYERDEPENDS_meta-klipper = "core openembedded-layer meta-python" 11 | 12 | LAYERSERIES_COMPAT_meta-klipper = "dunfell" 13 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-python/cachelib/python-cachelib_0.1.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "A collection of cache libraries in the same API interface. Extracted from werkzeug." 2 | LICENSE = "BSD-2-Clause" 3 | LIC_FILES_CHKSUM = "file://LICENSE;md5=a32a7594742a04098377c0c777ec1af7" 4 | 5 | SRC_URI[sha256sum] = "8b889b509d372095357b8705966e1282d40835c4126d7c2b07fd414514d8ae8d" 6 | 7 | inherit pypi setuptools 8 | 9 | PYPI_PACKAGE = "cachelib" 10 | 11 | BBCLASSEXTEND = "native nativesdk" 12 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-python/pylru/python-pylru_1.2.0.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "A least recently used (LRU) cache implementation" 2 | SECTION = "devel/python" 3 | 4 | HOMEPAGE = "https://pypi.python.org/pypi/pylru/" 5 | 6 | LICENSE = "GPLv2" 7 | LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=b234ee4d69f5fce4486a80fdaf4a4263" 8 | 9 | SRC_URI[sha256sum] = "492f934bb98dc6c8b2370c02c95c65516ddc08c8f64d27f70087eb038621d297" 10 | 11 | inherit pypi setuptools 12 | 13 | PYPI_PACKAGE = "pylru" 14 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-core/images/klipper-image.bb: -------------------------------------------------------------------------------- 1 | COMPATIBLE_MACHINE = "(tinker-board-s|cubietruck)" 2 | 3 | inherit image 4 | 5 | WKS_FILE_tinker-board-s = "tinker-board-s.wks.in" 6 | WKS_FILE_cubietruck = "cubietruck.wks.in" 7 | 8 | IMAGE_FSTYPES = "wic.bz2 wic.bmap" 9 | 10 | IMAGE_BASENAME = "klipper-image" 11 | 12 | do_image_wic[depends] += "\ 13 | virtual/bootloader:do_deploy \ 14 | virtual/kernel:do_deploy \ 15 | klipper-linux-rootfs:do_image_complete \ 16 | " 17 | 18 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-python/semantic-version/python-semantic-version_2.8.5.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "This small python library provides a few tools to handle SemVer in Python. It follows strictly the 2.0.0 version of the SemVer scheme." 2 | LICENSE = "BSD" 3 | LIC_FILES_CHKSUM = "file://LICENSE;md5=4fb31e3c1c7eeb8b5e8c07657cdd54e2" 4 | 5 | SRC_URI[sha256sum] = "d2cb2de0558762934679b9a104e82eca7af448c9f4974d1f3eeccff651df8a54" 6 | 7 | inherit pypi setuptools 8 | 9 | PYPI_PACKAGE = "semantic_version" 10 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-python/sarge/python-sarge_0.1.5.post0.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "A wrapper for subprocess which provides command pipeline functionality." 2 | SECTION = "devel/python" 3 | 4 | HOMEPAGE = "https://pypi.python.org/pypi/sarge" 5 | 6 | LICENSE = "BSD" 7 | LIC_FILES_CHKSUM = "file://LICENSE;md5=a5b7bcb59dada77822aa4d479a96cc6d" 8 | 9 | SRC_URI[sha256sum] = "da8cc90883f8e5ab4af0d746438f608662f5f2a35da2e858517927edefa134b0" 10 | 11 | inherit pypi setuptools 12 | 13 | PYPI_PACKAGE = "sarge" 14 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-python/filetype/python-filetype_1.0.7.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "Small and dependency free Python package to infer file type and MIME type checking the magic numbers signature of a file or buffer." 2 | LICENSE = "MIT" 3 | LIC_FILES_CHKSUM = "file://LICENSE;md5=cc0e8af5f14a75ce53b7b9db0f4bd91e" 4 | 5 | SRC_URI[sha256sum] = "da393ece8d98b47edf2dd5a85a2c8733e44b769e32c71af4cd96ed8d38d96aa7" 6 | 7 | PYPI_PACKAGE = "filetype" 8 | 9 | inherit pypi setuptools 10 | 11 | BBCLASSEXTEND = "native nativesdk" 12 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-python/pkginfo/python-pkginfo_1.5.0.1.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "Pattern matching and various utilities for file systems paths." 2 | SECTION = "devel/python" 3 | 4 | HOMEPAGE = "https://pypi.python.org/pypi/pkginfo/" 5 | 6 | LICENSE = "MIT" 7 | LIC_FILES_CHKSUM = "file://PKG-INFO;beginline=8;endline=8;md5=8227180126797a0148f94f483f3e1489" 8 | 9 | SRC_URI[sha256sum] = "7424f2c8511c186cd5424bbf31045b77435b37a8d604990b79d4e70d741148bb" 10 | 11 | inherit pypi setuptools 12 | 13 | PYPI_PACKAGE = "pkginfo" 14 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-python/unidecode/python-unidecode_0.04.21.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "ASCII transliterations of Unicode text" 2 | SECTION = "devel/python" 3 | 4 | HOMEPAGE = "https://pypi.python.org/pypi/Unidecode" 5 | 6 | LICENSE = "GPLv2+" 7 | LIC_FILES_CHKSUM = "file://LICENSE;md5=b234ee4d69f5fce4486a80fdaf4a4263" 8 | 9 | PYPI_PACKAGE = "Unidecode" 10 | 11 | SRC_URI[sha256sum] = "280a6ab88e1f2eb5af79edff450021a0d3f0448952847cd79677e55e58bad051" 12 | 13 | inherit pypi setuptools 14 | 15 | BBCLASSEXTEND = "native" 16 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-support/create-certificate/files/create-certificate.cron: -------------------------------------------------------------------------------- 1 | SHELL=/bin/sh 2 | PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 3 | 4 | #+---------------- minute (0 - 59) 5 | #| +------------- hour (0 - 23) 6 | #| | +---------- day of month (1 - 31) 7 | #| | | +------- month (1 - 12) 8 | #| | | | +---- day of week (0 - 6) (Sunday=0 or 7) 9 | #| | | | | 10 | #* * * * * user command to be executed 11 | 0 0 1 * * root /usr/bin/create-cert >/dev/null 2>&1 12 | 13 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-python/pathtools/python-pathtools_0.1.2.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "Pattern matching and various utilities for file systems paths." 2 | SECTION = "devel/python" 3 | 4 | HOMEPAGE = "https://pypi.python.org/pypi/pathtools/" 5 | 6 | LICENSE = "MIT" 7 | LIC_FILES_CHKSUM = "file://LICENSE;md5=a870e4c037fc40b3973dd56a1526fc5b" 8 | 9 | PYPI_PACKAGE = "pathtools" 10 | 11 | SRC_URI[sha256sum] = "7c35c5421a39bb82e58018febd90e3b6e5db34c5443aaaf742b3f33d4655f1c0" 12 | 13 | inherit pypi setuptools 14 | 15 | BBCLASSEXTEND = "native" 16 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-python/websocket-client/python-websocket-client_0.56.0.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "WebSocket client for python. hybi13 is supported." 2 | HOMEPAGE = "https://github.com/websocket-client/websocket-client.git" 3 | LICENSE = "LGPL-3.0" 4 | LIC_FILES_CHKSUM = "file://LICENSE;md5=c4c4a98fbc4836b81c8c64d6ecb01fc1" 5 | 6 | SRC_URI[sha256sum] = "1fd5520878b68b84b5748bb30e592b10d0a91529d5383f74f4964e72b297fd3a" 7 | 8 | inherit pypi setuptools 9 | 10 | PYPI_PACKAGE = "websocket_client" 11 | 12 | RDEPENDS_${PN} += "python-backports-ssl" 13 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-python/argh/python-argh_0.26.2.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "Pattern matching and various utilities for file systems paths." 2 | SECTION = "devel/python" 3 | 4 | HOMEPAGE = "https://pypi.python.org/pypi/argh/" 5 | 6 | LICENSE = "LGPLv2" 7 | LIC_FILES_CHKSUM = "file://PKG-INFO;beginline=8;endline=8;md5=cede70b648dcc81baf5b431d38905bad" 8 | 9 | PYPI_PACKAGE = "argh" 10 | 11 | SRC_URI[sha256sum] = "e9535b8c84dc9571a48999094fda7f33e63c3f1b74f3e5f3ac0105a58405bb65" 12 | 13 | inherit pypi setuptools 14 | 15 | BBCLASSEXTEND = "native" 16 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-python/webassets/python-webassets_2.0.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "Media asset management for Python, with glue code for various web frameworks" 2 | SECTION = "devel/python" 3 | 4 | HOMEPAGE = "https://pypi.python.org/pypi/webassets/" 5 | 6 | LICENSE = "BSD" 7 | LIC_FILES_CHKSUM = "file://LICENSE;md5=01c7e9175fd063ebb0a6304af80e9874" 8 | 9 | PYPI_PACKGE = "webassets" 10 | 11 | SRC_URI[sha256sum] = "167132337677c8cedc9705090f6d48da3fb262c8e0b2773b29f3352f050181cd" 12 | 13 | inherit pypi setuptools 14 | 15 | BBCLASSEXTEND = "native" 16 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-python/watchdog/python-watchdog_0.9.0.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "Filesystem events monitoring" 2 | SECTION = "devel/python" 3 | 4 | HOMEPAGE = "http://http://werkzeug.pocoo.org/" 5 | 6 | LICENSE = "Apache-2.0" 7 | LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57" 8 | 9 | SRC_URI[sha256sum] = "965f658d0732de3188211932aeb0bb457587f04f63ab4c1e33eab878e9de961d" 10 | 11 | DEPENDS = "python-argh" 12 | 13 | RDEPENDS_${PN} = "python-pathtools python-argh" 14 | 15 | inherit pypi setuptools 16 | 17 | PYPI_PACKAGE = "watchdog" 18 | -------------------------------------------------------------------------------- /yocto/meta-klipper/scripts/lib/wic/canned-wks/directdisk-gpt.wks: -------------------------------------------------------------------------------- 1 | # short-description: Create a 'pcbios' direct disk image 2 | # long-description: Creates a partitioned legacy BIOS disk image that the user 3 | # can directly dd to boot media. 4 | 5 | 6 | part /boot --source bootimg-pcbios --ondisk sda --label boot --active --align 1024 7 | part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024 --use-uuid 8 | 9 | bootloader --ptable gpt --timeout=0 --append="rootwait rootfstype=ext4 video=vesafb vga=0x318 console=tty0 console=ttyS0,115200n8" 10 | 11 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-webui/octoprint/files/octoprint.run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | DAEMON=/usr/bin/octoprint 3 | LOGDIR=/var/log/octoprint 4 | BASEDIR=/var/lib/octoprint 5 | CONFIGFILE=/etc/octoprint/config.yaml 6 | PORT=5000 7 | 8 | mkdir -p $LOGDIR 9 | mkdir -p $BASEDIR 10 | 11 | OPTIONS="serve --basedir $BASEDIR --config $CONFIGFILE --port $PORT \ 12 | --logging $LOGDIR --iknowwhatimdoing --host 127.0.0.1" 13 | 14 | if [ ! -x $DAEMON ]; then 15 | echo "$0: $DAEMON not found" 16 | sleep 10 17 | exit 1 18 | fi 19 | 20 | exec 2>&1 21 | exec $DAEMON $OPTIONS 22 | 23 | -------------------------------------------------------------------------------- /yocto/meta-klipper/scripts/lib/wic/canned-wks/mkefidisk.wks: -------------------------------------------------------------------------------- 1 | # short-description: Create an EFI disk image 2 | # long-description: Creates a partitioned EFI disk image that the user 3 | # can directly dd to boot media. 4 | 5 | part /boot --source bootimg-efi --sourceparams="loader=grub-efi" --ondisk sda --label msdos --active --align 1024 6 | 7 | part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024 --use-uuid 8 | 9 | part swap --ondisk sda --size 44 --label swap1 --fstype=swap 10 | 11 | bootloader --ptable gpt --timeout=5 --append="rootfstype=ext4 console=ttyS0,115200 console=tty0" 12 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-core/busybox/busybox_%.bbappend: -------------------------------------------------------------------------------- 1 | FILESEXTRAPATHS_prepend := "${THISDIR}/files:" 2 | 3 | SRC_URI += "\ 4 | file://runit.cfg \ 5 | file://runit.init \ 6 | " 7 | 8 | PACKAGES =+ "${PN}-runit" 9 | INITSCRIPT_PACKAGES += "${PN}-runit" 10 | FILES_${PN}-runit = "${sysconfdir}/init.d/runit" 11 | 12 | INITSCRIPT_NAME_${PN}-runit = "runit" 13 | INITSCRIPT_PARAMS_${PN}-runit = "defaults 80" 14 | 15 | do_install_append() { 16 | install -d ${D}${localstatedir}/service 17 | install -d ${D}${sysconfdir}/init.d 18 | install ${WORKDIR}/runit.init ${D}${sysconfdir}/init.d/runit 19 | } 20 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-python/sphinx/python-sphinx_1.8.5.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "Sphinx" 2 | SECTION = "devel/python" 3 | 4 | HOMEPAGE = "https://pypi.org/project/Sphinx/1.8.5/" 5 | 6 | LICENSE = "BSD" 7 | LIC_FILES_CHKSUM = "file://LICENSE;md5=cc3ed00294f08c93200bc064c73c9d40" 8 | 9 | PYPI_PACKAGE = "Sphinx" 10 | #PYPI_SRC_URI = "https://files.pythonhosted.org/packages/2a/86/8e1e8400bb6eca5ed960917952600fce90599e1cb0d20ddedd81ba163370/Sphinx-${PV}.tar.gz" 11 | 12 | SRC_URI[sha256sum] = "c7658aab75c920288a8cf6f09f244c6cfdae30d82d803ac1634d9f223a80ca08" 13 | 14 | inherit pypi setuptools 15 | 16 | BBCLASSEXTEND = "native" 17 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-python/regex/python-regex_2020.5.14.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "Alternative regular expression module, to replace re." 2 | SECTION = "devel/python" 3 | 4 | HOMEPAGE = "https://pypi.python.org/pypi/regex" 5 | 6 | LICENSE = "PSFL" 7 | LIC_FILES_CHKSUM = "file://setup.py;beginline=32;endline=31;md5=d41d8cd98f00b204e9800998ecf8427e" 8 | 9 | PIPY_PACKAGE = "regex" 10 | #PYPI_SRC_URI = "https://pypi.python.org/packages/source/r/regex/regex-${PV}.tar.gz" 11 | 12 | SRC_URI[sha256sum] = "ce450ffbfec93821ab1fea94779a8440e10cf63819be6e176eb1973a6017aff5" 13 | 14 | inherit pypi setuptools 15 | 16 | BBCLASSEXTEND = "native" 17 | -------------------------------------------------------------------------------- /targets/cubietruck/conf/bblayers.conf: -------------------------------------------------------------------------------- 1 | LCONF_VERSION = "7" 2 | 3 | BBLAYERS = " \ 4 | ${YOCTO_TOPDIR}/yocto/poky/meta \ 5 | ${YOCTO_TOPDIR}/yocto/poky/meta-poky \ 6 | ${YOCTO_TOPDIR}/yocto/poky/meta-yocto-bsp \ 7 | ${YOCTO_TOPDIR}/yocto/meta-openembedded/meta-oe \ 8 | ${YOCTO_TOPDIR}/yocto/meta-openembedded/meta-python \ 9 | ${YOCTO_TOPDIR}/yocto/meta-openembedded/meta-perl \ 10 | ${YOCTO_TOPDIR}/yocto/meta-openembedded/meta-networking \ 11 | ${YOCTO_TOPDIR}/yocto/meta-sunxi \ 12 | ${YOCTO_TOPDIR}/yocto/meta-python2 \ 13 | ${YOCTO_TOPDIR}/yocto/meta-klipper \ 14 | /home/jin/Work/oe/targets/cubietruck/workspace \ 15 | " 16 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-python/markdown/python-markdown_3.1.1.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "A Python implementation of John Gruber's Markdown." 2 | LICENSE = "BSD-3-Clause" 3 | LIC_FILES_CHKSUM = "file://LICENSE.md;md5=745aaad0c69c60039e638bff9ffc59ed" 4 | 5 | inherit pypi setuptools 6 | 7 | PYPI_PACKAGE = "Markdown" 8 | #PYPI_SRC_URI = "https://files.pythonhosted.org/packages/ac/df/0ae25a9fd5bb528fe3c65af7143708160aa3b47970d5272003a1ad5c03c6/Markdown-${PV}.tar.gz" 9 | 10 | SRC_URI[md5sum] = "d84732ecc65b3a1bff693d9d4c24277f" 11 | SRC_URI[sha256sum] = "2e50876bcdd74517e7b71f3e7a76102050edec255b3983403f1a63e7c8a41e7a" 12 | 13 | BBCLASSEXTEND = "native" 14 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-python/sphinxcontrib-httpdomain/python-sphinxcontrib-httpdomain_1.7.0.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "Sphinx domain for HTTP APIs." 2 | SECTION = "devel/python" 3 | 4 | HOMEPAGE = "https://pypi.python.org/pypi/sphinxcontrib-httpdomain" 5 | 6 | LICENSE = "BSD" 7 | LIC_FILES_CHKSUM = "file://LICENSE;md5=667c3e266c41ac5129a4478ad682b1c3" 8 | 9 | PYPI_PACKAGE = "sphinxcontrib-httpdomain" 10 | #PYPI_SRC_URI = "https://pypi.python.org/packages/source/s/sphinxcontrib-httpdomain/sphinxcontrib-httpdomain-${PV}.tar.gz" 11 | 12 | SRC_URI[sha256sum] = "ac40b4fba58c76b073b03931c7b8ead611066a6aebccafb34dc19694f4eb6335" 13 | 14 | inherit pypi setuptools 15 | 16 | BBCLASSEXTEND = "native" 17 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-bsp/u-boot/files/cubietruck/cubietruck_nand.cfg: -------------------------------------------------------------------------------- 1 | CONFIG_NAND_BOOT=y 2 | CONFIG_CMD_NAND=y 3 | CONFIG_CMD_NAND_TRIMFFS=y 4 | CONFIG_ENV_IS_IN_NAND=y 5 | #CONFIG_ENV_ADDR= 6 | CONFIG_MTD=y 7 | CONFIG_MTD_RAW_NAND=y 8 | CONFIG_SYS_NAND_SELF_INIT=y 9 | CONFIG_SYS_NAND_USE_FLASH_BBT=y 10 | CONFIG_NAND_SUNXI=y 11 | CONFIG_NAND_SUNXI_SPL_ECC_STRENGTH=64 12 | CONFIG_NAND_SUNXI_SPL_ECC_SIZE=1024 13 | CONFIG_NAND_SUNXI_SPL_USABLE_PAGE_SIZE=1024 14 | CONFIG_SYS_NAND_BLOCK_SIZE=0x40000 15 | CONFIG_SYS_NAND_PAGE_SIZE=4096 16 | CONFIG_SYS_NAND_OOBSIZE=256 17 | CONFIG_SYS_NAND_U_BOOT_LOCATIONS=y 18 | CONFIG_SYS_NAND_U_BOOT_OFFS=0x800000 19 | CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND=0x800000 20 | -------------------------------------------------------------------------------- /yocto/meta-klipper/scripts/lib/wic/canned-wks/systemd-bootdisk.wks: -------------------------------------------------------------------------------- 1 | # short-description: Create an EFI disk image with systemd-boot 2 | # long-description: Creates a partitioned EFI disk image that the user 3 | # can directly dd to boot media. The selected bootloader is systemd-boot. 4 | 5 | part /boot --source bootimg-efi --sourceparams="loader=systemd-boot" --ondisk sda --label msdos --active --align 1024 --use-uuid 6 | 7 | part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024 --use-uuid 8 | 9 | part swap --ondisk sda --size 44 --label swap1 --fstype=swap --use-uuid 10 | 11 | bootloader --ptable gpt --timeout=5 --append="rootwait rootfstype=ext4 console=ttyS0,115200 console=tty0" 12 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-devtools/python/python-nose.inc: -------------------------------------------------------------------------------- 1 | SUMMARY = "Extends Python unittest to make testing easier" 2 | HOMEPAGE = "http://readthedocs.org/docs/nose/" 3 | DESCRIPTION = "nose extends the test loading and running features of unittest, \ 4 | making it easier to write, find and run tests." 5 | SECTION = "devel/python" 6 | LICENSE = "LGPLv2.1" 7 | LIC_FILES_CHKSUM = "file://lgpl.txt;md5=a6f89e2100d9b6cdffcea4f398e37343" 8 | 9 | SRC_URI[md5sum] = "4d3ad0ff07b61373d2cefc89c5d0b20b" 10 | SRC_URI[sha256sum] = "f1bffef9cbc82628f6e7d7b40d7e255aefaa1adb6a1b1d26c69a8b79e6208a98" 11 | 12 | inherit pypi 13 | 14 | RDEPENDS_${PN} = "\ 15 | ${PYTHON_PN}-unittest \ 16 | " 17 | 18 | BBCLASSEXTEND = "native nativesdk" 19 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-printing/klipper/files/klipper.run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | DAEMON=/usr/bin/klippy 4 | LOGDIR=/var/log/klipper 5 | 6 | DEFAULTS_FILE=/etc/default/klipper 7 | 8 | mkdir -p $LOGDIR 9 | 10 | PRINTER_CONFIG_DIR="/etc/klipper" 11 | mkdir -p $PRINTER_CONFIG_DIR 12 | 13 | 14 | # Read defaults file 15 | if [ -r $DEFAULTS_FILE ]; then 16 | source $DEFAULTS_FILE 17 | fi 18 | 19 | PRINTER_CONFIG="$PRINTER_CONFIG_DIR/printer.cfg" 20 | 21 | OPTIONS="$PRINTER_CONFIG -l $LOGDIR/klipper.log -a /tmp/klippy_uds" 22 | 23 | if [ ! -x $DAEMON ] || [ ! -s $PRINTER_CONFIG ]; then 24 | echo "$0: $DAEMON or $PRINTER_CONFIG not found!" 25 | sleep 10 26 | exit 1 27 | fi 28 | 29 | exec 2>&1 30 | exec $DAEMON $OPTIONS 31 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-python/flask-assets/python-flask-assets_0.12.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "Flask webassets integration." 2 | SECTION = "devel/python" 3 | 4 | HOMEPAGE = "http://flask-assets.readthedocs.org/en/latest/" 5 | 6 | LICENSE = "BSD" 7 | LIC_FILES_CHKSUM = "file://LICENSE;md5=2c0c455026ee819a9365678bea8b2c82" 8 | 9 | DEPENDS = "python-webassets" 10 | 11 | PYPI_PACKAGE = "Flask-Assets" 12 | #PYPI_SRC_URI = "https://files.pythonhosted.org/packages/86/ff/6000451570745d7a90847f6528d96d6b24c800eaaf9f26cf398accd8cee5/Flask-Assets-${PV}.tar.gz" 13 | 14 | SRC_URI[sha256sum] = "6031527b89fb3509d1581d932affa5a79dd348cfffb58d0aef99a43461d47847" 15 | 16 | inherit pypi setuptools 17 | 18 | RDEPENDS_${PN} = "python-webassets" 19 | 20 | BBCLASSEXTEND = "native" 21 | -------------------------------------------------------------------------------- /yocto/meta-klipper/scripts/lib/wic/canned-wks/directdisk-bootloader-config.cfg: -------------------------------------------------------------------------------- 1 | # This is an example configuration file for syslinux. 2 | TIMEOUT 50 3 | ALLOWOPTIONS 1 4 | SERIAL 0 115200 5 | PROMPT 0 6 | 7 | UI vesamenu.c32 8 | menu title Select boot options 9 | menu tabmsg Press [Tab] to edit, [Return] to select 10 | 11 | DEFAULT Graphics console boot 12 | 13 | LABEL Graphics console boot 14 | KERNEL /vmlinuz 15 | APPEND label=boot rootwait 16 | 17 | LABEL Serial console boot 18 | KERNEL /vmlinuz 19 | APPEND label=boot rootwait console=ttyS0,115200 20 | 21 | LABEL Graphics console install 22 | KERNEL /vmlinuz 23 | APPEND label=install rootwait 24 | 25 | LABEL Serial console install 26 | KERNEL /vmlinuz 27 | APPEND label=install rootwait console=ttyS0,115200 28 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-python/certifi/python-certifi_2020.4.5.1.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "Python package for providing Mozilla's CA Bundle." 2 | DESCRIPTION = "This installable Python package contains a CA Bundle that you can reference in your \ 3 | Python code. This is useful for verifying HTTP requests, for example. This is the same CA Bundle \ 4 | which ships with the Requests codebase, and is derived from Mozilla Firefox's canonical set." 5 | HOMEPAGE = " http://certifi.io/" 6 | 7 | LICENSE = "ISC" 8 | LIC_FILES_CHKSUM = "file://LICENSE;md5=f77f61d14ee6feac4228d3ebd26cc1f1" 9 | 10 | PYPI_PACKAGE = "certifi" 11 | 12 | SRC_URI[sha256sum] = "51fcb31174be6e6664c5f69e3e1691a2d72a1a12e90f872cbdb1567eb47b6519" 13 | 14 | inherit pypi setuptools 15 | 16 | 17 | BBCLASSEXTEND = "native nativesdk" 18 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-python/flask/python-flask_0.12.5.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "A microframework based on Werkzeug, Jinja2 and good intentions" 2 | DESCRIPTION = "\ 3 | Flask is a microframework for Python based on Werkzeug, Jinja 2 and good \ 4 | intentions. And before you ask: It’s BSD licensed!" 5 | HOMEPAGE = "https://github.com/mitsuhiko/flask/" 6 | LICENSE = "BSD-3-Clause" 7 | LIC_FILES_CHKSUM = "file://LICENSE;md5=19866b76b054ab30c270c0eb9d7e43d7" 8 | 9 | SRC_URI[sha256sum] = "fac2b9d443e49f7e7358a444a3db5950bdd0324674d92ba67f8f1f15f876b14f" 10 | 11 | CLEANBROKEN = "1" 12 | 13 | PYPI_PACKAGE = "Flask" 14 | 15 | inherit pypi setuptools 16 | 17 | RDEPENDS_${PN} = "\ 18 | ${PYTHON_PN}-click \ 19 | ${PYTHON_PN}-itsdangerous \ 20 | ${PYTHON_PN}-jinja2 \ 21 | ${PYTHON_PN}-werkzeug \ 22 | " 23 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "yocto/poky"] 2 | path = yocto/poky 3 | url = git://git.yoctoproject.org/poky.git 4 | [submodule "meta-python2"] 5 | path = yocto/meta-python2 6 | url = git://git.openembedded.org/meta-python2 7 | [submodule "yocto/meta-rockchip"] 8 | path = yocto/meta-rockchip 9 | url = git://git.yoctoproject.org/meta-rockchip 10 | [submodule "meta-openembedded"] 11 | path = yocto/meta-openembedded 12 | url = git://git.openembedded.org/meta-openembedded 13 | [submodule "yocto/openembedded-core"] 14 | path = yocto/openembedded-core 15 | url = git://git.openembedded.org/openembedded-core 16 | [submodule "yocto/meta-sunxi"] 17 | path = yocto/meta-sunxi 18 | url = https://github.com/linux-sunxi/meta-sunxi 19 | [submodule "yocto/meta-arm"] 20 | path = yocto/meta-arm 21 | url = git://git.yoctoproject.org/meta-arm 22 | -------------------------------------------------------------------------------- /targets/tinker-board-s/conf/bblayers.conf: -------------------------------------------------------------------------------- 1 | LCONF_VERSION = "7" 2 | 3 | BBLAYERS = " \ 4 | ${YOCTO_TOPDIR}/yocto/poky/meta \ 5 | ${YOCTO_TOPDIR}/yocto/poky/meta-poky \ 6 | ${YOCTO_TOPDIR}/yocto/poky/meta-yocto-bsp \ 7 | ${YOCTO_TOPDIR}/yocto/meta-openembedded/meta-oe \ 8 | ${YOCTO_TOPDIR}/yocto/meta-openembedded/meta-python \ 9 | ${YOCTO_TOPDIR}/yocto/meta-openembedded/meta-perl \ 10 | ${YOCTO_TOPDIR}/yocto/meta-openembedded/meta-networking \ 11 | ${YOCTO_TOPDIR}/yocto/meta-arm/meta-arm-toolchain \ 12 | ${YOCTO_TOPDIR}/yocto/meta-arm/meta-arm \ 13 | ${YOCTO_TOPDIR}/yocto/meta-rockchip \ 14 | ${YOCTO_TOPDIR}/yocto/meta-python2 \ 15 | ${YOCTO_TOPDIR}/yocto/meta-klipper \ 16 | " 17 | 18 | BBMASK = "${YOCTO_TOPDIR}/yocto/meta-klipper/recipes-kernel/linux/linux-mainline_%.bbappend" 19 | -------------------------------------------------------------------------------- /yocto/meta-klipper/conf/distro/klipper-linux.conf: -------------------------------------------------------------------------------- 1 | # This distro is based on Poky 2 | require conf/distro/poky.conf 3 | 4 | DISTRO = "klipper-linux" 5 | DISTRO_NAME = "Klipper 3D Linux Distribution" 6 | MAINTAINER = "Sergey 'Jin' Bostandzhyan " 7 | 8 | PACKAGE_CLASSES = "package_ipk" 9 | 10 | GLIBC_GENERATE_LOCALES ?= "en_US.UTF-8" 11 | IMAGE_LINGUAS ?= "en-us" 12 | 13 | DISTRO_FEATURES = "ext2 ipv4 ipv6 usbgadget usbhost sysvinit dconfig zeroconf" 14 | 15 | # octoprint depends on some particular versions 16 | PREFERRED_VERSION_python-websocket-client = "0.56.0" 17 | PREFERRED_VERSION_python-pkginfo = "1.5.0.1" 18 | PREFERRED_VERSION_python-jinja2 = "2.8.1" 19 | PREFERRED_VERSION_python-flask = "0.12.5" 20 | PREFERRED_VERSION_python-pytest = "4.6.6" 21 | PREFERRED_VERSION_python-tornado = "4.5.3" 22 | 23 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-webui/octoprint/files/config.yaml: -------------------------------------------------------------------------------- 1 | serial: 2 | autoconnect: true 3 | baudrate: 115200 4 | port: /tmp/printer 5 | timeout: {} 6 | plugins: 7 | pluginmanager: 8 | pip: /usr/bin/pip 9 | pip_force_user: true 10 | softwareupdate: 11 | pip_command: /usr/bin/pip 12 | _config_version: 6 13 | checks: 14 | octoprint: 15 | checkout_folder: null 16 | prerelease: false 17 | prerelease_channel: null 18 | notify_users: false 19 | server: 20 | reverseProxy: 21 | prefixHeader: X-Script-Name 22 | onlineCheck: 23 | enabled: false 24 | pluginBlacklist: 25 | enabled: true 26 | commands: 27 | serverRestartCommand: sv restart octoprint 28 | systemRestartCommand: shutdown -r now 29 | systemShutdownCommand: shutdown -h now 30 | system: 31 | actions: [] 32 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-core/images/cubietruck-installer-image.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "Small image capable of booting a cubietruck with support for the \ 2 | Minimal MTD Utilities, which let the user interact with the MTD subsystem in \ 3 | the kernel to perform operations on flash devices." 4 | 5 | PR = "r1" 6 | 7 | COMPATIBLE_MACHINE = "cubietruck" 8 | 9 | IMAGE_INSTALL = "packagegroup-core-boot \ 10 | ${CORE_IMAGE_EXTRA_INSTALL} \ 11 | mtd-utils \ 12 | dosfstools \ 13 | e2fsprogs-e2fsck \ 14 | e2fsprogs-mke2fs \ 15 | e2fsprogs-tune2fs \ 16 | rsync \ 17 | util-linux-mkfs \ 18 | sunxi-tools \ 19 | mtd-utils-ubifs \ 20 | mtd-utils-misc \ 21 | " 22 | 23 | IMAGE_LINGUAS = " " 24 | 25 | LICENSE = "MIT" 26 | 27 | inherit core-image 28 | 29 | IMAGE_ROOTFS_SIZE="1384000" 30 | 31 | IMAGE_FEATURES += "ssh-server-openssh" 32 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-core/packagegroups/packagegroup-klipper-image.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "Klipper image dependency metapackage" 2 | 3 | PACKAGE_ARCH = "${MACHINE_ARCH}" 4 | 5 | inherit packagegroup 6 | 7 | RDEPENDS_${PN} = "\ 8 | e2fsprogs-e2fsck \ 9 | e2fsprogs-resize2fs \ 10 | kernel-devicetree \ 11 | klipper \ 12 | lighttpd \ 13 | avahi-daemon \ 14 | avahi-autoipd \ 15 | tzdata \ 16 | tzdata-africa \ 17 | tzdata-americas \ 18 | tzdata-antarctica \ 19 | tzdata-antarctica \ 20 | tzdata-asia \ 21 | tzdata-atlantic \ 22 | tzdata-australia \ 23 | tzdata-europe \ 24 | tzdata-pacific \ 25 | ntp \ 26 | ntpdate \ 27 | " 28 | 29 | RDEPENDS_${PN}_append_tinker_board_s = "\ 30 | kernel-image-zimage \ 31 | " 32 | 33 | RDEPENDS_${PN}_append_cubietruck = "\ 34 | kernel-image-uimage \ 35 | " 36 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-python/awesome-slugify/python-awesome-slugify_1.6.5.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "Python flexible slugify function https://pypi.python.org/pypi/awesome-slugify" 2 | SECTION = "devel/python" 3 | 4 | HOMEPAGE = "https://github.com/dimka665/awesome-slugify" 5 | 6 | LICENSE = "GPLv3" 7 | LIC_FILES_CHKSUM = "file://setup.py;beginline=22;endline=24;md5=ae3de4b453d37fcbff2ca5a8a4725cfd" 8 | 9 | PYPI_PACKAGE = "awesome-slugify" 10 | #PYPI_SRC_URI = "https://files.pythonhosted.org/packages/34/39/79ef4e640c3651b40de7812f5fcd04698abf14de4f57a81e12b6c753d168/awesome-slugify-${PV}.tar.gz" 11 | 12 | SRC_URI[sha256sum] = "bbdec3fa2187917473a2efad092b57f7125a55f841a7cf6a1773178d32ccfd71" 13 | 14 | inherit pypi setuptools 15 | 16 | RDEPENDS_${PN} = "python-nose \ 17 | python-regex \ 18 | python-unidecode \ 19 | " 20 | 21 | BBCLASSEXTEND = "native" 22 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-python/chainmap/python-chainmap_1.0.3.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "Backport/clone of ChainMap for py26, py32, and pypy3." 2 | DESCRIPTION = "\ 3 | This module is a polyfill, implementing ChainMap for reasonably-recent versions of Python that do not have collections.ChainMap–namely, Python 2.6, Python 3.2, and PyPy3 releases based on Python 3.2. (It will also work as expected on Python 2.7, PyPy, and Python 3.3 and higher, but it is not needed there since those verions’ collections modules contains a ChainMap implementation.)" 4 | LICENSE = "PSF" 5 | LIC_FILES_CHKSUM = "file://setup.py;beginline=23;endline=23;md5=fa869eb628865ee985e6a9d306744ac8" 6 | 7 | SRC_URI[sha256sum] = "e42aaa4b3e2f66102a11bfd563069704bfbfd84fdcb517b564effd736bf53cd9" 8 | 9 | PYPI_PACKAGE = "chainmap" 10 | 11 | CLEANBROKEN = "1" 12 | 13 | BBCLASSEXTEND = "native nativesdk" 14 | 15 | inherit pypi setuptools 16 | 17 | -------------------------------------------------------------------------------- /yocto/meta-klipper/wic/cubietruck.wks.in: -------------------------------------------------------------------------------- 1 | # The disk layout used is: 2 | # 3 | # 0 -> 8*1024 - reserverd 4 | # 8*1024 -> - arm combined spl/u-boot or aarch64 spl 5 | # 40*1024 -> - aarch64 u-boot 6 | # 2048*1024 -> BOOT_SPACE - bootloader and kernel 7 | 8 | part spl --offset 8k --source=rawcopy --sourceparams="file=u-boot-sunxi-with-spl.bin" --no-table 9 | part uboot --offset 2048k --active --source bootimg-partition --fstype=vfat --label BOOT --sourceparams="loader=u-boot" 10 | part root --size 256M --align 2048 --source rawcopy --sourceparams="file=klipper-linux-rootfs-${MACHINE}.ext4" --fstype=ext4 --label ROOT 11 | 12 | bootloader --ptable msdos --append="console=ttyS0,115200n8 rw rootfstype=ext4 init=/sbin/init root=/dev/mmcblk0p2" 13 | 14 | 15 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-bsp/u-boot/u-boot_%.bbappend: -------------------------------------------------------------------------------- 1 | FILESEXTRAPATHS_prepend := "${THISDIR}/files:" 2 | 3 | SRC_URI_append_cubietruck = " file://cubietruck_nand.cfg" 4 | 5 | SPL_ECC_BINARY = "sunxi-spl-with-ecc.bin" 6 | SPL_ECC_BINARYNAME = "${@os.path.basename(d.getVar('SPL_ECC_BINARY'))}" 7 | SPL_ECC_IMAGE = "${SPL_ECC_BINARYNAME}-${MACHINE}-${PV}-${PR}" 8 | SPL_ECC_SYMLINK = "${SPL_ECC_BINARYNAME}-${MACHINE}" 9 | 10 | do_install_append_cubietruck() { 11 | install -m 644 ${B}/spl/${SPL_ECC_BINARY} ${D}/boot/${SPL_ECC_IMAGE}-${type}-${PV}-${PR} 12 | ln -sf ${SPL_ECC_IMAGE}-${type}-${PV}-${PR} ${D}/boot/${SPL_ECC_BINARYNAME}-${type} 13 | ln -sf ${SPL_ECC_IMAGE}-${type}-${PV}-${PR} ${D}/boot/${SPL_ECC_BINARYNAME} 14 | 15 | } 16 | do_deploy_append_cubietruck() { 17 | install -m 644 ${B}/spl/${SPL_ECC_BINARY} ${DEPLOYDIR}/${SPL_ECC_IMAGE} 18 | rm -f ${DEPLOYDIR}/${SPL_ECC_BINARYNAME} ${DEPLOYDIR}/${SPL_ECC_SYMLINK} 19 | ln -sf ${SPL_ECC_IMAGE} ${DEPLOYDIR}/${SPL_ECC_BINARYNAME} 20 | ln -sf ${SPL_ECC_IMAGE} ${DEPLOYDIR}/${SPL_ECC_SYMLINK} 21 | } 22 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-python/jinja2/python-jinja2_2.8.1.bb: -------------------------------------------------------------------------------- 1 | 2 | SUMMARY = "Python Jinja2: A small but fast and easy to use stand-alone template engine written in pure python." 3 | DESCRIPTION = "Python Jinja2: A small but fast and easy to use stand-alone template engine written in pure python." 4 | LICENSE = "BSD" 5 | LIC_FILES_CHKSUM = "file://LICENSE;md5=20c831f91dd3bd486020f672ba2be386" 6 | 7 | SRC_URI[sha256sum] = "35341f3a97b46327b3ef1eb624aadea87a535b8f50863036e085e7c426ac5891" 8 | 9 | PYPI_PACKAGE = "Jinja2" 10 | 11 | inherit pypi setuptools 12 | 13 | RDEPENDS_${PN} += "\ 14 | ${PYTHON_PN}-crypt \ 15 | ${PYTHON_PN}-io \ 16 | ${PYTHON_PN}-json \ 17 | ${PYTHON_PN}-lang \ 18 | ${PYTHON_PN}-markupsafe \ 19 | ${PYTHON_PN}-math \ 20 | ${PYTHON_PN}-netclient \ 21 | ${PYTHON_PN}-pickle \ 22 | ${PYTHON_PN}-pprint \ 23 | ${PYTHON_PN}-re \ 24 | ${PYTHON_PN}-shell \ 25 | ${PYTHON_PN}-textutils \ 26 | ${PYTHON_PN}-threading \ 27 | ${PYTHON_PN}-numbers \ 28 | " 29 | 30 | CLEANBROKEN = "1" 31 | 32 | BBCLASSEXTEND = "native nativesdk" 33 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-core/images/klipper-linux-rootfs.bb: -------------------------------------------------------------------------------- 1 | include recipes-core/images/core-image-minimal.bb 2 | 3 | DESCRIPTION = "Klipper Linux rootfs image" 4 | IMAGE_FEATURES_append = " package-management ssh-server-dropbear" 5 | IMAGE_INSTALL_append = " packagegroup-klipper-image" 6 | 7 | IMAGE_FSTYPES = "ext4 ext4.gz" 8 | 9 | IMAGE_BASENAME = "${PN}" 10 | 11 | IMAGE_ROOTFS_EXTRA_SPACE = "204800" 12 | 13 | inherit extrausers 14 | EXTRA_USERS_PARAMS = "\ 15 | useradd -p \$6\$75uXvknClpLLmi\$SaSiPB9qALjsPn3W43Kn7rtAcW9Gz/fqKJYzAiGBestRPR8t8NyBUvC8OO49T61usTCQZgkDqBfh3GGApWuLP0 klipper ; \ 16 | " 17 | 18 | create_extlinux_config() { 19 | mkdir -p ${IMAGE_ROOTFS}/boot/extlinux 20 | cat > ${IMAGE_ROOTFS}/boot/extlinux/extlinux.conf < 3 | Date: Sat, 30 Nov 2019 18:39:15 -0800 4 | Subject: [PATCH] setup.py: remove setup_requires for setuptools-scm 5 | 6 | The setup_requires argument forces the download of the egg file for setuptools-scm 7 | during the do_compile phase. This download is incompatible with the typical fetch 8 | and mirror structure. The only usage of scm is the generation of the _version.py 9 | file and in the release tarball it is already correctly created 10 | 11 | Upstream-Status: Inappropriate [oe specific] 12 | 13 | Signed-off-by: Derek Straka 14 | Signed-off-by: Tim Orling 15 | --- 16 | setup.py | 2 +- 17 | 1 file changed, 1 insertion(+), 1 deletion(-) 18 | 19 | diff --git a/setup.py b/setup.py 20 | index 491a6f5..c6af9e2 100644 21 | --- a/setup.py 22 | +++ b/setup.py 23 | @@ -23,7 +23,7 @@ INSTALL_REQUIRES = [ 24 | def main(): 25 | setup( 26 | use_scm_version={"write_to": "src/_pytest/_version.py"}, 27 | - setup_requires=["setuptools-scm", "setuptools>=40.0"], 28 | + setup_requires=["setuptools>=40.0"], 29 | package_dir={"": "src"}, 30 | # fmt: off 31 | extras_require={ 32 | -------------------------------------------------------------------------------- /yocto/meta-klipper/wic/tinker-board-s.wks.in: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020 Garmin Ltd. or its subsidiaries 2 | # Released under the MIT license (see COPYING.MIT for the terms) 3 | # 4 | # Disk layout 5 | # Note that the reference documentation refers to 512 byte disk sectors, but 6 | # wic uses 1KB blocks 7 | # 8 | # Partition Start Sector Number of Sectors 9 | # loader1 64 8000 10 | # reserved1 8064 128 11 | # reserved2 8192 8192 12 | # loader2 16384 8192 13 | # atf 24576 8192 14 | # root 32768 - 15 | 16 | part loader1 --align 32 --size 4000K --ondisk ${RK_BOOT_DEVICE} --source rawcopy --sourceparams="file=idbloader.img" 17 | part reserved1 --align 4032 --size 64K --ondisk ${RK_BOOT_DEVICE} 18 | part reserved2 --align 4096 --size 4096K --ondisk ${RK_BOOT_DEVICE} 19 | part loader2 --align 8192 --size 4096K --ondisk ${RK_BOOT_DEVICE} --source rawcopy --sourceparams="file=u-boot.bin" 20 | part atf --align 12288 --size 4096K --ondisk ${RK_BOOT_DEVICE} 21 | part / --align 16384 --active --ondisk ${RK_BOOT_DEVICE} --source rawcopy --sourceparams="file=klipper-linux-rootfs-${MACHINE}.ext4" --fstype=ext4 --label root 22 | 23 | bootloader --ptable gpt --append="console=tty1 console=ttyS2,115200n8 rw root=/dev/${RK_BOOT_DEVICE}p6 rootfstype=ext4 init=/sbin/init" 24 | 25 | 26 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-devtools/python-numpy/files/0001-numpy-random-setup.py-remove-the-detection-of-x86-ta.patch: -------------------------------------------------------------------------------- 1 | From b881e0b2ba9cf1a4aa351a1c1ea90b1e1776ce21 Mon Sep 17 00:00:00 2001 2 | From: Alexander Kanavin 3 | Date: Mon, 12 Aug 2019 15:37:36 +0200 4 | Subject: [PATCH] numpy/random/setup.py: remove the detection of x86 targets 5 | via uname() 6 | 7 | This was badly breaking compilation for ARM targets (and possibly 8 | other non-x86 targets); if -msse2 is desirable for x86 builds it has 9 | to be passed through another channel. 10 | 11 | Upstream-Status: Inappropriate [oe-core specific] 12 | Signed-off-by: Alexander Kanavin 13 | --- 14 | numpy/random/setup.py | 5 ----- 15 | 1 file changed, 5 deletions(-) 16 | 17 | diff --git a/numpy/random/setup.py b/numpy/random/setup.py 18 | index a1bf3b8..60fb534 100644 19 | --- a/numpy/random/setup.py 20 | +++ b/numpy/random/setup.py 21 | @@ -49,11 +49,6 @@ def configuration(parent_package='', top_path=None): 22 | elif not is_msvc: 23 | # Some bit generators require c99 24 | EXTRA_COMPILE_ARGS += ['-std=c99'] 25 | - INTEL_LIKE = any(arch in platform.machine() 26 | - for arch in ('x86', 'i686', 'i386', 'amd64')) 27 | - if INTEL_LIKE: 28 | - # Assumes GCC or GCC-like compiler 29 | - EXTRA_COMPILE_ARGS += ['-msse2'] 30 | 31 | # Use legacy integer variable sizes 32 | LEGACY_DEFS = [('NP_RANDOM_LEGACY', '1')] 33 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-extended/lighttpd/files/0001-Use-pkg-config-for-pcre-dependency-instead-of-config.patch: -------------------------------------------------------------------------------- 1 | From 22afc5d9aaa215c3c87ba21c77d47da44ab3b113 Mon Sep 17 00:00:00 2001 2 | From: Alexander Kanavin 3 | Date: Fri, 26 Aug 2016 18:20:32 +0300 4 | Subject: [PATCH] Use pkg-config for pcre dependency instead of -config script. 5 | 6 | RP 2014/5/22 7 | Upstream-Status: Pending 8 | Signed-off-by: Alexander Kanavin 9 | --- 10 | configure.ac | 16 ++++++++++++---- 11 | 1 file changed, 12 insertions(+), 4 deletions(-) 12 | 13 | diff --git a/configure.ac b/configure.ac 14 | index 5383cec..c29a902 100644 15 | --- a/configure.ac 16 | +++ b/configure.ac 17 | @@ -651,10 +651,18 @@ AC_ARG_WITH([pcre], 18 | ) 19 | AC_MSG_RESULT([$WITH_PCRE]) 20 | 21 | -if test "$WITH_PCRE" != no; then 22 | - if test "$WITH_PCRE" != yes; then 23 | - PCRE_LIB="-L$WITH_PCRE/lib -lpcre" 24 | - CPPFLAGS="$CPPFLAGS -I$WITH_PCRE/include" 25 | +if test "$WITH_PCRE" != "no"; then 26 | + PKG_CHECK_MODULES(PCREPKG, [libpcre], [ 27 | + PCRE_LIB=${PCREPKG_LIBS} 28 | + CPPFLAGS="$CPPFLAGS ${PCREPKG_CFLAGS}" 29 | + ], [ 30 | + AC_MSG_ERROR([pcre pkgconfig not found, install the pcre-devel package or build with --without-pcre]) 31 | + ]) 32 | + 33 | + if test x"$PCRE_LIB" != x; then 34 | + AC_DEFINE([HAVE_LIBPCRE], [1], [libpcre]) 35 | + AC_DEFINE([HAVE_PCRE_H], [1], [pcre.h]) 36 | + AC_SUBST(PCRE_LIB) 37 | else 38 | AC_PATH_PROG([PCRECONFIG], [pcre-config]) 39 | if test -n "$PCRECONFIG"; then 40 | -- 41 | 2.15.0 42 | 43 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-devtools/python/python-pytest_4.6.6.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "Simple powerful teting with python" 2 | HOMEPAGE = "http://pytest.org" 3 | LICENSE = "MIT" 4 | LIC_FILES_CHKSUM = "file://LICENSE;md5=640061b8cee64b308a4d2f9f556c12f2" 5 | 6 | SRC_URI += " file://0001-setup.py-remove-setup_requires-for-setuptools-scm.patch" 7 | 8 | SRC_URI[sha256sum] = "692d9351353ef709c1126266579edd4fd469dcf6b5f4f583050f72161d6f3592" 9 | 10 | inherit update-alternatives pypi setuptools 11 | 12 | RDEPENDS_${PN}_class-target += " \ 13 | ${PYTHON_PN}-argparse \ 14 | ${PYTHON_PN}-atomicwrites \ 15 | ${PYTHON_PN}-attrs \ 16 | ${PYTHON_PN}-compiler \ 17 | ${PYTHON_PN}-debugger \ 18 | ${PYTHON_PN}-doctest \ 19 | ${PYTHON_PN}-funcsigs \ 20 | ${PYTHON_PN}-importlib-metadata \ 21 | ${PYTHON_PN}-json \ 22 | ${PYTHON_PN}-logging \ 23 | ${PYTHON_PN}-more-itertools \ 24 | ${PYTHON_PN}-packaging \ 25 | ${PYTHON_PN}-pathlib2 \ 26 | ${PYTHON_PN}-pluggy \ 27 | ${PYTHON_PN}-py \ 28 | ${PYTHON_PN}-setuptools \ 29 | ${PYTHON_PN}-six \ 30 | ${PYTHON_PN}-wcwidth \ 31 | " 32 | 33 | RDEPENDS_${PN}-ptest += "\ 34 | ${PYTHON_PN}-hypothesis \ 35 | " 36 | 37 | FILESEXTRAPATHS_prepend := "${THISDIR}/python-pytest:" 38 | 39 | ALTERNATIVE_${PN} += "py.test pytest" 40 | 41 | NATIVE_LINK_NAME[pytest] = "${bindir}/pytest" 42 | ALTERNATIVE_TARGET[pytest] = "${bindir}/pytest" 43 | 44 | ALTERNATIVE_LINK_NAME[py.test] = "${bindir}/py.test" 45 | ALTERNATIVE_TARGET[py.test] = "${bindir}/py.test" 46 | 47 | ALTERNATIVE_PRIORITY = "10" 48 | 49 | BBCLASSEXTEND = "native nativesdk" 50 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-devtools/python/python-pytest/pytest_version_fix.patch: -------------------------------------------------------------------------------- 1 | Upstream-Status: Inappropriate (OE specific) 2 | 3 | python-pytest: remove fetch during do_compile phase 4 | commit: c974fbf9ebf185552ab65301e07af44f36517abf 5 | 6 | introduced an issue by making the version 0.0.0 7 | this fixes that 8 | 9 | Signed-off-by: Armin Kuster 10 | 11 | Index: pytest-3.2.2/setup.py 12 | =================================================================== 13 | --- pytest-3.2.2.orig/setup.py 14 | +++ pytest-3.2.2/setup.py 15 | @@ -1,5 +1,6 @@ 16 | import os 17 | import sys 18 | +import re 19 | import setuptools 20 | import pkg_resources 21 | from setuptools import setup, Command 22 | @@ -22,6 +23,18 @@ classifiers = [ 23 | with open('README.rst') as fd: 24 | long_description = fd.read() 25 | 26 | +def read(*names, **kwargs): 27 | + with open(os.path.join( *names), 'r') as fp: 28 | + return fp.read() 29 | + 30 | +def find_version(*file_paths): 31 | + version_file = read(*file_paths) 32 | + version_match = re.search(r"^version = ['\']([^'\"]*)['\']", 33 | + version_file, re.M) 34 | + 35 | + if version_match: 36 | + return version_match.group(1) 37 | + raise RuntimeError("Unable to find version string.") 38 | 39 | def get_environment_marker_support_level(): 40 | """ 41 | @@ -59,9 +72,7 @@ def main(): 42 | name='pytest', 43 | description='pytest: simple powerful testing with Python', 44 | long_description=long_description, 45 | - use_scm_version={ 46 | - 'write_to': '_pytest/_version.py', 47 | - }, 48 | + version=find_version("_pytest", "_version.py"), 49 | url='http://pytest.org', 50 | license='MIT license', 51 | platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], 52 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-core/busybox/files/runit.init: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Imported from: 3 | # https://git.digitalstrom.org/dss-oe/dss-oe/blob/master/yocto/dS/meta-digitalstrom-devel/recipes-core/runit/files/runit.sh 4 | # License: MIT 5 | 6 | NAME="runsvdir" 7 | DESC="runit service supervisor" 8 | DAEMON=runsvdir 9 | 10 | case "$1" in 11 | start) 12 | if [ ! -d /etc/runit ]; then 13 | mkdir -p /etc/runit 14 | fi 15 | echo "Stopping running services..." 16 | for i in $(ls /etc/runit) 17 | do 18 | if [[ -f "/etc/runit/$i/supervise/stat" ]]; then 19 | if [[ "`cat /etc/runit/$i/supervise/stat`" == "run" ]]; then 20 | echo "Stopping $i..." 21 | sv force-stop $i 22 | fi 23 | fi 24 | done 25 | RUNSV_PROCS=$(pidof runsv) 26 | if [ $? -eq 0 ]; then 27 | kill $RUNSV_PROCS 28 | fi 29 | echo -n "Starting $DESC: " 30 | if ! start-stop-daemon --oknodo --start --background --exec $DAEMON -- /etc/runit 'log: ...........................................................................................................................................................................................................................................................................................................................................................................................................' ; then 31 | echo "failed." 32 | exit 1 33 | fi 34 | echo "$NAME." 35 | ;; 36 | stop) 37 | echo -n "Stopping $DESC: " 38 | RUNSV_PROCS=$(pidof runsv) 39 | if [ $? -eq 0 ]; then 40 | kill $RUNSV_PROCS 41 | fi 42 | start-stop-daemon --oknodo --stop --exec $DAEMON 43 | echo "$NAME." 44 | ;; 45 | restart) 46 | $0 stop 47 | $0 start 48 | ;; 49 | *) 50 | echo "Usage: $0 {start|stop|restart}" >&2 51 | exit 1 52 | ;; 53 | esac 54 | 55 | exit 0 56 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-printing/klipper/klipper_git.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "Klipper 3D Printing Software" 2 | HOMEPAGE = "https://www.klipper3d.org/" 3 | LICENSE = "GPL-3.0" 4 | LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504" 5 | 6 | inherit setuptools pkgconfig runit-service 7 | 8 | # setting "DEPENDS =" will break setuptools, make sure to append 9 | DEPENDS += "libusb" 10 | 11 | SRC_URI = "\ 12 | git://github.com/KevinOConnor/klipper.git;protocol=https \ 13 | file://0001-Allow-to-package-klippy-using-setuptools.patch \ 14 | file://klipper.default \ 15 | file://klipper.run \ 16 | " 17 | 18 | #SRCREV = "${AUTOREV}" 19 | SRCREV = "c148f17ea3391e3720961270a12eb0645f688e12" 20 | PV = "0.9.1+gitr${SRCPV}" 21 | 22 | S = "${WORKDIR}/git" 23 | 24 | RDEPENDS_${PN} = "\ 25 | python \ 26 | python-pyserial \ 27 | python-cffi \ 28 | python-greenlet \ 29 | python-jinja2 \ 30 | udev \ 31 | " 32 | 33 | FILES_${PN} += "${sysconfdir} ${localstatedir}" 34 | CONFFILES_${PN} += "${sysconfdir}/klipper/printer.cfg" 35 | 36 | RUNIT_SERVICES = "klipper" 37 | 38 | do_compile() { 39 | ${CC} ${CFLAGS} ${LDFLAGS} -o ${B}/hub-ctrl ${S}/lib/hub-ctrl/hub-ctrl.c `pkg-config --cflags --libs libusb` 40 | } 41 | 42 | do_install_append() { 43 | install -m 0755 -d ${D}${sysconfdir}/klipper 44 | install -m 0755 -d ${D}${sysconfdir}/default 45 | install -m 0644 ${WORKDIR}/klipper.default ${D}${sysconfdir}/default/klipper 46 | install -m 0755 -d ${D}${sysconfdir}/runit/klipper 47 | install -m 0755 ${WORKDIR}/klipper.run ${D}${sysconfdir}/runit/klipper/run 48 | install -m 0755 -d ${D}${bindir} 49 | install -m 0755 ${B}/hub-ctrl ${D}${bindir}/hub-ctrl 50 | 51 | install -d ${D}${localstatedir}/lib/klipper/sdcard 52 | install -d ${D}${localstatedir}/lib/klipper/config 53 | install -m 0644 ${S}/config/*.cfg ${D}${localstatedir}/lib/klipper/config 54 | } 55 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-devtools/python-numpy/python-numpy.inc: -------------------------------------------------------------------------------- 1 | SUMMARY = "A sophisticated Numeric Processing Package for Python" 2 | SECTION = "devel/python" 3 | LICENSE = "BSD-3-Clause & BSD-2-Clause & PSF & Apache-2.0 & BSD & MIT" 4 | LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=d26bde5432613cce2334b93985576231" 5 | 6 | SRCNAME = "numpy" 7 | 8 | SRC_URI = "https://github.com/${SRCNAME}/${SRCNAME}/releases/download/v${PV}/${SRCNAME}-${PV}.tar.gz" 9 | 10 | SRC_URI[md5sum] = "5e958c603605f3168b7b29f421f64cdd" 11 | SRC_URI[sha256sum] = "61562ddac78765969959500b0da9c6f9ba7d77eeb12ec3927afae5303df08777" 12 | 13 | UPSTREAM_CHECK_URI = "https://github.com/numpy/numpy/releases" 14 | UPSTREAM_CHECK_REGEX = "(?P\d+(\.\d+)+)\.tar" 15 | 16 | # Needed for building with gcc 4.x from centos 7 17 | CFLAGS_append_class-native = " -std=c99" 18 | 19 | S = "${WORKDIR}/numpy-${PV}" 20 | 21 | CLEANBROKEN = "1" 22 | 23 | FILES_${PN}-staticdev += "${PYTHON_SITEPACKAGES_DIR}/numpy/core/lib/*.a" 24 | 25 | # install what is needed for numpy.test() 26 | RDEPENDS_${PN} = "${PYTHON_PN}-unittest \ 27 | ${PYTHON_PN}-difflib \ 28 | ${PYTHON_PN}-pprint \ 29 | ${PYTHON_PN}-pickle \ 30 | ${PYTHON_PN}-shell \ 31 | ${PYTHON_PN}-nose \ 32 | ${PYTHON_PN}-doctest \ 33 | ${PYTHON_PN}-datetime \ 34 | ${PYTHON_PN}-distutils \ 35 | ${PYTHON_PN}-misc \ 36 | ${PYTHON_PN}-mmap \ 37 | ${PYTHON_PN}-netclient \ 38 | ${PYTHON_PN}-numbers \ 39 | ${PYTHON_PN}-pydoc \ 40 | ${PYTHON_PN}-pkgutil \ 41 | ${PYTHON_PN}-email \ 42 | ${PYTHON_PN}-compression \ 43 | ${PYTHON_PN}-ctypes \ 44 | ${PYTHON_PN}-threading \ 45 | ${PYTHON_PN}-multiprocessing \ 46 | " 47 | 48 | RDEPENDS_${PN}_class-native = "" 49 | 50 | BBCLASSEXTEND = "native nativesdk" 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Klipper Linux Distribution 2 | 3 | ## Overview 4 | 5 | Single purpose Linux Distro aimed at providing a Klipper-3D printing setup which can be built and run on any target supported by the Yocto build system. 6 | 7 | If you are looking for a desktop like experience, use Armbian, Raspbian, OctoPi, Debian, Fedora or whatever desktop distro there is that would run on your target. This is not it. 8 | 9 | My goal is to have images require a minimum of manual setup interaction, I'd like to keep fiddling around to a minimum, it should be more like: flash, select your printer, start printing. Perhaps this is better comparable to what you get with the native firmware, where you mostly use the local LCD. However here you get Klipper, which in my opinion is a very good choice, especially for those weaker printer boards. 10 | 11 | Currently the image includes Klipper 3D and Octoprint. 12 | 13 | ## Current State 14 | 15 | Right now it's a "work in progress" and by no means complete. I do use it on an Asus Tinker Board S, but there is still a lot to be done in terms of configuration, so the current image is rather a proof of concept and while it does work, it still involves some manual configuration steps. Some important features, like distributing and flashing the Klipper MCU Firmware are also missing. 16 | 17 | ## TODOs 18 | 19 | Random thoughts without any specific order: 20 | * add MCU firmware builds (all MCU firmware variants should be included in the image) 21 | * add lighttpd with a central entry page and a minimalistic web UI 22 | 23 | The web UI should at least allow to: 24 | * select and flash the firmware to your printer 25 | * select an existing klipper configuration or upload a custom klipper config 26 | * allow to enable/disable OctoPrint 27 | * backup/restore all important settings 28 | 29 | ## For Developers 30 | 31 | Assuming you had a look at the Yocto manual and installed the required build dependencies, to compile the tinker board s image first setup the environment: 32 | 33 | `$ source setup.sh targets/tinker-board-s/` 34 | 35 | And build the image: 36 | 37 | `$ bitbake klipper-image-tinker-board-s` 38 | 39 | Note, that git submodules are being used, so make sure to properly init them after initial cloning. 40 | 41 | ## Links 42 | 43 | If you have no clue what I am talking about: 44 | 45 | https://www.klipper3d.org/
46 | https://www.yoctoproject.org/docs/latest/ref-manual/ref-manual.html 47 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-webui/octoprint/octoprint_1.4.0.bb: -------------------------------------------------------------------------------- 1 | # original recipe imported from 2 | # https://git.yoctoproject.org/cgit/cgit.cgi/meta-maker/tree/recipes-webui/octoprint/octoprint_git.bb 3 | 4 | SUMMARY = "OctoPrint provides a responsive web interface for controlling a 3D printer." 5 | HOMEPAGE = "http://octoprint.org" 6 | 7 | SECTION = "devel/python" 8 | 9 | LICENSE = "AGPL-3.0" 10 | LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=73f1eb20517c55bf9493b7dd6e480788" 11 | 12 | SRC_URI = "\ 13 | git://github.com/OctoPrint/OctoPrint.git;protocol=https;tag=${PV} \ 14 | file://config.yaml \ 15 | file://octoprint.run \ 16 | " 17 | 18 | S = "${WORKDIR}/git" 19 | 20 | inherit setuptools runit-service 21 | 22 | 23 | export BUILD_SYS 24 | export HOST_SYS 25 | export STAGING_INCDIR 26 | export STAGING_LIBDIR 27 | 28 | BBCLASSEXTEND = "native" 29 | 30 | RUNIT_SERVICES = "octoprint" 31 | 32 | do_install_append(){ 33 | install -d ${D}${sysconfdir}/octoprint 34 | install -m 0644 ${WORKDIR}/config.yaml ${D}${sysconfdir}/octoprint/config.yaml 35 | install -m 0755 -d ${D}${sysconfdir}/runit/octoprint 36 | install -m 0755 ${WORKDIR}/octoprint.run ${D}${sysconfdir}/runit/octoprint/run 37 | install -d ${D}${localstatedir}/lib/octoprint 38 | } 39 | 40 | 41 | FILES_${PN} += "${sysconfdir} ${localstatedir}" 42 | CONFFILES_${PN} += "${sysconfdir}/octoprint/config.yaml" 43 | 44 | DEPENDS = "${PYTHON_PN} ${PYTHON_PN}-markdown-native" 45 | 46 | INSANE_SKIP_${PN} += "build-deps" 47 | 48 | RDEPENDS_${PN} = "\ 49 | ${PYTHON_PN}-markdown \ 50 | ${PYTHON_PN}-flask \ 51 | ${PYTHON_PN}-jinja2 \ 52 | ${PYTHON_PN}-tornado \ 53 | ${PYTHON_PN}-regex \ 54 | ${PYTHON_PN}-flask-login \ 55 | ${PYTHON_PN}-flask-babel \ 56 | ${PYTHON_PN}-flask-assets \ 57 | ${PYTHON_PN}-blinker \ 58 | ${PYTHON_PN}-werkzeug \ 59 | ${PYTHON_PN}-werkzeug-tests \ 60 | ${PYTHON_PN}-cachelib \ 61 | ${PYTHON_PN}-pyyaml \ 62 | ${PYTHON_PN}-markdown \ 63 | ${PYTHON_PN}-pyserial \ 64 | ${PYTHON_PN}-netaddr \ 65 | ${PYTHON_PN}-watchdog \ 66 | ${PYTHON_PN}-sarge \ 67 | ${PYTHON_PN}-netifaces \ 68 | ${PYTHON_PN}-pylru \ 69 | ${PYTHON_PN}-rsa \ 70 | ${PYTHON_PN}-pkginfo \ 71 | ${PYTHON_PN}-requests \ 72 | ${PYTHON_PN}-semantic-version \ 73 | ${PYTHON_PN}-psutil \ 74 | ${PYTHON_PN}-click \ 75 | ${PYTHON_PN}-awesome-slugify \ 76 | ${PYTHON_PN}-feedparser \ 77 | ${PYTHON_PN}-future \ 78 | ${PYTHON_PN}-websocket-client \ 79 | ${PYTHON_PN}-wrapt \ 80 | ${PYTHON_PN}-emoji \ 81 | ${PYTHON_PN}-frozendict \ 82 | ${PYTHON_PN}-sentry-sdk \ 83 | ${PYTHON_PN}-filetype \ 84 | ${PYTHON_PN}-futures \ 85 | ${PYTHON_PN}-monotonic \ 86 | ${PYTHON_PN}-scandir \ 87 | ${PYTHON_PN}-chainmap \ 88 | ${PYTHON_PN}-typing \ 89 | ${PYTHON_PN}-pip \ 90 | " 91 | 92 | BBCLASSEXTEND = "native" 93 | -------------------------------------------------------------------------------- /yocto/meta-klipper/scripts/lib/wic/plugins/source/rawcopy.py: -------------------------------------------------------------------------------- 1 | # 2 | # SPDX-License-Identifier: GPL-2.0-only 3 | # 4 | 5 | import logging 6 | import os 7 | 8 | from wic import WicError 9 | from wic.pluginbase import SourcePlugin 10 | from wic.misc import exec_cmd, get_bitbake_var 11 | from wic.filemap import sparse_copy 12 | 13 | logger = logging.getLogger('wic') 14 | 15 | class RawCopyPlugin(SourcePlugin): 16 | """ 17 | Populate partition content from raw image file. 18 | """ 19 | 20 | name = 'rawcopy' 21 | 22 | @staticmethod 23 | def do_image_label(fstype, dst, label): 24 | if fstype.startswith('ext'): 25 | cmd = 'tune2fs -L %s %s' % (label, dst) 26 | elif fstype in ('msdos', 'vfat'): 27 | cmd = 'dosfslabel %s %s' % (dst, label) 28 | elif fstype == 'btrfs': 29 | cmd = 'btrfs filesystem label %s %s' % (dst, label) 30 | elif fstype == 'swap': 31 | cmd = 'mkswap -L %s %s' % (label, dst) 32 | elif fstype == 'squashfs': 33 | raise WicError("It's not possible to update a squashfs " 34 | "filesystem label '%s'" % (label)) 35 | else: 36 | raise WicError("Cannot update filesystem label: " 37 | "Unknown fstype: '%s'" % (fstype)) 38 | 39 | exec_cmd(cmd) 40 | 41 | @classmethod 42 | def do_prepare_partition(cls, part, source_params, cr, cr_workdir, 43 | oe_builddir, bootimg_dir, kernel_dir, 44 | rootfs_dir, native_sysroot): 45 | """ 46 | Called to do the actual content population for a partition i.e. it 47 | 'prepares' the partition to be incorporated into the image. 48 | """ 49 | if not kernel_dir: 50 | kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") 51 | if not kernel_dir: 52 | raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting") 53 | 54 | logger.debug('Kernel dir: %s', kernel_dir) 55 | 56 | if 'file' not in source_params: 57 | raise WicError("No file specified") 58 | 59 | src = os.path.join(kernel_dir, source_params['file']) 60 | dst = os.path.join(cr_workdir, "%s.%s" % (os.path.basename(source_params['file']), part.lineno)) 61 | 62 | if not os.path.exists(os.path.dirname(dst)): 63 | os.makedirs(os.path.dirname(dst)) 64 | 65 | if 'skip' in source_params: 66 | sparse_copy(src, dst, skip=int(source_params['skip'])) 67 | else: 68 | sparse_copy(src, dst) 69 | 70 | # get the size in the right units for kickstart (kB) 71 | du_cmd = "du -Lbks %s" % dst 72 | out = exec_cmd(du_cmd) 73 | filesize = int(out.split()[0]) 74 | 75 | if filesize > part.size: 76 | part.size = filesize 77 | 78 | if part.label: 79 | RawCopyPlugin.do_image_label(part.fstype, dst, part.label) 80 | 81 | part.source_file = dst 82 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-devtools/python-numpy/files/0001-Don-t-search-usr-and-so-on-for-libraries-by-default-.patch: -------------------------------------------------------------------------------- 1 | From 672a75c8417ce08db9e31fc415ec445479231d5a Mon Sep 17 00:00:00 2001 2 | From: Alexander Kanavin 3 | Date: Thu, 10 Dec 2015 13:20:30 +0200 4 | Subject: [PATCH] Don't search /usr and so on for libraries by default to 5 | 6 | avoid host contamination. 7 | 8 | Upstream-Status: Inappropriate (As the code stands, this is a hack) 9 | Signed-off-by: Ross Burton 10 | Signed-off-by: Alexander Kanavin 11 | 12 | --- 13 | numpy/distutils/system_info.py | 42 ++++------------------------------ 14 | 1 file changed, 5 insertions(+), 37 deletions(-) 15 | 16 | diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py 17 | index ba2b1f4..f94dce1 100644 18 | --- a/numpy/distutils/system_info.py 19 | +++ b/numpy/distutils/system_info.py 20 | @@ -278,45 +278,13 @@ if sys.platform == 'win32': 21 | add_system_root(os.path.join(conda_dir, 'Library')) 22 | 23 | else: 24 | - default_lib_dirs = libpaths(['/usr/local/lib', '/opt/lib', '/usr/lib', 25 | - '/opt/local/lib', '/sw/lib'], platform_bits) 26 | default_runtime_dirs = [] 27 | - default_include_dirs = ['/usr/local/include', 28 | - '/opt/include', '/usr/include', 29 | - # path of umfpack under macports 30 | - '/opt/local/include/ufsparse', 31 | - '/opt/local/include', '/sw/include', 32 | - '/usr/include/suitesparse'] 33 | - default_src_dirs = ['.', '/usr/local/src', '/opt/src', '/sw/src'] 34 | - 35 | - default_x11_lib_dirs = libpaths(['/usr/X11R6/lib', '/usr/X11/lib', 36 | - '/usr/lib'], platform_bits) 37 | - default_x11_include_dirs = ['/usr/X11R6/include', '/usr/X11/include', 38 | - '/usr/include'] 39 | - 40 | - if os.path.exists('/usr/lib/X11'): 41 | - globbed_x11_dir = glob('/usr/lib/*/libX11.so') 42 | - if globbed_x11_dir: 43 | - x11_so_dir = os.path.split(globbed_x11_dir[0])[0] 44 | - default_x11_lib_dirs.extend([x11_so_dir, '/usr/lib/X11']) 45 | - default_x11_include_dirs.extend(['/usr/lib/X11/include', 46 | - '/usr/include/X11']) 47 | - 48 | - with open(os.devnull, 'w') as tmp: 49 | - try: 50 | - p = subprocess.Popen(["gcc", "-print-multiarch"], stdout=subprocess.PIPE, 51 | - stderr=tmp) 52 | - except (OSError, DistutilsError): 53 | - # OSError if gcc is not installed, or SandboxViolation (DistutilsError 54 | - # subclass) if an old setuptools bug is triggered (see gh-3160). 55 | - pass 56 | - else: 57 | - triplet = str(p.communicate()[0].decode().strip()) 58 | - if p.returncode == 0: 59 | - # gcc supports the "-print-multiarch" option 60 | - default_x11_lib_dirs += [os.path.join("/usr/lib/", triplet)] 61 | - default_lib_dirs += [os.path.join("/usr/lib/", triplet)] 62 | + default_lib_dirs = libpaths(['/deadir/lib'], platform_bits) 63 | + default_include_dirs = ['/deaddir/include'] 64 | + default_src_dirs = ['.', '/deaddir/src'] 65 | 66 | + default_x11_lib_dirs = libpaths(['/deaddir/lib'], platform_bits) 67 | + default_x11_include_dirs = ['/deaddir/include'] 68 | 69 | if os.path.join(sys.prefix, 'lib') not in default_lib_dirs: 70 | default_lib_dirs.insert(0, os.path.join(sys.prefix, 'lib')) 71 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-extended/lighttpd/files/htdigest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # htdigest.sh 4 | # http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ModAuth 5 | # 6 | export PATH="/bin:/usr/bin:/usr/sbin:$PATH" 7 | 8 | # when input ctrl-c, remove lockfile and exit 9 | trap '[ $lockstart -eq 1 ] && unlock $pfile && exit 0 || exit 0' INT 10 | 11 | pfile="/etc/lighttpd.user" 12 | lockstart=0 13 | remove=0 14 | 15 | errmsg() { 16 | echo "$1" 1>&2 17 | } 18 | 19 | user_check() { 20 | check_user=$1 21 | grep "^${check_user}:" ${pfile} >& /dev/null 22 | return $? 23 | } 24 | 25 | lock() { 26 | lockfile="$1" 27 | lockfile="${lockfile}.lock" 28 | 29 | [ -f "${lockfile}" ] && { 30 | errmsg "WARNING: lock file ${lockfile} is already exists" 31 | errmsg " Wait minites for end of previous working ..." 32 | } 33 | 34 | while [ -f "${lockfile}" ]; do echo >& /dev/null ; done 35 | touch ${lockfile} 36 | lockstart=1 37 | } 38 | 39 | unlock() { 40 | lockfile="$1" 41 | lockfile="${lockfile}.lock" 42 | 43 | [ -f "${lockfile}" ] && rm -f ${lockfile} && lockstart=0 44 | } 45 | 46 | usage() { 47 | errmsg 48 | errmsg "lightdigest: lighttpd htdigest password generation program" 49 | errmsg "Scripted by JoungKyun.Kim " 50 | errmsg 51 | errmsg "Usage: $0 -[hd] -u user -p pass -r realm [-f password_file]" 52 | errmsg "Options:" 53 | errmsg " -h print this help messages" 54 | errmsg " -u user username" 55 | errmsg " -p pass password" 56 | errmsg " -r realm realm name" 57 | errmsg " -f filename password file [default: /etc/lighttpd/conf.d/lighttpd.user]" 58 | errmsg " -d remove user" 59 | errmsg 60 | 61 | [ $lockstart -eq 1 ] && rm -f ${pfile}.lock 62 | 63 | exit 1 64 | } 65 | 66 | opts=$(getopt df:hp:r:u: $*) 67 | [ $? != 0 ] && usage 68 | 69 | set -- ${opts} 70 | for i 71 | do 72 | case "$i" in 73 | -d) remove=1; shift;; 74 | -f) pfile="$2"; shift; shift;; 75 | -p) pass="$2"; shift; shift;; 76 | -r) realm="$2"; shift; shift;; 77 | -u) user="$2"; shift; shift;; 78 | --) shift; break; 79 | esac 80 | done 81 | 82 | [ -z "$user" ] && errmsg "ERROR: User is none!!" && usage 83 | [ ${remove} -eq 0 -a -z "${realm}" ] && errmsg "ERROR: Realm is none!!" && usage 84 | 85 | if [ -z "${pass}" -a ${remove} -eq 0 ]; then 86 | echo -n "Input new password : " 87 | read newpass 88 | echo -n "Reinput password for confirm : " 89 | read renewpass 90 | 91 | if [ "${newpass}" != "${renewpass}" ]; then 92 | errmsg "ERROR: Password is not match" 93 | exit 1 94 | fi 95 | 96 | pass=${newpass} 97 | fi 98 | 99 | lock ${pfile} 100 | 101 | if [ ${remove} -eq 0 ]; then 102 | # User Add Mode 103 | hash=$(echo -n "${user}:${realm}:${pass}" | md5sum | cut -b -32) 104 | user_check ${user} 105 | already=$? 106 | 107 | # [ -f "${pfile}" ] && cp -af ${pfile} ${pfile}.bak 108 | if [ ${already} -eq 0 ]; then 109 | # already exists 110 | sed -i "s/^${user}:.*$/${user}:${realm}:${hash}/g" ${pfile} 111 | else 112 | # add new user 113 | echo "${user}:${realm}:${hash}" >> ${pfile} 114 | fi 115 | else 116 | echo "Removing..." 117 | # User Remove Mode 118 | tmp_htdigest="/tmp/lighttpd-htdiges.tmp.$$" 119 | # cp -af ${pfile} ${pfile}.bak 120 | grep -v "^${user}:" ${pfile} > ${tmp_htdigest} 121 | mv -f ${tmp_htdigest} ${pfile} 122 | fi 123 | 124 | unlock ${pfile} 125 | 126 | exit 0 127 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-extended/lighttpd/lighttpd_1.4.55.bb: -------------------------------------------------------------------------------- 1 | # recipe imported from Poky 2 | SUMMARY = "Lightweight high-performance web server" 3 | HOMEPAGE = "http://www.lighttpd.net/" 4 | BUGTRACKER = "http://redmine.lighttpd.net/projects/lighttpd/issues" 5 | 6 | LICENSE = "BSD-3-Clause" 7 | LIC_FILES_CHKSUM = "file://COPYING;md5=e4dac5c6ab169aa212feb5028853a579" 8 | 9 | SECTION = "net" 10 | 11 | RDEPENDS_${PN} = "\ 12 | lighttpd-module-access \ 13 | lighttpd-module-accesslog \ 14 | lighttpd-module-auth \ 15 | lighttpd-module-authn-file \ 16 | lighttpd-module-cgi \ 17 | lighttpd-module-dirlisting \ 18 | lighttpd-module-indexfile \ 19 | lighttpd-module-openssl \ 20 | lighttpd-module-proxy \ 21 | lighttpd-module-redirect \ 22 | lighttpd-module-setenv \ 23 | lighttpd-module-staticfile \ 24 | create-certificate \ 25 | " 26 | 27 | SRC_URI = "http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-${PV}.tar.xz \ 28 | file://lighttpd.conf \ 29 | file://htdigest.sh \ 30 | file://lighttpd.user \ 31 | file://lighttpd.run \ 32 | file://0001-Use-pkg-config-for-pcre-dependency-instead-of-config.patch \ 33 | " 34 | 35 | SRC_URI[md5sum] = "be4bda2c28bcbdac6eb941528f6edf03" 36 | SRC_URI[sha256sum] = "6a0b50e9c9d5cc3d9e48592315c25a2d645858f863e1ccd120507a30ce21e927" 37 | 38 | PACKAGECONFIG = "openssl pcre zlib" 39 | 40 | PACKAGECONFIG[ipv6] = "--enable-ipv6,--disable-ipv6" 41 | PACKAGECONFIG[mmap] = "--enable-mmap,--disable-mmap" 42 | PACKAGECONFIG[libev] = "--with-libev,--without-libev,libev" 43 | PACKAGECONFIG[mysql] = "--with-mysql,--without-mysql,mariadb" 44 | PACKAGECONFIG[ldap] = "--with-ldap,--without-ldap,openldap" 45 | PACKAGECONFIG[attr] = "--with-attr,--without-attr,attr" 46 | PACKAGECONFIG[valgrind] = "--with-valgrind,--without-valgrind,valgrind" 47 | PACKAGECONFIG[openssl] = "--with-openssl,--without-openssl,openssl" 48 | PACKAGECONFIG[krb5] = "--with-krb5,--without-krb5,krb5" 49 | PACKAGECONFIG[pcre] = "--with-pcre,--without-pcre,libpcre" 50 | PACKAGECONFIG[zlib] = "--with-zlib,--without-zlib,zlib" 51 | PACKAGECONFIG[bzip2] = "--with-bzip2,--without-bzip2,bzip2" 52 | PACKAGECONFIG[webdav-props] = "--with-webdav-props,--without-webdav-props,libxml2 sqlite3" 53 | PACKAGECONFIG[webdav-locks] = "--with-webdav-locks,--without-webdav-locks,util-linux" 54 | PACKAGECONFIG[gdbm] = "--with-gdbm,--without-gdbm,gdbm" 55 | PACKAGECONFIG[memcache] = "--with-memcached,--without-memcached,libmemcached" 56 | PACKAGECONFIG[lua] = "--with-lua,--without-lua,lua" 57 | 58 | EXTRA_OECONF += "--enable-lfs --without-fam" 59 | 60 | inherit autotools pkgconfig gettext runit-service 61 | 62 | RUNIT_SERVICES = "lighttpd" 63 | RUNIT_PACKAGES = "lighttpd" 64 | 65 | do_install_append() { 66 | install -d ${D}${sysconfdir}/runit/lighttpd ${D}${sysconfdir}/lighttpd 67 | install -d ${D}${sysconfdir}/lighttpd.d ${D}/www/pages/ 68 | install -d ${D}${bindir} 69 | 70 | install -m 0755 ${WORKDIR}/lighttpd.run ${D}${sysconfdir}/runit/lighttpd/run 71 | install -m 0644 ${WORKDIR}/lighttpd.conf ${D}${sysconfdir}/lighttpd 72 | 73 | #For FHS compliance, create symbolic links to /var/log and /var/tmp for logs and temporary data 74 | ln -sf ${localstatedir}/log ${D}/www/logs 75 | ln -sf ${localstatedir}/tmp ${D}/www/var 76 | 77 | install -m 0755 -d ${D}${bindir} 78 | install -m 0755 -d ${D}/www/pages 79 | 80 | install -m 0644 ${WORKDIR}/lighttpd.user ${D}${sysconfdir}/lighttpd/lighttpd.user 81 | install -m 0755 ${WORKDIR}/htdigest.sh ${D}${bindir}/htdigest.sh 82 | 83 | } 84 | 85 | FILES_${PN} += "${sysconfdir} /www" 86 | 87 | CONFFILES_${PN} = "${sysconfdir}/lighttpd/lighttpd.user" 88 | 89 | PACKAGES_DYNAMIC += "^lighttpd-module-.*" 90 | 91 | python populate_packages_prepend () { 92 | lighttpd_libdir = d.expand('${libdir}') 93 | do_split_packages(d, lighttpd_libdir, r'^mod_(.*)\.so$', 'lighttpd-module-%s', 'Lighttpd module for %s', extra_depends='') 94 | } 95 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-devtools/gcc/gcc-configure-common.inc: -------------------------------------------------------------------------------- 1 | require gcc-multilib-config.inc 2 | require gcc-shared-source.inc 3 | # 4 | # Build the list of lanaguages to build. 5 | # 6 | # These can be overridden by the version specific .inc file. 7 | 8 | # gcc 3.x expects 'f77', 4.0 expects 'f95', 4.1 and 4.2 expect 'fortran' 9 | FORTRAN ?= ",f77" 10 | LANGUAGES ?= "c,c++${FORTRAN}" 11 | 12 | EXTRA_OECONF_BASE ?= "" 13 | EXTRA_OECONF_PATHS ?= "" 14 | 15 | GCCMULTILIB ?= "--disable-multilib" 16 | GCCTHREADS ?= "posix" 17 | 18 | GCCPIE ??= "" 19 | 20 | SYMVERS_CONF ?= "--enable-symvers=gnu" 21 | 22 | EXTRA_OECONF = "\ 23 | ${@['--enable-clocale=generic', ''][d.getVar('USE_NLS') != 'no']} \ 24 | --with-gnu-ld \ 25 | --enable-shared \ 26 | --enable-languages=${LANGUAGES} \ 27 | --enable-threads=${GCCTHREADS} \ 28 | ${GCCMULTILIB} \ 29 | ${GCCPIE} \ 30 | --enable-c99 \ 31 | --enable-long-long \ 32 | ${SYMVERS_CONF} \ 33 | --enable-libstdcxx-pch \ 34 | --program-prefix=${TARGET_PREFIX} \ 35 | --without-local-prefix \ 36 | --disable-install-libiberty \ 37 | ${EXTRA_OECONF_BASE} \ 38 | ${EXTRA_OECONF_GCC_FLOAT} \ 39 | ${EXTRA_OECONF_PATHS} \ 40 | ${@get_gcc_mips_plt_setting(bb, d)} \ 41 | ${@get_gcc_ppc_plt_settings(bb, d)} \ 42 | ${@get_gcc_multiarch_setting(bb, d)} \ 43 | " 44 | 45 | # glibc version is a minimum controlling whether features are enabled. 46 | # Doesn't need to track glibc exactly 47 | EXTRA_OECONF_append_libc-glibc = " --with-glibc-version=2.28 " 48 | 49 | # Set this here since GCC configure won't auto-detect and enable 50 | # initfini-arry when cross compiling. 51 | EXTRA_OECONF_append = " --enable-initfini-array" 52 | 53 | export gcc_cv_collect2_libs = 'none required' 54 | # We need to set gcc_cv_collect2_libs else there is cross-compilation badness 55 | # in the config.log files (which might not get generated until do_compile 56 | # hence being missed by the insane do_configure check). 57 | 58 | EXTRA_OECONF_append_linux = " --enable-__cxa_atexit" 59 | 60 | EXTRA_OECONF_append_mips64 = " --with-abi=64 --with-arch-64=mips64 --with-tune-64=mips64" 61 | EXTRA_OECONF_append_mips64el = " --with-abi=64 --with-arch-64=mips64 --with-tune-64=mips64" 62 | EXTRA_OECONF_append_mips64n32 = " --with-abi=64 --with-arch-64=mips64 --with-tune-64=mips64" 63 | EXTRA_OECONF_append_mips64eln32 = " --with-abi=64 --with-arch-64=mips64 --with-tune-64=mips64" 64 | EXTRA_OECONF_append_mipsisa32r6el = " --with-abi=32 --with-arch=mips32r6" 65 | EXTRA_OECONF_append_mipsisa32r6 = " --with-abi=32 --with-arch=mips32r6" 66 | EXTRA_OECONF_append_mipsisa64r6el = " --with-abi=64 --with-arch-64=mips64r6" 67 | EXTRA_OECONF_append_mipsisa64r6 = " --with-abi=64 --with-arch-64=mips64r6" 68 | 69 | EXTRA_OECONF_GCC_FLOAT ??= "" 70 | CPPFLAGS = "" 71 | 72 | SYSTEMHEADERS = "${target_includedir}" 73 | SYSTEMLIBS = "${target_base_libdir}/" 74 | SYSTEMLIBS1 = "${target_libdir}/" 75 | 76 | do_configure_prepend () { 77 | # teach gcc to find correct target includedir when checking libc ssp support 78 | mkdir -p ${B}/gcc 79 | echo "NATIVE_SYSTEM_HEADER_DIR = ${SYSTEMHEADERS}" > ${B}/gcc/t-oe 80 | cat ${S}/gcc/defaults.h | grep -v "\#endif.*GCC_DEFAULTS_H" > ${B}/gcc/defaults.h.new 81 | cat >>${B}/gcc/defaults.h.new <<_EOF 82 | #define NATIVE_SYSTEM_HEADER_DIR "${SYSTEMHEADERS}" 83 | #define STANDARD_STARTFILE_PREFIX_1 "${SYSTEMLIBS}" 84 | #define STANDARD_STARTFILE_PREFIX_2 "${SYSTEMLIBS1}" 85 | #define SYSTEMLIBS_DIR "${SYSTEMLIBS}" 86 | #endif /* ! GCC_DEFAULTS_H */ 87 | _EOF 88 | mv ${B}/gcc/defaults.h.new ${B}/gcc/defaults.h 89 | } 90 | 91 | do_configure () { 92 | # Setup these vars for cross building only 93 | # ... because foo_FOR_TARGET apparently gets misinterpreted inside the 94 | # gcc build stuff when the build is producing a cross compiler - i.e. 95 | # when the 'current' target is the 'host' system, and the host is not 96 | # the target (because the build is actually making a cross compiler!) 97 | if [ "${BUILD_SYS}" != "${HOST_SYS}" ]; then 98 | export CC_FOR_TARGET="${CC}" 99 | export GCC_FOR_TARGET="${CC}" 100 | export CXX_FOR_TARGET="${CXX}" 101 | export AS_FOR_TARGET="${HOST_PREFIX}as" 102 | export LD_FOR_TARGET="${HOST_PREFIX}ld" 103 | export NM_FOR_TARGET="${HOST_PREFIX}nm" 104 | export AR_FOR_TARGET="${HOST_PREFIX}ar" 105 | export GFORTRAN_FOR_TARGET="gfortran" 106 | export RANLIB_FOR_TARGET="${HOST_PREFIX}ranlib" 107 | fi 108 | export CC_FOR_BUILD="${BUILD_CC}" 109 | export CXX_FOR_BUILD="${BUILD_CXX}" 110 | export CFLAGS_FOR_BUILD="${BUILD_CFLAGS} -fpermissive" 111 | export CPPFLAGS_FOR_BUILD="${BUILD_CPPFLAGS}" 112 | export CXXFLAGS_FOR_BUILD="${BUILD_CXXFLAGS}" 113 | export LDFLAGS_FOR_BUILD="${BUILD_LDFLAGS}" 114 | export CFLAGS_FOR_TARGET="${TARGET_CFLAGS}" 115 | export CPPFLAGS_FOR_TARGET="${TARGET_CPPFLAGS}" 116 | export CXXFLAGS_FOR_TARGET="${TARGET_CXXFLAGS}" 117 | export LDFLAGS_FOR_TARGET="${TARGET_LDFLAGS}" 118 | 119 | 120 | oe_runconf 121 | } 122 | 123 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-extended/lighttpd/files/lighttpd.conf: -------------------------------------------------------------------------------- 1 | # lighttpd server configuration 2 | 3 | server.modules = ( 4 | "mod_access", 5 | "mod_accesslog", 6 | "mod_auth", 7 | "mod_cgi", 8 | "mod_openssl", 9 | "mod_proxy", 10 | "mod_redirect", 11 | "mod_setenv") 12 | 13 | server.document-root = "/www/pages/" 14 | 15 | server.errorlog = "/var/log/lighttpd/lighttpd.error.log" 16 | 17 | index-file.names = ( "index.html" ) 18 | 19 | mimetype.assign = ( 20 | ".pdf" => "application/pdf", 21 | ".sig" => "application/pgp-signature", 22 | ".spl" => "application/futuresplash", 23 | ".class" => "application/octet-stream", 24 | ".ps" => "application/postscript", 25 | ".torrent" => "application/x-bittorrent", 26 | ".dvi" => "application/x-dvi", 27 | ".gz" => "application/x-gzip", 28 | ".pac" => "application/x-ns-proxy-autoconfig", 29 | ".swf" => "application/x-shockwave-flash", 30 | ".tar.gz" => "application/x-tgz", 31 | ".tgz" => "application/x-tgz", 32 | ".zip" => "application/zip", 33 | ".mp3" => "audio/mpeg", 34 | ".m3u" => "audio/x-mpegurl", 35 | ".wma" => "audio/x-ms-wma", 36 | ".wax" => "audio/x-ms-wax", 37 | ".ogg" => "application/ogg", 38 | ".wav" => "audio/x-wav", 39 | ".gif" => "image/gif", 40 | ".jpg" => "image/jpeg", 41 | ".jpeg" => "image/jpeg", 42 | ".png" => "image/png", 43 | ".xbm" => "image/x-xbitmap", 44 | ".xpm" => "image/x-xpixmap", 45 | ".xwd" => "image/x-xwindowdump", 46 | ".css" => "text/css", 47 | ".html" => "text/html", 48 | ".htm" => "text/html", 49 | ".js" => "text/javascript", 50 | ".json" => "application/json", 51 | ".asc" => "text/plain", 52 | ".c" => "text/plain", 53 | ".cpp" => "text/plain", 54 | ".log" => "text/plain", 55 | ".conf" => "text/plain", 56 | ".text" => "text/plain", 57 | ".txt" => "text/plain", 58 | ".dtd" => "text/xml", 59 | ".xml" => "text/xml", 60 | ".mpeg" => "video/mpeg", 61 | ".mpg" => "video/mpeg", 62 | ".mov" => "video/quicktime", 63 | ".qt" => "video/quicktime", 64 | ".avi" => "video/x-msvideo", 65 | ".asf" => "video/x-ms-asf", 66 | ".asx" => "video/x-ms-asf", 67 | ".wmv" => "video/x-ms-wmv", 68 | ".bz2" => "application/x-bzip", 69 | ".tbz" => "application/x-bzip-compressed-tar", 70 | ".tar.bz2" => "application/x-bzip-compressed-tar", 71 | ".crt" => "application/x-x509-ca-cert" 72 | ) 73 | 74 | accesslog.filename = "/var/log/lighttpd/lighttpd.access.log" 75 | debug.log-request-handling = "disable" 76 | 77 | ## deny access the file-extensions 78 | # 79 | # ~ is for backupfiles from vi, emacs, joe, ... 80 | # .inc is often used for code includes which should in general not be part 81 | # of the document-root 82 | url.access-deny = ( "~", ".inc" ) 83 | 84 | $HTTP["url"] =~ "\.pdf$" { 85 | server.range-requests = "disable" 86 | } 87 | 88 | ## 89 | # which extensions should not be handle via static-file transfer 90 | # 91 | # .php, .pl, .fcgi are most often handled by mod_fastcgi or mod_cgi 92 | static-file.exclude-extensions = ( ".sh" ) 93 | 94 | # always redirect to https 95 | $SERVER["socket"] == ":80" { 96 | $HTTP["remoteip"] != "127.0.0.1" { 97 | $HTTP["host"] =~ "(.*)" { 98 | url.redirect = ( "^/(.*)" => "https://%1/$1" ) 99 | } 100 | } 101 | } 102 | 103 | #### CGI module 104 | $HTTP["url"] =~ "^/cgi-bin/" { 105 | # disable directory listings 106 | dir-listing.activate = "disable" 107 | # only allow cgi's in this directory 108 | cgi.assign = ( ".sh" => "/bin/sh" ) 109 | } 110 | 111 | #### use self signed certificate 112 | ssl.engine = "enable" 113 | ssl.pemfile = "/etc/ssl/certs/localcert.pem" 114 | 115 | #### https://syslink.pl/cipherlist/ 116 | ssl.honor-cipher-order = "enable" 117 | ssl.cipher-list = "EECDH+AESGCM:EDH+AESGCM" 118 | setenv.add-response-header = ( 119 | "Strict-Transport-Security" => "max-age=63072000; includeSubDomains; preload", 120 | "X-Frame-Options" => "DENY", 121 | "X-Content-Type-Options" => "nosniff" 122 | ) 123 | ssl.use-sslv2 = "disable" 124 | ssl.use-sslv3 = "disable" 125 | ssl.openssl.ssl-conf-cmd = ("Protocol" => "-TLSv1.1, -TLSv1, -SSLv3") # v1.4.48 or up 126 | ssl.ec-curve = "secp384r1" 127 | 128 | #### auth 129 | auth.backend = "htdigest" 130 | auth.backend.htdigest.userfile = "/etc/lighttpd/lighttpd.user" 131 | auth.require = ( 132 | "/" => 133 | ( 134 | "method" => "digest", 135 | "realm" => "klipper", 136 | "require" => "user=printer" 137 | ) 138 | ) 139 | 140 | #### redirect to to octoprint 141 | $HTTP["url"] =~ "^/octoprint/" { 142 | proxy.server = ( "" => ( ( "host" => "127.0.0.1", "port" => 5000 ) ) ) 143 | setenv.add-request-header = ( "X-Script-Name" => "/octoprint/" ) 144 | } 145 | -------------------------------------------------------------------------------- /yocto/meta-klipper/scripts/lib/wic/pluginbase.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2011 Intel, Inc. 4 | # 5 | # SPDX-License-Identifier: GPL-2.0-only 6 | # 7 | 8 | __all__ = ['ImagerPlugin', 'SourcePlugin'] 9 | 10 | import os 11 | import logging 12 | 13 | from collections import defaultdict 14 | from importlib.machinery import SourceFileLoader 15 | 16 | from wic import WicError 17 | from wic.misc import get_bitbake_var 18 | 19 | PLUGIN_TYPES = ["imager", "source"] 20 | 21 | SCRIPTS_PLUGIN_DIR = ["scripts/lib/wic/plugins", "lib/wic/plugins"] 22 | 23 | logger = logging.getLogger('wic') 24 | 25 | PLUGINS = defaultdict(dict) 26 | 27 | class PluginMgr: 28 | _plugin_dirs = [] 29 | 30 | @classmethod 31 | def get_plugins(cls, ptype): 32 | """Get dictionary of : pairs.""" 33 | if ptype not in PLUGIN_TYPES: 34 | raise WicError('%s is not valid plugin type' % ptype) 35 | 36 | # collect plugin directories 37 | if not cls._plugin_dirs: 38 | cls._plugin_dirs = [os.path.join(os.path.dirname(__file__), 'plugins')] 39 | layers = get_bitbake_var("BBLAYERS") or '' 40 | for layer_path in layers.split(): 41 | for script_plugin_dir in SCRIPTS_PLUGIN_DIR: 42 | path = os.path.join(layer_path, script_plugin_dir) 43 | path = os.path.abspath(os.path.expanduser(path)) 44 | if path not in cls._plugin_dirs and os.path.isdir(path): 45 | cls._plugin_dirs.insert(0, path) 46 | 47 | if ptype not in PLUGINS: 48 | # load all ptype plugins 49 | for pdir in cls._plugin_dirs: 50 | ppath = os.path.join(pdir, ptype) 51 | if os.path.isdir(ppath): 52 | for fname in os.listdir(ppath): 53 | if fname.endswith('.py'): 54 | mname = fname[:-3] 55 | mpath = os.path.join(ppath, fname) 56 | logger.debug("loading plugin module %s", mpath) 57 | SourceFileLoader(mname, mpath).load_module() 58 | 59 | return PLUGINS.get(ptype) 60 | 61 | class PluginMeta(type): 62 | def __new__(cls, name, bases, attrs): 63 | class_type = type.__new__(cls, name, bases, attrs) 64 | if 'name' in attrs: 65 | PLUGINS[class_type.wic_plugin_type][attrs['name']] = class_type 66 | 67 | return class_type 68 | 69 | class ImagerPlugin(metaclass=PluginMeta): 70 | wic_plugin_type = "imager" 71 | 72 | def do_create(self): 73 | raise WicError("Method %s.do_create is not implemented" % 74 | self.__class__.__name__) 75 | 76 | class SourcePlugin(metaclass=PluginMeta): 77 | wic_plugin_type = "source" 78 | """ 79 | The methods that can be implemented by --source plugins. 80 | 81 | Any methods not implemented in a subclass inherit these. 82 | """ 83 | 84 | @classmethod 85 | def do_install_disk(cls, disk, disk_name, creator, workdir, oe_builddir, 86 | bootimg_dir, kernel_dir, native_sysroot): 87 | """ 88 | Called after all partitions have been prepared and assembled into a 89 | disk image. This provides a hook to allow finalization of a 90 | disk image e.g. to write an MBR to it. 91 | """ 92 | logger.debug("SourcePlugin: do_install_disk: disk: %s", disk_name) 93 | 94 | @classmethod 95 | def do_stage_partition(cls, part, source_params, creator, cr_workdir, 96 | oe_builddir, bootimg_dir, kernel_dir, 97 | native_sysroot): 98 | """ 99 | Special content staging hook called before do_prepare_partition(), 100 | normally empty. 101 | 102 | Typically, a partition will just use the passed-in parame e.g 103 | straight bootimg_dir, etc, but in some cases, things need to 104 | be more tailored e.g. to use a deploy dir + /boot, etc. This 105 | hook allows those files to be staged in a customized fashion. 106 | Not that get_bitbake_var() allows you to acces non-standard 107 | variables that you might want to use for this. 108 | """ 109 | logger.debug("SourcePlugin: do_stage_partition: part: %s", part) 110 | 111 | @classmethod 112 | def do_configure_partition(cls, part, source_params, creator, cr_workdir, 113 | oe_builddir, bootimg_dir, kernel_dir, 114 | native_sysroot): 115 | """ 116 | Called before do_prepare_partition(), typically used to create 117 | custom configuration files for a partition, for example 118 | syslinux or grub config files. 119 | """ 120 | logger.debug("SourcePlugin: do_configure_partition: part: %s", part) 121 | 122 | @classmethod 123 | def do_prepare_partition(cls, part, source_params, creator, cr_workdir, 124 | oe_builddir, bootimg_dir, kernel_dir, rootfs_dir, 125 | native_sysroot): 126 | """ 127 | Called to do the actual content population for a partition i.e. it 128 | 'prepares' the partition to be incorporated into the image. 129 | """ 130 | logger.debug("SourcePlugin: do_prepare_partition: part: %s", part) 131 | 132 | @classmethod 133 | def do_post_partition(cls, part, source_params, creator, cr_workdir, 134 | oe_builddir, bootimg_dir, kernel_dir, rootfs_dir, 135 | native_sysroot): 136 | """ 137 | Called after the partition is created. It is useful to add post 138 | operations e.g. security signing the partition. 139 | """ 140 | logger.debug("SourcePlugin: do_post_partition: part: %s", part) 141 | -------------------------------------------------------------------------------- /yocto/meta-klipper/classes/runit-service.bbclass: -------------------------------------------------------------------------------- 1 | # Imported from: 2 | # https://git.digitalstrom.org/dss-oe/dss-oe/blob/master/yocto/dS/meta-digitalstrom-devel/classes/runit-service.bbclass 3 | # 4 | # License: MIT 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to deal 8 | # in the Software without restriction, including without limitation the rights 9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | # copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included in 14 | # all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | # THE SOFTWARE. 23 | # 24 | # 25 | # Class that handles control of the runit service, similar to update-rc.d class. 26 | # 27 | # RUNIT_SERVICES: name of the services that we want to control 28 | # RUNIT_SERVICE_PACKAGES: list of packages that should be handled by this class 29 | # RUNIT_SERVICE_AUTOSTART: allows to control automatic service startup after 30 | # package installation 31 | 32 | RUNIT_SERVICE_PN ?= "${PN}" 33 | RUNIT_SERVICE_AUTOSTART ?= "1" 34 | RUNIT_SERVICE_DIR ?= "/var/service" 35 | 36 | RDEPENDS_${PN}_append = "busybox busybox-runit" 37 | 38 | runit_service_prerm() { 39 | if [ "x$D" = "x" ]; then 40 | if [ ! -f "/etc/runit/${RUNIT_SERVICE_NAME}/down" ]; then 41 | if [ -f "/etc/runit/${RUNIT_SERVICE_NAME}/supervise/stat" ]; then 42 | if [ "`cat /etc/runit/${RUNIT_SERVICE_NAME}/supervise/stat`" = "run" ]; then 43 | echo "Stopping ${RUNIT_SERVICE_NAME}..." 44 | sv force-stop /etc/runit/${RUNIT_SERVICE_NAME} || true 45 | fi # current service status 46 | fi # suervice existence 47 | fi # service "down" file 48 | fi # live image check 49 | } 50 | 51 | runit_service_postinst_ontarget() { 52 | # only link when autostart is true, but otherwise do not modify existing 53 | # rootfs configuration, i.e. dont force disable 54 | if [ "${RUNIT_SERVICE_AUTOSTART}" -eq "1" ]; then 55 | if [ -d "/etc/runit/${RUNIT_SERVICE_NAME}" ] && [ ! -L "${RUNIT_SERVICE_DIR}/${RUNIT_SERVICE_NAME}" ]; then 56 | ln -s "/etc/runit/${RUNIT_SERVICE_NAME}" "${RUNIT_SERVICE_DIR}/${RUNIT_SERVICE_NAME}" 57 | fi 58 | fi 59 | } 60 | 61 | runit_service_postrm() { 62 | if [ "x$D" = "x" ]; then 63 | if [ ! -f "/etc/runit/${RUNIT_SERVICE_NAME}/down" ]; then 64 | if [ -n "${RUNIT_SERVICE_NAME}" ] && [ -d "/etc/runit/${RUNIT_SERVICE_NAME}" ]; then 65 | rm -rf "/etc/runit/${RUNIT_SERVICE_NAME}" 66 | fi 67 | fi 68 | fi 69 | } 70 | 71 | def runit_service_after_parse(d): 72 | if d.getVar('RUNIT_SERVICES') == None: 73 | raise bb.build.FuncFailed("%s inherits runit-service but doesn't set RUNIT_SERVICES" % d.getVar('FILE')) 74 | 75 | python __anonymous() { 76 | runit_service_after_parse(d) 77 | } 78 | 79 | PACKAGESPLITFUNCS_prepend = "populate_packages_runit_service " 80 | 81 | populate_packages_runit_service[vardeps] += "runit_service_prerm runit_service_postinst_ontarget runit_service_postrm" 82 | 83 | python populate_packages_runit_service() { 84 | def runit_service(pkg, service): 85 | localdata = bb.data.createCopy(d) 86 | localdata.setVar("RUNIT_SERVICE_NAME", service) 87 | bb.data.update_data(localdata) 88 | 89 | postinst = d.getVar('pkg_postinst_ontarget_%s' % pkg, True) 90 | if not postinst: 91 | postinst = '#!/bin/sh\n' 92 | postinst += localdata.getVar('runit_service_postinst_ontarget', True) 93 | d.setVar('pkg_postinst_ontarget_%s' % pkg, postinst) 94 | 95 | prerm = d.getVar('pkg_prerm_%s' % pkg, True) 96 | if not prerm: 97 | prerm = '#!/bin/sh\n' 98 | prerm += localdata.getVar('runit_service_prerm', True) 99 | d.setVar('pkg_prerm_%s' % pkg, prerm) 100 | 101 | if d.getVar("RUNIT_SERVICE_PN", True) == service: 102 | postrm = d.getVar('pkg_postrm_%s' % pkg, True) 103 | if not postrm: 104 | postrm = '#!/bin/sh\n' 105 | postrm += localdata.getVar('runit_service_postrm', True) 106 | d.setVar('pkg_postrm_%s' % pkg, postrm) 107 | 108 | def runit_services_package(pkg): 109 | localdata = bb.data.createCopy(d) 110 | overrides = localdata.getVar("OVERRIDES", True) 111 | localdata.setVar("OVERRIDES", "%s:%s" % (pkg, overrides)) 112 | bb.data.update_data(localdata) 113 | 114 | localdata = bb.data.createCopy(d) 115 | overrides = localdata.getVar("OVERRIDES", True) 116 | localdata.setVar("OVERRIDES", "%s:%s" % (pkg, overrides)) 117 | bb.data.update_data(localdata) 118 | 119 | services = (d.getVar("RUNIT_SERVICES", True) or "").split() 120 | for service in services: 121 | runit_service(pkg, service) 122 | 123 | pkgs = d.getVar("RUNIT_SERVICE_PACKAGES", True) 124 | if pkgs == None: 125 | pkgs = d.getVar("RUNIT_SERVICE_PN", True) 126 | packages = (d.getVar("PACKAGES", True) or "").split() 127 | if not pkgs in packages and packages != []: 128 | pkgs = packages[0] 129 | for pkg in pkgs.split(): 130 | runit_services_package(pkg) 131 | } 132 | 133 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-support/create-certificate/files/create-cert: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | CERTPATH="/etc/ssl/certs/" 4 | 5 | while [ -n "$1" ]; do 6 | CMD="${1%=*}" 7 | ARG="${1#*=}" 8 | if [ "$CMD" == "refresh" ]; then 9 | rm -f "$CERTPATH/localcert.pem" "$CERTPATH/localcertreq.csr" 10 | elif [ "$CMD" == "path" ]; then 11 | CERTPATH=$ARG 12 | fi 13 | shift 14 | done 15 | mkdir -p "$CERTPATH" 16 | 17 | # keep compatibility 18 | if [ -s "$CERTPATH/privkey.pem" ]; then 19 | mv -f "$CERTPATH/privkey.pem" "$CERTPATH/localprivkey.pem" 20 | fi 21 | if [ -s "$CERTPATH/certreq.csr" ]; then 22 | mv -f "$CERTPATH/certreq.csr" "$CERTPATH/localcertreq.csr" 23 | fi 24 | 25 | TMPFILE=`mktemp` 26 | DATE_MODIFIED=0 27 | 28 | # Input: Jan 1 00:00:03 1995 GMT 29 | # busybox date is too limited to parse that 30 | ssl_date_to_epoch() 31 | { 32 | MONTHS="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec" 33 | MONTH=$(echo "$1" | awk '{ print $1 }') 34 | STR="${MONTHS%$MONTH*}" 35 | MONTH_NUM=$(echo "$((${#string}/4 + 1))") 36 | 37 | MONTH_DAY=$(echo "$1" | awk '{ print $2 }') 38 | TIME=$(echo "$1" | awk '{ print $3 }') 39 | YEAR=$(echo "$1" | awk '{ print $4 }') 40 | echo `date -d "$YEAR-$MONTH_NUM-$MONTH_DAY $TIME" +%s` 41 | } 42 | 43 | which openssl >/dev/null 44 | if [ "$?" -ne "0" ]; then 45 | echo "Please install openssl and make sure it is in your PATH!" 46 | exit 1 47 | fi 48 | 49 | if [ -n "$CERTPATH" ] && [ ! -d "$CERTPATH" ]; then 50 | echo "Output directory does not exist, creating $CERTPATH" 51 | mkdir -p "$1" 52 | fi 53 | 54 | date2epoch () { 55 | if [ -n "$1" ]; then 56 | date --utc --date "$1" '+%s' 57 | else 58 | date --utc '+%s' 59 | fi 60 | } 61 | 62 | # if systemtime is *before* year 2015 then go forward in time 63 | # to year 2015 and create a certificate that is valid until 2037 64 | sanitize_start_date() 65 | { 66 | if [ $DATE_MODIFIED -eq 1 ]; then 67 | return; 68 | fi 69 | 70 | TNOW=$(date2epoch) 71 | TMIN=$(date2epoch "2015-01-01 00:00:00") 72 | if [ $TNOW -le $TMIN ]; then 73 | DATE_MODIFIED=1 74 | date -u -s "2015-01-01 00:00:00" 75 | fi 76 | } 77 | 78 | cleanup () 79 | { 80 | if [ $DATE_MODIFIED -eq 1 ]; then 81 | date -s "`cat $TMPFILE`" 82 | fi 83 | rm -f $TMPFILE 84 | } 85 | 86 | trap cleanup EXIT 87 | 88 | date +"%Y-%m-%d %T" > $TMPFILE 89 | sanitize_start_date 90 | 91 | EPOCH_CURRENT_DATE=$(date2epoch) 92 | TMAX=$(date2epoch "2037-01-01 00:00:00") 93 | DAYS_VALID=$(expr $(expr $TMAX - $EPOCH_CURRENT_DATE) / 86400) 94 | 95 | if [ -f /etc/init.d/rng-tools ]; then 96 | # ensure that we will have enough entropy to generate rsa key 97 | /etc/init.d/rng-tools start 98 | fi 99 | 100 | if [ ! -s "$CERTPATH/localprivkey.pem" ]; then 101 | openssl genrsa -out $CERTPATH/localprivkey.pem 2048 102 | if [ "$?" -ne "0" ]; then 103 | echo "Failed to generate private key!" 104 | exit 1 105 | fi 106 | chmod 400 $CERTPATH/localprivkey.pem 107 | else 108 | echo "Reusing existing localprivkey.pem file as private key." 109 | fi 110 | 111 | create_request () 112 | { 113 | cat > "$CERTPATH/localreq.conf" <<-EOD 114 | [req] 115 | default_bits = 4096 # key length 4096 bits RSA 116 | distinguished_name = req_distinguished_name 117 | req_extensions = SAN 118 | default_md = sha256 119 | dirstring_type = nombstr 120 | prompt = no 121 | 122 | [req_distinguished_name] 123 | C = XX 124 | ST = YY 125 | L = Klipper 126 | O = Klipper 127 | OU = Klipper 128 | CN = $1 129 | 130 | [SAN] 131 | subjectAltName = @alt_names 132 | 133 | [alt_names] 134 | DNS.1 = $1.local 135 | EOD 136 | if [ -e /sys/class/net/eth0 ]; then 137 | IP=`ifconfig eth0 | sed -n '/inet addr/s/.*addr.\([^ ]*\) .*/\1/p'` 138 | if [ -n "$IP" ]; then 139 | echo "IP.1 = $IP" >> "$CERTPATH/localreq.conf" 140 | fi 141 | fi 142 | if [ -e /sys/class/net/eth1 ]; then 143 | IP=`ifconfig eth1 | sed -n '/inet addr/s/.*addr.\([^ ]*\) .*/\1/p'` 144 | if [ -n "$IP" ]; then 145 | echo "IP.2 = $IP" >> "$CERTPATH/localreq.conf" 146 | fi 147 | fi 148 | } 149 | 150 | create_request $(hostname) 151 | 152 | if [ ! -s "$CERTPATH/localcertreq.csr" ]; then 153 | openssl req -new -sha256 -nodes -newkey rsa:2048 -batch -days $DAYS_VALID -config $CERTPATH/localreq.conf -key $CERTPATH/localprivkey.pem -out $CERTPATH/localcertreq.csr -reqexts SAN -extensions SAN 154 | if [ "$?" -ne "0" ]; then 155 | echo "Failed to create a certificate signing request!" 156 | exit 1 157 | fi 158 | else 159 | echo "Reusing existing localcertreq.csr file as certificate signing request." 160 | fi 161 | 162 | if [ -s $CERTPATH/localcert.pem ]; then 163 | EPOCH_CERT_DATE=0 164 | CURRENT_CERT_DATE=$(openssl x509 -noout -in $CERTPATH/localcert.pem -enddate | cut -d '=' -f 2) 165 | 166 | if [ -n "$CURRENT_CERT_DATE" ]; then 167 | EPOCH_CERT_DATE=$(ssl_date_to_epoch "$CURRENT_CERT_DATE") 168 | fi 169 | 170 | # recreate certificate 2 months prior to current date 171 | # 5184000 seconds = roughly two months 172 | EPOCH_CURRENT_DATE=$(expr $EPOCH_CURRENT_DATE - 5184000) 173 | 174 | if [ $EPOCH_CERT_DATE -lt $EPOCH_CURRENT_DATE ]; then 175 | rm -f $CERTPATH/localcert.pem 176 | echo "Certificate will expire on $CURRENT_CERT_DATE, removing." 177 | fi 178 | fi 179 | 180 | if [ ! -s "$CERTPATH/localcert.pem" ]; then 181 | openssl req -x509 -sha256 -nodes -newkey rsa:2048 -days $DAYS_VALID -config $CERTPATH/localreq.conf -in $CERTPATH/localcertreq.csr -key $CERTPATH/localprivkey.pem -out $CERTPATH/localcert.pem -extensions SAN 182 | if [ "$?" -ne "0" ]; then 183 | echo "Could not create self signed certificate!" 184 | exit 1 185 | fi 186 | 187 | cat $CERTPATH/localprivkey.pem >> $CERTPATH/localcert.pem 188 | if [ "$?" -ne "0" ]; then 189 | echo "Failed to add localprivkey.pem to localcert.pem" 190 | exit 1 191 | fi 192 | 193 | echo "Certificate created as \"localcert.pem\"" 194 | fi 195 | 196 | exit 0 197 | 198 | -------------------------------------------------------------------------------- /yocto/meta-klipper/scripts/lib/wic/plugins/source/bootimg-partition.py: -------------------------------------------------------------------------------- 1 | # 2 | # SPDX-License-Identifier: GPL-2.0-only 3 | # 4 | # DESCRIPTION 5 | # This implements the 'bootimg-partition' source plugin class for 6 | # 'wic'. The plugin creates an image of boot partition, copying over 7 | # files listed in IMAGE_BOOT_FILES bitbake variable. 8 | # 9 | # AUTHORS 10 | # Maciej Borzecki 11 | # 12 | 13 | import logging 14 | import os 15 | import re 16 | 17 | from glob import glob 18 | 19 | from wic import WicError 20 | from wic.engine import get_custom_config 21 | from wic.pluginbase import SourcePlugin 22 | from wic.misc import exec_cmd, get_bitbake_var 23 | 24 | logger = logging.getLogger('wic') 25 | 26 | class BootimgPartitionPlugin(SourcePlugin): 27 | """ 28 | Create an image of boot partition, copying over files 29 | listed in IMAGE_BOOT_FILES bitbake variable. 30 | """ 31 | 32 | name = 'bootimg-partition' 33 | 34 | @classmethod 35 | def do_configure_partition(cls, part, source_params, cr, cr_workdir, 36 | oe_builddir, bootimg_dir, kernel_dir, 37 | native_sysroot): 38 | """ 39 | Called before do_prepare_partition(), create u-boot specific boot config 40 | """ 41 | hdddir = "%s/boot.%d" % (cr_workdir, part.lineno) 42 | install_cmd = "install -d %s" % hdddir 43 | exec_cmd(install_cmd) 44 | 45 | if not kernel_dir: 46 | kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") 47 | if not kernel_dir: 48 | raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting") 49 | 50 | boot_files = None 51 | for (fmt, id) in (("_uuid-%s", part.uuid), ("_label-%s", part.label), (None, None)): 52 | if fmt: 53 | var = fmt % id 54 | else: 55 | var = "" 56 | 57 | boot_files = get_bitbake_var("IMAGE_BOOT_FILES" + var) 58 | if boot_files is not None: 59 | break 60 | 61 | if boot_files is None: 62 | raise WicError('No boot files defined, IMAGE_BOOT_FILES unset for entry #%d' % part.lineno) 63 | 64 | logger.debug('Boot files: %s', boot_files) 65 | 66 | # list of tuples (src_name, dst_name) 67 | deploy_files = [] 68 | for src_entry in re.findall(r'[\w;\-\./\*]+', boot_files): 69 | if ';' in src_entry: 70 | dst_entry = tuple(src_entry.split(';')) 71 | if not dst_entry[0] or not dst_entry[1]: 72 | raise WicError('Malformed boot file entry: %s' % src_entry) 73 | else: 74 | dst_entry = (src_entry, src_entry) 75 | 76 | logger.debug('Destination entry: %r', dst_entry) 77 | deploy_files.append(dst_entry) 78 | 79 | cls.install_task = []; 80 | for deploy_entry in deploy_files: 81 | src, dst = deploy_entry 82 | if '*' in src: 83 | # by default install files under their basename 84 | entry_name_fn = os.path.basename 85 | if dst != src: 86 | # unless a target name was given, then treat name 87 | # as a directory and append a basename 88 | entry_name_fn = lambda name: \ 89 | os.path.join(dst, 90 | os.path.basename(name)) 91 | 92 | srcs = glob(os.path.join(kernel_dir, src)) 93 | 94 | logger.debug('Globbed sources: %s', ', '.join(srcs)) 95 | for entry in srcs: 96 | src = os.path.relpath(entry, kernel_dir) 97 | entry_dst_name = entry_name_fn(entry) 98 | cls.install_task.append((src, entry_dst_name)) 99 | else: 100 | cls.install_task.append((src, dst)) 101 | 102 | if source_params.get('loader') != "u-boot": 103 | return 104 | 105 | configfile = cr.ks.bootloader.configfile 106 | custom_cfg = None 107 | if configfile: 108 | custom_cfg = get_custom_config(configfile) 109 | if custom_cfg: 110 | # Use a custom configuration for extlinux.conf 111 | extlinux_conf = custom_cfg 112 | logger.debug("Using custom configuration file " 113 | "%s for extlinux.cfg", configfile) 114 | else: 115 | raise WicError("configfile is specified but failed to " 116 | "get it from %s." % configfile) 117 | 118 | if not custom_cfg: 119 | # The kernel types supported by the sysboot of u-boot 120 | kernel_types = ["zImage", "Image", "fitImage", "uImage", "vmlinux"] 121 | has_dtb = False 122 | fdt_dir = '/' 123 | kernel_name = None 124 | 125 | # Find the kernel image name, from the highest precedence to lowest 126 | for image in kernel_types: 127 | for task in cls.install_task: 128 | src, dst = task 129 | if re.match(image, src): 130 | kernel_name = os.path.join('/', dst) 131 | break 132 | if kernel_name: 133 | break 134 | 135 | for task in cls.install_task: 136 | src, dst = task 137 | # We suppose that all the dtb are in the same directory 138 | if re.search(r'\.dtb', src) and fdt_dir == '/': 139 | has_dtb = True 140 | fdt_dir = os.path.join(fdt_dir, os.path.dirname(dst)) 141 | break 142 | 143 | if not kernel_name: 144 | raise WicError('No kernel file found') 145 | 146 | # Compose the extlinux.conf 147 | extlinux_conf = "default Yocto\n" 148 | extlinux_conf += "label Yocto\n" 149 | extlinux_conf += " kernel %s\n" % kernel_name 150 | if has_dtb: 151 | extlinux_conf += " fdtdir %s\n" % fdt_dir 152 | bootloader = cr.ks.bootloader 153 | extlinux_conf += "append root=%s rootwait %s\n" \ 154 | % (cr.rootdev, bootloader.append if bootloader.append else '') 155 | 156 | install_cmd = "install -d %s/extlinux/" % hdddir 157 | exec_cmd(install_cmd) 158 | cfg = open("%s/extlinux/extlinux.conf" % hdddir, "w") 159 | cfg.write(extlinux_conf) 160 | cfg.close() 161 | 162 | 163 | @classmethod 164 | def do_prepare_partition(cls, part, source_params, cr, cr_workdir, 165 | oe_builddir, bootimg_dir, kernel_dir, 166 | rootfs_dir, native_sysroot): 167 | """ 168 | Called to do the actual content population for a partition i.e. it 169 | 'prepares' the partition to be incorporated into the image. 170 | In this case, does the following: 171 | - sets up a vfat partition 172 | - copies all files listed in IMAGE_BOOT_FILES variable 173 | """ 174 | hdddir = "%s/boot.%d" % (cr_workdir, part.lineno) 175 | 176 | if not kernel_dir: 177 | kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") 178 | if not kernel_dir: 179 | raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting") 180 | 181 | logger.debug('Kernel dir: %s', bootimg_dir) 182 | 183 | 184 | for task in cls.install_task: 185 | src_path, dst_path = task 186 | logger.debug('Install %s as %s', src_path, dst_path) 187 | install_cmd = "install -m 0644 -D %s %s" \ 188 | % (os.path.join(kernel_dir, src_path), 189 | os.path.join(hdddir, dst_path)) 190 | exec_cmd(install_cmd) 191 | 192 | logger.debug('Prepare boot partition using rootfs in %s', hdddir) 193 | part.prepare_rootfs(cr_workdir, oe_builddir, hdddir, 194 | native_sysroot, False) 195 | -------------------------------------------------------------------------------- /yocto/meta-klipper/scripts/lib/wic/plugins/source/bootimg-biosplusefi.py: -------------------------------------------------------------------------------- 1 | # 2 | # This program is free software; you can redistribute it and/or modify 3 | # it under the terms of the GNU General Public License version 2 as 4 | # published by the Free Software Foundation. 5 | # 6 | # This program is distributed in the hope that it will be useful, 7 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | # GNU General Public License for more details. 10 | # 11 | # You should have received a copy of the GNU General Public License along 12 | # with this program; if not, write to the Free Software Foundation, Inc., 13 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 14 | # 15 | # DESCRIPTION 16 | # This implements the 'bootimg-biosplusefi' source plugin class for 'wic' 17 | # 18 | # AUTHORS 19 | # William Bourque 20 | 21 | import types 22 | 23 | from wic.pluginbase import SourcePlugin 24 | from importlib.machinery import SourceFileLoader 25 | 26 | class BootimgBiosPlusEFIPlugin(SourcePlugin): 27 | """ 28 | Create MBR + EFI boot partition 29 | 30 | This plugin creates a boot partition that contains both 31 | legacy BIOS and EFI content. It will be able to boot from both. 32 | This is useful when managing PC fleet with some older machines 33 | without EFI support. 34 | 35 | Note it is possible to create an image that can boot from both 36 | legacy BIOS and EFI by defining two partitions : one with arg 37 | --source bootimg-efi and another one with --source bootimg-pcbios. 38 | However, this method has the obvious downside that it requires TWO 39 | partitions to be created on the storage device. 40 | Both partitions will also be marked as "bootable" which does not work on 41 | most BIOS, has BIOS often uses the "bootable" flag to determine 42 | what to boot. If you have such a BIOS, you need to manually remove the 43 | "bootable" flag from the EFI partition for the drive to be bootable. 44 | Having two partitions also seems to confuse wic : the content of 45 | the first partition will be duplicated into the second, even though it 46 | will not be used at all. 47 | 48 | Also, unlike "isoimage-isohybrid" that also does BIOS and EFI, this plugin 49 | allows you to have more than only a single rootfs partitions and does 50 | not turn the rootfs into an initramfs RAM image. 51 | 52 | This plugin is made to put everything into a single /boot partition so it 53 | does not have the limitations listed above. 54 | 55 | The plugin is made so it does tries not to reimplement what's already 56 | been done in other plugins; as such it imports "bootimg-pcbios" 57 | and "bootimg-efi". 58 | Plugin "bootimg-pcbios" is used to generate legacy BIOS boot. 59 | Plugin "bootimg-efi" is used to generate the UEFI boot. Note that it 60 | requires a --sourceparams argument to know which loader to use; refer 61 | to "bootimg-efi" code/documentation for the list of loader. 62 | 63 | Imports are handled with "SourceFileLoader" from importlib as it is 64 | otherwise very difficult to import module that has hyphen "-" in their 65 | filename. 66 | The SourcePlugin() methods used in the plugins (do_install_disk, 67 | do_configure_partition, do_prepare_partition) are then called on both, 68 | beginning by "bootimg-efi". 69 | 70 | Plugin options, such as "--sourceparams" can still be passed to a 71 | plugin, as long they does not cause issue in the other plugin. 72 | 73 | Example wic configuration: 74 | part /boot --source bootimg-biosplusefi --sourceparams="loader=grub-efi"\\ 75 | --ondisk sda --label os_boot --active --align 1024 --use-uuid 76 | """ 77 | 78 | name = 'bootimg-biosplusefi' 79 | 80 | __PCBIOS_MODULE_NAME = "bootimg-pcbios" 81 | __EFI_MODULE_NAME = "bootimg-efi" 82 | 83 | __imgEFIObj = None 84 | __imgBiosObj = None 85 | 86 | @classmethod 87 | def __init__(cls): 88 | """ 89 | Constructor (init) 90 | """ 91 | 92 | # XXX 93 | # For some reasons, __init__ constructor is never called. 94 | # Something to do with how pluginbase works? 95 | cls.__instanciateSubClasses() 96 | 97 | @classmethod 98 | def __instanciateSubClasses(cls): 99 | """ 100 | 101 | """ 102 | 103 | # Import bootimg-pcbios (class name "BootimgPcbiosPlugin") 104 | modulePath = os.path.join(os.path.dirname(os.path.realpath(__file__)), 105 | cls.__PCBIOS_MODULE_NAME + ".py") 106 | loader = SourceFileLoader(cls.__PCBIOS_MODULE_NAME, modulePath) 107 | mod = types.ModuleType(loader.name) 108 | loader.exec_module(mod) 109 | cls.__imgBiosObj = mod.BootimgPcbiosPlugin() 110 | 111 | # Import bootimg-efi (class name "BootimgEFIPlugin") 112 | modulePath = os.path.join(os.path.dirname(os.path.realpath(__file__)), 113 | cls.__EFI_MODULE_NAME + ".py") 114 | loader = SourceFileLoader(cls.__EFI_MODULE_NAME, modulePath) 115 | mod = types.ModuleType(loader.name) 116 | loader.exec_module(mod) 117 | cls.__imgEFIObj = mod.BootimgEFIPlugin() 118 | 119 | @classmethod 120 | def do_install_disk(cls, disk, disk_name, creator, workdir, oe_builddir, 121 | bootimg_dir, kernel_dir, native_sysroot): 122 | """ 123 | Called after all partitions have been prepared and assembled into a 124 | disk image. 125 | """ 126 | 127 | if ( (not cls.__imgEFIObj) or (not cls.__imgBiosObj) ): 128 | cls.__instanciateSubClasses() 129 | 130 | cls.__imgEFIObj.do_install_disk( 131 | disk, 132 | disk_name, 133 | creator, 134 | workdir, 135 | oe_builddir, 136 | bootimg_dir, 137 | kernel_dir, 138 | native_sysroot) 139 | 140 | cls.__imgBiosObj.do_install_disk( 141 | disk, 142 | disk_name, 143 | creator, 144 | workdir, 145 | oe_builddir, 146 | bootimg_dir, 147 | kernel_dir, 148 | native_sysroot) 149 | 150 | @classmethod 151 | def do_configure_partition(cls, part, source_params, creator, cr_workdir, 152 | oe_builddir, bootimg_dir, kernel_dir, 153 | native_sysroot): 154 | """ 155 | Called before do_prepare_partition() 156 | """ 157 | 158 | if ( (not cls.__imgEFIObj) or (not cls.__imgBiosObj) ): 159 | cls.__instanciateSubClasses() 160 | 161 | cls.__imgEFIObj.do_configure_partition( 162 | part, 163 | source_params, 164 | creator, 165 | cr_workdir, 166 | oe_builddir, 167 | bootimg_dir, 168 | kernel_dir, 169 | native_sysroot) 170 | 171 | cls.__imgBiosObj.do_configure_partition( 172 | part, 173 | source_params, 174 | creator, 175 | cr_workdir, 176 | oe_builddir, 177 | bootimg_dir, 178 | kernel_dir, 179 | native_sysroot) 180 | 181 | @classmethod 182 | def do_prepare_partition(cls, part, source_params, creator, cr_workdir, 183 | oe_builddir, bootimg_dir, kernel_dir, 184 | rootfs_dir, native_sysroot): 185 | """ 186 | Called to do the actual content population for a partition i.e. it 187 | 'prepares' the partition to be incorporated into the image. 188 | """ 189 | 190 | if ( (not cls.__imgEFIObj) or (not cls.__imgBiosObj) ): 191 | cls.__instanciateSubClasses() 192 | 193 | cls.__imgEFIObj.do_prepare_partition( 194 | part, 195 | source_params, 196 | creator, 197 | cr_workdir, 198 | oe_builddir, 199 | bootimg_dir, 200 | kernel_dir, 201 | rootfs_dir, 202 | native_sysroot) 203 | 204 | cls.__imgBiosObj.do_prepare_partition( 205 | part, 206 | source_params, 207 | creator, 208 | cr_workdir, 209 | oe_builddir, 210 | bootimg_dir, 211 | kernel_dir, 212 | rootfs_dir, 213 | native_sysroot) 214 | -------------------------------------------------------------------------------- /yocto/meta-klipper/scripts/lib/wic/plugins/source/bootimg-pcbios.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2014, Intel Corporation. 3 | # 4 | # SPDX-License-Identifier: GPL-2.0-only 5 | # 6 | # DESCRIPTION 7 | # This implements the 'bootimg-pcbios' source plugin class for 'wic' 8 | # 9 | # AUTHORS 10 | # Tom Zanussi 11 | # 12 | 13 | import logging 14 | import os 15 | import re 16 | 17 | from wic import WicError 18 | from wic.engine import get_custom_config 19 | from wic.pluginbase import SourcePlugin 20 | from wic.misc import (exec_cmd, exec_native_cmd, 21 | get_bitbake_var, BOOTDD_EXTRA_SPACE) 22 | 23 | logger = logging.getLogger('wic') 24 | 25 | class BootimgPcbiosPlugin(SourcePlugin): 26 | """ 27 | Create MBR boot partition and install syslinux on it. 28 | """ 29 | 30 | name = 'bootimg-pcbios' 31 | 32 | @classmethod 33 | def _get_bootimg_dir(cls, bootimg_dir, dirname): 34 | """ 35 | Check if dirname exists in default bootimg_dir or in STAGING_DIR. 36 | """ 37 | staging_datadir = get_bitbake_var("STAGING_DATADIR") 38 | for result in (bootimg_dir, staging_datadir): 39 | if os.path.exists("%s/%s" % (result, dirname)): 40 | return result 41 | 42 | # STAGING_DATADIR is expanded with MLPREFIX if multilib is enabled 43 | # but dependency syslinux is still populated to original STAGING_DATADIR 44 | nonarch_datadir = re.sub('/[^/]*recipe-sysroot', '/recipe-sysroot', staging_datadir) 45 | if os.path.exists(os.path.join(nonarch_datadir, dirname)): 46 | return nonarch_datadir 47 | 48 | raise WicError("Couldn't find correct bootimg_dir, exiting") 49 | 50 | @classmethod 51 | def do_install_disk(cls, disk, disk_name, creator, workdir, oe_builddir, 52 | bootimg_dir, kernel_dir, native_sysroot): 53 | """ 54 | Called after all partitions have been prepared and assembled into a 55 | disk image. In this case, we install the MBR. 56 | """ 57 | bootimg_dir = cls._get_bootimg_dir(bootimg_dir, 'syslinux') 58 | mbrfile = "%s/syslinux/" % bootimg_dir 59 | if creator.ptable_format == 'msdos': 60 | mbrfile += "mbr.bin" 61 | elif creator.ptable_format == 'gpt': 62 | mbrfile += "gptmbr.bin" 63 | else: 64 | raise WicError("Unsupported partition table: %s" % 65 | creator.ptable_format) 66 | 67 | if not os.path.exists(mbrfile): 68 | raise WicError("Couldn't find %s. If using the -e option, do you " 69 | "have the right MACHINE set in local.conf? If not, " 70 | "is the bootimg_dir path correct?" % mbrfile) 71 | 72 | full_path = creator._full_path(workdir, disk_name, "direct") 73 | logger.debug("Installing MBR on disk %s as %s with size %s bytes", 74 | disk_name, full_path, disk.min_size) 75 | 76 | dd_cmd = "dd if=%s of=%s conv=notrunc" % (mbrfile, full_path) 77 | exec_cmd(dd_cmd, native_sysroot) 78 | 79 | @classmethod 80 | def do_configure_partition(cls, part, source_params, creator, cr_workdir, 81 | oe_builddir, bootimg_dir, kernel_dir, 82 | native_sysroot): 83 | """ 84 | Called before do_prepare_partition(), creates syslinux config 85 | """ 86 | hdddir = "%s/hdd/boot" % cr_workdir 87 | 88 | install_cmd = "install -d %s" % hdddir 89 | exec_cmd(install_cmd) 90 | 91 | bootloader = creator.ks.bootloader 92 | 93 | custom_cfg = None 94 | if bootloader.configfile: 95 | custom_cfg = get_custom_config(bootloader.configfile) 96 | if custom_cfg: 97 | # Use a custom configuration for grub 98 | syslinux_conf = custom_cfg 99 | logger.debug("Using custom configuration file %s " 100 | "for syslinux.cfg", bootloader.configfile) 101 | else: 102 | raise WicError("configfile is specified but failed to " 103 | "get it from %s." % bootloader.configfile) 104 | 105 | if not custom_cfg: 106 | # Create syslinux configuration using parameters from wks file 107 | splash = os.path.join(cr_workdir, "/hdd/boot/splash.jpg") 108 | if os.path.exists(splash): 109 | splashline = "menu background splash.jpg" 110 | else: 111 | splashline = "" 112 | 113 | syslinux_conf = "" 114 | syslinux_conf += "PROMPT 0\n" 115 | syslinux_conf += "TIMEOUT " + str(bootloader.timeout) + "\n" 116 | syslinux_conf += "\n" 117 | syslinux_conf += "ALLOWOPTIONS 1\n" 118 | syslinux_conf += "SERIAL 0 115200\n" 119 | syslinux_conf += "\n" 120 | if splashline: 121 | syslinux_conf += "%s\n" % splashline 122 | syslinux_conf += "DEFAULT boot\n" 123 | syslinux_conf += "LABEL boot\n" 124 | 125 | kernel = "/vmlinuz" 126 | syslinux_conf += "KERNEL " + kernel + "\n" 127 | 128 | syslinux_conf += "APPEND label=boot root=%s %s\n" % \ 129 | (creator.rootdev, bootloader.append) 130 | 131 | logger.debug("Writing syslinux config %s/hdd/boot/syslinux.cfg", 132 | cr_workdir) 133 | cfg = open("%s/hdd/boot/syslinux.cfg" % cr_workdir, "w") 134 | cfg.write(syslinux_conf) 135 | cfg.close() 136 | 137 | @classmethod 138 | def do_prepare_partition(cls, part, source_params, creator, cr_workdir, 139 | oe_builddir, bootimg_dir, kernel_dir, 140 | rootfs_dir, native_sysroot): 141 | """ 142 | Called to do the actual content population for a partition i.e. it 143 | 'prepares' the partition to be incorporated into the image. 144 | In this case, prepare content for legacy bios boot partition. 145 | """ 146 | bootimg_dir = cls._get_bootimg_dir(bootimg_dir, 'syslinux') 147 | 148 | staging_kernel_dir = kernel_dir 149 | 150 | hdddir = "%s/hdd/boot" % cr_workdir 151 | 152 | kernel = get_bitbake_var("KERNEL_IMAGETYPE") 153 | if get_bitbake_var("INITRAMFS_IMAGE_BUNDLE") == "1": 154 | if get_bitbake_var("INITRAMFS_IMAGE"): 155 | kernel = "%s-%s.bin" % \ 156 | (get_bitbake_var("KERNEL_IMAGETYPE"), get_bitbake_var("INITRAMFS_LINK_NAME")) 157 | 158 | cmds = ("install -m 0644 %s/%s %s/vmlinuz" % 159 | (staging_kernel_dir, kernel, hdddir), 160 | "install -m 444 %s/syslinux/ldlinux.sys %s/ldlinux.sys" % 161 | (bootimg_dir, hdddir), 162 | "install -m 0644 %s/syslinux/vesamenu.c32 %s/vesamenu.c32" % 163 | (bootimg_dir, hdddir), 164 | "install -m 444 %s/syslinux/libcom32.c32 %s/libcom32.c32" % 165 | (bootimg_dir, hdddir), 166 | "install -m 444 %s/syslinux/libutil.c32 %s/libutil.c32" % 167 | (bootimg_dir, hdddir)) 168 | 169 | for install_cmd in cmds: 170 | exec_cmd(install_cmd) 171 | 172 | du_cmd = "du -bks %s" % hdddir 173 | out = exec_cmd(du_cmd) 174 | blocks = int(out.split()[0]) 175 | 176 | extra_blocks = part.get_extra_block_count(blocks) 177 | 178 | if extra_blocks < BOOTDD_EXTRA_SPACE: 179 | extra_blocks = BOOTDD_EXTRA_SPACE 180 | 181 | blocks += extra_blocks 182 | 183 | logger.debug("Added %d extra blocks to %s to get to %d total blocks", 184 | extra_blocks, part.mountpoint, blocks) 185 | 186 | # dosfs image, created by mkdosfs 187 | bootimg = "%s/boot%s.img" % (cr_workdir, part.lineno) 188 | 189 | dosfs_cmd = "mkdosfs -n boot -i %s -S 512 -C %s %d" % \ 190 | (part.fsuuid, bootimg, blocks) 191 | exec_native_cmd(dosfs_cmd, native_sysroot) 192 | 193 | mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (bootimg, hdddir) 194 | exec_native_cmd(mcopy_cmd, native_sysroot) 195 | 196 | syslinux_cmd = "syslinux %s" % bootimg 197 | exec_native_cmd(syslinux_cmd, native_sysroot) 198 | 199 | chmod_cmd = "chmod 644 %s" % bootimg 200 | exec_cmd(chmod_cmd) 201 | 202 | du_cmd = "du -Lbks %s" % bootimg 203 | out = exec_cmd(du_cmd) 204 | bootimg_size = out.split()[0] 205 | 206 | part.size = int(bootimg_size) 207 | part.source_file = bootimg 208 | -------------------------------------------------------------------------------- /yocto/meta-klipper/scripts/lib/wic/misc.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2013, Intel Corporation. 3 | # 4 | # SPDX-License-Identifier: GPL-2.0-only 5 | # 6 | # DESCRIPTION 7 | # This module provides a place to collect various wic-related utils 8 | # for the OpenEmbedded Image Tools. 9 | # 10 | # AUTHORS 11 | # Tom Zanussi 12 | # 13 | """Miscellaneous functions.""" 14 | 15 | import logging 16 | import os 17 | import re 18 | import subprocess 19 | 20 | from collections import defaultdict 21 | from distutils import spawn 22 | 23 | from wic import WicError 24 | 25 | logger = logging.getLogger('wic') 26 | 27 | # executable -> recipe pairs for exec_native_cmd 28 | NATIVE_RECIPES = {"bmaptool": "bmap-tools", 29 | "grub-mkimage": "grub-efi", 30 | "isohybrid": "syslinux", 31 | "mcopy": "mtools", 32 | "mdel" : "mtools", 33 | "mdeltree" : "mtools", 34 | "mdir" : "mtools", 35 | "mkdosfs": "dosfstools", 36 | "mkisofs": "cdrtools", 37 | "mkfs.btrfs": "btrfs-tools", 38 | "mkfs.ext2": "e2fsprogs", 39 | "mkfs.ext3": "e2fsprogs", 40 | "mkfs.ext4": "e2fsprogs", 41 | "mkfs.vfat": "dosfstools", 42 | "mksquashfs": "squashfs-tools", 43 | "mkswap": "util-linux", 44 | "mmd": "mtools", 45 | "parted": "parted", 46 | "sfdisk": "util-linux", 47 | "sgdisk": "gptfdisk", 48 | "syslinux": "syslinux", 49 | "tar": "tar" 50 | } 51 | 52 | def runtool(cmdln_or_args): 53 | """ wrapper for most of the subprocess calls 54 | input: 55 | cmdln_or_args: can be both args and cmdln str (shell=True) 56 | return: 57 | rc, output 58 | """ 59 | if isinstance(cmdln_or_args, list): 60 | cmd = cmdln_or_args[0] 61 | shell = False 62 | else: 63 | import shlex 64 | cmd = shlex.split(cmdln_or_args)[0] 65 | shell = True 66 | 67 | sout = subprocess.PIPE 68 | serr = subprocess.STDOUT 69 | 70 | try: 71 | process = subprocess.Popen(cmdln_or_args, stdout=sout, 72 | stderr=serr, shell=shell) 73 | sout, serr = process.communicate() 74 | # combine stdout and stderr, filter None out and decode 75 | out = ''.join([out.decode('utf-8') for out in [sout, serr] if out]) 76 | except OSError as err: 77 | if err.errno == 2: 78 | # [Errno 2] No such file or directory 79 | raise WicError('Cannot run command: %s, lost dependency?' % cmd) 80 | else: 81 | raise # relay 82 | 83 | return process.returncode, out 84 | 85 | def _exec_cmd(cmd_and_args, as_shell=False): 86 | """ 87 | Execute command, catching stderr, stdout 88 | 89 | Need to execute as_shell if the command uses wildcards 90 | """ 91 | logger.debug("_exec_cmd: %s", cmd_and_args) 92 | args = cmd_and_args.split() 93 | logger.debug(args) 94 | 95 | if as_shell: 96 | ret, out = runtool(cmd_and_args) 97 | else: 98 | ret, out = runtool(args) 99 | out = out.strip() 100 | if ret != 0: 101 | raise WicError("_exec_cmd: %s returned '%s' instead of 0\noutput: %s" % \ 102 | (cmd_and_args, ret, out)) 103 | 104 | logger.debug("_exec_cmd: output for %s (rc = %d): %s", 105 | cmd_and_args, ret, out) 106 | 107 | return ret, out 108 | 109 | 110 | def exec_cmd(cmd_and_args, as_shell=False): 111 | """ 112 | Execute command, return output 113 | """ 114 | return _exec_cmd(cmd_and_args, as_shell)[1] 115 | 116 | def find_executable(cmd, paths): 117 | recipe = cmd 118 | if recipe in NATIVE_RECIPES: 119 | recipe = NATIVE_RECIPES[recipe] 120 | provided = get_bitbake_var("ASSUME_PROVIDED") 121 | if provided and "%s-native" % recipe in provided: 122 | return True 123 | 124 | return spawn.find_executable(cmd, paths) 125 | 126 | def exec_native_cmd(cmd_and_args, native_sysroot, pseudo=""): 127 | """ 128 | Execute native command, catching stderr, stdout 129 | 130 | Need to execute as_shell if the command uses wildcards 131 | 132 | Always need to execute native commands as_shell 133 | """ 134 | # The reason -1 is used is because there may be "export" commands. 135 | args = cmd_and_args.split(';')[-1].split() 136 | logger.debug(args) 137 | 138 | if pseudo: 139 | cmd_and_args = pseudo + cmd_and_args 140 | 141 | native_paths = "%s/sbin:%s/usr/sbin:%s/usr/bin:%s/bin" % \ 142 | (native_sysroot, native_sysroot, 143 | native_sysroot, native_sysroot) 144 | 145 | native_cmd_and_args = "export PATH=%s:$PATH;%s" % \ 146 | (native_paths, cmd_and_args) 147 | logger.debug("exec_native_cmd: %s", native_cmd_and_args) 148 | 149 | # If the command isn't in the native sysroot say we failed. 150 | if find_executable(args[0], native_paths): 151 | ret, out = _exec_cmd(native_cmd_and_args, True) 152 | else: 153 | ret = 127 154 | out = "can't find native executable %s in %s" % (args[0], native_paths) 155 | 156 | prog = args[0] 157 | # shell command-not-found 158 | if ret == 127 \ 159 | or (pseudo and ret == 1 and out == "Can't find '%s' in $PATH." % prog): 160 | msg = "A native program %s required to build the image "\ 161 | "was not found (see details above).\n\n" % prog 162 | recipe = NATIVE_RECIPES.get(prog) 163 | if recipe: 164 | msg += "Please make sure wic-tools have %s-native in its DEPENDS, "\ 165 | "build it with 'bitbake wic-tools' and try again.\n" % recipe 166 | else: 167 | msg += "Wic failed to find a recipe to build native %s. Please "\ 168 | "file a bug against wic.\n" % prog 169 | raise WicError(msg) 170 | 171 | return ret, out 172 | 173 | BOOTDD_EXTRA_SPACE = 16384 174 | 175 | class BitbakeVars(defaultdict): 176 | """ 177 | Container for Bitbake variables. 178 | """ 179 | def __init__(self): 180 | defaultdict.__init__(self, dict) 181 | 182 | # default_image and vars_dir attributes should be set from outside 183 | self.default_image = None 184 | self.vars_dir = None 185 | 186 | def _parse_line(self, line, image, matcher=re.compile(r"^([a-zA-Z0-9\-_+./~]+)=(.*)")): 187 | """ 188 | Parse one line from bitbake -e output or from .env file. 189 | Put result key-value pair into the storage. 190 | """ 191 | if "=" not in line: 192 | return 193 | match = matcher.match(line) 194 | if not match: 195 | return 196 | key, val = match.groups() 197 | self[image][key] = val.strip('"') 198 | 199 | def get_var(self, var, image=None, cache=True): 200 | """ 201 | Get bitbake variable from 'bitbake -e' output or from .env file. 202 | This is a lazy method, i.e. it runs bitbake or parses file only when 203 | only when variable is requested. It also caches results. 204 | """ 205 | if not image: 206 | image = self.default_image 207 | 208 | if image not in self: 209 | if image and self.vars_dir: 210 | fname = os.path.join(self.vars_dir, image + '.env') 211 | if os.path.isfile(fname): 212 | # parse .env file 213 | with open(fname) as varsfile: 214 | for line in varsfile: 215 | self._parse_line(line, image) 216 | else: 217 | print("Couldn't get bitbake variable from %s." % fname) 218 | print("File %s doesn't exist." % fname) 219 | return 220 | else: 221 | # Get bitbake -e output 222 | cmd = "bitbake -e" 223 | if image: 224 | cmd += " %s" % image 225 | 226 | log_level = logger.getEffectiveLevel() 227 | logger.setLevel(logging.INFO) 228 | ret, lines = _exec_cmd(cmd) 229 | logger.setLevel(log_level) 230 | 231 | if ret: 232 | logger.error("Couldn't get '%s' output.", cmd) 233 | logger.error("Bitbake failed with error:\n%s\n", lines) 234 | return 235 | 236 | # Parse bitbake -e output 237 | for line in lines.split('\n'): 238 | self._parse_line(line, image) 239 | 240 | # Make first image a default set of variables 241 | if cache: 242 | images = [key for key in self if key] 243 | if len(images) == 1: 244 | self[None] = self[image] 245 | 246 | result = self[image].get(var) 247 | if not cache: 248 | self.pop(image, None) 249 | 250 | return result 251 | 252 | # Create BB_VARS singleton 253 | BB_VARS = BitbakeVars() 254 | 255 | def get_bitbake_var(var, image=None, cache=True): 256 | """ 257 | Provide old get_bitbake_var API by wrapping 258 | get_var method of BB_VARS singleton. 259 | """ 260 | return BB_VARS.get_var(var, image, cache) 261 | -------------------------------------------------------------------------------- /yocto/meta-klipper/scripts/lib/wic/plugins/source/rootfs.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2014, Intel Corporation. 3 | # 4 | # SPDX-License-Identifier: GPL-2.0-only 5 | # 6 | # DESCRIPTION 7 | # This implements the 'rootfs' source plugin class for 'wic' 8 | # 9 | # AUTHORS 10 | # Tom Zanussi 11 | # Joao Henrique Ferreira de Freitas 12 | # 13 | 14 | import logging 15 | import os 16 | import shutil 17 | import sys 18 | 19 | from oe.path import copyhardlinktree 20 | from pathlib import Path 21 | 22 | from wic import WicError 23 | from wic.pluginbase import SourcePlugin 24 | from wic.misc import get_bitbake_var, exec_native_cmd 25 | 26 | logger = logging.getLogger('wic') 27 | 28 | class RootfsPlugin(SourcePlugin): 29 | """ 30 | Populate partition content from a rootfs directory. 31 | """ 32 | 33 | name = 'rootfs' 34 | 35 | @staticmethod 36 | def __validate_path(cmd, rootfs_dir, path): 37 | if os.path.isabs(path): 38 | logger.error("%s: Must be relative: %s" % (cmd, orig_path)) 39 | sys.exit(1) 40 | 41 | # Disallow climbing outside of parent directory using '..', 42 | # because doing so could be quite disastrous (we will delete the 43 | # directory, or modify a directory outside OpenEmbedded). 44 | full_path = os.path.realpath(os.path.join(rootfs_dir, path)) 45 | if not full_path.startswith(os.path.realpath(rootfs_dir)): 46 | logger.error("%s: Must point inside the rootfs:" % (cmd, path)) 47 | sys.exit(1) 48 | 49 | return full_path 50 | 51 | @staticmethod 52 | def __get_rootfs_dir(rootfs_dir): 53 | if os.path.isdir(rootfs_dir): 54 | return os.path.realpath(rootfs_dir) 55 | 56 | image_rootfs_dir = get_bitbake_var("IMAGE_ROOTFS", rootfs_dir) 57 | if not os.path.isdir(image_rootfs_dir): 58 | raise WicError("No valid artifact IMAGE_ROOTFS from image " 59 | "named %s has been found at %s, exiting." % 60 | (rootfs_dir, image_rootfs_dir)) 61 | 62 | return os.path.realpath(image_rootfs_dir) 63 | 64 | @staticmethod 65 | def __get_pseudo(native_sysroot, rootfs, pseudo_dir): 66 | pseudo = "export PSEUDO_PREFIX=%s/usr;" % native_sysroot 67 | pseudo += "export PSEUDO_LOCALSTATEDIR=%s;" % pseudo_dir 68 | pseudo += "export PSEUDO_PASSWD=%s;" % rootfs 69 | pseudo += "export PSEUDO_NOSYMLINKEXP=1;" 70 | pseudo += "%s " % get_bitbake_var("FAKEROOTCMD") 71 | return pseudo 72 | 73 | @classmethod 74 | def do_prepare_partition(cls, part, source_params, cr, cr_workdir, 75 | oe_builddir, bootimg_dir, kernel_dir, 76 | krootfs_dir, native_sysroot): 77 | """ 78 | Called to do the actual content population for a partition i.e. it 79 | 'prepares' the partition to be incorporated into the image. 80 | In this case, prepare content for legacy bios boot partition. 81 | """ 82 | if part.rootfs_dir is None: 83 | if not 'ROOTFS_DIR' in krootfs_dir: 84 | raise WicError("Couldn't find --rootfs-dir, exiting") 85 | 86 | rootfs_dir = krootfs_dir['ROOTFS_DIR'] 87 | else: 88 | if part.rootfs_dir in krootfs_dir: 89 | rootfs_dir = krootfs_dir[part.rootfs_dir] 90 | elif part.rootfs_dir: 91 | rootfs_dir = part.rootfs_dir 92 | else: 93 | raise WicError("Couldn't find --rootfs-dir=%s connection or " 94 | "it is not a valid path, exiting" % part.rootfs_dir) 95 | 96 | part.rootfs_dir = cls.__get_rootfs_dir(rootfs_dir) 97 | pseudo_dir = os.path.join(part.rootfs_dir, "../pseudo") 98 | if not os.path.lexists(pseudo_dir): 99 | logger.warn("%s folder does not exist. " 100 | "Usernames and permissions will be invalid " % pseudo_dir) 101 | pseudo_dir = None 102 | 103 | new_rootfs = None 104 | new_pseudo = None 105 | # Handle excluded paths. 106 | if part.exclude_path or part.include_path or part.change_directory: 107 | # We need a new rootfs directory we can delete files from. Copy to 108 | # workdir. 109 | new_rootfs = os.path.realpath(os.path.join(cr_workdir, "rootfs%d" % part.lineno)) 110 | 111 | if os.path.lexists(new_rootfs): 112 | shutil.rmtree(os.path.join(new_rootfs)) 113 | 114 | if part.change_directory: 115 | cd = part.change_directory 116 | if cd[-1] == '/': 117 | cd = cd[:-1] 118 | orig_dir = cls.__validate_path("--change-directory", part.rootfs_dir, cd) 119 | else: 120 | orig_dir = part.rootfs_dir 121 | copyhardlinktree(orig_dir, new_rootfs) 122 | 123 | # Convert the pseudo directory to its new location 124 | if (pseudo_dir): 125 | new_pseudo = os.path.realpath( 126 | os.path.join(cr_workdir, "pseudo%d" % part.lineno)) 127 | if os.path.lexists(new_pseudo): 128 | shutil.rmtree(new_pseudo) 129 | os.mkdir(new_pseudo) 130 | shutil.copy(os.path.join(pseudo_dir, "files.db"), 131 | os.path.join(new_pseudo, "files.db")) 132 | 133 | pseudo_cmd = "%s -B -m %s -M %s" % (cls.__get_pseudo(native_sysroot, 134 | new_rootfs, 135 | new_pseudo), 136 | orig_dir, new_rootfs) 137 | exec_native_cmd(pseudo_cmd, native_sysroot) 138 | 139 | for in_path in part.include_path or []: 140 | #parse arguments 141 | include_path = in_path[0] 142 | if len(in_path) > 2: 143 | logger.error("'Invalid number of arguments for include-path") 144 | sys.exit(1) 145 | if len(in_path) == 2: 146 | path = in_path[1] 147 | else: 148 | path = None 149 | 150 | # Pack files to be included into a tar file. 151 | # We need to create a tar file, because that way we can keep the 152 | # permissions from the files even when they belong to different 153 | # pseudo enviroments. 154 | # If we simply copy files using copyhardlinktree/copytree... the 155 | # copied files will belong to the user running wic. 156 | tar_file = os.path.realpath( 157 | os.path.join(cr_workdir, "include-path%d.tar" % part.lineno)) 158 | if os.path.isfile(include_path): 159 | parent = os.path.dirname(os.path.realpath(include_path)) 160 | tar_cmd = "tar c --owner=root --group=root -f %s -C %s %s" % ( 161 | tar_file, parent, os.path.relpath(include_path, parent)) 162 | exec_native_cmd(tar_cmd, native_sysroot) 163 | else: 164 | if include_path in krootfs_dir: 165 | include_path = krootfs_dir[include_path] 166 | include_path = cls.__get_rootfs_dir(include_path) 167 | include_pseudo = os.path.join(include_path, "../pseudo") 168 | if os.path.lexists(include_pseudo): 169 | pseudo = cls.__get_pseudo(native_sysroot, include_path, 170 | include_pseudo) 171 | tar_cmd = "tar cf %s -C %s ." % (tar_file, include_path) 172 | else: 173 | pseudo = None 174 | tar_cmd = "tar c --owner=root --group=root -f %s -C %s ." % ( 175 | tar_file, include_path) 176 | exec_native_cmd(tar_cmd, native_sysroot, pseudo) 177 | 178 | #create destination 179 | if path: 180 | destination = cls.__validate_path("--include-path", new_rootfs, path) 181 | Path(destination).mkdir(parents=True, exist_ok=True) 182 | else: 183 | destination = new_rootfs 184 | 185 | #extract destination 186 | untar_cmd = "tar xf %s -C %s" % (tar_file, destination) 187 | if new_pseudo: 188 | pseudo = cls.__get_pseudo(native_sysroot, new_rootfs, new_pseudo) 189 | else: 190 | pseudo = None 191 | exec_native_cmd(untar_cmd, native_sysroot, pseudo) 192 | os.remove(tar_file) 193 | 194 | for orig_path in part.exclude_path or []: 195 | path = orig_path 196 | 197 | full_path = cls.__validate_path("--exclude-path", new_rootfs, path) 198 | 199 | if not os.path.lexists(full_path): 200 | continue 201 | 202 | if path.endswith(os.sep): 203 | # Delete content only. 204 | for entry in os.listdir(full_path): 205 | full_entry = os.path.join(full_path, entry) 206 | if os.path.isdir(full_entry) and not os.path.islink(full_entry): 207 | shutil.rmtree(full_entry) 208 | else: 209 | os.remove(full_entry) 210 | else: 211 | # Delete whole directory. 212 | shutil.rmtree(full_path) 213 | 214 | part.prepare_rootfs(cr_workdir, oe_builddir, 215 | new_rootfs or part.rootfs_dir, native_sysroot, 216 | pseudo_dir = new_pseudo or pseudo_dir) 217 | -------------------------------------------------------------------------------- /yocto/meta-klipper/scripts/lib/wic/ksparser.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2016 Intel, Inc. 4 | # 5 | # SPDX-License-Identifier: GPL-2.0-only 6 | # 7 | # DESCRIPTION 8 | # This module provides parser for kickstart format 9 | # 10 | # AUTHORS 11 | # Ed Bartosh (at] linux.intel.com> 12 | 13 | """Kickstart parser module.""" 14 | 15 | import os 16 | import shlex 17 | import logging 18 | import re 19 | 20 | from argparse import ArgumentParser, ArgumentError, ArgumentTypeError 21 | 22 | from wic.engine import find_canned 23 | from wic.partition import Partition 24 | from wic.misc import get_bitbake_var 25 | 26 | logger = logging.getLogger('wic') 27 | 28 | __expand_var_regexp__ = re.compile(r"\${[^{}@\n\t :]+}") 29 | 30 | def expand_line(line): 31 | while True: 32 | m = __expand_var_regexp__.search(line) 33 | if not m: 34 | return line 35 | key = m.group()[2:-1] 36 | val = get_bitbake_var(key) 37 | if val is None: 38 | logger.warning("cannot expand variable %s" % key) 39 | return line 40 | line = line[:m.start()] + val + line[m.end():] 41 | 42 | class KickStartError(Exception): 43 | """Custom exception.""" 44 | pass 45 | 46 | class KickStartParser(ArgumentParser): 47 | """ 48 | This class overwrites error method to throw exception 49 | instead of producing usage message(default argparse behavior). 50 | """ 51 | def error(self, message): 52 | raise ArgumentError(None, message) 53 | 54 | def sizetype(default, size_in_bytes=False): 55 | def f(arg): 56 | """ 57 | Custom type for ArgumentParser 58 | Converts size string in [S|s|K|k|M|G] format into the integer value 59 | """ 60 | try: 61 | suffix = default 62 | size = int(arg) 63 | except ValueError: 64 | try: 65 | suffix = arg[-1:] 66 | size = int(arg[:-1]) 67 | except ValueError: 68 | raise ArgumentTypeError("Invalid size: %r" % arg) 69 | 70 | 71 | if size_in_bytes: 72 | if suffix == 's' or suffix == 'S': 73 | return size * 512 74 | mult = 1024 75 | else: 76 | mult = 1 77 | 78 | if suffix == "k" or suffix == "K": 79 | return size * mult 80 | if suffix == "M": 81 | return size * mult * 1024 82 | if suffix == "G": 83 | return size * mult * 1024 * 1024 84 | 85 | raise ArgumentTypeError("Invalid size: %r" % arg) 86 | return f 87 | 88 | def overheadtype(arg): 89 | """ 90 | Custom type for ArgumentParser 91 | Converts overhead string to float and checks if it's bigger than 1.0 92 | """ 93 | try: 94 | result = float(arg) 95 | except ValueError: 96 | raise ArgumentTypeError("Invalid value: %r" % arg) 97 | 98 | if result < 1.0: 99 | raise ArgumentTypeError("Overhead factor should be > 1.0" % arg) 100 | 101 | return result 102 | 103 | def cannedpathtype(arg): 104 | """ 105 | Custom type for ArgumentParser 106 | Tries to find file in the list of canned wks paths 107 | """ 108 | scripts_path = os.path.abspath(os.path.dirname(__file__) + '../../..') 109 | result = find_canned(scripts_path, arg) 110 | if not result: 111 | raise ArgumentTypeError("file not found: %s" % arg) 112 | return result 113 | 114 | def systemidtype(arg): 115 | """ 116 | Custom type for ArgumentParser 117 | Checks if the argument sutisfies system id requirements, 118 | i.e. if it's one byte long integer > 0 119 | """ 120 | error = "Invalid system type: %s. must be hex "\ 121 | "between 0x1 and 0xFF" % arg 122 | try: 123 | result = int(arg, 16) 124 | except ValueError: 125 | raise ArgumentTypeError(error) 126 | 127 | if result <= 0 or result > 0xff: 128 | raise ArgumentTypeError(error) 129 | 130 | return arg 131 | 132 | class KickStart(): 133 | """Kickstart parser implementation.""" 134 | 135 | DEFAULT_EXTRA_SPACE = 10*1024 136 | DEFAULT_OVERHEAD_FACTOR = 1.3 137 | 138 | def __init__(self, confpath): 139 | 140 | self.partitions = [] 141 | self.bootloader = None 142 | self.lineno = 0 143 | self.partnum = 0 144 | 145 | parser = KickStartParser() 146 | subparsers = parser.add_subparsers() 147 | 148 | part = subparsers.add_parser('part') 149 | part.add_argument('mountpoint', nargs='?') 150 | part.add_argument('--active', action='store_true') 151 | part.add_argument('--align', type=int) 152 | part.add_argument('--offset', type=sizetype("K", True)) 153 | part.add_argument('--exclude-path', nargs='+') 154 | part.add_argument('--include-path', nargs='+', action='append') 155 | part.add_argument('--change-directory') 156 | part.add_argument("--extra-space", type=sizetype("M")) 157 | part.add_argument('--fsoptions', dest='fsopts') 158 | part.add_argument('--fstype', default='vfat', 159 | choices=('ext2', 'ext3', 'ext4', 'btrfs', 160 | 'squashfs', 'vfat', 'msdos', 'swap')) 161 | part.add_argument('--mkfs-extraopts', default='') 162 | part.add_argument('--label') 163 | part.add_argument('--use-label', action='store_true') 164 | part.add_argument('--no-table', action='store_true') 165 | part.add_argument('--ondisk', '--ondrive', dest='disk', default='sda') 166 | part.add_argument("--overhead-factor", type=overheadtype) 167 | part.add_argument('--part-name') 168 | part.add_argument('--part-type') 169 | part.add_argument('--rootfs-dir') 170 | part.add_argument('--type', default='primary', 171 | choices = ('primary', 'logical')) 172 | 173 | # --size and --fixed-size cannot be specified together; options 174 | # ----extra-space and --overhead-factor should also raise a parser 175 | # --error, but since nesting mutually exclusive groups does not work, 176 | # ----extra-space/--overhead-factor are handled later 177 | sizeexcl = part.add_mutually_exclusive_group() 178 | sizeexcl.add_argument('--size', type=sizetype("M"), default=0) 179 | sizeexcl.add_argument('--fixed-size', type=sizetype("M"), default=0) 180 | 181 | part.add_argument('--source') 182 | part.add_argument('--sourceparams') 183 | part.add_argument('--system-id', type=systemidtype) 184 | part.add_argument('--use-uuid', action='store_true') 185 | part.add_argument('--uuid') 186 | part.add_argument('--fsuuid') 187 | 188 | bootloader = subparsers.add_parser('bootloader') 189 | bootloader.add_argument('--append') 190 | bootloader.add_argument('--configfile') 191 | bootloader.add_argument('--ptable', choices=('msdos', 'gpt'), 192 | default='msdos') 193 | bootloader.add_argument('--timeout', type=int) 194 | bootloader.add_argument('--source') 195 | 196 | include = subparsers.add_parser('include') 197 | include.add_argument('path', type=cannedpathtype) 198 | 199 | self._parse(parser, confpath) 200 | if not self.bootloader: 201 | logger.warning('bootloader config not specified, using defaults\n') 202 | self.bootloader = bootloader.parse_args([]) 203 | 204 | def _parse(self, parser, confpath): 205 | """ 206 | Parse file in .wks format using provided parser. 207 | """ 208 | with open(confpath) as conf: 209 | lineno = 0 210 | for line in conf: 211 | line = line.strip() 212 | lineno += 1 213 | if line and line[0] != '#': 214 | line = expand_line(line) 215 | try: 216 | line_args = shlex.split(line) 217 | parsed = parser.parse_args(line_args) 218 | except ArgumentError as err: 219 | raise KickStartError('%s:%d: %s' % \ 220 | (confpath, lineno, err)) 221 | if line.startswith('part'): 222 | # SquashFS does not support filesystem UUID 223 | if parsed.fstype == 'squashfs': 224 | if parsed.fsuuid: 225 | err = "%s:%d: SquashFS does not support UUID" \ 226 | % (confpath, lineno) 227 | raise KickStartError(err) 228 | if parsed.label: 229 | err = "%s:%d: SquashFS does not support LABEL" \ 230 | % (confpath, lineno) 231 | raise KickStartError(err) 232 | if parsed.use_label and not parsed.label: 233 | err = "%s:%d: Must set the label with --label" \ 234 | % (confpath, lineno) 235 | raise KickStartError(err) 236 | # using ArgumentParser one cannot easily tell if option 237 | # was passed as argument, if said option has a default 238 | # value; --overhead-factor/--extra-space cannot be used 239 | # with --fixed-size, so at least detect when these were 240 | # passed with non-0 values ... 241 | if parsed.fixed_size: 242 | if parsed.overhead_factor or parsed.extra_space: 243 | err = "%s:%d: arguments --overhead-factor and --extra-space not "\ 244 | "allowed with argument --fixed-size" \ 245 | % (confpath, lineno) 246 | raise KickStartError(err) 247 | else: 248 | # ... and provide defaults if not using 249 | # --fixed-size iff given option was not used 250 | # (again, one cannot tell if option was passed but 251 | # with value equal to 0) 252 | if '--overhead-factor' not in line_args: 253 | parsed.overhead_factor = self.DEFAULT_OVERHEAD_FACTOR 254 | if '--extra-space' not in line_args: 255 | parsed.extra_space = self.DEFAULT_EXTRA_SPACE 256 | 257 | self.partnum += 1 258 | self.partitions.append(Partition(parsed, self.partnum)) 259 | elif line.startswith('include'): 260 | self._parse(parser, parsed.path) 261 | elif line.startswith('bootloader'): 262 | if not self.bootloader: 263 | self.bootloader = parsed 264 | # Concatenate the strings set in APPEND 265 | append_var = get_bitbake_var("APPEND") 266 | if append_var: 267 | self.bootloader.append = ' '.join(filter(None, \ 268 | (self.bootloader.append, append_var))) 269 | else: 270 | err = "%s:%d: more than one bootloader specified" \ 271 | % (confpath, lineno) 272 | raise KickStartError(err) 273 | -------------------------------------------------------------------------------- /yocto/meta-klipper/scripts/lib/wic/plugins/source/bootimg-efi.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2014, Intel Corporation. 3 | # 4 | # SPDX-License-Identifier: GPL-2.0-only 5 | # 6 | # DESCRIPTION 7 | # This implements the 'bootimg-efi' source plugin class for 'wic' 8 | # 9 | # AUTHORS 10 | # Tom Zanussi 11 | # 12 | 13 | import logging 14 | import os 15 | import shutil 16 | import re 17 | 18 | from glob import glob 19 | 20 | from wic import WicError 21 | from wic.engine import get_custom_config 22 | from wic.pluginbase import SourcePlugin 23 | from wic.misc import (exec_cmd, exec_native_cmd, 24 | get_bitbake_var, BOOTDD_EXTRA_SPACE) 25 | 26 | logger = logging.getLogger('wic') 27 | 28 | class BootimgEFIPlugin(SourcePlugin): 29 | """ 30 | Create EFI boot partition. 31 | This plugin supports GRUB 2 and systemd-boot bootloaders. 32 | """ 33 | 34 | name = 'bootimg-efi' 35 | 36 | @classmethod 37 | def do_configure_grubefi(cls, hdddir, creator, cr_workdir, source_params): 38 | """ 39 | Create loader-specific (grub-efi) config 40 | """ 41 | configfile = creator.ks.bootloader.configfile 42 | custom_cfg = None 43 | if configfile: 44 | custom_cfg = get_custom_config(configfile) 45 | if custom_cfg: 46 | # Use a custom configuration for grub 47 | grubefi_conf = custom_cfg 48 | logger.debug("Using custom configuration file " 49 | "%s for grub.cfg", configfile) 50 | else: 51 | raise WicError("configfile is specified but failed to " 52 | "get it from %s." % configfile) 53 | 54 | initrd = source_params.get('initrd') 55 | 56 | if initrd: 57 | bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") 58 | if not bootimg_dir: 59 | raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting") 60 | 61 | initrds = initrd.split(';') 62 | for rd in initrds: 63 | cp_cmd = "cp %s/%s %s" % (bootimg_dir, rd, hdddir) 64 | exec_cmd(cp_cmd, True) 65 | else: 66 | logger.debug("Ignoring missing initrd") 67 | 68 | if not custom_cfg: 69 | # Create grub configuration using parameters from wks file 70 | bootloader = creator.ks.bootloader 71 | title = source_params.get('title') 72 | 73 | grubefi_conf = "" 74 | grubefi_conf += "serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1\n" 75 | grubefi_conf += "default=boot\n" 76 | grubefi_conf += "timeout=%s\n" % bootloader.timeout 77 | grubefi_conf += "menuentry '%s'{\n" % (title if title else "boot") 78 | 79 | kernel = get_bitbake_var("KERNEL_IMAGETYPE") 80 | if get_bitbake_var("INITRAMFS_IMAGE_BUNDLE") == "1": 81 | if get_bitbake_var("INITRAMFS_IMAGE"): 82 | kernel = "%s-%s.bin" % \ 83 | (get_bitbake_var("KERNEL_IMAGETYPE"), get_bitbake_var("INITRAMFS_LINK_NAME")) 84 | 85 | label = source_params.get('label') 86 | label_conf = "root=%s" % creator.rootdev 87 | if label: 88 | label_conf = "LABEL=%s" % label 89 | 90 | grubefi_conf += "linux /%s %s rootwait %s\n" \ 91 | % (kernel, label_conf, bootloader.append) 92 | 93 | if initrd: 94 | initrds = initrd.split(';') 95 | grubefi_conf += "initrd" 96 | for rd in initrds: 97 | grubefi_conf += " /%s" % rd 98 | grubefi_conf += "\n" 99 | 100 | grubefi_conf += "}\n" 101 | 102 | logger.debug("Writing grubefi config %s/hdd/boot/EFI/BOOT/grub.cfg", 103 | cr_workdir) 104 | cfg = open("%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir, "w") 105 | cfg.write(grubefi_conf) 106 | cfg.close() 107 | 108 | @classmethod 109 | def do_configure_systemdboot(cls, hdddir, creator, cr_workdir, source_params): 110 | """ 111 | Create loader-specific systemd-boot/gummiboot config 112 | """ 113 | install_cmd = "install -d %s/loader" % hdddir 114 | exec_cmd(install_cmd) 115 | 116 | install_cmd = "install -d %s/loader/entries" % hdddir 117 | exec_cmd(install_cmd) 118 | 119 | bootloader = creator.ks.bootloader 120 | 121 | loader_conf = "" 122 | loader_conf += "default boot\n" 123 | loader_conf += "timeout %d\n" % bootloader.timeout 124 | 125 | initrd = source_params.get('initrd') 126 | 127 | if initrd: 128 | # obviously we need to have a common common deploy var 129 | bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") 130 | if not bootimg_dir: 131 | raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting") 132 | 133 | initrds = initrd.split(';') 134 | for rd in initrds: 135 | cp_cmd = "cp %s/%s %s" % (bootimg_dir, rd, hdddir) 136 | exec_cmd(cp_cmd, True) 137 | else: 138 | logger.debug("Ignoring missing initrd") 139 | 140 | logger.debug("Writing systemd-boot config " 141 | "%s/hdd/boot/loader/loader.conf", cr_workdir) 142 | cfg = open("%s/hdd/boot/loader/loader.conf" % cr_workdir, "w") 143 | cfg.write(loader_conf) 144 | cfg.close() 145 | 146 | configfile = creator.ks.bootloader.configfile 147 | custom_cfg = None 148 | if configfile: 149 | custom_cfg = get_custom_config(configfile) 150 | if custom_cfg: 151 | # Use a custom configuration for systemd-boot 152 | boot_conf = custom_cfg 153 | logger.debug("Using custom configuration file " 154 | "%s for systemd-boots's boot.conf", configfile) 155 | else: 156 | raise WicError("configfile is specified but failed to " 157 | "get it from %s.", configfile) 158 | 159 | if not custom_cfg: 160 | # Create systemd-boot configuration using parameters from wks file 161 | kernel = get_bitbake_var("KERNEL_IMAGETYPE") 162 | if get_bitbake_var("INITRAMFS_IMAGE_BUNDLE") == "1": 163 | if get_bitbake_var("INITRAMFS_IMAGE"): 164 | kernel = "%s-%s.bin" % \ 165 | (get_bitbake_var("KERNEL_IMAGETYPE"), get_bitbake_var("INITRAMFS_LINK_NAME")) 166 | 167 | title = source_params.get('title') 168 | 169 | boot_conf = "" 170 | boot_conf += "title %s\n" % (title if title else "boot") 171 | boot_conf += "linux /%s\n" % kernel 172 | 173 | label = source_params.get('label') 174 | label_conf = "LABEL=Boot root=%s" % creator.rootdev 175 | if label: 176 | label_conf = "LABEL=%s" % label 177 | 178 | boot_conf += "options %s %s\n" % \ 179 | (label_conf, bootloader.append) 180 | 181 | if initrd: 182 | initrds = initrd.split(';') 183 | for rd in initrds: 184 | boot_conf += "initrd /%s\n" % rd 185 | 186 | logger.debug("Writing systemd-boot config " 187 | "%s/hdd/boot/loader/entries/boot.conf", cr_workdir) 188 | cfg = open("%s/hdd/boot/loader/entries/boot.conf" % cr_workdir, "w") 189 | cfg.write(boot_conf) 190 | cfg.close() 191 | 192 | 193 | @classmethod 194 | def do_configure_partition(cls, part, source_params, creator, cr_workdir, 195 | oe_builddir, bootimg_dir, kernel_dir, 196 | native_sysroot): 197 | """ 198 | Called before do_prepare_partition(), creates loader-specific config 199 | """ 200 | hdddir = "%s/hdd/boot" % cr_workdir 201 | 202 | install_cmd = "install -d %s/EFI/BOOT" % hdddir 203 | exec_cmd(install_cmd) 204 | 205 | try: 206 | if source_params['loader'] == 'grub-efi': 207 | cls.do_configure_grubefi(hdddir, creator, cr_workdir, source_params) 208 | elif source_params['loader'] == 'systemd-boot': 209 | cls.do_configure_systemdboot(hdddir, creator, cr_workdir, source_params) 210 | else: 211 | raise WicError("unrecognized bootimg-efi loader: %s" % source_params['loader']) 212 | except KeyError: 213 | raise WicError("bootimg-efi requires a loader, none specified") 214 | 215 | if get_bitbake_var("IMAGE_BOOT_FILES") is None: 216 | logger.debug('No boot files defined in IMAGE_BOOT_FILES') 217 | else: 218 | boot_files = None 219 | for (fmt, id) in (("_uuid-%s", part.uuid), ("_label-%s", part.label), (None, None)): 220 | if fmt: 221 | var = fmt % id 222 | else: 223 | var = "" 224 | 225 | boot_files = get_bitbake_var("IMAGE_BOOT_FILES" + var) 226 | if boot_files: 227 | break 228 | 229 | logger.debug('Boot files: %s', boot_files) 230 | 231 | # list of tuples (src_name, dst_name) 232 | deploy_files = [] 233 | for src_entry in re.findall(r'[\w;\-\./\*]+', boot_files): 234 | if ';' in src_entry: 235 | dst_entry = tuple(src_entry.split(';')) 236 | if not dst_entry[0] or not dst_entry[1]: 237 | raise WicError('Malformed boot file entry: %s' % src_entry) 238 | else: 239 | dst_entry = (src_entry, src_entry) 240 | 241 | logger.debug('Destination entry: %r', dst_entry) 242 | deploy_files.append(dst_entry) 243 | 244 | cls.install_task = []; 245 | for deploy_entry in deploy_files: 246 | src, dst = deploy_entry 247 | if '*' in src: 248 | # by default install files under their basename 249 | entry_name_fn = os.path.basename 250 | if dst != src: 251 | # unless a target name was given, then treat name 252 | # as a directory and append a basename 253 | entry_name_fn = lambda name: \ 254 | os.path.join(dst, 255 | os.path.basename(name)) 256 | 257 | srcs = glob(os.path.join(kernel_dir, src)) 258 | 259 | logger.debug('Globbed sources: %s', ', '.join(srcs)) 260 | for entry in srcs: 261 | src = os.path.relpath(entry, kernel_dir) 262 | entry_dst_name = entry_name_fn(entry) 263 | cls.install_task.append((src, entry_dst_name)) 264 | else: 265 | cls.install_task.append((src, dst)) 266 | 267 | @classmethod 268 | def do_prepare_partition(cls, part, source_params, creator, cr_workdir, 269 | oe_builddir, bootimg_dir, kernel_dir, 270 | rootfs_dir, native_sysroot): 271 | """ 272 | Called to do the actual content population for a partition i.e. it 273 | 'prepares' the partition to be incorporated into the image. 274 | In this case, prepare content for an EFI (grub) boot partition. 275 | """ 276 | if not kernel_dir: 277 | kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") 278 | if not kernel_dir: 279 | raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting") 280 | 281 | staging_kernel_dir = kernel_dir 282 | 283 | hdddir = "%s/hdd/boot" % cr_workdir 284 | 285 | kernel = get_bitbake_var("KERNEL_IMAGETYPE") 286 | if get_bitbake_var("INITRAMFS_IMAGE_BUNDLE") == "1": 287 | if get_bitbake_var("INITRAMFS_IMAGE"): 288 | kernel = "%s-%s.bin" % \ 289 | (get_bitbake_var("KERNEL_IMAGETYPE"), get_bitbake_var("INITRAMFS_LINK_NAME")) 290 | 291 | install_cmd = "install -m 0644 %s/%s %s/%s" % \ 292 | (staging_kernel_dir, kernel, hdddir, kernel) 293 | exec_cmd(install_cmd) 294 | 295 | if get_bitbake_var("IMAGE_BOOT_FILES"): 296 | for src_path, dst_path in cls.install_task: 297 | install_cmd = "install -m 0644 -D %s %s" \ 298 | % (os.path.join(kernel_dir, src_path), 299 | os.path.join(hdddir, dst_path)) 300 | exec_cmd(install_cmd) 301 | 302 | try: 303 | if source_params['loader'] == 'grub-efi': 304 | shutil.copyfile("%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir, 305 | "%s/grub.cfg" % cr_workdir) 306 | for mod in [x for x in os.listdir(kernel_dir) if x.startswith("grub-efi-")]: 307 | cp_cmd = "cp %s/%s %s/EFI/BOOT/%s" % (kernel_dir, mod, hdddir, mod[9:]) 308 | exec_cmd(cp_cmd, True) 309 | shutil.move("%s/grub.cfg" % cr_workdir, 310 | "%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir) 311 | elif source_params['loader'] == 'systemd-boot': 312 | for mod in [x for x in os.listdir(kernel_dir) if x.startswith("systemd-")]: 313 | cp_cmd = "cp %s/%s %s/EFI/BOOT/%s" % (kernel_dir, mod, hdddir, mod[8:]) 314 | exec_cmd(cp_cmd, True) 315 | else: 316 | raise WicError("unrecognized bootimg-efi loader: %s" % 317 | source_params['loader']) 318 | except KeyError: 319 | raise WicError("bootimg-efi requires a loader, none specified") 320 | 321 | startup = os.path.join(kernel_dir, "startup.nsh") 322 | if os.path.exists(startup): 323 | cp_cmd = "cp %s %s/" % (startup, hdddir) 324 | exec_cmd(cp_cmd, True) 325 | 326 | du_cmd = "du -bks %s" % hdddir 327 | out = exec_cmd(du_cmd) 328 | blocks = int(out.split()[0]) 329 | 330 | extra_blocks = part.get_extra_block_count(blocks) 331 | 332 | if extra_blocks < BOOTDD_EXTRA_SPACE: 333 | extra_blocks = BOOTDD_EXTRA_SPACE 334 | 335 | blocks += extra_blocks 336 | 337 | logger.debug("Added %d extra blocks to %s to get to %d total blocks", 338 | extra_blocks, part.mountpoint, blocks) 339 | 340 | # dosfs image, created by mkdosfs 341 | bootimg = "%s/boot.img" % cr_workdir 342 | 343 | label = part.label if part.label else "ESP" 344 | 345 | dosfs_cmd = "mkdosfs -n %s -i %s -C %s %d" % \ 346 | (label, part.fsuuid, bootimg, blocks) 347 | exec_native_cmd(dosfs_cmd, native_sysroot) 348 | 349 | mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (bootimg, hdddir) 350 | exec_native_cmd(mcopy_cmd, native_sysroot) 351 | 352 | chmod_cmd = "chmod 644 %s" % bootimg 353 | exec_cmd(chmod_cmd) 354 | 355 | du_cmd = "du -Lbks %s" % bootimg 356 | out = exec_cmd(du_cmd) 357 | bootimg_size = out.split()[0] 358 | 359 | part.size = int(bootimg_size) 360 | part.source_file = bootimg 361 | -------------------------------------------------------------------------------- /yocto/meta-klipper/scripts/lib/wic/partition.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2013-2016 Intel Corporation. 3 | # 4 | # SPDX-License-Identifier: GPL-2.0-only 5 | # 6 | # DESCRIPTION 7 | # This module provides the OpenEmbedded partition object definitions. 8 | # 9 | # AUTHORS 10 | # Tom Zanussi 11 | # Ed Bartosh (at] linux.intel.com> 12 | 13 | import logging 14 | import os 15 | import uuid 16 | 17 | from wic import WicError 18 | from wic.misc import exec_cmd, exec_native_cmd, get_bitbake_var 19 | from wic.pluginbase import PluginMgr 20 | 21 | logger = logging.getLogger('wic') 22 | 23 | class Partition(): 24 | 25 | def __init__(self, args, lineno): 26 | self.args = args 27 | self.active = args.active 28 | self.align = args.align 29 | self.disk = args.disk 30 | self.device = None 31 | self.extra_space = args.extra_space 32 | self.exclude_path = args.exclude_path 33 | self.include_path = args.include_path 34 | self.change_directory = args.change_directory 35 | self.fsopts = args.fsopts 36 | self.fstype = args.fstype 37 | self.label = args.label 38 | self.use_label = args.use_label 39 | self.mkfs_extraopts = args.mkfs_extraopts 40 | self.mountpoint = args.mountpoint 41 | self.no_table = args.no_table 42 | self.num = None 43 | self.offset = args.offset 44 | self.overhead_factor = args.overhead_factor 45 | self.part_name = args.part_name 46 | self.part_type = args.part_type 47 | self.rootfs_dir = args.rootfs_dir 48 | self.size = args.size 49 | self.fixed_size = args.fixed_size 50 | self.source = args.source 51 | self.sourceparams = args.sourceparams 52 | self.system_id = args.system_id 53 | self.use_uuid = args.use_uuid 54 | self.uuid = args.uuid 55 | self.fsuuid = args.fsuuid 56 | self.type = args.type 57 | 58 | self.lineno = lineno 59 | self.source_file = "" 60 | 61 | def get_extra_block_count(self, current_blocks): 62 | """ 63 | The --size param is reflected in self.size (in kB), and we already 64 | have current_blocks (1k) blocks, calculate and return the 65 | number of (1k) blocks we need to add to get to --size, 0 if 66 | we're already there or beyond. 67 | """ 68 | logger.debug("Requested partition size for %s: %d", 69 | self.mountpoint, self.size) 70 | 71 | if not self.size: 72 | return 0 73 | 74 | requested_blocks = self.size 75 | 76 | logger.debug("Requested blocks %d, current_blocks %d", 77 | requested_blocks, current_blocks) 78 | 79 | if requested_blocks > current_blocks: 80 | return requested_blocks - current_blocks 81 | else: 82 | return 0 83 | 84 | def get_rootfs_size(self, actual_rootfs_size=0): 85 | """ 86 | Calculate the required size of rootfs taking into consideration 87 | --size/--fixed-size flags as well as overhead and extra space, as 88 | specified in kickstart file. Raises an error if the 89 | `actual_rootfs_size` is larger than fixed-size rootfs. 90 | 91 | """ 92 | if self.fixed_size: 93 | rootfs_size = self.fixed_size 94 | if actual_rootfs_size > rootfs_size: 95 | raise WicError("Actual rootfs size (%d kB) is larger than " 96 | "allowed size %d kB" % 97 | (actual_rootfs_size, rootfs_size)) 98 | else: 99 | extra_blocks = self.get_extra_block_count(actual_rootfs_size) 100 | if extra_blocks < self.extra_space: 101 | extra_blocks = self.extra_space 102 | 103 | rootfs_size = actual_rootfs_size + extra_blocks 104 | rootfs_size *= self.overhead_factor 105 | 106 | logger.debug("Added %d extra blocks to %s to get to %d total blocks", 107 | extra_blocks, self.mountpoint, rootfs_size) 108 | 109 | return rootfs_size 110 | 111 | @property 112 | def disk_size(self): 113 | """ 114 | Obtain on-disk size of partition taking into consideration 115 | --size/--fixed-size options. 116 | 117 | """ 118 | return self.fixed_size if self.fixed_size else self.size 119 | 120 | def prepare(self, creator, cr_workdir, oe_builddir, rootfs_dir, 121 | bootimg_dir, kernel_dir, native_sysroot): 122 | """ 123 | Prepare content for individual partitions, depending on 124 | partition command parameters. 125 | """ 126 | if not self.source: 127 | if not self.size and not self.fixed_size: 128 | raise WicError("The %s partition has a size of zero. Please " 129 | "specify a non-zero --size/--fixed-size for that " 130 | "partition." % self.mountpoint) 131 | 132 | if self.fstype == "swap": 133 | self.prepare_swap_partition(cr_workdir, oe_builddir, 134 | native_sysroot) 135 | self.source_file = "%s/fs.%s" % (cr_workdir, self.fstype) 136 | else: 137 | if self.fstype == 'squashfs': 138 | raise WicError("It's not possible to create empty squashfs " 139 | "partition '%s'" % (self.mountpoint)) 140 | 141 | rootfs = "%s/fs_%s.%s.%s" % (cr_workdir, self.label, 142 | self.lineno, self.fstype) 143 | if os.path.isfile(rootfs): 144 | os.remove(rootfs) 145 | 146 | prefix = "ext" if self.fstype.startswith("ext") else self.fstype 147 | method = getattr(self, "prepare_empty_partition_" + prefix) 148 | method(rootfs, oe_builddir, native_sysroot) 149 | self.source_file = rootfs 150 | return 151 | 152 | plugins = PluginMgr.get_plugins('source') 153 | 154 | if self.source not in plugins: 155 | raise WicError("The '%s' --source specified for %s doesn't exist.\n\t" 156 | "See 'wic list source-plugins' for a list of available" 157 | " --sources.\n\tSee 'wic help source-plugins' for " 158 | "details on adding a new source plugin." % 159 | (self.source, self.mountpoint)) 160 | 161 | srcparams_dict = {} 162 | if self.sourceparams: 163 | # Split sourceparams string of the form key1=val1[,key2=val2,...] 164 | # into a dict. Also accepts valueless keys i.e. without = 165 | splitted = self.sourceparams.split(',') 166 | srcparams_dict = dict(par.split('=', 1) for par in splitted if par) 167 | 168 | plugin = PluginMgr.get_plugins('source')[self.source] 169 | plugin.do_configure_partition(self, srcparams_dict, creator, 170 | cr_workdir, oe_builddir, bootimg_dir, 171 | kernel_dir, native_sysroot) 172 | plugin.do_stage_partition(self, srcparams_dict, creator, 173 | cr_workdir, oe_builddir, bootimg_dir, 174 | kernel_dir, native_sysroot) 175 | plugin.do_prepare_partition(self, srcparams_dict, creator, 176 | cr_workdir, oe_builddir, bootimg_dir, 177 | kernel_dir, rootfs_dir, native_sysroot) 178 | plugin.do_post_partition(self, srcparams_dict, creator, 179 | cr_workdir, oe_builddir, bootimg_dir, 180 | kernel_dir, rootfs_dir, native_sysroot) 181 | 182 | # further processing required Partition.size to be an integer, make 183 | # sure that it is one 184 | if not isinstance(self.size, int): 185 | raise WicError("Partition %s internal size is not an integer. " 186 | "This a bug in source plugin %s and needs to be fixed." % 187 | (self.mountpoint, self.source)) 188 | 189 | if self.fixed_size and self.size > self.fixed_size: 190 | raise WicError("File system image of partition %s is " 191 | "larger (%d kB) than its allowed size %d kB" % 192 | (self.mountpoint, self.size, self.fixed_size)) 193 | 194 | def prepare_rootfs(self, cr_workdir, oe_builddir, rootfs_dir, 195 | native_sysroot, real_rootfs = True, pseudo_dir = None): 196 | """ 197 | Prepare content for a rootfs partition i.e. create a partition 198 | and fill it from a /rootfs dir. 199 | 200 | Currently handles ext2/3/4, btrfs, vfat and squashfs. 201 | """ 202 | p_prefix = os.environ.get("PSEUDO_PREFIX", "%s/usr" % native_sysroot) 203 | if (pseudo_dir): 204 | pseudo = "export PSEUDO_PREFIX=%s;" % p_prefix 205 | pseudo += "export PSEUDO_LOCALSTATEDIR=%s;" % pseudo_dir 206 | pseudo += "export PSEUDO_PASSWD=%s;" % rootfs_dir 207 | pseudo += "export PSEUDO_NOSYMLINKEXP=1;" 208 | pseudo += "%s " % get_bitbake_var("FAKEROOTCMD") 209 | else: 210 | pseudo = None 211 | 212 | rootfs = "%s/rootfs_%s.%s.%s" % (cr_workdir, self.label, 213 | self.lineno, self.fstype) 214 | if os.path.isfile(rootfs): 215 | os.remove(rootfs) 216 | 217 | if not self.size and real_rootfs: 218 | # The rootfs size is not set in .ks file so try to get it 219 | # from bitbake variable 220 | rsize_bb = get_bitbake_var('ROOTFS_SIZE') 221 | rdir = get_bitbake_var('IMAGE_ROOTFS') 222 | if rsize_bb and rdir == rootfs_dir: 223 | # Bitbake variable ROOTFS_SIZE is calculated in 224 | # Image._get_rootfs_size method from meta/lib/oe/image.py 225 | # using IMAGE_ROOTFS_SIZE, IMAGE_ROOTFS_ALIGNMENT, 226 | # IMAGE_OVERHEAD_FACTOR and IMAGE_ROOTFS_EXTRA_SPACE 227 | self.size = int(round(float(rsize_bb))) 228 | else: 229 | # Bitbake variable ROOTFS_SIZE is not defined so compute it 230 | # from the rootfs_dir size using the same logic found in 231 | # get_rootfs_size() from meta/classes/image.bbclass 232 | du_cmd = "du -ks %s" % rootfs_dir 233 | out = exec_cmd(du_cmd) 234 | self.size = int(out.split()[0]) 235 | 236 | prefix = "ext" if self.fstype.startswith("ext") else self.fstype 237 | method = getattr(self, "prepare_rootfs_" + prefix) 238 | method(rootfs, oe_builddir, rootfs_dir, native_sysroot, pseudo) 239 | self.source_file = rootfs 240 | 241 | # get the rootfs size in the right units for kickstart (kB) 242 | du_cmd = "du -Lbks %s" % rootfs 243 | out = exec_cmd(du_cmd) 244 | self.size = int(out.split()[0]) 245 | 246 | def prepare_rootfs_ext(self, rootfs, oe_builddir, rootfs_dir, 247 | native_sysroot, pseudo): 248 | """ 249 | Prepare content for an ext2/3/4 rootfs partition. 250 | """ 251 | du_cmd = "du -ks %s" % rootfs_dir 252 | out = exec_cmd(du_cmd) 253 | actual_rootfs_size = int(out.split()[0]) 254 | 255 | rootfs_size = self.get_rootfs_size(actual_rootfs_size) 256 | 257 | with open(rootfs, 'w') as sparse: 258 | os.ftruncate(sparse.fileno(), rootfs_size * 1024) 259 | 260 | extraopts = self.mkfs_extraopts or "-F -i 8192" 261 | 262 | label_str = "" 263 | if self.label: 264 | label_str = "-L %s" % self.label 265 | 266 | mkfs_cmd = "mkfs.%s %s %s %s -U %s -d %s" % \ 267 | (self.fstype, extraopts, rootfs, label_str, self.fsuuid, rootfs_dir) 268 | exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo) 269 | 270 | mkfs_cmd = "fsck.%s -pvfD %s" % (self.fstype, rootfs) 271 | exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo) 272 | 273 | def prepare_rootfs_btrfs(self, rootfs, oe_builddir, rootfs_dir, 274 | native_sysroot, pseudo): 275 | """ 276 | Prepare content for a btrfs rootfs partition. 277 | """ 278 | du_cmd = "du -ks %s" % rootfs_dir 279 | out = exec_cmd(du_cmd) 280 | actual_rootfs_size = int(out.split()[0]) 281 | 282 | rootfs_size = self.get_rootfs_size(actual_rootfs_size) 283 | 284 | with open(rootfs, 'w') as sparse: 285 | os.ftruncate(sparse.fileno(), rootfs_size * 1024) 286 | 287 | label_str = "" 288 | if self.label: 289 | label_str = "-L %s" % self.label 290 | 291 | mkfs_cmd = "mkfs.%s -b %d -r %s %s %s -U %s %s" % \ 292 | (self.fstype, rootfs_size * 1024, rootfs_dir, label_str, 293 | self.mkfs_extraopts, self.fsuuid, rootfs) 294 | exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo) 295 | 296 | def prepare_rootfs_msdos(self, rootfs, oe_builddir, rootfs_dir, 297 | native_sysroot, pseudo): 298 | """ 299 | Prepare content for a msdos/vfat rootfs partition. 300 | """ 301 | du_cmd = "du -bks %s" % rootfs_dir 302 | out = exec_cmd(du_cmd) 303 | blocks = int(out.split()[0]) 304 | 305 | rootfs_size = self.get_rootfs_size(blocks) 306 | 307 | label_str = "-n boot" 308 | if self.label: 309 | label_str = "-n %s" % self.label 310 | 311 | size_str = "" 312 | if self.fstype == 'msdos': 313 | size_str = "-F 16" # FAT 16 314 | 315 | extraopts = self.mkfs_extraopts or '-S 512' 316 | 317 | dosfs_cmd = "mkdosfs %s -i %s %s %s -C %s %d" % \ 318 | (label_str, self.fsuuid, size_str, extraopts, rootfs, 319 | rootfs_size) 320 | exec_native_cmd(dosfs_cmd, native_sysroot) 321 | 322 | mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (rootfs, rootfs_dir) 323 | exec_native_cmd(mcopy_cmd, native_sysroot) 324 | 325 | chmod_cmd = "chmod 644 %s" % rootfs 326 | exec_cmd(chmod_cmd) 327 | 328 | prepare_rootfs_vfat = prepare_rootfs_msdos 329 | 330 | def prepare_rootfs_squashfs(self, rootfs, oe_builddir, rootfs_dir, 331 | native_sysroot, pseudo): 332 | """ 333 | Prepare content for a squashfs rootfs partition. 334 | """ 335 | extraopts = self.mkfs_extraopts or '-noappend' 336 | squashfs_cmd = "mksquashfs %s %s %s" % \ 337 | (rootfs_dir, rootfs, extraopts) 338 | exec_native_cmd(squashfs_cmd, native_sysroot, pseudo=pseudo) 339 | 340 | def prepare_empty_partition_ext(self, rootfs, oe_builddir, 341 | native_sysroot): 342 | """ 343 | Prepare an empty ext2/3/4 partition. 344 | """ 345 | size = self.disk_size 346 | with open(rootfs, 'w') as sparse: 347 | os.ftruncate(sparse.fileno(), size * 1024) 348 | 349 | extraopts = self.mkfs_extraopts or "-i 8192" 350 | 351 | label_str = "" 352 | if self.label: 353 | label_str = "-L %s" % self.label 354 | 355 | mkfs_cmd = "mkfs.%s -F %s %s -U %s %s" % \ 356 | (self.fstype, extraopts, label_str, self.fsuuid, rootfs) 357 | exec_native_cmd(mkfs_cmd, native_sysroot) 358 | 359 | def prepare_empty_partition_btrfs(self, rootfs, oe_builddir, 360 | native_sysroot): 361 | """ 362 | Prepare an empty btrfs partition. 363 | """ 364 | size = self.disk_size 365 | with open(rootfs, 'w') as sparse: 366 | os.ftruncate(sparse.fileno(), size * 1024) 367 | 368 | label_str = "" 369 | if self.label: 370 | label_str = "-L %s" % self.label 371 | 372 | mkfs_cmd = "mkfs.%s -b %d %s -U %s %s %s" % \ 373 | (self.fstype, self.size * 1024, label_str, self.fsuuid, 374 | self.mkfs_extraopts, rootfs) 375 | exec_native_cmd(mkfs_cmd, native_sysroot) 376 | 377 | def prepare_empty_partition_msdos(self, rootfs, oe_builddir, 378 | native_sysroot): 379 | """ 380 | Prepare an empty vfat partition. 381 | """ 382 | blocks = self.disk_size 383 | 384 | label_str = "-n boot" 385 | if self.label: 386 | label_str = "-n %s" % self.label 387 | 388 | size_str = "" 389 | if self.fstype == 'msdos': 390 | size_str = "-F 16" # FAT 16 391 | 392 | extraopts = self.mkfs_extraopts or '-S 512' 393 | 394 | dosfs_cmd = "mkdosfs %s -i %s %s %s -C %s %d" % \ 395 | (label_str, self.fsuuid, extraopts, size_str, rootfs, 396 | blocks) 397 | 398 | exec_native_cmd(dosfs_cmd, native_sysroot) 399 | 400 | chmod_cmd = "chmod 644 %s" % rootfs 401 | exec_cmd(chmod_cmd) 402 | 403 | prepare_empty_partition_vfat = prepare_empty_partition_msdos 404 | 405 | def prepare_swap_partition(self, cr_workdir, oe_builddir, native_sysroot): 406 | """ 407 | Prepare a swap partition. 408 | """ 409 | path = "%s/fs.%s" % (cr_workdir, self.fstype) 410 | 411 | with open(path, 'w') as sparse: 412 | os.ftruncate(sparse.fileno(), self.size * 1024) 413 | 414 | label_str = "" 415 | if self.label: 416 | label_str = "-L %s" % self.label 417 | 418 | mkswap_cmd = "mkswap %s -U %s %s" % (label_str, self.fsuuid, path) 419 | exec_native_cmd(mkswap_cmd, native_sysroot) 420 | -------------------------------------------------------------------------------- /yocto/meta-klipper/recipes-printing/klipper/files/0001-Allow-to-package-klippy-using-setuptools.patch: -------------------------------------------------------------------------------- 1 | From bd3745c73a9204d80f9b5e578bd3ad3d68c9f35b Mon Sep 17 00:00:00 2001 2 | From: Sergey 'Jin' Bostandzhyan 3 | Date: Wed, 2 Jun 2021 23:57:32 +0200 4 | Subject: [PATCH] Allow to package klippy using setuptools 5 | 6 | --- 7 | MANIFEST.in | 2 ++ 8 | klippy/__init__.py | 6 ++++++ 9 | klippy/chelper/__init__.py | 5 +---- 10 | klippy/extras/bed_tilt.py | 2 +- 11 | klippy/extras/bus.py | 2 +- 12 | klippy/extras/delta_calibrate.py | 2 +- 13 | klippy/extras/ds18b20.py | 2 +- 14 | klippy/extras/endstop_phase.py | 2 +- 15 | klippy/extras/extruder_stepper.py | 2 +- 16 | klippy/extras/force_move.py | 2 +- 17 | klippy/extras/input_shaper.py | 2 +- 18 | klippy/extras/manual_stepper.py | 2 +- 19 | klippy/extras/probe.py | 2 +- 20 | klippy/extras/replicape.py | 2 +- 21 | klippy/extras/shaper_calibrate.py | 2 +- 22 | klippy/extras/sx1509.py | 2 +- 23 | klippy/extras/temperature_mcu.py | 2 +- 24 | klippy/extras/tmc.py | 2 +- 25 | klippy/extras/z_tilt.py | 2 +- 26 | klippy/kinematics/cartesian.py | 2 +- 27 | klippy/kinematics/corexy.py | 2 +- 28 | klippy/kinematics/corexz.py | 2 +- 29 | klippy/kinematics/delta.py | 2 +- 30 | klippy/kinematics/extruder.py | 2 +- 31 | klippy/kinematics/hybrid_corexy.py | 2 +- 32 | klippy/kinematics/hybrid_corexz.py | 2 +- 33 | klippy/kinematics/polar.py | 2 +- 34 | klippy/kinematics/rotary_delta.py | 2 +- 35 | klippy/kinematics/winch.py | 2 +- 36 | klippy/klippy.py | 2 +- 37 | klippy/toolhead.py | 2 +- 38 | setup.py | 31 ++++++++++++++++++++++++++++++ 39 | 32 files changed, 68 insertions(+), 32 deletions(-) 40 | create mode 100644 MANIFEST.in 41 | create mode 100644 klippy/__init__.py 42 | create mode 100644 setup.py 43 | 44 | diff --git a/MANIFEST.in b/MANIFEST.in 45 | new file mode 100644 46 | index 00000000..8e306491 47 | --- /dev/null 48 | +++ b/MANIFEST.in 49 | @@ -0,0 +1,2 @@ 50 | +include klippy/extras/display/menu.cfg 51 | +include klippy/extras/display/display.cfg 52 | diff --git a/klippy/__init__.py b/klippy/__init__.py 53 | new file mode 100644 54 | index 00000000..a6947c8d 55 | --- /dev/null 56 | +++ b/klippy/__init__.py 57 | @@ -0,0 +1,6 @@ 58 | +# Package definition for the extras directory 59 | +# 60 | +# Copyright (C) 2018 Kevin O'Connor 61 | +# 62 | +# This file may be distributed under the terms of the GNU GPLv3 license. 63 | + 64 | diff --git a/klippy/chelper/__init__.py b/klippy/chelper/__init__.py 65 | index 4d199126..90a5e6e9 100644 66 | --- a/klippy/chelper/__init__.py 67 | +++ b/klippy/chelper/__init__.py 68 | @@ -261,16 +261,13 @@ HC_COMPILE_CMD = "gcc -Wall -g -O2 -o %s %s -lusb" 69 | HC_SOURCE_FILES = ['hub-ctrl.c'] 70 | HC_SOURCE_DIR = '../../lib/hub-ctrl' 71 | HC_TARGET = "hub-ctrl" 72 | -HC_CMD = "sudo %s/hub-ctrl -h 0 -P 2 -p %d" 73 | +HC_CMD = "%s/hub-ctrl -h 0 -P 2 -p %d" 74 | 75 | def run_hub_ctrl(enable_power): 76 | srcdir = os.path.dirname(os.path.realpath(__file__)) 77 | hubdir = os.path.join(srcdir, HC_SOURCE_DIR) 78 | srcfiles = get_abs_files(hubdir, HC_SOURCE_FILES) 79 | destlib = get_abs_files(hubdir, [HC_TARGET])[0] 80 | - if check_build_code(srcfiles, destlib): 81 | - logging.info("Building C code module %s", HC_TARGET) 82 | - do_build_code(HC_COMPILE_CMD % (destlib, ' '.join(srcfiles))) 83 | os.system(HC_CMD % (hubdir, enable_power)) 84 | 85 | 86 | diff --git a/klippy/extras/bed_tilt.py b/klippy/extras/bed_tilt.py 87 | index cd1ce177..d86768fc 100644 88 | --- a/klippy/extras/bed_tilt.py 89 | +++ b/klippy/extras/bed_tilt.py 90 | @@ -4,7 +4,7 @@ 91 | # 92 | # This file may be distributed under the terms of the GNU GPLv3 license. 93 | import logging 94 | -import mathutil 95 | +from klippy import mathutil 96 | from . import probe 97 | 98 | class BedTilt: 99 | diff --git a/klippy/extras/bus.py b/klippy/extras/bus.py 100 | index 9b3e476a..dcb25362 100644 101 | --- a/klippy/extras/bus.py 102 | +++ b/klippy/extras/bus.py 103 | @@ -3,7 +3,7 @@ 104 | # Copyright (C) 2018,2019 Kevin O'Connor 105 | # 106 | # This file may be distributed under the terms of the GNU GPLv3 license. 107 | -import mcu 108 | +from klippy import mcu 109 | 110 | def resolve_bus_name(mcu, param, bus): 111 | # Find enumerations for the given bus 112 | diff --git a/klippy/extras/delta_calibrate.py b/klippy/extras/delta_calibrate.py 113 | index 4301c89a..e5a47633 100644 114 | --- a/klippy/extras/delta_calibrate.py 115 | +++ b/klippy/extras/delta_calibrate.py 116 | @@ -4,7 +4,7 @@ 117 | # 118 | # This file may be distributed under the terms of the GNU GPLv3 license. 119 | import math, logging, collections 120 | -import mathutil 121 | +from klippy import mathutil 122 | from . import probe 123 | 124 | # A "stable position" is a 3-tuple containing the number of steps 125 | diff --git a/klippy/extras/ds18b20.py b/klippy/extras/ds18b20.py 126 | index 49d658a1..da2f0341 100644 127 | --- a/klippy/extras/ds18b20.py 128 | +++ b/klippy/extras/ds18b20.py 129 | @@ -4,7 +4,7 @@ 130 | # 131 | # This file may be distributed under the terms of the GNU GPLv3 license. 132 | import logging 133 | -import mcu 134 | +from klippy import mcu 135 | 136 | DS18_REPORT_TIME = 3.0 137 | # Temperature can be sampled at any time but conversion time is ~750ms, so 138 | diff --git a/klippy/extras/endstop_phase.py b/klippy/extras/endstop_phase.py 139 | index a2b2b548..50fa76db 100644 140 | --- a/klippy/extras/endstop_phase.py 141 | +++ b/klippy/extras/endstop_phase.py 142 | @@ -4,7 +4,7 @@ 143 | # 144 | # This file may be distributed under the terms of the GNU GPLv3 license. 145 | import math, logging 146 | -import stepper 147 | +from klippy import stepper 148 | 149 | TRINAMIC_DRIVERS = ["tmc2130", "tmc2208", "tmc2209", "tmc2660", "tmc5160"] 150 | 151 | diff --git a/klippy/extras/extruder_stepper.py b/klippy/extras/extruder_stepper.py 152 | index a62b3f83..bcec2c7e 100644 153 | --- a/klippy/extras/extruder_stepper.py 154 | +++ b/klippy/extras/extruder_stepper.py 155 | @@ -4,7 +4,7 @@ 156 | # 157 | # This file may be distributed under the terms of the GNU GPLv3 license. 158 | import logging 159 | -import stepper 160 | +from klippy import stepper 161 | 162 | class ExtruderStepper: 163 | def __init__(self, config): 164 | diff --git a/klippy/extras/force_move.py b/klippy/extras/force_move.py 165 | index eb2577df..75fd49c8 100644 166 | --- a/klippy/extras/force_move.py 167 | +++ b/klippy/extras/force_move.py 168 | @@ -4,7 +4,7 @@ 169 | # 170 | # This file may be distributed under the terms of the GNU GPLv3 license. 171 | import math, logging 172 | -import chelper 173 | +from klippy import chelper 174 | 175 | BUZZ_DISTANCE = 1. 176 | BUZZ_VELOCITY = BUZZ_DISTANCE / .250 177 | diff --git a/klippy/extras/input_shaper.py b/klippy/extras/input_shaper.py 178 | index 69ac3cde..2ee1717d 100644 179 | --- a/klippy/extras/input_shaper.py 180 | +++ b/klippy/extras/input_shaper.py 181 | @@ -4,7 +4,7 @@ 182 | # Copyright (C) 2020 Dmitry Butyugin 183 | # 184 | # This file may be distributed under the terms of the GNU GPLv3 license. 185 | -import chelper 186 | +from klippy import chelper 187 | 188 | class InputShaper: 189 | def __init__(self, config): 190 | diff --git a/klippy/extras/manual_stepper.py b/klippy/extras/manual_stepper.py 191 | index 2f36b6d1..e3e6e298 100644 192 | --- a/klippy/extras/manual_stepper.py 193 | +++ b/klippy/extras/manual_stepper.py 194 | @@ -3,7 +3,7 @@ 195 | # Copyright (C) 2019-2021 Kevin O'Connor 196 | # 197 | # This file may be distributed under the terms of the GNU GPLv3 license. 198 | -import stepper, chelper 199 | +from klippy import stepper, chelper 200 | from . import force_move 201 | 202 | class ManualStepper: 203 | diff --git a/klippy/extras/probe.py b/klippy/extras/probe.py 204 | index a8fc36a6..a71e9cea 100644 205 | --- a/klippy/extras/probe.py 206 | +++ b/klippy/extras/probe.py 207 | @@ -4,7 +4,7 @@ 208 | # 209 | # This file may be distributed under the terms of the GNU GPLv3 license. 210 | import logging 211 | -import pins 212 | +from klippy import pins 213 | from . import manual_probe 214 | 215 | HINT_TIMEOUT = """ 216 | diff --git a/klippy/extras/replicape.py b/klippy/extras/replicape.py 217 | index 0f5bef0e..2507cc13 100644 218 | --- a/klippy/extras/replicape.py 219 | +++ b/klippy/extras/replicape.py 220 | @@ -4,7 +4,7 @@ 221 | # 222 | # This file may be distributed under the terms of the GNU GPLv3 license. 223 | import logging, os 224 | -import pins, mcu 225 | +from klippy import pins, mcu 226 | from . import bus 227 | 228 | REPLICAPE_MAX_CURRENT = 3.84 229 | diff --git a/klippy/extras/shaper_calibrate.py b/klippy/extras/shaper_calibrate.py 230 | index 3c6065de..8c8738de 100644 231 | --- a/klippy/extras/shaper_calibrate.py 232 | +++ b/klippy/extras/shaper_calibrate.py 233 | @@ -184,7 +184,7 @@ class ShaperCalibrate: 234 | def background_process_exec(self, method, args): 235 | if self.printer is None: 236 | return method(*args) 237 | - import queuelogger 238 | + from klippy import queuelogger 239 | parent_conn, child_conn = multiprocessing.Pipe() 240 | def wrapper(): 241 | queuelogger.clear_bg_logging() 242 | diff --git a/klippy/extras/sx1509.py b/klippy/extras/sx1509.py 243 | index 8b19dda8..60a0b56c 100644 244 | --- a/klippy/extras/sx1509.py 245 | +++ b/klippy/extras/sx1509.py 246 | @@ -3,7 +3,7 @@ 247 | # Copyright (C) 2018 Florian Heilmann 248 | # 249 | # This file may be distributed under the terms of the GNU GPLv3 license. 250 | -import pins 251 | +from klippy import pins 252 | from . import bus 253 | 254 | # Word registers 255 | diff --git a/klippy/extras/temperature_mcu.py b/klippy/extras/temperature_mcu.py 256 | index 1a1510da..568f4b30 100644 257 | --- a/klippy/extras/temperature_mcu.py 258 | +++ b/klippy/extras/temperature_mcu.py 259 | @@ -4,7 +4,7 @@ 260 | # 261 | # This file may be distributed under the terms of the GNU GPLv3 license. 262 | import logging 263 | -import mcu 264 | +from klippy import mcu 265 | 266 | SAMPLE_TIME = 0.001 267 | SAMPLE_COUNT = 8 268 | diff --git a/klippy/extras/tmc.py b/klippy/extras/tmc.py 269 | index 6868b994..88095dd5 100644 270 | --- a/klippy/extras/tmc.py 271 | +++ b/klippy/extras/tmc.py 272 | @@ -4,7 +4,7 @@ 273 | # 274 | # This file may be distributed under the terms of the GNU GPLv3 license. 275 | import logging, collections 276 | -import stepper 277 | +from klippy import stepper 278 | 279 | 280 | ###################################################################### 281 | diff --git a/klippy/extras/z_tilt.py b/klippy/extras/z_tilt.py 282 | index f8a8c718..3075ff25 100644 283 | --- a/klippy/extras/z_tilt.py 284 | +++ b/klippy/extras/z_tilt.py 285 | @@ -4,7 +4,7 @@ 286 | # 287 | # This file may be distributed under the terms of the GNU GPLv3 license. 288 | import logging 289 | -import mathutil 290 | +from klippy import mathutil 291 | from . import probe 292 | 293 | class ZAdjustHelper: 294 | diff --git a/klippy/kinematics/cartesian.py b/klippy/kinematics/cartesian.py 295 | index 6c44c120..9237bcdf 100644 296 | --- a/klippy/kinematics/cartesian.py 297 | +++ b/klippy/kinematics/cartesian.py 298 | @@ -4,7 +4,7 @@ 299 | # 300 | # This file may be distributed under the terms of the GNU GPLv3 license. 301 | import logging 302 | -import stepper 303 | +from klippy import stepper 304 | 305 | class CartKinematics: 306 | def __init__(self, toolhead, config): 307 | diff --git a/klippy/kinematics/corexy.py b/klippy/kinematics/corexy.py 308 | index 33f5fcf5..df4b47f4 100644 309 | --- a/klippy/kinematics/corexy.py 310 | +++ b/klippy/kinematics/corexy.py 311 | @@ -4,7 +4,7 @@ 312 | # 313 | # This file may be distributed under the terms of the GNU GPLv3 license. 314 | import logging, math 315 | -import stepper 316 | +from klippy import stepper 317 | 318 | class CoreXYKinematics: 319 | def __init__(self, toolhead, config): 320 | diff --git a/klippy/kinematics/corexz.py b/klippy/kinematics/corexz.py 321 | index dbd5c372..a2510cdd 100644 322 | --- a/klippy/kinematics/corexz.py 323 | +++ b/klippy/kinematics/corexz.py 324 | @@ -4,7 +4,7 @@ 325 | # 326 | # This file may be distributed under the terms of the GNU GPLv3 license. 327 | import logging, math 328 | -import stepper 329 | +from klippy import stepper 330 | 331 | class CoreXZKinematics: 332 | def __init__(self, toolhead, config): 333 | diff --git a/klippy/kinematics/delta.py b/klippy/kinematics/delta.py 334 | index 104d2122..7ecc0f0a 100644 335 | --- a/klippy/kinematics/delta.py 336 | +++ b/klippy/kinematics/delta.py 337 | @@ -4,7 +4,7 @@ 338 | # 339 | # This file may be distributed under the terms of the GNU GPLv3 license. 340 | import math, logging 341 | -import stepper, mathutil 342 | +from klippy import stepper, mathutil 343 | 344 | # Slow moves once the ratio of tower to XY movement exceeds SLOW_RATIO 345 | SLOW_RATIO = 3. 346 | diff --git a/klippy/kinematics/extruder.py b/klippy/kinematics/extruder.py 347 | index 6f2138ae..4b9f1c7e 100644 348 | --- a/klippy/kinematics/extruder.py 349 | +++ b/klippy/kinematics/extruder.py 350 | @@ -4,7 +4,7 @@ 351 | # 352 | # This file may be distributed under the terms of the GNU GPLv3 license. 353 | import math, logging 354 | -import stepper, chelper 355 | +from klippy import stepper, chelper 356 | 357 | class PrinterExtruder: 358 | def __init__(self, config, extruder_num): 359 | diff --git a/klippy/kinematics/hybrid_corexy.py b/klippy/kinematics/hybrid_corexy.py 360 | index 43cf7dd9..304194fa 100644 361 | --- a/klippy/kinematics/hybrid_corexy.py 362 | +++ b/klippy/kinematics/hybrid_corexy.py 363 | @@ -4,7 +4,7 @@ 364 | # 365 | # This file may be distributed under the terms of the GNU GPLv3 license. 366 | import logging 367 | -import stepper 368 | +from klippy import stepper 369 | 370 | # The hybrid-corexy kinematic is also known as Markforged kinematics 371 | class HybridCoreXYKinematics: 372 | diff --git a/klippy/kinematics/hybrid_corexz.py b/klippy/kinematics/hybrid_corexz.py 373 | index 47aa430e..d8d02a52 100644 374 | --- a/klippy/kinematics/hybrid_corexz.py 375 | +++ b/klippy/kinematics/hybrid_corexz.py 376 | @@ -4,7 +4,7 @@ 377 | # 378 | # This file may be distributed under the terms of the GNU GPLv3 license. 379 | import logging 380 | -import stepper 381 | +from klippy import stepper 382 | 383 | # The hybrid-corexz kinematic is also known as Markforged kinematics 384 | class HybridCoreXZKinematics: 385 | diff --git a/klippy/kinematics/polar.py b/klippy/kinematics/polar.py 386 | index ef8c0d97..e250e853 100644 387 | --- a/klippy/kinematics/polar.py 388 | +++ b/klippy/kinematics/polar.py 389 | @@ -4,7 +4,7 @@ 390 | # 391 | # This file may be distributed under the terms of the GNU GPLv3 license. 392 | import logging, math 393 | -import stepper 394 | +from klippy import stepper 395 | 396 | class PolarKinematics: 397 | def __init__(self, toolhead, config): 398 | diff --git a/klippy/kinematics/rotary_delta.py b/klippy/kinematics/rotary_delta.py 399 | index 1eb050ba..71e02920 100644 400 | --- a/klippy/kinematics/rotary_delta.py 401 | +++ b/klippy/kinematics/rotary_delta.py 402 | @@ -4,7 +4,7 @@ 403 | # 404 | # This file may be distributed under the terms of the GNU GPLv3 license. 405 | import math, logging 406 | -import stepper, mathutil, chelper 407 | +from klippy import stepper, mathutil, chelper 408 | 409 | class RotaryDeltaKinematics: 410 | def __init__(self, toolhead, config): 411 | diff --git a/klippy/kinematics/winch.py b/klippy/kinematics/winch.py 412 | index 11475d24..4d4787d8 100644 413 | --- a/klippy/kinematics/winch.py 414 | +++ b/klippy/kinematics/winch.py 415 | @@ -3,7 +3,7 @@ 416 | # Copyright (C) 2018-2021 Kevin O'Connor 417 | # 418 | # This file may be distributed under the terms of the GNU GPLv3 license. 419 | -import stepper, mathutil 420 | +from klippy import stepper, mathutil 421 | 422 | class WinchKinematics: 423 | def __init__(self, toolhead, config): 424 | diff --git a/klippy/klippy.py b/klippy/klippy.py 425 | index 5914c1ca..389a8940 100644 426 | --- a/klippy/klippy.py 427 | +++ b/klippy/klippy.py 428 | @@ -118,7 +118,7 @@ class Printer: 429 | if default is not configfile.sentinel: 430 | return default 431 | raise self.config_error("Unable to load module '%s'" % (section,)) 432 | - mod = importlib.import_module('extras.' + module_name) 433 | + mod = importlib.import_module('klippy.extras.' + module_name) 434 | init_func = 'load_config' 435 | if len(module_parts) > 1: 436 | init_func = 'load_config_prefix' 437 | diff --git a/klippy/toolhead.py b/klippy/toolhead.py 438 | index abb4eb5f..ec243d9a 100644 439 | --- a/klippy/toolhead.py 440 | +++ b/klippy/toolhead.py 441 | @@ -252,7 +252,7 @@ class ToolHead: 442 | self.extruder = kinematics.extruder.DummyExtruder(self.printer) 443 | kin_name = config.get('kinematics') 444 | try: 445 | - mod = importlib.import_module('kinematics.' + kin_name) 446 | + mod = importlib.import_module('klippy.kinematics.' + kin_name) 447 | self.kin = mod.load_kinematics(self, config) 448 | except config.error as e: 449 | raise 450 | diff --git a/setup.py b/setup.py 451 | new file mode 100644 452 | index 00000000..548cc9ea 453 | --- /dev/null 454 | +++ b/setup.py 455 | @@ -0,0 +1,31 @@ 456 | +from setuptools import setup, find_packages, Extension 457 | + 458 | +c_helper = Extension('klippy/chelper/c_helper', 459 | + define_macros = [('MAJOR_VERSION', '1'), 460 | + ('MINOR_VERSION', '0')], 461 | + sources = [ 'klippy/chelper/itersolve.c', 462 | + 'klippy/chelper/kin_cartesian.c', 463 | + 'klippy/chelper/kin_corexy.c', 464 | + 'klippy/chelper/kin_corexz.c', 465 | + 'klippy/chelper/kin_delta.c', 466 | + 'klippy/chelper/kin_extruder.c', 467 | + 'klippy/chelper/kin_polar.c', 468 | + 'klippy/chelper/kin_rotary_delta.c', 469 | + 'klippy/chelper/kin_shaper.c', 470 | + 'klippy/chelper/kin_winch.c', 471 | + 'klippy/chelper/pyhelper.c', 472 | + 'klippy/chelper/serialqueue.c', 473 | + 'klippy/chelper/stepcompress.c', 474 | + 'klippy/chelper/trapq.c' ]) 475 | + 476 | +setup( 477 | + name = 'klipper', 478 | + version = '0.9.1+git', 479 | + description = 'Klipper 3D Printing Firmware', 480 | + packages=find_packages(), 481 | + include_package_data = True, 482 | + entry_points = { "console_scripts": [ "klippy = klippy.klippy:main" ] }, 483 | + url = "https://www.klipper3d.org/", 484 | + ext_modules = [ c_helper ] 485 | +) 486 | + 487 | -- 488 | 2.31.1 489 | 490 | --------------------------------------------------------------------------------