Browse Source

Temporarily revert progress/cancelation changes as they are not ready for release

r50782
tags/0.32
Frans Pop 13 years ago
parent
commit
b4aa7d758b
7 changed files with 30 additions and 117 deletions
  1. +3
    -17
      README
  2. +6
    -24
      apt-setup
  3. +16
    -57
      apt-setup-verify
  4. +1
    -15
      debian/changelog
  5. +2
    -2
      generators/50mirror
  6. +1
    -1
      generators/91security
  7. +1
    -1
      generators/92volatile

+ 3
- 17
README View File

@@ -6,12 +6,11 @@ is passed the name of a temporary file that it can write sources.list lines
(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 works, and it will be
on it to verify that each line of the sources 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 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.
exits nonzero if all deb and deb-src lines in the file failed.

Generators should add both "deb" lines and corresponding
deb-src lines to the sources.list. apt-setup-verify will handle commenting
@@ -26,21 +25,8 @@ after the first dot (if any) will also be removed when constructing the
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 the progress bar
will not be moved. Use --from and --to options to override this. The values
of these options will be used as start and end points for the progress bar;
each source line to be tested will get an equal share. The resulting values
are passed on to debconf-apt-progress.
For example:
apt-setup-verify --from 1 --to 100 <file>

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
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
and all sources.list validation will occur inside the chroot.



+ 6
- 24
apt-setup View File

@@ -2,6 +2,7 @@
set -e

. /usr/share/debconf/confmodule
db_capb backup

gendir=/usr/lib/apt-setup/generators

@@ -32,40 +33,24 @@ warning() {
log "warning: $@"
}

gencount=$(ls "$gendir"/* | wc -l)
db_capb backup progresscancel
db_progress START 0 $(expr $gencount \* 200) apt-setup/progress/title

PROGRESS_FROM=0
PROGRESS_TO=100
export PROGRESS_FROM
export PROGRESS_TO

progress_advance() {
db_progress SET $PROGRESS_TO || true
PROGRESS_FROM=$PROGRESS_TO
PROGRESS_TO=$(expr $PROGRESS_FROM + 100)
}
gencount=`ls "$gendir"/* | wc -l`
db_progress START 0 $gencount apt-setup/progress/title

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 || true
db_progress INFO apt-setup/progress/fallback
fi
tmp=$($chroot $ROOT tempfile)

code=0
$generator $ROOT$tmp || code=$?
progress_advance

case $code in
0)
if ! apt-setup-verify \
--from $PROGRESS_FROM --to $PROGRESS_TO \
$ROOT$tmp $ROOT/etc/apt/sources.list.new; then
if ! apt-setup-verify $ROOT$tmp $ROOT/etc/apt/sources.list.new; then
warning "$generator output did not verify"
fi
;;
@@ -78,7 +63,6 @@ for generator in $gendir/*; do
log "$generator backed up"
rm -f $ROOT$tmp $ROOT/etc/apt/sources.list.new
db_progress STOP
db_capb backup
exit 10
;;
*)
@@ -86,8 +70,7 @@ for generator in $gendir/*; do
;;
esac
rm -f $ROOT$tmp

progress_advance
db_progress STEP 1
done
mv $ROOT/etc/apt/sources.list.new $ROOT/etc/apt/sources.list
if [ -s $ROOT/etc/apt/apt.conf.new ]; then
@@ -97,4 +80,3 @@ else
fi

db_progress STOP
db_capb backup

+ 16
- 57
apt-setup-verify View File

@@ -6,46 +6,22 @@ NL="
"

NOTEST=""
PROGRESS=""
PROGRESS_FROM=""
PROGRESS_TO=""
while [ "$1" ]; do
case "$1" in
--invalid)
NOTEST=1 ;;
--from)
shift
PROGRESS_FROM=$1 ;;
--to)
shift
PROGRESS_TO=$1 ;;
*)
if [ -z "$file" ]; then
file="$1"
else
saveto="$1"
fi ;;
esac
if [ "$1" = "--invalid" ]; then
NOTEST=1
shift
done

if [ "$PROGRESS_FROM" ] && [ "$PROGRESS_TO" ] && \
[ $PROGRESS_FROM -lt $PROGRESS_TO ]; then
PROGRESS=1
else
DAP_OPTS="--no-progress"
fi

file="$1"
saveto="$2"

logoutput=""
if [ "$CATCHLOG" ]; then
logoutput="log-output -t apt-setup"
fi

chroot=
intarget=
if [ "$ROOT" ]; then
chroot=chroot
intarget=in-target
fi

saveline () {
@@ -55,20 +31,16 @@ saveline () {
}

valid () {
local line="$1"
local dap_opts="$2"
line="$1"

[ "${line%%:*}" != "deb cdrom" ] || return 0

tmp=$($chroot $ROOT tempfile)
echo "$line" > $ROOT$tmp
code=0
$logoutput $intarget debconf-apt-progress --logstderr $dap_opts -- \
apt-get -o APT::Get::List-Cleanup=false \
-o Dir::Etc::sourcelist=$tmp $ASV_TIMEOUT update || code=$?
if [ $code -eq 30 ]; then
exit 30 # canceled
elif [ $code -eq 0 ]; then
if $logoutput $chroot $ROOT apt-get -o APT::Get::List-Cleanup=false \
-o Dir::Etc::sourcelist=$tmp $ASV_TIMEOUT update
then
rm -f $ROOT$tmp
else
rm -f $ROOT$tmp
@@ -76,11 +48,6 @@ valid () {
fi
}

if [ "$PROGRESS" ]; then
tot_items=$(grep -Ev "^(#.*|)[[:space:]]*$" $file | wc -l)
p_from=$PROGRESS_FROM
fi

items=0
gooditems=0

@@ -91,23 +58,15 @@ IFS="$NL"
for line in $(sed 's/^/:/' $file); do
IFS="$OLDIFS"
line="${line#:}"
if echo "$line" | grep -Evq "^(#.*|)[[:space:]]*$"; then
items=$(expr $items + 1)
if expr "$line" : '.*[^ ].*' >/dev/null && [ "$(expr "$line" : "#")" != 1 ]; then
items=$(expr "$items" + 1)
# Write blank line between generators
if [ $items = 1 ] && [ -f "$saveto" ]; then
saveline ""
fi

if [ "$PROGRESS" ]; then
[ $items -eq 1 ] || p_from=$p_to
p_to=$(expr $PROGRESS_FROM + \
\( $PROGRESS_TO - $PROGRESS_FROM \) \* \
$items / $tot_items)
DAP_OPTS="--dlwaypoint 100 --from $p_from --to $p_to"
fi

if [ -z "$NOTEST" ] && valid "$line" "$DAP_OPTS"; then
gooditems=$(expr $gooditems + 1)
if [ -z "$NOTEST" ] && valid "$line"; then
gooditems=$(expr "$gooditems" + 1)
saveline "$line"
else
saveline "# Line commented out by installer because it failed to verify:"
@@ -115,12 +74,12 @@ for line in $(sed 's/^/:/' $file); do
fi
else
# Ignore leading empty lines
if [ $items -ne 0 ] || [ "$line" ]; then
if [ $items != 0 ] || [ "$line" ]; then
saveline "$line"
fi
fi
done

if [ $gooditems -ne $items ]; then
if [ "$gooditems" != "$items" ]; then
exit 1
fi

+ 1
- 15
debian/changelog View File

@@ -16,26 +16,12 @@ apt-setup (1:0.32) UNRELEASED; urgency=low
Requires apt (0.7.9) in testing for #448187 and #448521, and requires
pkgsel (1.16) and di-utils (1.50).

[ Joey Hess ]
* Put apt downloading info in the progress bar.
* Allocate 100 steps on the progress bar for each generator,
and 100 steps for verifying each generated block.
* 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.
* 50mirror: Call choose-mirror -n to avoid trashing the progress bar.
* Needs debconf 1.5.17.

[ Colin Watson ]
* Strip 'deb ' from the start of apt-setup/local*/repository, just in case
somebody copies and pastes from an existing sources.list; see also
#420894.

-- Joey Hess <joeyh@debian.org> Sat, 03 Nov 2007 17:10:03 -0400
-- Frans Pop <fjp@debian.org> Sat, 03 Nov 2007 19:19:35 +0100

apt-setup (1:0.31) unstable; urgency=low



+ 2
- 2
generators/50mirror View File

@@ -184,7 +184,7 @@ while [ ! "$done" ]; do

echo "deb $protocol://$hostname$directory $codename $dists" > $file
if apt-setup-verify --from $PROGRESS_FROM --to $PROGRESS_TO $file; then
if apt-setup-verify $file; then
done=1
else
db_set apt-setup/mirror/error Retry
@@ -192,7 +192,7 @@ while [ ! "$done" ]; do
db_go || exit 10
db_get apt-setup/mirror/error
if [ "$RET" = "Change mirror" ]; then
choose-mirror -n || true
choose-mirror || true
elif [ "$RET" = Ignore ]; then
exit 1
fi


+ 1
- 1
generators/91security View File

@@ -36,7 +36,7 @@ if db_get netcfg/dhcp_options && \
else
CODE=0
export ASV_TIMEOUT="-o Acquire::http::Timeout=30"
if ! apt-setup-verify --from $PROGRESS_FROM --to $PROGRESS_TO $file; then
if ! apt-setup-verify $file; then
db_subst apt-setup/service-failed HOST "$host"
db_input critical apt-setup/service-failed || true
if ! db_go; then


+ 1
- 1
generators/92volatile View File

@@ -42,7 +42,7 @@ if db_get netcfg/dhcp_options && \
else
CODE=0
export ASV_TIMEOUT="-o Acquire::http::Timeout=30"
if ! apt-setup-verify --from $PROGRESS_FROM --to $PROGRESS_TO $file; then
if ! apt-setup-verify $file; then
db_subst apt-setup/service-failed HOST "$host"
db_input critical apt-setup/service-failed || true
if ! db_go; then


Loading…
Cancel
Save