4 . /usr/share/debconf/confmodule
6 db_capb backup # allow to go back, for that we implement that STATE loop
10 [ "${DEBCONF_DEBUG:-}" != "developer" ] || echo -e "D: $*" >&2
13 db_settitle neurodebian/title
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
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
26 neurodebian_releases="auto"
28 # This implements a simple state machine so the back button can be handled.
29 # taken from debconf demo example
31 while [ "$STATE" != 0 -a "$STATE" -lt 9 ]; do
34 # allow to be overriden by environment variable as discussed with
36 if [ ! -z "${NEURODEBIAN_ENABLE:-}" ]; then
37 case "${NEURODEBIAN_ENABLE}" in
38 true|yes|YES|1) enable=true;;
39 false|no|NO|0) enable=false;;
40 *) echo "Non-supported value $NEURODEBIAN_ENABLE of NEURODEBIAN_ENABLE env variable. Use yes or no" >&2;
43 db_set neurodebian/enable $enable
45 db_input medium neurodebian/enable || true
48 neurodebian_releases="$(ND_IFS=', ' nd-configurerepo --print-releases)"
49 debian_release="$(ND_IFS=', ' nd-configurerepo --print-release)"
50 if [ -z "$debian_release" ]; then # just a failover
53 debug "releases: $neurodebian_releases"
54 db_subst neurodebian/release releases "$neurodebian_releases"
55 db_subst neurodebian/release release "$debian_release"
56 db_input medium neurodebian/release || true
59 neurodebian_mirrors="$(ND_IFS=', ' nd-configurerepo --print-mirrors)"
60 debug "mirrors: $neurodebian_mirrors"
61 db_subst neurodebian/mirror mirrors "$neurodebian_mirrors"
62 db_input medium neurodebian/mirror || true
63 mirror_selection_ret="$RET"
64 debug "mirror select return: <$mirror_selection_ret>"
66 4) neurodebian_flavor="$(ND_IFS=', ' nd-configurerepo --print-flavor)"
67 db_subst neurodebian/flavor flavor "$neurodebian_flavor"
68 db_input medium neurodebian/flavor || true ;;
69 5) db_input medium neurodebian/components || true ;;
70 6) db_input low neurodebian/suffix || true ;;
71 7) db_input low neurodebian/overwrite || true ;;
72 8) db_input medium neurodebian/run-update-note || true ;;
78 db_get neurodebian/enable # get new value
79 if [ "$RET" = "false" ]; then
80 # no need to proceed with further questions
81 if /bin/ls /etc/apt/sources.list.d/neurodebian.sources*.list &>/dev/null; then
82 # we have configuration present -- display a note about apt-get update
85 STATE=100 # just go out -- nothing to do, nothing to inform about
89 # Ubuntus managed to remove netselect "to accompany apt-netselect"
90 # https://bugs.launchpad.net/ubuntu/+source/netselect/+bug/337377
91 # So for now remove this mandatory demanding of netselect for "best", and
92 # rely on logic in nd-configurerepo to select default mirror (currently origin)
96 # db_metaget neurodebian/mirror value
97 # selected_mirror="$RET"
100 # # - separate out alias from url
101 # debug "selected mirror: $selected_mirror"
102 # if [ "$selected_mirror" = "best" ] && ! which netselect &>/dev/null; then
103 # if [ "$mirror_selection_ret" = "30 question skipped" ]; then
104 # # if the question was not even shown, we would
105 # # not get a chance to specify mirror, thus
106 # # better just fail altogether and demand intervention
107 # db_input high neurodebian/netselect-cannot-be-used
110 # db_input high neurodebian/netselect-not-found
115 STATE=$(($STATE + 1))
117 STATE=$(($STATE - 1))