]> git.donarmstrong.com Git - neurodebian.git/blob - debian/neurodebian-repository.config
BF: actually we need to aim for multiverse (not restricted) on ubuntus to decide...
[neurodebian.git] / debian / neurodebian-repository.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-repository/title
14
15 if [ "$1" = "configure" ]; then
16     # Must have been called in preinst state, so no nd-aptenable
17     # tool is yet installed, thus delay asking questions to
18     # whenever will be called in postinst state
19     which nd-aptenable 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                         export neurodebian_releases="$(ND_IFS=', ' nd-aptenable --print-releases)"
35                         debug "releases: $neurodebian_releases"
36                         db_subst neurodebian-repository/release releases "$neurodebian_releases"
37                         db_input medium neurodebian-repository/release || true
38                         ;;
39         2)
40                         export neurodebian_mirrors="$(ND_IFS=', ' nd-aptenable --print-mirrors)"
41                         debug "mirrors: $neurodebian_mirrors"
42                         db_subst neurodebian-repository/mirror mirrors "$neurodebian_mirrors"
43                         db_input medium neurodebian-repository/mirror || true
44                         mirror_selection_ret="$RET"
45                         debug "mirror select return: <$mirror_selection_ret>"
46                         ;;
47         3)  db_input medium neurodebian-repository/flavor || true ;;
48         4)  db_input medium neurodebian-repository/components || true ;;
49         5)  db_input low neurodebian-repository/overwrite || true ;;
50         6)  db_input low neurodebian-repository/suffix || true ;;
51         7)  db_input medium neurodebian-repository/run-update-note || true ;;
52     esac
53
54     if db_go; then
55 # Ubuntus managed to remove netselect "to accompany apt-netselect"
56 # https://bugs.launchpad.net/ubuntu/+source/netselect/+bug/337377
57 # So for now remove this mandatory demanding of netselect for "best", and
58 # rely on logic in nd-aptenable to select default mirror (currently origin)
59 # as the 'best'
60 #
61 #               case $STATE in
62 #                       2)
63 #                               db_metaget neurodebian-repository/mirror value
64 #                               selected_mirror="$RET"
65 #                               # TODOs:
66 #                               # - handle custom
67 #                               # - separate out alias from url
68 #                               debug "selected mirror: $selected_mirror"
69 #                               if [ "$selected_mirror" = "best" ] && ! which netselect &>/dev/null; then
70 #                                       if [ "$mirror_selection_ret" = "30 question skipped" ]; then
71 #                                               # if the question was not even shown, we would
72 #                                               # not get a chance to specify mirror, thus
73 #                                               # better just fail altogether and demand intervention
74 #                                               db_input high neurodebian-repository/netselect-cannot-be-used
75 #                                               exit 1
76 #                                       else
77 #                                               db_input high neurodebian-repository/netselect-not-found
78 #                                               continue;
79 #                                       fi
80 #                               fi
81 #               esac
82         STATE=$(($STATE + 1))
83     else
84         STATE=$(($STATE - 1))
85     fi
86 done
87
88 db_stop
89