debian/: Add packaging support.
[runlisp] / debian / runlisp.config
1 #! /bin/sh -e
2
3 . /usr/share/debconf/confmodule
4 db_capb backup
5
6 ## Main state machine.
7 state=0
8 while :; do
9 case $state in
10
11 0)
12 db_input medium runlisp/dump-custom-images || :
13 ;;
14
15 1)
16 db_get runlisp/dump-custom-images
17 case $RET in select) ;; *) state=2; continue ;; esac
18
19 ## Determine the configured Lisp systems.
20 sects=$(query-runlisp-config -LM)
21 unset lisps
22 for s in $sects; do
23 case $s in @*) continue ;; esac
24 if ! query-runlisp-config -M -p$s:dump-image >/dev/null 2>&1
25 then continue; fi
26 lisps=${lisps+$lisps, }$s
27 done
28 db_subst runlisp/selected-implementations lisps "$lisps"
29
30 ## See if the list has changed recently.
31 db_get runlisp/available-implementations
32 case $RET in
33 "$lisps")
34 ch=nil prio=medium
35 ;;
36 *)
37 ch=t prio=high
38 db_set runlisp/available-implementations "$lisps"
39 ;;
40 esac
41
42 ## Filter nonexistent implementations from the active list.
43 db_get runlisp/selected-implementations
44 case $RET in
45 -)
46 v=$lisps
47 ;;
48 *)
49 unset v
50 for i in $(echo "$RET" | tr , " "); do
51 case " $lisps," in *" $i,"*) v=${v+$v, }$i ;; esac
52 done
53 ;;
54 esac
55 db_set runlisp/selected-implementations "$v"
56 case $ch in
57 t) db_fset runlisp/selected-implementations seen false ;;
58 esac
59 db_input $prio runlisp/selected-implementations || :
60 ;;
61
62 -1)
63 exit 10
64 ;;
65 *)
66 break
67 ;;
68 esac
69
70 set +e; db_go; rc=$?; set -e
71 case $rc in
72 0) state=$(( $state + 1 )) ;;
73 30) state=$(( $state - 1 )) ;;
74 *) exit $rc ;;
75 esac
76 done