meta-digi-dey: crank-demos: fix crank demo for CCMP15
Crank demo was not working on CCMP15 devices due to several changes on weston service and the user launching it. This commit makes several fixes to make the demo to work again: - Add 'DEMO_USER' parameter to determine which user will launch the demo. Update recipe and start script accordingly. - Add 'DEMO_DISPLAY' parameter to determine the display that will be used to launch the demo. Update recipe and start script accordingly. - Parameterize the name of the Weston service after which the demo must be started. Update recipe and service file accordingly. - Give Crank engine read and execution permissions so the engine can be started by any user. - Add new method to the demo start script to wait until Wayland is fully setup before actually starting the demo. Signed-off-by: David Escalona <david.escalona@digi.com>
This commit is contained in:
parent
64cea0e066
commit
1ec5cc172c
|
|
@ -14,8 +14,10 @@
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|
||||||
readonly DEMO="##CRANK_DEMO_PATH##"
|
readonly DEMO="##CRANK_DEMO_PATH##"
|
||||||
|
readonly DEMO_DISPLAY="##CRANK_DEMO_DISPLAY##"
|
||||||
readonly DEMO_OPTS="##CRANK_DEMO_OPTIONS##"
|
readonly DEMO_OPTS="##CRANK_DEMO_OPTIONS##"
|
||||||
readonly DEMO_ENV="##CRANK_DEMO_ENV##"
|
readonly DEMO_ENV="##CRANK_DEMO_ENV##"
|
||||||
|
readonly DEMO_USER="##CRANK_DEMO_USER##"
|
||||||
readonly SB_LAUNCHER="sb-launcher"
|
readonly SB_LAUNCHER="sb-launcher"
|
||||||
readonly SB_LAUNCHER_SCRIPT="/usr/bin/${SB_LAUNCHER}"
|
readonly SB_LAUNCHER_SCRIPT="/usr/bin/${SB_LAUNCHER}"
|
||||||
readonly CRANK_DEMO="crank-demo"
|
readonly CRANK_DEMO="crank-demo"
|
||||||
|
|
@ -31,14 +33,9 @@ log() {
|
||||||
}
|
}
|
||||||
|
|
||||||
get_crank_demo_pid() {
|
get_crank_demo_pid() {
|
||||||
local pids="$(pidof -o $$ "${SB_LAUNCHER}" 2>/dev/null)"
|
local pid="$(pgrep -f ${DEMO})"
|
||||||
|
|
||||||
[ -n "${pids}" ] || return 1
|
[ -n "${pid}" ] && { echo "${pid}"; return 0; }
|
||||||
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
|
return 1
|
||||||
}
|
}
|
||||||
|
|
@ -46,7 +43,7 @@ get_crank_demo_pid() {
|
||||||
check_is_running() {
|
check_is_running() {
|
||||||
local pid
|
local pid
|
||||||
|
|
||||||
if [ -f "${PID_FILE}" ]; then
|
if [ -s "${PID_FILE}" ]; then
|
||||||
pid="$(cat ${PID_FILE})"
|
pid="$(cat ${PID_FILE})"
|
||||||
else
|
else
|
||||||
pid="$(get_crank_demo_pid)"
|
pid="$(get_crank_demo_pid)"
|
||||||
|
|
@ -57,18 +54,35 @@ check_is_running() {
|
||||||
kill -0 "${pid}" >/dev/null 2>&1 && return 0
|
kill -0 "${pid}" >/dev/null 2>&1 && return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
rm -f "${PID_FILE}"
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wait_for_wayland() {
|
||||||
|
local count=20
|
||||||
|
local wayland_socket="/run/user/$(id -u ${DEMO_USER})/${DEMO_DISPLAY}"
|
||||||
|
|
||||||
|
[ -S "${wayland_socket}" -o ! -d "/usr/share/wayland/" ] && return 0
|
||||||
|
while [ ! -S "${wayland_socket}" ]; do
|
||||||
|
sleep 1
|
||||||
|
count=$((count-1))
|
||||||
|
if [ "${count}" = 0 ]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
check_is_running || { rm -f "${PID_FILE}"; return; }
|
check_is_running || return
|
||||||
|
|
||||||
local pid="$(cat ${PID_FILE})"
|
local pid="$(cat ${PID_FILE})"
|
||||||
kill -TERM "${pid}" >/dev/null 2>&1
|
kill -TERM "${pid}" >/dev/null 2>&1
|
||||||
|
|
||||||
local STOP_TIMEOUT="5"
|
local STOP_TIMEOUT="5"
|
||||||
for i in $(seq ${STOP_TIMEOUT}); do
|
for i in $(seq ${STOP_TIMEOUT}); do
|
||||||
check_is_running || { rm -f "${PID_FILE}"; log info "stopped"; break; }
|
check_is_running || { log info "stopped"; break; }
|
||||||
if [ "${i}" -eq ${STOP_TIMEOUT} ]; then
|
if [ "${i}" -eq ${STOP_TIMEOUT} ]; then
|
||||||
log warning "stop: ${CRANK_DEMO} did not stop gracefully"
|
log warning "stop: ${CRANK_DEMO} did not stop gracefully"
|
||||||
kill -KILL "${pid}" >/dev/null 2>&1
|
kill -KILL "${pid}" >/dev/null 2>&1
|
||||||
|
|
@ -80,9 +94,11 @@ stop() {
|
||||||
start() {
|
start() {
|
||||||
check_is_running && { log warning "start: ${CRANK_DEMO} ALREADY running"; exit 0; }
|
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 &
|
wait_for_wayland
|
||||||
|
env ${DEMO_ENV} ${SB_LAUNCHER_SCRIPT} ${DEMO_USER} ${DEMO_OPTS} ${DEMO} >/dev/null 2>&1 &
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo $! > ${PID_FILE}
|
echo $! > ${PID_FILE}
|
||||||
|
log info "$(cat ${PID_FILE})"
|
||||||
log info "started"
|
log info "started"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ Description=Crank Software demo
|
||||||
Documentation=https://www.cranksoftware.com/
|
Documentation=https://www.cranksoftware.com/
|
||||||
|
|
||||||
# Make sure we are started after graphic service is available
|
# Make sure we are started after graphic service is available
|
||||||
After=weston@root.service
|
After=##WESTON_SERVICE##
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=forking
|
Type=forking
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,20 @@ SRC_URI = " \
|
||||||
SRC_URI[md5sum] = "e7cfbe9590041c0d9bf8c64ab69ee57d"
|
SRC_URI[md5sum] = "e7cfbe9590041c0d9bf8c64ab69ee57d"
|
||||||
SRC_URI[sha256sum] = "2aa767f51183a5e96bacf5e4b03345524d29c30f7338b1a55e5a1080252bfd4a"
|
SRC_URI[sha256sum] = "2aa767f51183a5e96bacf5e4b03345524d29c30f7338b1a55e5a1080252bfd4a"
|
||||||
|
|
||||||
|
WESTON_SERVICE ?= "weston@root.service"
|
||||||
|
WESTON_SERVICE:ccmp15 ?= "weston-launch.service"
|
||||||
|
|
||||||
CRANK_DEMOS_TARBALL_PATH ?= ""
|
CRANK_DEMOS_TARBALL_PATH ?= ""
|
||||||
CRANK_DEMO_PATH ?= "${datadir}/crank/apps/Thermostat/Thermostat.gapp"
|
CRANK_DEMO_DISPLAY ?= "wayland-0"
|
||||||
|
CRANK_DEMO_DISPLAY:ccmp15 ?= "wayland-1"
|
||||||
|
CRANK_DEMO_ENV ?= "DISPLAY=:0.0 XDG_RUNTIME_DIR=/run/user/0 WAYLAND_DISPLAY=\${DEMO_DISPLAY}"
|
||||||
|
CRANK_DEMO_ENV:ccimx6ul ?= ""
|
||||||
|
CRANK_DEMO_ENV:ccmp15 ?= "DISPLAY=:0.0 XDG_RUNTIME_DIR=/run/user/1000 WAYLAND_DISPLAY=\${DEMO_DISPLAY}"
|
||||||
CRANK_DEMO_OPTIONS ?= ""
|
CRANK_DEMO_OPTIONS ?= ""
|
||||||
CRANK_DEMO_OPTIONS:ccimx6ul ?= "-odev-input,mouse=/dev/input/mouse0 -oscreen_mgr,swcursor"
|
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_PATH ?= "${datadir}/crank/apps/Thermostat/Thermostat.gapp"
|
||||||
CRANK_DEMO_ENV:ccimx6ul ?= ""
|
CRANK_DEMO_USER ?= "root"
|
||||||
|
CRANK_DEMO_USER:ccmp15 ?= "weston"
|
||||||
|
|
||||||
# The tarball is only available for downloading after registration, so provide
|
# 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
|
# a PREMIRROR to a local directory that can be configured in the project's
|
||||||
|
|
@ -64,6 +72,8 @@ do_install () {
|
||||||
# Install systemd unit files
|
# Install systemd unit files
|
||||||
install -d ${D}${systemd_unitdir}/system
|
install -d ${D}${systemd_unitdir}/system
|
||||||
install -m 0644 ${WORKDIR}/crank-demo.service ${D}${systemd_unitdir}/system/
|
install -m 0644 ${WORKDIR}/crank-demo.service ${D}${systemd_unitdir}/system/
|
||||||
|
sed -i -e "s@##WESTON_SERVICE##@${WESTON_SERVICE}@g" \
|
||||||
|
"${D}${systemd_unitdir}/system/crank-demo.service"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install wrapper bootscript to launch Crank demo on boot
|
# Install wrapper bootscript to launch Crank demo on boot
|
||||||
|
|
@ -72,6 +82,8 @@ do_install () {
|
||||||
sed -i -e "s@##CRANK_DEMO_PATH##@${CRANK_DEMO_PATH}@g" \
|
sed -i -e "s@##CRANK_DEMO_PATH##@${CRANK_DEMO_PATH}@g" \
|
||||||
-e "s@##CRANK_DEMO_OPTIONS##@${CRANK_DEMO_OPTIONS}@g" \
|
-e "s@##CRANK_DEMO_OPTIONS##@${CRANK_DEMO_OPTIONS}@g" \
|
||||||
-e "s@##CRANK_DEMO_ENV##@${CRANK_DEMO_ENV}@g" \
|
-e "s@##CRANK_DEMO_ENV##@${CRANK_DEMO_ENV}@g" \
|
||||||
|
-e "s@##CRANK_DEMO_USER##@${CRANK_DEMO_USER}@g" \
|
||||||
|
-e "s@##CRANK_DEMO_DISPLAY##@${CRANK_DEMO_DISPLAY}@g" \
|
||||||
"${D}${sysconfdir}/crank-demo"
|
"${D}${sysconfdir}/crank-demo"
|
||||||
ln -sf ${sysconfdir}/crank-demo ${D}${sysconfdir}/init.d/crank-demo
|
ln -sf ${sysconfdir}/crank-demo ${D}${sysconfdir}/init.d/crank-demo
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,7 @@
|
||||||
|
|
||||||
ENGINE="/usr/share/crank/sbengine"
|
ENGINE="/usr/share/crank/sbengine"
|
||||||
|
|
||||||
exec env LD_LIBRARY_PATH="${ENGINE}/lib" SB_PLUGINS="${ENGINE}/plugins" ${ENGINE}/bin/sbengine "$@"
|
USER=$1
|
||||||
|
shift
|
||||||
|
|
||||||
|
exec su -l "${USER}" -c "env LD_LIBRARY_PATH=${ENGINE}/lib SB_PLUGINS=${ENGINE}/plugins ${ENGINE}/bin/sbengine $*"
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ do_install () {
|
||||||
# Copy the engine
|
# Copy the engine
|
||||||
install -d -m 0755 ${D}${datadir}/crank/sbengine
|
install -d -m 0755 ${D}${datadir}/crank/sbengine
|
||||||
cp -drf ${S}/${SBENGINE_NAME}/* ${D}${datadir}/crank/sbengine
|
cp -drf ${S}/${SBENGINE_NAME}/* ${D}${datadir}/crank/sbengine
|
||||||
|
chmod a+rx ${D}${datadir}/crank/sbengine/*
|
||||||
}
|
}
|
||||||
|
|
||||||
FILES:${PN} = " \
|
FILES:${PN} = " \
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue