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

Bug#492861: Progress bar rewinds when running pre-pkgsel.d/10popcon



Package: pkgsel
Version: 0.21
Severity: minor

Before pkgsel 0.21, the progress bar had progress points between 0 and
100, with the following steps:
       0    initialization
       1    after retrieving debconf-apt-progress configuration
       1-5  installation of popcon
       5-90 tasksel
   or  5-95 (empty pkgsel-include)
      90-95 installation of packages in pkgsel/include
      95    cleanup
      97    scrollkeeper and fontconfig update
     100    end

pkgsel 0.21 added a system upgrade step.  It is actually run before the
execution of pre-pkgsel.d hooks, but progresses between 5 and 10.

As pre-pkgsel.d/10popcon is ran after this, the progress bar currently
goes back to 1, progress to 5, and jumps to 10 when tasksel starts.

One solution to solve this would be to change the API of pre-pkgsel.d
scripts.  They could have the current progress step as their
command-line argument and echo the standard output the new progress
step.

Attached is a patch set implementing this solution.  The last patch adds
a default stepping by 1 for each pre-pkgsel.d script.  I thought it was
a nice addition and it can easily be removed.

What do you think?

PS : I have been playing a little more with this idea, and we could
     probably manage to convert all pkgsel steps to individual scripts
     in a pkgsel.d directory by extending this idea a little bit
     further.  But that's beyond Lenny.

Cheers,
-- 
Jérémy Bobbio                        .''`. 
lunar@debian.org                    : :Ⓐ  :  # apt-get install anarchism
                                    `. `'` 
                                      `-   
commit 79c6f7b7eca7ad0ad3805950da87ea9a3f011221
Author: Jérémy Bobbio <lunar@debian.org>
Date:   Tue Jul 29 14:44:27 2008 +0200

    Handle progress bar moves in pre-pkgsel.d scripts
    
    pre-pkgsel.d scripts are now given the current progress bar
    position as their first argument.  They can optionally return the new
    progress bar position as the last line of their standard output.
    
    This will allow other pre-pkgsel.d scripts and the rest of pkgsel to
    know the current progress bar position.

diff --git a/installer/doc/devel/available-hooks.txt b/installer/doc/devel/available-hooks.txt
index e7a3f81..8ceca50 100644
--- a/installer/doc/devel/available-hooks.txt
+++ b/installer/doc/devel/available-hooks.txt
@@ -36,6 +36,9 @@ This list is probably incomplete.
     tasks (tasksel-data) from source added during apt-setup.
     Using the installation CD and thus installing udebs is not possible
     in these scripts (but should also not be needed).
+    Those scripts are called with the current progress bar position as
+    their first argument.  If the progress bar is moved forward, the new
+    position should be printed as the last line of the standard output.
 
 /usr/lib/finish-install.d/* [finish-install]
     The files in this directory are executed in sequence at the end of
diff --git a/packages/pkgsel/debian/changelog b/packages/pkgsel/debian/changelog
index 6ac9335..f705c3c 100644
--- a/packages/pkgsel/debian/changelog
+++ b/packages/pkgsel/debian/changelog
@@ -1,8 +1,14 @@
 pkgsel (0.22) UNRELEASED; urgency=low
 
+  [ Frans Pop ]
   * Disable system upgrades for Etch installs as upgrade options used are
     incompatible with the Etch version of aptitude. Closes: #492593.
 
+  [ Jérémy Bobbio ]
+  * pre-pkgsel.d scripts are now given the current progress bar position as
+    their first argument.  They can optionally return the new progress bar
+    position as the last line of their standard output.
+
  -- Frans Pop <fjp@debian.org>  Sun, 27 Jul 2008 18:24:15 +0200
 
 pkgsel (0.21) unstable; urgency=low
diff --git a/packages/pkgsel/debian/postinst b/packages/pkgsel/debian/postinst
index b959f98..74b8bb4 100755
--- a/packages/pkgsel/debian/postinst
+++ b/packages/pkgsel/debian/postinst
@@ -90,6 +90,7 @@ else
 	tasksel_start=10
 fi
 
+progress_from=$tasksel_start
 partsdir="/usr/lib/pre-pkgsel.d"
 if [ -d "$partsdir" ]; then
 	for script in `ls "$partsdir"/* 2>/dev/null`; do
@@ -100,16 +101,21 @@ if [ -d "$partsdir" ]; then
 		fi
 		if [ -x "$script" ] ; then
 			# be careful to preserve exit code
-			if log-output -t pkgsel "$script"; then
+			if progress_to=$(log-output -t pkgsel --pass-stdout \
+					"$script" $progress_from | tail -n 1); then
 				:
 			else
 				warning "$script returned error code $?"
 			fi
+			if [ "$progress_to" -gt $progress_from ]; then
+				progress_from=$progress_to
+			fi
 		else
 			error "Unable to execute $script"
 		fi
 	done
 fi
+tasksel_start=$progress_from
 
 db_get pkgsel/include
 if [ "$RET" ]; then

commit 479f7fff673ec3109fc2d0fc67b7a16b15661489
Author: Jérémy Bobbio <lunar@debian.org>
Date:   Tue Jul 29 14:53:28 2008 +0200

    Fix progress moving backward on pre-pkgsel.d/10popcon
    
    Since pkgsel 0.21 and the addition of the upgrade step, the progress bar
    was moving backward when pre-pkgsel.d/10popcon was run.
    
    Use the new pre-pkgsel.d API to dynamically compute the progress bar
    position in pre-pkgsel.d/10popcon and adjust the progress bar position
    for the upgrade step.

diff --git a/packages/pkgsel/debian/changelog b/packages/pkgsel/debian/changelog
index f705c3c..d69e6dd 100644
--- a/packages/pkgsel/debian/changelog
+++ b/packages/pkgsel/debian/changelog
@@ -8,6 +8,8 @@ pkgsel (0.22) UNRELEASED; urgency=low
   * pre-pkgsel.d scripts are now given the current progress bar position as
     their first argument.  They can optionally return the new progress bar
     position as the last line of their standard output.
+  * Use the new pre-pkgsel.d API to fix the progress bar moving backward on
+    pre-pkgsel.d/10popcon script since 0.21.
 
  -- Frans Pop <fjp@debian.org>  Sun, 27 Jul 2008 18:24:15 +0200
 
diff --git a/packages/pkgsel/debian/postinst b/packages/pkgsel/debian/postinst
index 74b8bb4..bcadc19 100755
--- a/packages/pkgsel/debian/postinst
+++ b/packages/pkgsel/debian/postinst
@@ -80,14 +80,14 @@ suite=$RET
 
 db_get pkgsel/upgrade
 if [ "$RET" = none ] || [ "$suite" = etch ]; then
-	tasksel_start=5
+	tasksel_start=1
 else
 	upgrade_type="$RET"
 	db_progress INFO pkgsel/progress/upgrade
 	sleep 2 # allow the message to be seen
 
-	in-target sh -c "$config debconf-apt-progress --from 5 --to 10 --logstderr -- aptitude -q --without-recommends -y -o DPkg::options=--force-confnew '$upgrade_type'" || aptfailed
-	tasksel_start=10
+	in-target sh -c "$config debconf-apt-progress --from 1 --to 6 --logstderr -- aptitude -q --without-recommends -y -o DPkg::options=--force-confnew '$upgrade_type'" || aptfailed
+	tasksel_start=6
 fi
 
 progress_from=$tasksel_start
diff --git a/packages/pkgsel/pre-pkgsel.d/10popcon b/packages/pkgsel/pre-pkgsel.d/10popcon
index c17d1e4..2b53f77 100755
--- a/packages/pkgsel/pre-pkgsel.d/10popcon
+++ b/packages/pkgsel/pre-pkgsel.d/10popcon
@@ -2,13 +2,17 @@
 
 set -e
 
+progress_from="$1"
+progress_to=$(($progress_from + 4))
+
 # get debconf-apt-progress config, which will make it run properly later
 config=$(chroot /target debconf-apt-progress --config| sed "s/$/;/")
 
 # Install popularity-contest but remove it if the user decides not to
 # participate.
-if in-target sh -c "$config debconf-apt-progress --from 1 --to 5 --logstderr -- apt-get -o APT::Install-Recommends=false -q -y -f install popularity-contest"; then
+if in-target sh -c "$config debconf-apt-progress --from $progress_from --to $progress_to --logstderr -- apt-get -o APT::Install-Recommends=false -q -y -f install popularity-contest"; then
 	if ! grep -q '^PARTICIPATE=\"*yes\"*' /target/etc/popularity-contest.conf; then
 		in-target dpkg --purge popularity-contest
 	fi
 fi
+echo $progress_to

commit c4ba955019b129452129007b75304e3b520bb331
Author: Jérémy Bobbio <lunar@debian.org>
Date:   Tue Jul 29 14:48:53 2008 +0200

    Step progress by 1 as default for pre-pkgsel.d scripts
    
    When a pre-pkgsel.d script does not return a new progress bar position,
    the progress bar will be moved one step forward for an extra visual
    feedback.

diff --git a/packages/pkgsel/debian/changelog b/packages/pkgsel/debian/changelog
index d69e6dd..673c607 100644
--- a/packages/pkgsel/debian/changelog
+++ b/packages/pkgsel/debian/changelog
@@ -10,6 +10,8 @@ pkgsel (0.22) UNRELEASED; urgency=low
     position as the last line of their standard output.
   * Use the new pre-pkgsel.d API to fix the progress bar moving backward on
     pre-pkgsel.d/10popcon script since 0.21.
+  * When a pre-pkgsel.d script does not return a new progress bar position,
+    move the progress bar one step forward.
 
  -- Frans Pop <fjp@debian.org>  Sun, 27 Jul 2008 18:24:15 +0200
 
diff --git a/packages/pkgsel/debian/postinst b/packages/pkgsel/debian/postinst
index bcadc19..9c0c989 100755
--- a/packages/pkgsel/debian/postinst
+++ b/packages/pkgsel/debian/postinst
@@ -109,6 +109,10 @@ if [ -d "$partsdir" ]; then
 			fi
 			if [ "$progress_to" -gt $progress_from ]; then
 				progress_from=$progress_to
+			else
+				# Move one step forward by default
+				db_progress STEP 1
+				progress_from=$(($progress_from + 1))
 			fi
 		else
 			error "Unable to execute $script"

Attachment: signature.asc
Description: Digital signature


Reply to: