Here'a an attempt at cancelable progress bars for apt-setup. If apt's bug gets fixed the progress bar will also include download speed and time estimates. The behavior when cancel is pressed could be improved, it currently behaves the same as if the apt source failed to validate, which typically loops back and lets the user try it again. I ran out of time to do any testing. -- see shy jo
Index: debian/changelog =================================================================== --- debian/changelog (revision 49947) +++ debian/changelog (working copy) @@ -1,3 +1,20 @@ +apt-setup (1:0.31) UNRELEASED; urgency=low + + * Allocate 100 steps on the progress bar for each generator, and + set the progress absolutely to the next position after calling each + generator. This allows generators to step the progress bar up to 100 + steps if desired. + * Export PROGRESS_FROM and PROGRESS_TO to generators, giving the + starting and ending progress bar position for that generator. This can + be used by generators that need an absolute progress bar position for + calling debconf-apt-progress. + * apt-setup-verify: Use debconf-apt-progress and add a way for generators + to specify how it should advance the progress bar. + * Allow the progress bar to be canceled (needs debconf 1.5.17 for proper + operation). + + -- Joey Hess <joeyh@debian.org> Thu, 01 Nov 2007 17:17:18 -0400 + apt-setup (1:0.30) unstable; urgency=low [ Frans Pop ] Index: apt-setup =================================================================== --- apt-setup (revision 49947) +++ apt-setup (working copy) @@ -34,14 +34,19 @@ } gencount=`ls "$gendir"/* | wc -l` -db_progress START 0 $gencount apt-setup/progress/title +db_capb backup progresscancel +db_progress START 0 $(expr "$gencount" * 100) apt-setup/progress/title +PROGRESS_FROM=0 +PROGRESS_TO=100 +export PROGRESS_FROM +export PROGRESS_TO for generator in $gendir/*; do base=$(basename $generator | sed 's/[0-9]*//') base="${base%%.*}" if ! db_progress INFO apt-setup/progress/$base; then db_subst apt-setup/progress/fallback SCRIPT "$base" - db_progress INFO apt-setup/progress/fallback + db_progress INFO apt-setup/progress/fallback || true fi tmp=$($chroot $ROOT tempfile) @@ -63,6 +68,7 @@ log "$generator backed up" rm -f $ROOT$tmp $ROOT/etc/apt/sources.list.new db_progress STOP + db_capb backup exit 10 ;; *) @@ -70,7 +76,10 @@ ;; esac rm -f $ROOT$tmp - db_progress STEP 1 + + db_progress SET $PROGRESS_TO || true + PROGRESS_FROM=$PROGRESS_TO + PROGRESS_TO=$(expr $PROGRESS_FROM + 100) done mv $ROOT/etc/apt/sources.list.new $ROOT/etc/apt/sources.list if [ -s $ROOT/etc/apt/apt.conf.new ]; then @@ -80,3 +89,4 @@ fi db_progress STOP +db_capb backup Index: apt-setup-verify =================================================================== --- apt-setup-verify (revision 49947) +++ apt-setup-verify (working copy) @@ -14,6 +14,13 @@ file="$1" saveto="$2" +while [ -n "$1" ] && [ "$1" != "--" ]; do + shift 1 +done +if [ "$1" = "--" ]; then + shift 1 +fi + logoutput="" if [ "$CATCHLOG" ]; then logoutput="log-output -t apt-setup" @@ -32,15 +39,19 @@ valid () { line="$1" + shift 1 [ "${line%%:*}" = "deb cdrom" ] || return 0 tmp=$($chroot $ROOT tempfile) echo "$line" > $ROOT$tmp - - if $logoutput $chroot $ROOT apt-get -o APT::Get::List-Cleanup=false \ - -o Dir::Etc::sourcelist=$tmp $ASV_TIMEOUT update - then + code=0 + $logoutput $chroot $ROOT debconf-apt-progress "${@:---no-progress}" + apt-get -o APT::Get::List-Cleanup=false \ + -o Dir::Etc::sourcelist=$tmp $ASV_TIMEOUT update || code = $? + if [ "$code" == 30 ]; then + exit 30 # canceled + elif [ "$code" == 0 ] then rm -f $ROOT$tmp else rm -f $ROOT$tmp @@ -65,13 +76,22 @@ saveline "" fi - if [ -z "$NOTEST" ] && valid "$line"; then + if [ -z "$NOTEST" ] && valid "$line" "$@"; then gooditems=$(expr "$gooditems" + 1) saveline "$line" else saveline "# Line commented out by installer because it failed to verify:" saveline "#$line" fi + + # shift away remaining options to avoid passing them + # to debconf-apt-progress a second time. + while [ -n "$1" ] && [ "$1" != "--" ]; do + shift 1 + done + if [ "$1" = "--" ]; then + shift 1 + fi else # Ignore leading empty lines if [ $items != 0 ] || [ "$line" ]; then Index: generators/50mirror =================================================================== --- generators/50mirror (revision 49947) +++ generators/50mirror (working copy) @@ -184,7 +184,7 @@ echo "deb $protocol://$hostname$directory $codename $dists" > $file - if apt-setup-verify $file; then + if apt-setup-verify $file -- --from $PROGRESS_FROM --to $PROGRESS_TO; then done=1 else db_set apt-setup/mirror/error Retry Index: generators/91security =================================================================== --- generators/91security (revision 49947) +++ generators/91security (working copy) @@ -36,7 +36,7 @@ else CODE=0 export ASV_TIMEOUT="-o Acquire::http::Timeout=30" - if ! apt-setup-verify $file; then + if ! apt-setup-verify $file --from $PROGRESS_FROM --to $PROGRESS_TO; then db_subst apt-setup/service-failed HOST "$host" db_input critical apt-setup/service-failed || true if ! db_go; then Index: generators/92volatile =================================================================== --- generators/92volatile (revision 49947) +++ generators/92volatile (working copy) @@ -42,7 +42,7 @@ else CODE=0 export ASV_TIMEOUT="-o Acquire::http::Timeout=30" - if ! apt-setup-verify $file; then + if ! apt-setup-verify $file --from $PROGRESS_FROM --to $PROGRESS_TO; then db_subst apt-setup/service-failed HOST "$host" db_input critical apt-setup/service-failed || true if ! db_go; then Index: README =================================================================== --- README (revision 49947) +++ README (working copy) @@ -6,11 +6,12 @@ (and comments) to. After the generator finishes writing the file, apt-setup-verify will be run -on it to verify that each line of the sources sources works, and it will be +on it to verify that each line of the sources works, and it will be added to the sources.list. Generators can also run apt-setup-verify themselves and do their own error recovery if it fails. apt-setup-verify tests each line of the file and comments out lines that do not work, and -exits nonzero if all deb and deb-src lines in the file failed. +exits zero if all deb and deb-src lines in the file are ok, 30 if the +verification process was canceled, and otherwise nonzero on error. Generators should add both "deb" lines and corresponding deb-src lines to the sources.list. apt-setup-verify will handle commenting @@ -25,6 +26,17 @@ progress template name, so that different scripts that share the same purpose can easily be written. +Generators can advance the progress bar from PROGRESS_FROM up to +PROGRESS_TO, or it will be moved to the next step before the next +generator is started. + +apt-setup-verify runs apt-get update inside debconf-apt-progress, to update +the progress bar with apt progress information. By default, +debconf-apt-progress is not allowed to move the progress bar. To override +this, pass apt-setup-verify options after "--"; these options will be +passed on to debconf-apt-progress. For example: + apt-setup-verify file -- --from 1 --to 100 + Note that apt-setup and its generators may be run against some other system in a chroot. (i.e., when installing Debian.) If apt-setup is running this way, then ROOT will be set to the root of the chroot that it is acting on
Attachment:
signature.asc
Description: Digital signature