debian: acrn-hypervisor: Refactor debconf
Tracked-On: #6688 Signed-off-by: Helmut Buchsbaum <helmut.buchsbaum@opensource.tttech-industrial.com>
This commit is contained in:
parent
e49f18f1f3
commit
46416f9fc4
|
@ -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
|
|
@ -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
|
||||
|
|
@ -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}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 ###############################################################
|
||||
|
|
Loading…
Reference in New Issue