]> git.donarmstrong.com Git - neurodebian.git/blob - debian/neurodebian.config
ENH: report to debconf interface what would be the release/flavor to be used if ...
[neurodebian.git] / debian / neurodebian.config
1 #!/bin/bash
2 set -e
3
4 . /usr/share/debconf/confmodule
5
6 db_capb backup # allow to go back, for that we implement that STATE loop
7
8 debug()
9 {
10     [ "${DEBCONF_DEBUG:-}" != "developer" ] || echo -e "D: $*" >&2
11 }
12
13 db_settitle neurodebian/title
14
15 if [ "$1" = "configure" ]; then
16     # Must have been called in preinst state, so no nd-configurerepo
17     # tool is yet installed, thus delay asking questions to
18     # whenever will be called in postinst state
19     which nd-configurerepo 1>/dev/null 2>&1 || exit 0
20 fi
21
22 # Create temporary directory which will be reused
23 export ND_AE_TEMPDIR=$(mktemp -d)
24 trap "rm -rf \"$ND_AE_TEMPDIR\"" TERM INT EXIT
25
26 neurodebian_releases="auto"
27
28 # This implements a simple state machine so the back button can be handled.
29 # taken from debconf demo example
30 STATE=1
31 while [ "$STATE" != 0 -a "$STATE" != 8 ]; do
32     case $STATE in
33         1)
34                         neurodebian_releases="$(ND_IFS=', ' nd-configurerepo --print-releases)"
35                         debian_release="$(ND_IFS=', ' nd-configurerepo --print-release)"
36                         if [ -z "$debian_release" ]; then # just a failover
37                                 debian_release="sid"
38                         fi
39                         debug "releases: $neurodebian_releases"
40                         db_subst neurodebian/release releases "$neurodebian_releases"
41                         db_subst neurodebian/release release  "$debian_release"
42                         db_input medium neurodebian/release || true
43                         ;;
44         2)
45                         neurodebian_mirrors="$(ND_IFS=', ' nd-configurerepo --print-mirrors)"
46                         debug "mirrors: $neurodebian_mirrors"
47                         db_subst neurodebian/mirror mirrors "$neurodebian_mirrors"
48                         db_input medium neurodebian/mirror || true
49                         mirror_selection_ret="$RET"
50                         debug "mirror select return: <$mirror_selection_ret>"
51                         ;;
52         3)  neurodebian_flavor="$(ND_IFS=', ' nd-configurerepo --print-flavor)"
53                         db_subst neurodebian/flavor flavor "$neurodebian_flavor"
54                         db_input medium neurodebian/flavor || true ;;
55         4)  db_input medium neurodebian/components || true ;;
56         5)  db_input low neurodebian/overwrite || true ;;
57         6)  db_input low neurodebian/suffix || true ;;
58         7)  db_input medium neurodebian/run-update-note || true ;;
59     esac
60
61     if db_go; then
62 # Ubuntus managed to remove netselect "to accompany apt-netselect"
63 # https://bugs.launchpad.net/ubuntu/+source/netselect/+bug/337377
64 # So for now remove this mandatory demanding of netselect for "best", and
65 # rely on logic in nd-configurerepo to select default mirror (currently origin)
66 # as the 'best'
67 #
68 #               case $STATE in
69 #                       2)
70 #                               db_metaget neurodebian/mirror value
71 #                               selected_mirror="$RET"
72 #                               # TODOs:
73 #                               # - handle custom
74 #                               # - separate out alias from url
75 #                               debug "selected mirror: $selected_mirror"
76 #                               if [ "$selected_mirror" = "best" ] && ! which netselect &>/dev/null; then
77 #                                       if [ "$mirror_selection_ret" = "30 question skipped" ]; then
78 #                                               # if the question was not even shown, we would
79 #                                               # not get a chance to specify mirror, thus
80 #                                               # better just fail altogether and demand intervention
81 #                                               db_input high neurodebian/netselect-cannot-be-used
82 #                                               exit 1
83 #                                       else
84 #                                               db_input high neurodebian/netselect-not-found
85 #                                               continue;
86 #                                       fi
87 #                               fi
88 #               esac
89         STATE=$(($STATE + 1))
90     else
91         STATE=$(($STATE - 1))
92     fi
93 done
94
95 db_stop
96