[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: boot floppies 2.2.0 expected within 72 hours



> > I can imagine something like a ui that lets you build entries for the
> > sources list. Or at least one entry. The user could choose the aquisition
> > method (ftp, http, cdrom, nfs mount), and then answer questions based on
> > that (choose from a list of ftp/http mirrors, insert cd roms to be scanned,
> > enter nfs mountpoint and path). Then choose which sections they want (main,
> > non-free, contrib).
> 
> Yeah.

Here is a first stab at such a UI. I am using debconf as the frontend to it,
which means it can have a variety of looks and feels, including a dialog ui,
like Adam wants. To take a look at it:

* get Mirrors.masterlist out of the CVS for the debian web site (it's in
  english/mirror/).
* apt-get source debconf
* go into debconf/samples, and put aptconf.config and aptconf.templates there.
  Make sure aptconf.config is executable.
* go up one directory and run "make clean test FRONTEND=dialog PACKAGE=aptconf"

It currently handles http and ftp well; cdrom, nfs, and a mounted filesystem
need to be fleshed out. It asks if you want non-free, and if so, if you want
contrib. Then it lets you pick from a list of countries, and choose from a
list of mirrors in the country. It finishes by spitting out an apt.sources
line. There is also provision made for entering mirror data manually.

Using debconf for the frontend might be controversial, but I think it can
handle all the types of prompting we might want to add to this, except
perhaps ordering a list of sources be priority, which I doubt we want to
trouble people with anyway.

One nice features comes to light if you test it with this command:

make clean test FRONTEND=dialog PACKAGE=aptconf PRIORITY=critical

That makes it skip some of the less important questions, which happen to be
those RMS wouldn't like and those I don't think we should trouble a newbie
with. :-)

-- 
see shy jo
#!/bin/sh -e

# Where is the mirrors master list?
MIRRORLIST=~/Mirrors.masterlist

PATH=$PATH:Client
if [ -e Client/confmodule.sh ]; then
	. Client/confmodule.sh
else
	. /usr/share/debconf/confmodule.sh
fi

# Establish the preliminaries.
db_version
db_capb 'backup'
db_title 'Apt Configuration'

# Ask some unreleated questions to get started.
db_beginblock
db_input low aptconf/distribution
db_input critical aptconf/uri_type
db_input medium aptconf/non-free
db_endblock
db_go

# If they choose to use non-free, ask about contrib.
# Doesn't seem to make much sense to even ask, otherwise.
db_get aptconf/non-free
if [ "$RET" = true ]; then
	db_input medium aptconf/contrib
	db_go
fi

# If they selected http or ftp, prompt them for a mirror.
db_get aptconf/uri_type
URI="$RET"
if [ "$URI" = http -o "$URI" = ftp ]; then
	# Come up with a list of countries that match the mirror
	# type that was selected.
	COUNTRIES=`perl -ne '
			BEGIN { $/="\n\n"; $type=shift }
			if (/Archive-$type:/) {
				($c)=/Country: (.*?)\s*\n/;
				$countries{$c}=1 if $c;
			}
			END { print join(", ", sort(keys %countries)) }
		' $URI $MIRRORLIST`
	db_subst aptconf/country countries "$COUNTRIES"
	db_input critical aptconf/country
	db_go
	
	db_get aptconf/country
	if [ "$RET" != "enter information manually" ]; then
		# Now come up with a list of mirrors in the selected country.
		# It is ordered with push mirrors at top.
		MIRRORS=`perl -ne '
			BEGIN { $/="\n\n"; $type=shift; $country=shift }
			if (/Archive-$type:/ && /Country: $country\s*\n/) {
				($s)=/Site: (.*?)\n/;
				($t)=/Type: (.*?)\n/;
				$rating=0;
				$rating=1 if $t=~/push/i;
				$rating=2 if $t=~/push-primary/i;
				$mirrors{$s}=$rating;
			}
			END { print join(", ", 
				sort { $mirrors{$b} <=> $mirrors{$a} }
				(keys %mirrors)) }
		' $URI "$RET" $MIRRORLIST`
		db_subst aptconf/mirror mirrors "$MIRRORS"
		db_input critical aptconf/mirror
		db_go
		
		# Now at last we have the mirror. Get the
		# server name and the directory the mirror is in, 
		# and set two questions to them.
		db_get aptconf/mirror
		MIRROR="$RET"
		db_set aptconf/hostname $MIRROR
		db_set aptconf/directory `perl -ne '
			BEGIN { $/="\n\n"; $type=shift; $mirror=shift }
			if (/Archive-$type: (.*)\n/) {
				print $1;
				exit;
			}
		' $URI $MIRROR $MIRRORLIST`
	fi	
fi

# If they selected nfs, or they decided to enter mirror info
# manually, prompt for hostname and directory mirror is in.
db_get aptconf/country
if [ "$RET" = "enter information manually" -o "$URI" = nfs ]; then
	db_beginblock
	db_input critical aptconf/hostname
	db_input critical aptconf/directory
	db_endblock
	db_go
fi

# TODO: handle nfs automounting
# TODO: handle URI = filesystem
# TODO: handle filesystem automounting

# Now we have all the information we need. Spit out the resulting entry.
if [ "$URI" = nfs ]; then
	URI=file
fi

db_get aptconf/hostname
HOST="$RET"
db_get aptconf/directory
DIR="$RET"
db_get aptconf/distribution
DIST="$RET"
db_get aptconf/non-free
if [ "$RET" = true ]; then
	NONFREE="non-free"
fi
db_get aptconf/contrib
if [ "$RET" = true ]; then
	CONTRIB="contrib"
fi

if [ "$URI" = ftp -o "$URI" = http ]; then
	SEP=//
fi

echo "deb $URI:$SEP$HOST$DIR $DIST main $NONFREE $CONTRIB"
Template: aptconf/uri_type
Type: select
Choices: cdrom, http, ftp, nfs, filesystem
Default: cdrom
Description: Choose what method apt will use to access the Debian archive
 Apt can access the Debian archive in a variety of ways. Choose the access
 method apt should use. For example if you have a Debian cd, select "cdrom",
 while if you plan to install via a Debian mirror, choose "ftp" or "http".

Template: aptconf/country
Type: select
Choices: ${countries}, enter information manually
Default: US
Description: Select your country
 The first step in choosing what Debian mirror you use is selecting your
 country. If your country is not on this list, select a neighboring
 country. The goal is to find a mirror that is close to you on the network.
 .
 If you want to enter mirror information manually, select the last item on
 the list.

Template: aptconf/mirror
Type: select
Choices: ${mirrors}
Description: Choose the debian mirror to use
 Select the debian mirror apt should use. You should select a mirror that
 is close to you on the net.

Template: aptconf/hostname
Type: string
Description: Enter mirror hostname
 Enter the hostname of the mirror you want to use.

Template: aptconf/directory
Type: string
Default: /debian
Description: Enter mirror directory
 Enter the directory the mirror is located in.

Template: aptconf/non-free
Type: boolean
Default: false
Description: Use non-free software?
 Debian makes available some non-free software. though this software is not
 part of Debian proper, it can be installed with apt. This software has
 limitations on its distribution, modification, and/or use. Do you wish to
 use this software?

Template: aptconf/contrib
Type: boolean
Default: false
Description: Use contrib software?
 Debian includes some software that, while free, does not work without other,
 non-free software. Do you wish to use this software?

Template: aptconf/distribution
Type: select
Choices: stable, unstable
Default: stable
Description: Select Debian distribution to use
 Debian comes in two flavors. Stable is well-tested and rarely changes.
 Unstable is untested and frequently changing. Which of the two do you wish
 to install?

Reply to: