debian: acrn-hypervisor: Refactor debconf

Tracked-On: #6688
Signed-off-by: Helmut Buchsbaum <helmut.buchsbaum@opensource.tttech-industrial.com>
This commit is contained in:
Helmut Buchsbaum 2022-05-04 19:58:37 +02:00 committed by acrnsi-robot
parent e49f18f1f3
commit 46416f9fc4
6 changed files with 59 additions and 27 deletions

View File

@ -1,13 +0,0 @@
#!/bin/sh
# Exit on error
set -e
# Source debconf library.
. /usr/share/debconf/confmodule
# query board
db_input critical acrn-hypervisor/board || true
# Show interface
db_go || true

44
debian/acrn-hypervisor.config.in vendored Normal file
View File

@ -0,0 +1,44 @@
#!/bin/bash
# inspired by http://www.fifi.org/doc/debconf-doc/tutorial.html
# Exit on error
set -e
# Source debconf library.
. /usr/share/debconf/confmodule
db_version 2.0
# This conf script is capable of backing up
db_capb backup
ACRNDIR=@acrndir@
declare -A SCENARIOS=@scenarios@
STATE="board"
while [ "$STATE" != "quit" -a "$STATE" != "done" ]; do
case "$STATE" in
board)
# query board
db_input critical acrn-hypervisor/board || true
if db_go; then
STATE="scenario"
else
STATE="quit"
fi
;;
scenario)
db_get acrn-hypervisor/board
db_subst acrn-hypervisor/scenario scenariolist ${SCENARIOS[${RET}]}
db_clear
db_input critical acrn-hypervisor/scenario || true
if db_go; then
STATE="done"
else
STATE="board"
fi
;;
esac
done
# trigger grub update
dpkg-trigger --await --by-package=acrn-hypervisor grub-acrn-update

View File

@ -11,16 +11,6 @@ ACRNDIR=@acrndir@
db_get acrn-hypervisor/board
BOARD=${RET}
SCENARIOS=$(find ${ACRNDIR}/${BOARD} -maxdepth 1 -type d \
| tail -n +2 | sed "s#${ACRNDIR}/${BOARD}/##" \
| sort | awk '{s=s (s?OFS:x) $1} END {print s}' OFS=", ")
db_subst acrn-hypervisor/scenario scenariolist ${SCENARIOS}
db_clear
db_input critical acrn-hypervisor/scenario || true
db_go || true
db_get acrn-hypervisor/scenario
SCENARIO=${RET}

View File

@ -30,9 +30,12 @@ rm_acrn()
case "$1" in
remove|purge)
remove)
rm_acrn
db_purge acrn-hypervisor || :
;;
purge)
rm_acrn
db_purge acrn-hypervisor || :
;;
upgrade)
rm_acrn

3
debian/control vendored
View File

@ -59,7 +59,8 @@ Depends:
${misc:Depends},
grub-acrn,
acrn-devicemodel,
debconf (>=1.5.71)
debconf (>=1.5.71),
bash (>=4)
Suggests: acrn-doc
Recommends: setserial
Description: ACRN Hypervisor for IoT

9
debian/rules vendored
View File

@ -165,7 +165,14 @@ debian/acrn-hypervisor.templates: debian/acrn-hypervisor.templates.in
@$(call echo-silent,CREATE $@)
$(Q)sed -e 's/@boardlist@/$(call commasep,$(boardlist))/g' $< > $@
override_dh_installdebconf-arch: debian/acrn-hypervisor.templates
debian/acrn-hypervisor.config: debian/acrn-hypervisor.config.in
@$(call echo-verbose)
@$(call echo-silent,CREATE $@)
@# create scenarios as bash associative array
$(Q)sed -e 's%@acrndir@%$(libdir)/acrn%g' \
-e 's%@scenarios@%($(foreach b,$(boardlist),[$b]="$(call commasep,$(scenariolist_$b))"))%g' $< > $@
override_dh_installdebconf-arch: debian/acrn-hypervisor.templates debian/acrn-hypervisor.config
$(Q)dh_installdebconf -a
### build-arch ###############################################################