initial commit. builds but not tested

This commit is contained in:
vaughn committed 2026-03-04 13:24:24 -05:00
1 parent 3cd2ec2aa2
commit da2d80592c
14 files changed
+468

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
# We have a conf and classes directory, add to BBPATH
BBPATH .= ":${LAYERDIR}"
# We have recipes-* directories, add to BBFILES
BBFILES += "${LAYERDIR}/recipes-*/*.bb \
${LAYERDIR}/recipes-*/*/*.bbappend"
BBFILE_COLLECTIONS += "meta-openplc"
BBFILE_PATTERN_meta-openplc = "^${LAYERDIR}/"
BBFILE_PRIORITY_meta-openplc = "6"
LAYERDEPENDS_meta-openplc = "core"
LAYERSERIES_COMPAT_meta-openplc = "walnascar whinlatter"
+131
View File
@@ -0,0 +1,131 @@
Upstream-Status: Inappropriate [oe-specific]
diff --git a/install.sh b/install.sh
index 4b5b633..f8bfba7 100755
--- a/install.sh
+++ b/install.sh
@@ -36,6 +36,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
OPENPLC_DIR="$SCRIPT_DIR"
VENV_DIR="$OPENPLC_DIR/venvs/runtime"
SCRIPTS_DIR="$OPENPLC_DIR/scripts"
+ROOT_DIR="$D"
# Colors for output
RED='\033[0;31m'
@@ -71,12 +72,14 @@ has_systemd_support() {
# Check if systemctl command exists
if ! command -v systemctl >/dev/null 2>&1; then
+ log_warning "systemctl command not found"
return 1
fi
# Check if systemd is running as PID 1
# This handles Docker containers and GitHub Actions where systemctl may exist but systemd isn't PID 1
if [ ! -d "/run/systemd/system" ]; then
+ log_warning "systemd not running as PID 1"
return 1
fi
@@ -85,6 +88,7 @@ has_systemd_support() {
local pid1_name
pid1_name=$(cat /proc/1/comm 2>/dev/null)
if [ "$pid1_name" != "systemd" ]; then
+ log_warning "PID 1 is not systemd"
return 1
fi
fi
@@ -92,6 +96,7 @@ has_systemd_support() {
# Final check: can we actually communicate with systemd?
# Use 'if' to prevent set -e from aborting on failure
if ! systemctl show-environment >/dev/null 2>&1; then
+ log_warning "cannot communicate with systemd"
return 1
fi
@@ -100,7 +105,7 @@ has_systemd_support() {
# Install systemd service for OpenPLC Runtime
install_systemd_service() {
- local service_file="/etc/systemd/system/openplc-runtime.service"
+ local service_file="$ROOT_DIR/etc/systemd/system/openplc-runtime.service"
log_info "Installing OpenPLC Runtime systemd service..."
@@ -321,9 +326,11 @@ setup_plugin_venvs() {
log_warning "Plugins directory not found: $plugins_dir"
return 0
fi
-
# Find directories with requirements.txt for all plugins (regardless of enabled status)
local plugins_with_requirements=()
+ #:
+# ln -s /proc/self/fd /dev/fd
+find "$plugins_dir" -name "requirements.txt" -type f -print0 > tmp
while IFS= read -r -d '' requirements_file; do
# Get the directory name (plugin name)
local plugin_dir=$(dirname "$requirements_file")
@@ -335,9 +342,13 @@ setup_plugin_venvs() {
continue
fi
+ echo ${#plugins_with_requirements[@]}
plugins_with_requirements+=("$plugin_name")
+ echo ${#plugins_with_requirements[@]}
log_info "Found plugin with requirements: $plugin_name"
- done < <(find "$plugins_dir" -name "requirements.txt" -type f -print0)
+ done < tmp
+ rm tmp
+ echo ${#plugins_with_requirements[@]}
# If no plugins found, return
if [ ${#plugins_with_requirements[@]} -eq 0 ]; then
@@ -489,18 +500,18 @@ build_native_plugins() {
# Setup runtime directory (needed for both Linux and Docker)
# On MSYS2, use /run/runtime which maps to the MSYS2 installation directory
if is_msys2; then
- mkdir -p /run/runtime 2>/dev/null || true
- chmod 775 /run/runtime 2>/dev/null || true
+ mkdir -p $ROOT_DIR/run/runtime 2>/dev/null || true
+ chmod 775 $ROOT_DIR/run/runtime 2>/dev/null || true
else
- mkdir -p /var/run/runtime
- chmod 775 /var/run/runtime 2>/dev/null || true # Ignore permission errors in Docker
+ mkdir -p $ROOT_DIR/var/run/runtime
+ chmod 775 $ROOT_DIR/var/run/runtime 2>/dev/null || true # Ignore permission errors in Docker
# Create persistent data directory for native Linux installs
# This directory stores .env and database files that must survive reboot
# In Docker, /var/run/runtime is mounted as a persistent volume instead
if has_systemd_support; then
- mkdir -p /var/lib/openplc-runtime
- chmod 755 /var/lib/openplc-runtime
+ mkdir -p $ROOT_DIR/var/lib/openplc-runtime
+ chmod 755 $ROOT_DIR/var/lib/openplc-runtime
log_info "Created persistent data directory at /var/lib/openplc-runtime"
fi
fi
@@ -510,11 +521,23 @@ chmod +x "$OPENPLC_DIR/install.sh" 2>/dev/null || true
chmod +x "$OPENPLC_DIR/scripts/"* 2>/dev/null || true
chmod +x "$OPENPLC_DIR/start_openplc.sh" 2>/dev/null || true
-install_dependencies
+#install_dependencies
+#python3 -m venv tempvenv
+#./tempvenv/bin/python3 -m pip install crossenv
+#log_info "///////////////////////////////////////////////////////////////////////////////"
+#log_info "tgtpy $TGTPY"
+#log_info "venvdir $VENV_DIR"
+#./tempvenv/bin/python3 -m crossenv $TGTPY cross-venv #$VENV_DIR
+#. cross-venv/bin/activate
+#. $VENV_DIR/bin/activate
python3 -m venv "$VENV_DIR"
+#./cross-venv/bin/cross-python3 -m venv "$VENV_DIR"
"$VENV_DIR/bin/python3" -m pip install --upgrade pip setuptools wheel
"$VENV_DIR/bin/python3" -m pip install -r "$OPENPLC_DIR/requirements.txt"
"$VENV_DIR/bin/python3" -m pip install -e .
+#python3 -m pip install --upgrade pip setuptools wheel
+#python3 -m pip install -r "$OPENPLC_DIR/requirements.txt"
+#python3 -m pip install -e .
echo "Dependencies installed..."
echo "Virtual environment created at $VENV_DIR"
+15
View File
@@ -0,0 +1,15 @@
[Unit]
Description=OpenPLC Runtime v4 Service
After=network.target
[Service]
Type=simple
Restart=always
RestartSec=5
User=root
Group=root
WorkingDirectory=/openplc/
ExecStart=/openplc/start_openplc.sh
[Install]
WantedBy=multi-user.target
+157
View File
@@ -0,0 +1,157 @@
SUMMARY = "This recipe will automatically install the OpenPLC Runtime Environment"
HOMEPAGE = "https://autonomylogic.com/"
LICENSE = "MIT"
#SRC_URI:append = "file://sdaglue.service"
SRC_URI:append = "git://github.com/Autonomy-Logic/openplc-runtime.git;protocol=https;branch=main \
file://openplc.service \
file://fake_root.patch \
"
SRCREV = "cd9825b703f17c0d5db2fc99c5454f3cf822f3b3"
LIC_FILES_CHKSUM = "file://LICENSE;md5=1e9650a938047d709b897ea200cd0a71"
#UNPACKDIR = "${D}/openplc"
#WORKDIR = "${D}/openplc"
OPENPLC_USER = "plc"
inherit systemd cmake pkgconfig
#do_configure:prepend() {
#rm -rf ${S}/*
#mkdir -p ${D}/openplc
#rm -rf ${D}/openplc/*
#}
#do_unpack:append() {
#}
do_install[network] = "1"
INHIBIT_PACKAGE_STRIP = "1"
PACKAGE_STRIP = "no"
INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
do_install() {
mkdir -p ${D}/openplc
#chown ${OPENPLC_USER} ${D}/openplc
#TODO make this more granular. openplc depends on some files from the source to be present on the final system, but surely not all of them.
#cp -r ${S}/* ${D}/openplc
#find ${S}/* -type f -exec install -Dm 755 -o ${OPENPLC_USER} "{}" "${D}/openplc/{}" \;
export tmppwd=${PWD}
#cd ${S}
#find ./ -type f -exec install -Dm 755 "{}" "${D}/openplc/{}" \;
#cd $tmppwd
#cd ${D}/openplc
#chroot ${D}
export D="${D}/openplc"
export TGTPY=$(find ${D}/../../../python3 -type l -wholename */image${PYTHON} -executable)
echo "find ${B}/python3 -type l -wholename */image${PYTHON} -executable)"
#export PYDIR="${STAGING_LIBDIR}"
#mkdir ${D}/openplc
#${D}/openplc/install.sh
#/openplc/install.sh
#exit
#cd $tmppwd
${S}/install.sh
#grep -rlw ${S}/venvs -e "${S}" | xargs sed -i -e "s|${S}|/|g"
cp ${S}/start_openplc.sh ${D}/openplc
#cp -r ${S}/venvs ${D}/openplc #bitbake seems to have a problem with either stripping these files out or giving incorrect ownership
#rm -rf ${D}/openplc/venvs/opcua
#rm -rf "${D}/openplc/venvs/runtime/lib/python3.12/site-packages/greenlet"
#rm -rf "${D}/openplc/venvs/runtime/lib/python3.12/site-packages/sqlalchemy"
cp -r ${S}/scripts ${D}/openplc
cp -r ${S}/webserver ${D}/openplc
mkdir -p ${D}/openplc/build/
cp ${S}/build/plc_main ${D}/openplc/build
cp -r ${S}/build/plugins ${D}/openplc/build
#cp -r ${S}/* ${D}/openplc
#${D}/openplc/install.sh
rm -rf ${D}/var
find ${D} -name *.pyc -delete
#find ${D}/openplc/venvs -name python3 -delete #should hopefully only kil symlinks
#grep -rlw ${D}/openplc/venvs -e "${D}" | xargs sed -i -e "s|${D}|/|g"
#grep -rlw ${D}/openplc -e ${TMPDIR} | xargs sed -i -e "s|${TMPDIR}|/tmp|g" #this should maybe pipe to rm -f instead?
install -d ${D}${systemd_system_unitdir}
install -m 0755 ${UNPACKDIR}/openplc.service ${D}${systemd_system_unitdir}/openplc.service
#bbwarn "attempting to install service"
#${D}${BIN_FILE} service install
#bbwarn "attempting to start service"
#${D}${BIN_FILE} service start
}
#addtask do_populate_sdk before do_install after do_fetch_sources
do_package:append() {
#the following scrubs all instances of tmpdir from the target files. This will probably break things
#os.system('grep -Rnw ${D}/openplc -e ${D} | sed -i -e "s|${D}|/|g"')
#os.system('grep -Rnw ${D}/openplc -e ${TMPDIR} | sed -i -e "s|${TMPDIR}|/|g"') #this should maybe pipe to rm -f instead?
}
INHERIT += "extrausers"
EXTRA_USERS_PARAMS += " useradd ${OPENPLC_USER}; \
usermod -p '\$6\$TNPZD8XEuoDZWxLo\$WOIudv2UA5eePqcX0qgiS.o0feNZow1cAq9OnYLIZYsE6Jq2n.G/7792z73lx0h6EpBr/FUZpEqIDpWliK7Oy.' ${OPENPLC_USER}; \
"
SYSTEMD_PACKAGES = "${@bb.utils.contains('DISTRO_FEATURES','systemd','${PN}','',d)}"
SYSTEMD_SERVICE:${PN} = "openplc.service"
SYSTEMD_AUTO_ENABLE:${PN} = "enable"
DEPENDS = "\
python3 \
python3-pip \
pkgconfig \
cmake \
pkgconfig-native \
"
RDEPENDS:${PN} = "\
python3 \
python3-pip \
python3-venv \
python3-modules \
python3-pymodbus \
python3-greenlet \
python3-sqlalchemy \
python3-psutil \
python3-markupsafe \
python3-asyncua \
python3-pyserial \
python3-flask \
python3-cryptography \
python3-pytest \
python3-pytest-asyncio \
python3-pytest-mock \
python3-psutil \
python3-bcrypt \
python3-socketio \
python3-python-dotenv \
python3-pyjwt \
python3-flask-sqlalchemy \
python3-pre-commit \
python3-flask-jwt-extended \
python3-flask-login \
python3-aiomqtt \
bash \
"
#python3-dev
#python3-yaml
#iproute
#nc
FILES:${PN} = "\
/var \
/run \
/run/runtime \
/openplc \
/openplc/* \
${systemd_system_unitdir}/openplc.service \
"
+16
View File
@@ -0,0 +1,16 @@
SUMMARY = "File support for asyncio."
HOMEPAGE = "None"
AUTHOR = "None <Tin Tvrtkovic <tinchester@gmail.com>>"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=d2794c0df5b907fdace235a619d80314"
SRC_URI = "https://files.pythonhosted.org/packages/41/c3/534eac40372d8ee36ef40df62ec129bee4fdb5ad9706e58a29be53b2c970/aiofiles-25.1.0.tar.gz"
SRC_URI[md5sum] = "7a92207aab48342239959dc5ccffb81d"
SRC_URI[sha256sum] = "a8d728f0a29de45dc521f18f07297428d56992a742f0cd2701ba86e44d23d5b2"
#S = "${WORKDIR}/aiofiles-25.1.0"
RDEPENDS_${PN} = ""
inherit setuptools3
+20
View File
@@ -0,0 +1,20 @@
SUMMARY = "The idiomatic asyncio MQTT client"
HOMEPAGE = "https://github.com/empicano/aiomqtt"
LICENSE = "BSD-3-Clause"
LIC_FILES_CHKSUM = "file://LICENSE;md5=a462083fa4d830bdcf8c22a8ddf453cf"
RECIPE_MAINTAINER = "Tom Geelen <t.f.g.geelen@gmail.com>"
DEPENDS = "python3-hatchling-native"
SRC_URI[sha256sum] = "ab0f18fc5b7ffaa57451c407417d674db837b00a9c7d953cccd02be64f046c17"
inherit pypi python_hatchling ptest-python-pytest
RDEPENDS:${PN} = "\
python3-paho-mqtt (>=2.1.0) \
"
RDEPENDS:${PN}-ptest += "\
python3-anyio \
"
PYPI_PACKAGE = "aiomqtt"
@@ -0,0 +1,16 @@
SUMMARY = "asyncio bridge to the standard sqlite3 module"
HOMEPAGE = "None"
AUTHOR = "None <Amethyst Reese <amethyst@n7.gg>>"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=f0c422eaa1f23d09f8203dc0af3e2d54"
SRC_URI = "https://files.pythonhosted.org/packages/4e/8a/64761f4005f17809769d23e518d915db74e6310474e733e3593cfc854ef1/aiosqlite-0.22.1.tar.gz"
SRC_URI[md5sum] = "254707dc29315a01a95728d749d13e56"
SRC_URI[sha256sum] = "043e0bd78d32888c0a9ca90fc788b38796843360c855a7262a532813133a0650"
#S = "${WORKDIR}/aiosqlite-0.22.1"
RDEPENDS_${PN} = ""
inherit setuptools3
+18
View File
@@ -0,0 +1,18 @@
SUMMARY = "Pure Python OPC-UA client and server library"
HOMEPAGE = "None"
AUTHOR = "None <Olivier Roulet-Dubonnet <olivier.roulet@gmail.com>>"
LICENSE = "LGPL-3.0-or-later"
LIC_FILES_CHKSUM = "file://COPYING;md5=e6a600fd5e1d9cbde2d983680233ad02"
SRC_URI = "https://files.pythonhosted.org/packages/78/47/a141ba533ab4a361238f94ffd3b357dd198cf99a446e91dcbb9175b152c6/asyncua-1.1.8.tar.gz"
SRC_URI[md5sum] = "265292aa15fb150e592661772861aa0a"
SRC_URI[sha256sum] = "4a348e2b9bdfa7869edaef2d7f1b08920140d01ab79f336744b06e4c692e509d"
#S = "${WORKDIR}/asyncua-1.1.8"
RDEPENDS_${PN} = "python3-aiofiles python3-aiosqlite python3-cryptography python3-pyopenssl python3-python-dateutil python3-pytz python3-sortedcontainers python3-typing-extensions"
inherit pypi
inherit python_hatchling
PYPI_PACKAGE = "asyncua"
@@ -0,0 +1,16 @@
SUMMARY = "Python wrapper module around the OpenSSL library"
HOMEPAGE = "https://pyopenssl.org/"
AUTHOR = "The pyOpenSSL developers <cryptography-dev@python.org>"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57"
SRC_URI = "https://files.pythonhosted.org/packages/80/be/97b83a464498a79103036bc74d1038df4a7ef0e402cfaf4d5e113fb14759/pyopenssl-25.3.0.tar.gz"
SRC_URI[md5sum] = "d755732945157fb8ca98c2d66a55755d"
SRC_URI[sha256sum] = "c981cb0a3fd84e8602d7afc209522773b94c1c2446a3c710a75b06fe1beae329"
#S = "${WORKDIR}/pyopenssl-25.3.0"
RDEPENDS_${PN} = "python3-cryptography"
inherit setuptools3
@@ -0,0 +1,16 @@
SUMMARY = "Extensions to the standard Python datetime module"
HOMEPAGE = "https://github.com/dateutil/dateutil"
AUTHOR = "Gustavo Niemeyer <gustavo@niemeyer.net>"
LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://LICENSE;md5=e3155c7bdc71f66e02678411d2abf996"
SRC_URI = "https://files.pythonhosted.org/packages/66/c0/0c8b6ad9f17a802ee498c46e004a0eb49bc148f2fd230864601a86dcf6db/python-dateutil-2.9.0.post0.tar.gz"
SRC_URI[md5sum] = "81cb6aad924ef40ebfd3d62eaebe47c6"
SRC_URI[sha256sum] = "37dd54208da7e1cd875388217d5e00ebd4179249f90fb72437e91a35459a0ad3"
#S = "${WORKDIR}/python-dateutil-2.9.0.post0"
RDEPENDS_${PN} = "python3-six"
inherit setuptools3
@@ -0,0 +1,16 @@
SUMMARY = "World timezone definitions, modern and historical"
HOMEPAGE = "http://pythonhosted.org/pytz"
AUTHOR = "Stuart Bishop <stuart@stuartbishop.net>"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=1a67fc46c1b596cce5d21209bbe75999"
SRC_URI = "https://files.pythonhosted.org/packages/56/db/b8721d71d945e6a8ac63c0fc900b2067181dbb50805958d4d4661cf7d277/pytz-2026.1.post1.tar.gz"
SRC_URI[md5sum] = "d805ceb0fe3717e324299865398d70b0"
SRC_URI[sha256sum] = "3378dde6a0c3d26719182142c56e60c7f9af7e968076f31aae569d72a0358ee1"
S = "${UNPACKDIR}/pytz-2026.1.post1"
RDEPENDS_${PN} = ""
inherit setuptools3
+16
View File
@@ -0,0 +1,16 @@
SUMMARY = "Python 2 and 3 compatibility utilities"
HOMEPAGE = "https://github.com/benjaminp/six"
AUTHOR = "Benjamin Peterson <benjamin@python.org>"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=e50fab7e9501f3dfc920eafeb24b46ea"
SRC_URI = "https://files.pythonhosted.org/packages/94/e7/b2c673351809dca68a0e064b6af791aa332cf192da575fd474ed7d6f16a2/six-1.17.0.tar.gz"
SRC_URI[md5sum] = "a0387fe15662c71057b4fb2b7aa9056a"
SRC_URI[sha256sum] = "ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81"
S = "${UNPACKDIR}/six-1.17.0"
RDEPENDS_${PN} = ""
inherit setuptools3
@@ -0,0 +1,16 @@
SUMMARY = "Backported and Experimental Type Hints for Python 3.9+"
HOMEPAGE = "None"
AUTHOR = "None <"Guido van Rossum, Jukka Lehtosalo, Łukasz Langa, Michael Lee" <levkivskyi@gmail.com>>"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=fcf6b249c2641540219a727f35d8d2c2"
SRC_URI = "https://files.pythonhosted.org/packages/72/94/1a15dd82efb362ac84269196e94cf00f187f7ed21c242792a923cdb1c61f/typing_extensions-4.15.0.tar.gz"
SRC_URI[md5sum] = "079e529d0b271647f3ec2720aee8fc65"
SRC_URI[sha256sum] = "0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466"
S = "${UNPACKDIR}/typing_extensions-4.15.0"
RDEPENDS_${PN} = ""
inherit python_flit_core
+2
View File
@@ -0,0 +1,2 @@
PREFERRED_VERSION_python3-aiomqtt = "2.5.0"
PREFERRED_VERSION_python3-paho-mqtt = "2.1.0"