debian: Fixup ACRN lifemngr package build

Part of fix for
https://github.com/tttech-industrial-buchsbaum/acrn-hypervisor/issues/6

Tracked-On: #6688
Signed-off-by: Helmut Buchsbaum <helmut.buchsbaum@opensource.tttech-industrial.com>
This commit is contained in:
Helmut Buchsbaum 2022-05-03 11:29:05 +02:00 committed by acrnsi-robot
parent a22d0497d7
commit f792336c1c
8 changed files with 97 additions and 38 deletions

View File

@ -1,2 +1,3 @@
usr/bin/acrn-lifemngr
usr/share/acrn-lifemngr/*
lib/systemd/system/acrn-lifemngr.service

46
debian/acrn-lifemngr.postrm vendored Normal file
View File

@ -0,0 +1,46 @@
#!/bin/sh
# postrm script for grub-acrn
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <postrm> `remove'
# * <postrm> `purge'
# * <old-postrm> `upgrade' <new-version>
# * <new-postrm> `failed-upgrade' <old-version>
# * <new-postrm> `abort-install'
# * <new-postrm> `abort-install' <old-version>
# * <new-postrm> `abort-upgrade' <old-version>
# * <disappearer's-postrm> `disappear' <overwriter>
# <overwriter-version>
# for details, see https://www.debian.org/doc/debian-policy/ or
# the debian-policy package
case "$1" in
remove|purge)
# remove any preinstalled & unchanged configfile
if cmp -s "/etc/life_mngr/life_mngr.conf" "/usr/share/acrn-lifemngr/life_mngr.conf.service_vm" || \
cmp -s "/etc/life_mngr/life_mngr.conf" "/usr/share/acrn-lifemngr/life_mngr.conf.user_vm" ; then
rm -f /etc/life_mngr/life_mngr.conf
# also remove an empty config directory
[ "$(ls -A /etc/life_mngr)" ] && rm -rf /etc/life_mngr
fi
;;
upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
;;
*)
echo "postrm called with unknown argument \`$1'" >&2
exit 1
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0

View File

@ -1,13 +0,0 @@
[Unit]
Description=ACRN lifemngr daemon
After=systemd-resolved.service
[Service]
Type=simple
ExecStart=/usr/share/acrn-lifemngr/start-acrn-lifemngr.sh
StandardOutput=journal
StandardError=journal
Restart=always
[Install]
WantedBy=multi-user.target

2
debian/control vendored
View File

@ -120,7 +120,7 @@ Description: Public headers and libs for ACRN
Package: acrn-lifemngr
Architecture: amd64
Depends: ${shlibs:Depends}, ${misc:Depends}
Depends: ${shlibs:Depends}, ${misc:Depends}, setserial
Suggests: acrn-doc
Description: ACRN life manager
ACRN is an open source reference hypervisor, built to meet the unique

View File

@ -1,9 +0,0 @@
# ACRN lifemngr invocation configuration file
# set the following items accordingly to override default:
# Use 'sos' or 'uos' here. Usually detect automatically.
# LIFEMNGR_VM=<vm type>
# Use the respective serial port here:
# LIFEMNGR_TTY=<serial port device>

20
debian/lifemngr/life_mngr.conf.user_vm vendored Normal file
View File

@ -0,0 +1,20 @@
# The VM type of a VM which lifecycle manager will run on
# -service_vm the lifecycle manager will be run on the service VM
# -user_vm the lifecycle manager will be run on the user VM
VM_TYPE=user_vm
# The VM name of a VM which lifecycle manager will run on, the name should
# be unique in the whole system, this name will be embedded log message to
# help user to do system debugging.
VM_NAME=user_VM
# The device type and device names of the devices which are used to
# communicate with other VMs in lifecycle manager.
# For user VM, the default value is tty:/dev/ttyS1;
#
# For service VM, the default setting rule of this field: /dev/ttyS8 is to
# communicate with VM1 (VM ID in hypervisor = 1), /dev/ttyS9 is for VM2 (VM ID is 2),
# /dev/ttyS10 is for VM3 (VM ID is 3) ... /dev/ttyS14 is for VM7 (VM ID is 7)
# note: need to double check related communication vuarts are valid in hypervisor scenario config
# file.
DEV_NAME=tty:/dev/ttyS1

View File

@ -1,14 +1,16 @@
#!/bin/sh
# helper to start ACRN lifemnr according to VM type
LIFEMNGR_CONF=/usr/share/acrn-lifemngr/acrn-lifemngr.conf
# must coincide with fixed coding in
# misc/services/life_mngr/config.h
LIFE_MNGR_CONFIG_PATH="/etc/life_mngr/life_mngr.conf"
# distinguish service/user VM
LIFEMNGR_VM=${LIFEMNGR_VM:-$(if [ -c /dev/acrn_hsm ]; then echo service_vm; else echo user_vm; fi)}
# eventually include configuration for overriding default configuration
if [ -f ${LIFEMNGR_CONF} ]; then
. ${LIFEMNGR_CONF}
# eventually install default configuration
if [ ! -f ${LIFE_MNGR_CONFIG_PATH} ]; then
mkdir -p $(dirname ${LIFE_MNGR_CONFIG_PATH})
cp /usr/share/acrn-lifemngr/life_mngr.conf.${LIFEMNGR_VM} ${LIFE_MNGR_CONFIG_PATH}
fi
LIFEMNGR_VM=${LIFEMNGR_VM:-$(if [ -c /dev/acrn_hsm ]; then echo sos; else echo uos; fi)}
LIFEMNGR_TTY=${LIFEMNGR_TTY:-/dev/ttyS1}
/usr/bin/acrn-lifemngr ${LIFEMNGR_VM} ${LIFEMNGR_TTY}
exec /usr/bin/acrn-lifemngr

24
debian/rules vendored
View File

@ -245,14 +245,26 @@ override_dh_auto_install-arch:
$(Q)$(MAKE) O=$(O)/common DESTDIR=$(DESTDIR) tools-install $(devnull)
@:
@# install life_mngr
@$(call echo-silent,INSTALL devicemodel & tools)
$(Q)install -d $(DESTDIR)$(bindir)
@# install life_mngr as acrn-lifemngr
$(Q)install -m 0755 -T $(O)/common/misc/services/life_mngr $(DESTDIR)$(bindir)/acrn-lifemngr
@# install invocation helper and config
@$(call echo-silent,INSTALL life_mngr)
$(Q)mkdir -p $(O)/common/misc
$(Q)$(MAKE) -C misc \
DESTDIR=$(DESTDIR) \
OUT_DIR=$(abspath $(O)/common/misc) \
acrn-life-mngr-install $(devnull)
@# rename to acrn-lifemngr
$(Q)mv $(DESTDIR)$(bindir)/life_mngr $(DESTDIR)$(bindir)/acrn-lifemngr
@# install config file templates
$(Q)install -d $(DESTDIR)$(datadir)/acrn-lifemngr
$(Q)mv $(DESTDIR)$(sysconfdir)/life_mngr/life_mngr.conf \
$(DESTDIR)$(datadir)/acrn-lifemngr/life_mngr.conf.service_vm
$(Q)install -m 0644 debian/lifemngr/life_mngr.conf.user_vm $(DESTDIR)$(datadir)/acrn-lifemngr
@# install invocation helper
$(Q)install -m 0755 debian/lifemngr/start-acrn-lifemngr.sh $(DESTDIR)$(datadir)/acrn-lifemngr
$(Q)install -m 0644 debian/lifemngr/acrn-lifemngr.conf $(DESTDIR)$(datadir)/acrn-lifemngr
@# adapt life_mngr.service
$(Q)mv $(DESTDIR)$(systemd_unitdir)/system/life_mngr.service \
$(DESTDIR)$(systemd_unitdir)/system/acrn-lifemngr.service
$(Q)sed -i -e 's#^ExecStart=.*#ExecStart=$(datadir)/acrn-lifemngr/start-acrn-lifemngr.sh#' \
$(DESTDIR)$(systemd_unitdir)/system/acrn-lifemngr.service
@:
@# move/adapt network configs as examples only
$(Q)mkdir -p $(DESTDIR)$(docdir)/acrnd/examples