crank: recipe for crank demos
This recipe downloads a tarball with Crank demos (http://log-sln-jenkins.digi.com/yocto/downloads/crank-demos-7.1.tar.gz) NOTE: Currently it will only includes the 'Thermostat' sample. It installs these demos inside '/usr/share/crank/apps' and configures one of them (Thermostat application) to be launched on boot. https://onedigi.atlassian.net/browse/DEL-7969 Signed-off-by: Tatiana Leon <Tatiana.Leon@digi.com>
This commit is contained in:
parent
37f67132bd
commit
93e69dfb3e
|
|
@ -36,6 +36,12 @@ do_install:append() {
|
|||
>> ${D}${sysconfdir}/udev/rules.d/localextra.rules
|
||||
fi
|
||||
|
||||
# Mouse symlink
|
||||
printf "%s\n%s\n" \
|
||||
"# Symlink to the mouse" \
|
||||
"SUBSYSTEM==\"input\", KERNEL==\"event[0-9]*\", ENV{ID_INPUT_MOUSE}==\"1\", SYMLINK+=\"input/mouse0\"" \
|
||||
>> ${D}${sysconfdir}/udev/rules.d/localextra.rules
|
||||
|
||||
install -d ${D}${sysconfdir}/modprobe.d
|
||||
if ${@bb.utils.contains('MACHINE_FEATURES','gpu','false','true',d)}; then
|
||||
# evbug debug tool
|
||||
|
|
|
|||
|
|
@ -0,0 +1,106 @@
|
|||
#!/bin/sh
|
||||
#===============================================================================
|
||||
#
|
||||
# Copyright (C) 2022 by Digi International Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 as published by
|
||||
# the Free Software Foundation.
|
||||
#
|
||||
#
|
||||
# !Description: Initialize Crank demo
|
||||
#
|
||||
#===============================================================================
|
||||
|
||||
readonly DEMO="##CRANK_DEMO_PATH##"
|
||||
readonly DEMO_OPTS="##CRANK_DEMO_OPTIONS##"
|
||||
readonly DEMO_ENV="##CRANK_DEMO_ENV##"
|
||||
readonly SB_LAUNCHER="sb-launcher"
|
||||
readonly SB_LAUNCHER_SCRIPT="/usr/bin/${SB_LAUNCHER}"
|
||||
readonly CRANK_DEMO="crank-demo"
|
||||
readonly PID_FILE="/run/${CRANK_DEMO}.pid"
|
||||
|
||||
[ -f "/etc/profile.d/tslib.sh" ] && . /etc/profile.d/tslib.sh
|
||||
|
||||
log() {
|
||||
if type "systemd-cat" >/dev/null 2>/dev/null; then
|
||||
systemd-cat -p "${1}" -t "${CRANK_DEMO}" printf "%s" "${2}"
|
||||
fi
|
||||
logger -p "${1}" -t "${CRANK_DEMO}" "${2}"
|
||||
}
|
||||
|
||||
get_crank_demo_pid() {
|
||||
local pids="$(pidof -o $$ "${SB_LAUNCHER}" 2>/dev/null)"
|
||||
|
||||
[ -n "${pids}" ] || return 1
|
||||
for pid in ${pids}; do
|
||||
local cmd_line=$(xargs -0 < /proc/${pid}/cmdline)
|
||||
local app="${cmd_line##* }"
|
||||
[ "${app}" = "${DEMO}" ] && { echo "${pid}"; return 0; }
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
check_is_running() {
|
||||
local pid
|
||||
|
||||
if [ -f "${PID_FILE}" ]; then
|
||||
pid="$(cat ${PID_FILE})"
|
||||
else
|
||||
pid="$(get_crank_demo_pid)"
|
||||
echo "${pid}" > ${PID_FILE}
|
||||
fi
|
||||
|
||||
if [ "${pid}" ]; then
|
||||
kill -0 "${pid}" >/dev/null 2>&1 && return 0
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
stop() {
|
||||
check_is_running || { rm -f "${PID_FILE}"; return; }
|
||||
|
||||
local pid="$(cat ${PID_FILE})"
|
||||
kill -TERM "${pid}" >/dev/null 2>&1
|
||||
|
||||
local STOP_TIMEOUT="5"
|
||||
for i in $(seq ${STOP_TIMEOUT}); do
|
||||
check_is_running || { rm -f "${PID_FILE}"; log info "stopped"; break; }
|
||||
if [ "${i}" -eq ${STOP_TIMEOUT} ]; then
|
||||
log warning "stop: ${CRANK_DEMO} did not stop gracefully"
|
||||
kill -KILL "${pid}" >/dev/null 2>&1
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
start() {
|
||||
check_is_running && { log warning "start: ${CRANK_DEMO} ALREADY running"; exit 0; }
|
||||
|
||||
env ${DEMO_ENV} ${SB_LAUNCHER_SCRIPT} ${DEMO_OPTS} ${DEMO} >/dev/null 2>&1 &
|
||||
if [ $? -eq 0 ]; then
|
||||
echo $! > ${PID_FILE}
|
||||
log info "started"
|
||||
fi
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
sleep 1
|
||||
start
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
[Unit]
|
||||
Description=Crank Software demo
|
||||
Documentation=https://www.cranksoftware.com/
|
||||
|
||||
# Make sure we are started after graphic service is available
|
||||
After=weston@root.service
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
PIDFile=/run/crank-demo.pid
|
||||
ExecStart=/etc/crank-demo start
|
||||
ExecStop=/etc/crank-demo stop
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
# Copyright (C) 2022, Digi International Inc.
|
||||
|
||||
SUMMARY = "Crank Demo"
|
||||
HOMEPAGE = "https://www.cranksoftware.com/"
|
||||
LICENSE = "Proprietary"
|
||||
LIC_FILES_CHKSUM = "file://EULA.pdf;md5=fcb6aca5219f44fea1c073405a378250"
|
||||
|
||||
DEPENDS = "crank-sbengine"
|
||||
|
||||
SRC_URI = " \
|
||||
http:///not/exist/crank-demos-${PV}.tar.gz \
|
||||
file://crank-demo.service \
|
||||
file://crank-demo-init \
|
||||
"
|
||||
SRC_URI[md5sum] = "e7cfbe9590041c0d9bf8c64ab69ee57d"
|
||||
SRC_URI[sha256sum] = "2aa767f51183a5e96bacf5e4b03345524d29c30f7338b1a55e5a1080252bfd4a"
|
||||
|
||||
CRANK_DEMOS_TARBALL_PATH ?= ""
|
||||
CRANK_DEMO_PATH ?= "${datadir}/crank/apps/Thermostat/Thermostat.gapp"
|
||||
CRANK_DEMO_OPTIONS ?= ""
|
||||
CRANK_DEMO_OPTIONS:ccimx6ul ?= "-odev-input,mouse=/dev/input/mouse0 -oscreen_mgr,swcursor"
|
||||
CRANK_DEMO_ENV ?= "DISPLAY=:0.0 XDG_RUNTIME_DIR=/run/user/0 WAYLAND_DISPLAY=wayland-0"
|
||||
CRANK_DEMO_ENV:ccimx6ul ?= ""
|
||||
|
||||
# The tarball is only available for downloading after registration, so provide
|
||||
# a PREMIRROR to a local directory that can be configured in the project's
|
||||
# local.conf file using CRANK_DEMOS_TARBALL_PATH variable.
|
||||
python() {
|
||||
crank_demos_tarball_path = d.getVar('CRANK_DEMOS_TARBALL_PATH', True)
|
||||
if crank_demos_tarball_path:
|
||||
premirrors = d.getVar('PREMIRRORS', True)
|
||||
d.setVar('PREMIRRORS', "http:///not/exist/crank-demos-.* %s \\n %s" % (crank_demos_tarball_path, premirrors))
|
||||
}
|
||||
|
||||
inherit systemd update-rc.d
|
||||
|
||||
# Disable tasks not needed for the binary package
|
||||
do_configure[noexec] = "1"
|
||||
|
||||
do_compile () {
|
||||
for f in ${S}/*; do
|
||||
if [ -d "${f}/source_code" ]; then
|
||||
oe_runmake -C "${f}/source_code"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
do_install () {
|
||||
install -d -m 0755 ${D}${datadir}/crank/apps
|
||||
|
||||
# Install Crank demos
|
||||
tar --no-same-owner --exclude='EULA.pdf' --exclude='*/source_code' -cpf - -C ${S} . \
|
||||
| tar --no-same-owner -xpf - -C ${D}${datadir}/crank/apps
|
||||
|
||||
# Install required binaries
|
||||
for f in ${S}/*; do
|
||||
if [ -d "${f}/source_code" ]; then
|
||||
oe_runmake DESTDIR=${D}${datadir}/crank/apps/$(basename ${f}) -C "${f}/source_code" install
|
||||
fi
|
||||
done
|
||||
|
||||
# Install systemd service
|
||||
if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
|
||||
# Install systemd unit files
|
||||
install -d ${D}${systemd_unitdir}/system
|
||||
install -m 0644 ${WORKDIR}/crank-demo.service ${D}${systemd_unitdir}/system/
|
||||
fi
|
||||
|
||||
# Install wrapper bootscript to launch Crank demo on boot
|
||||
install -d ${D}${sysconfdir}/init.d
|
||||
install -m 0755 ${WORKDIR}/crank-demo-init ${D}${sysconfdir}/crank-demo
|
||||
sed -i -e "s@##CRANK_DEMO_PATH##@${CRANK_DEMO_PATH}@g" \
|
||||
-e "s@##CRANK_DEMO_OPTIONS##@${CRANK_DEMO_OPTIONS}@g" \
|
||||
-e "s@##CRANK_DEMO_ENV##@${CRANK_DEMO_ENV}@g" \
|
||||
"${D}${sysconfdir}/crank-demo"
|
||||
ln -sf ${sysconfdir}/crank-demo ${D}${sysconfdir}/init.d/crank-demo
|
||||
}
|
||||
|
||||
FILES:${PN} = " \
|
||||
${datadir}/crank/apps/* \
|
||||
${sysconfdir}/crank-demo \
|
||||
${sysconfdir}/init.d/crank-demo \
|
||||
${systemd_unitdir}/system/crank-demo.service \
|
||||
"
|
||||
|
||||
INITSCRIPT_NAME = "crank-demo"
|
||||
INITSCRIPT_PARAMS = "defaults 90 10"
|
||||
|
||||
SYSTEMD_SERVICE:${PN} = "crank-demo.service"
|
||||
|
||||
RDEPENDS:${PN} += "crank-sbengine"
|
||||
Loading…
Reference in New Issue