On Tue, Aug 02, 2005 at 08:41:53PM +0100, Colin Watson wrote:
> I've implemented a first cut at the base-config code for this (although
> in Ubuntu base-config which uses aptitude rather than tasksel, so it
> would take a small change to port it to Debian; however I've made it
> fairly generic so I don't expect it to be difficult), which I'm testing
> at the moment.

Oh, I should post my work so far. It's in arch here:

  baz register-archive http://people.ubuntu.com/~cjwatson/archives/[EMAIL 
PROTECTED]
  baz get [EMAIL PROTECTED]/base-config--pkgsel-progress--0

... and the diff against Ubuntu's current base-config is attached. It
needs an extra versioned dependency on apt, but I don't know which
version will have Michael's progress code yet. It also doesn't wrap all
the bits of pkgsel that print output to the console, but that can come
in time.

Cheers,

-- 
Colin Watson                                       [EMAIL PROTECTED]
* finding or making [EMAIL PROTECTED]/base-config--ubuntu--0--patch-67
* finding or making [EMAIL PROTECTED]/base-config--pkgsel-progress--0--patch-5
* auto-adding [EMAIL PROTECTED]/base-config--pkgsel-progress--0--patch-5 to 
greedy revision library /home/cjwatson/.arch-revlib
* computing changeset
A/ {arch}/base-config/base-config--pkgsel-progress
A/ 
{arch}/base-config/base-config--pkgsel-progress/base-config--pkgsel-progress--0
A/ 
{arch}/base-config/base-config--pkgsel-progress/base-config--pkgsel-progress--0/[EMAIL
 PROTECTED]
A/ 
{arch}/base-config/base-config--pkgsel-progress/base-config--pkgsel-progress--0/[EMAIL
 PROTECTED]/patch-log
A  
{arch}/base-config/base-config--pkgsel-progress/base-config--pkgsel-progress--0/[EMAIL
 PROTECTED]/patch-log/base-0
A  
{arch}/base-config/base-config--pkgsel-progress/base-config--pkgsel-progress--0/[EMAIL
 PROTECTED]/patch-log/patch-1
A  
{arch}/base-config/base-config--pkgsel-progress/base-config--pkgsel-progress--0/[EMAIL
 PROTECTED]/patch-log/patch-2
A  
{arch}/base-config/base-config--pkgsel-progress/base-config--pkgsel-progress--0/[EMAIL
 PROTECTED]/patch-log/patch-3
A  
{arch}/base-config/base-config--pkgsel-progress/base-config--pkgsel-progress--0/[EMAIL
 PROTECTED]/patch-log/patch-4
A  
{arch}/base-config/base-config--pkgsel-progress/base-config--pkgsel-progress--0/[EMAIL
 PROTECTED]/patch-log/patch-5
M  debian/templates
M  debian/control
M  lib/menu/pkgsel
* changeset report
* modified files

--- orig/debian/control
+++ mod/debian/control
@@ -8,7 +8,7 @@
 
 Package: base-config
 Architecture: all
-Depends: debconf (>= 1.4.42ubuntu3), apt, adduser, console-data (>= 
2002.12.04dbs-16), console-tools, passwd (>= 20000902-6), bsdutils (>= 
1:2.11l), debianutils (>= 1.6), gettext-base
+Depends: debconf (>= 1.4.55), apt, adduser, console-data (>= 
2002.12.04dbs-16), console-tools, passwd (>= 20000902-6), bsdutils (>= 
1:2.11l), debianutils (>= 1.6), gettext-base
 Conflicts: tasksel (<< 2.25)
 Description: Debian base system configurator
  This package handles setting up the Debian base system. It contains the


--- orig/debian/templates
+++ mod/debian/templates
@@ -167,6 +167,19 @@
 Type: text
 _Description: Execute a shell
 
