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

+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 \
"