Pre-depends: neurodebian-keyring, python-minimal, wget
Depends: ${misc:Depends}
Recommends: netselect
-Description: installer of the NeuroDebian APT repository
+Description: NeuroDebian APT repository installer
Besides making (neuro)scientific software available on stock Debian
systems, neuro.debian.net (and mirrors around the globe) provides
a repository with backport builds of the NeuroDebian-maintained
--- /dev/null
+#!/bin/bash
+set -e
+
+. /usr/share/debconf/confmodule
+
+db_capb backup # allow to go back, for that we implement that STATE loop
+
+debug()
+{
+ [ "${DEBCONF_DEBUG:-}" != "developer" ] || echo -e "D: $*" >&2
+}
+
+db_settitle neurodebian-repository/title
+
+if [ "$1" = "configure" ]; then
+ # Must have been called in preinst state, so no nd-aptenable
+ # tool is yet installed, thus delay asking questions to
+ # whenever will be called in postinst state
+ which nd-aptenable 1>/dev/null 2>&1 || exit 0
+fi
+
+# Create temporary directory which will be reused
+export ND_AE_TEMPDIR=$(mktemp -d)
+trap "rm -rf \"$ND_AE_TEMPDIR\"" TERM INT EXIT
+
+neurodebian_releases="auto"
+
+# This implements a simple state machine so the back button can be handled.
+# taken from debconf demo example
+STATE=1
+while [ "$STATE" != 0 -a "$STATE" != 8 ]; do
+ case $STATE in
+ 1)
+ export neurodebian_releases="$(ND_IFS=', ' nd-aptenable --print-releases)"
+ debug "releases: $neurodebian_releases"
+ db_subst neurodebian-repository/release releases "$neurodebian_releases"
+ db_input medium neurodebian-repository/release || true
+ ;;
+ 2)
+ export neurodebian_mirrors="$(ND_IFS=', ' nd-aptenable --print-mirrors)"
+ debug "mirrors: $neurodebian_mirrors"
+ db_subst neurodebian-repository/mirror mirrors "$neurodebian_mirrors"
+ db_input medium neurodebian-repository/mirror || true
+ mirror_selection_ret="$RET"
+ debug "mirror select return: <$mirror_selection_ret>"
+ ;;
+ 3) db_input medium neurodebian-repository/flavor || true ;;
+ 4) db_input medium neurodebian-repository/components || true ;;
+ 5) db_input low neurodebian-repository/overwrite || true ;;
+ 6) db_input low neurodebian-repository/suffix || true ;;
+ 7) db_input low neurodebian-repository/apt-update || true ;;
+ esac
+
+ if db_go; then
+ case $STATE in
+ 2)
+ db_metaget neurodebian-repository/mirror value
+ selected_mirror="$RET"
+ # TODOs:
+ # - handle custom
+ # - separate out alias from url
+ debug "selected mirror: $selected_mirror"
+ if [ "$selected_mirror" = "best" ] && ! which netselect &>/dev/null; then
+ if [ "$mirror_selection_ret" = "30 question skipped" ]; then
+ # if the question was not even shown, we would
+ # not get a chance to specify mirror, thus
+ # better just fail altogether and demand intervention
+ db_input high neurodebian-repository/netselect-cannot-be-used
+ exit 1
+ else
+ db_input high neurodebian-repository/netselect-not-found
+ continue;
+ fi
+ fi
+ esac
+ STATE=$(($STATE + 1))
+ else
+ STATE=$(($STATE - 1))
+ fi
+done
+
+db_stop
+
--- /dev/null
+tools/nd-aptenable usr/bin
--- /dev/null
+Template: neurodebian-repository/title
+Type: title
+Description: NeuroDebian APT repository installer
+
+
+Template: neurodebian-repository/release
+Type: select
+Choices: auto, ${releases}
+Default: auto
+Description: Release name of the base system
+ Specify for which Debian or Ubuntu release (e.g. wheezy or trusty).
+ .
+ If 'auto', Debian or Ubuntu release name will be deduced from
+ apt-cache policy.
+
+
+Template: neurodebian-repository/mirror
+Type: select
+Choices: origin, best, custom, ${mirrors}
+Default: best
+Description: NeuroDebian mirror to use:
+ NeuroDebian project has a number of community-maintainer mirrors
+ around the globe.
+ .
+ If you do not know which mirror URL to choose, select among
+ .
+ - origin: original NeuroDebian repository
+ - best: will try to use netselect to select "closest" mirror.
+ Depending on the configuration of the firewall, and actual mirror
+ setup, might fail to select actually closest one. netselect
+ must be installed to use this feature.
+
+
+Template: neurodebian-repository/flavor
+Type: select
+Choices: auto, libre, full
+Default: auto
+Description: NeuroDebian flavor to use:
+ NeuroDebian project adheres to Debian Free Software Guidelines and
+ has three areas of the archive in all suites/releases:
+ .
+ libre
+ only the DFSG-compliant materials
+ full
+ all three areas (main, contrib, non-free)
+ auto
+ determine which flavor to choose based on current output of
+ apt-cache policy ('full' -- if non-free or restricted
+ archives are enabled)
+
+Template: neurodebian-repository/components
+Type: multiselect
+Choices: software, data, devel
+Default: software, data
+Description: Select NeuroDebian repository components to enable
+ NeuroDebian repository provides
+ .
+ software
+ Packages containing software packages, often backports of stable
+ software releases for previous Debian/Ubuntu releases
+ devel
+ Additional "bleeding edge" software packages, which might not be a
+ good fit for being enabled by default. (Similar to Debian
+ experimental)
+ data
+ Packages containing data (e.g. atlases, sample datasets), often
+ required by software packages. Should generally be enabled.
+
+
+Template: neurodebian-repository/overwrite
+Type: boolean
+Default: true
+Description: Should existing NeuroDebian APT file be overridden?
+ If not allowed, configuration would fail if there is
+ an existing apt configuration file for the NeuroDebian.
+
+Template: neurodebian-repository/suffix
+Type: string
+Default:
+Description: Additional suffix to use in the NeuroDebian APT file name
+ For instance if you would like to enable additional repository
+ (e.g. NeuroDebian devel) or release, without interfering with the
+ main/default configuration file.
+
+Template: neurodebian-repository/apt-update
+Type: boolean
+Default: true
+Description: Should apt-get update be run to update list of packages?
+
+Template: neurodebian-repository/apt-update-failed
+Type: error
+Description: apt-get update failed
+ An attempt to update package lists of enabled APT repositories (via
+ apt-get update) has failed.
+
+Template: neurodebian-repository/netselect-not-found
+Type: error
+Description: netselect tool was not found
+ Please install netselect tool first (apt-get install netselect) or
+ choose a specific mirror.
+
+Template: neurodebian-repository/netselect-not-found
+Type: error
+Description: netselect tool was not found
+ Please install netselect tool first (apt-get install netselect) or
+ choose a specific mirror.
+
+Template: neurodebian-repository/netselect-cannot-be-used
+Type: error
+Description: netselect tool was not found (no other mirror)
+ Please install netselect tool first (apt-get install netselect)
+ before installing/configuring this package, or run with a lower
+ DEBIAN_PRIORITY to choose a specific mirror.
+
# - apt priority! (so we could avoid automagic upgrades etc)
# - multiarch setups
-ae_tempdir=$(mktemp -d)
-trap "rm -rf \"$ae_tempdir\"" TERM INT EXIT
+if [ -z "${ND_AE_TEMPDIR:-}" ]; then
+ ae_tempdir=$(mktemp -d)
+ trap "rm -rf \"$ae_tempdir\"" TERM INT EXIT
+else
+ # reuse the same directory/fetched configuration if was specified
+ ae_tempdir="${ND_AE_TEMPDIR:-}"
+fi
+nd_config_file_fresh="$ae_tempdir/neurodebian.cfg"
+
print_verbose()
{
level=$1; shift
it is deduced from the apt-cache policy output, by taking repository
of Debian or Ubuntu origin with highest priority.
+ --print-releases
+ Return a list of releases present in NeuroDebian repository.
+
-f, --flavor=full|libre
Which flavor of the repository should be enabled:
libre -- Only main component, containing only DFSG-compliant content.
Which mirror to use. Could be a mirror code-name (as specified in
/etc/neurodebian/neurodebian.cfg), or a URL.
+ --print-mirrors
+ Return a list (with abbreviation) of known NeuroDebian mirrors.
+
--overwrite,
If apt file already present, it would not be overriden (by default).
Use this option to overwrite.
get_neurodebian_cfg()
{
+ if [ -s "$nd_config_file_fresh" ]; then
+ print_verbose 3 "Config file $nd_config_file_fresh exists -- not fetching"
+ echo "$nd_config_file_fresh"
+ return 0
+ fi
# First we try to fetch the most recent version from the github
print_verbose 3 "Fetching config file from the github repository"
- cfgfile_temp="$ae_tempdir/neurodebian.cfg"
assure_command_from_package wget wget 1
- wget --no-check-certificate -c -q -O$cfgfile_temp \
+ wget --no-check-certificate -c -q -O$nd_config_file_fresh \
$nd_config_url \
- && { echo $cfgfile_temp; } \
+ && { echo "$nd_config_file_fresh"; } \
|| { [ -e "$nd_config_file" ] \
&& echo "$nd_config_file" \
|| error 10 "Neither could fetch $nd_config_url, nor found $nd_config_file"; }
{
nd_config=`get_neurodebian_cfg`
# $exe_dir/nd_querycfg -F" " --config-file="$nd_config" "mirrors" \
+ n=""
query_cfg_section "$nd_config" "mirrors" \
| while read mirror_name mirror_url; do
# verify that url is just a url
if echo "$mirror_url" | grep -v -e '^[a-z0-9:+]*://[-+_%.a-z0-9/]*$'; then
print_verbose 1 "Mirror $mirror_name has 'illegit' URL: $mirror_url. Skipping"
fi
- echo "$mirror_name $mirror_url"
+ [ -z "$n" ] || echo -ne "${ND_IFS:-\n}"; n+=1
+ echo -n "$mirror_name $mirror_url"
+ done
+}
+
+get_releases()
+{
+ nd_config=`get_neurodebian_cfg`
+ n=""
+ query_cfg_section "$nd_config" "release files" \
+ | while read release_name release_url; do
+ # verify that url is just a url
+ if [ "$release_name" = "data" ]; then
+ # skip data
+ continue
+ fi
+ [ -z "$n" ] || echo -ne "${ND_IFS:-\n}"; n+=1
+ echo -n "$release_name"
done
}
# Note that we use `"$@"' to let each command-line parameter expand to a
# separate word. The quotes around `$@' are essential!
# We need CLOPTS as the `eval set --' would nuke the return value of getopt.
-CLOPTS=`getopt -o h,r:,m:,f:,c:,q,v,n --long help,version,quiet,verbose,mirror:,release:,flavor:,components:,suffix:,overwrite,sources,no-sources,install,dry-run,print-mirrors,print-best-mirror -n 'nd-aptenable' -- "$@"`
+CLOPTS=`getopt -o h,r:,m:,f:,c:,q,v,n --long help,version,quiet,verbose,mirror:,release:,flavor:,components:,suffix:,overwrite,sources,no-sources,install,dry-run,print-releases,print-mirrors,print-best-mirror -n 'nd-aptenable' -- "$@"`
if [ $? != 0 ] ; then
error 2 "Problem with parsing cmdline. Terminating..."
-m|--mirror) shift; ae_mirror="$1"; shift;;
--print-mirrors) get_mirrors; exit 0;;
--print-best-mirror) netselect_mirror; exit 0;;
+ --print-releases) get_releases; exit 0;;
-n|--dry-run) ae_dry_run=1; shift;;
--suffix) shift; ae_suffix="$1"; shift;;
--overwrite) ae_overwrite="$1"; shift;;