+Template: base-config/progress/main-title
+Type: text
+_Description: Installing packages
+
+Template: base-config/progress/main-prep
+Type: text
+_Description: Preparing to install packages...
+
+Template: base-config/progress/info
+Type: text
+# Not translated; apt emits translated descriptions for us already.
+Description: ${DESCRIPTION}
+
 Template: debian-installer/keymap
 Type: string
 Description: dummy item


--- orig/lib/menu/pkgsel
+++ mod/lib/menu/pkgsel
@@ -10,6 +10,41 @@
                /usr/bin/scrollkeeper-rebuilddb
 }
 
+# Wrap package installation in a progress bar. The nominated subprocess
+# should output apt install-status information to fd 4, and should ensure to
+# keep fds 5 and 6 open when invoking debconf (directly or indirectly), as
+# those fds will be used for the debconf passthrough protocol.
+progress () {
+       TITLE="$1"
+       PREPINFO="$2"
+       shift 2
+
+       # Create a temporary config database for use by the debconf instance
+       # responsible for displaying the progress bar. This allows it to
+       # avoid locking the normal config database, which will be needed by
+       # other debconf instances while installing packages.
+       debconf-copydb configdb progressdb -c Name:progressdb -c Driver:File \
+               -c Filename:"$BC_TMPDIR/progress.dat" \
+               --pattern='^base-config/progress/'
+
+       # This is much less messy than trying to use normal pipes.
+       rm -f "$BC_TMPDIR/progress.fifo"
+       mkfifo -m 0600 "$BC_TMPDIR/progress.fifo"
+
+       # Start up the progress bar in the background.
+       DEBCONF_DB_REPLACE="File{$BC_TMPDIR/progress.dat}" \
+               $0 progress "$TITLE" "$PREPINFO" 4<"$BC_TMPDIR/progress.fifo" &
+       PROGRESS_PID="$!"
+
+       # Do the installation.
+       DEBIAN_FRONTEND=passthrough DEBCONF_READFD=5 DEBCONF_WRITEFD=6 \
+               "$@" >/var/log/base-config-pkgsel.log \
+                       2>&1 4>"$BC_TMPDIR/progress.fifo"
+
+       # Clean up the progress bar process.
+       wait "$PROGRESS_PID"
+}
+
 case "$1" in
 ''|new)
        # Make dpkg not background itself to get a shell.
@@ -77,9 +112,13 @@
                                || true
                else
                        PATTERN="$($0 get_package_selection 4>&1)"
-                       if [ "$PATTERN" ] && ! DEBIAN_PRIORITY=high aptitude \
-                                       --without-recommends -y install \
-                                       "$PATTERN"; then
+                       if [ "$PATTERN" ] && ! DEBIAN_PRIORITY=high \
+                           progress base-config/progress/main-title \
+                                    base-config/progress/main-prep \
+                           aptitude -o APT::Status-Fd=4 \
+                                    -o APT::Keep-Fds::=5 -o APT::Keep-Fds::=6 \
+                                    --without-recommends -y install \
+                                    "$PATTERN"; then
                                cleanup
                                $0 failure
                                DEBIAN_PRIORITY=high aptitude \
@@ -204,4 +243,27 @@
        db_get base-config/install-language-support
        echo "$RET" >&4
        ;;
+progress)
+       . /usr/share/debconf/confmodule
+       shift
+       TITLE="$1"
+       PREPINFO="$2"
+       shift 2
+       db_progress START 0 100 "$TITLE"
+       db_progress INFO "$PREPINFO"
+       OLDIFS="$IFS"
+       IFS=:
+       while read status pkg percent description <&4; do
+               IFS="$OLDIFS"
+               case $status in
+                       status) ;;
+                       *)      continue ;;
+               esac
+               db_progress SET "${percent%%.*}"
+               db_subst base-config/progress/info DESCRIPTION "$description"
+               db_progress INFO base-config/progress/info
+               IFS=:
+       done
+       IFS="$OLDIFS"
+       ;;
 esac

Reply via email to